diff --git a/beike/Shop/Services/CheckoutService.php b/beike/Shop/Services/CheckoutService.php index 22e435c7..a3537592 100644 --- a/beike/Shop/Services/CheckoutService.php +++ b/beike/Shop/Services/CheckoutService.php @@ -191,7 +191,7 @@ class CheckoutService 'shipping_methods' => $shipments, 'payment_methods' => $payments, 'carts' => $carts, - 'totals' => $totalService->getTotals(), + 'totals' => $totalService->getTotals($this), ]; return hook_filter('checkout.data', $data); diff --git a/beike/Shop/Services/TotalService.php b/beike/Shop/Services/TotalService.php index 501b38b1..496c78da 100644 --- a/beike/Shop/Services/TotalService.php +++ b/beike/Shop/Services/TotalService.php @@ -83,9 +83,10 @@ class TotalService /** + * @param CheckoutService $checkout * @return array */ - public function getTotals(): array + public function getTotals(CheckoutService $checkout): array { foreach (self::TOTAL_CODES as $code) { $serviceName = Str::studly($code) . 'Service'; @@ -93,7 +94,7 @@ class TotalService if (!class_exists($service) || !method_exists($service, 'getTotal')) { continue; } - $service::getTotal($this); + $service::getTotal($checkout); } return $this->totals; diff --git a/beike/Shop/Services/TotalServices/OrderTotalService.php b/beike/Shop/Services/TotalServices/OrderTotalService.php index 7bd5f7da..57c4549e 100644 --- a/beike/Shop/Services/TotalServices/OrderTotalService.php +++ b/beike/Shop/Services/TotalServices/OrderTotalService.php @@ -11,12 +11,17 @@ namespace Beike\Shop\Services\TotalServices; -use Beike\Shop\Services\TotalService; +use Beike\Shop\Services\CheckoutService; class OrderTotalService { - public static function getTotal(TotalService $totalService) + /** + * @param CheckoutService $checkout + * @return array + */ + public static function getTotal(CheckoutService $checkout) { + $totalService = $checkout->totalService; $amount = $totalService->amount; $totalData = [ 'code' => 'order_total', diff --git a/beike/Shop/Services/TotalServices/ShippingService.php b/beike/Shop/Services/TotalServices/ShippingService.php index e5458f66..f14d1c94 100644 --- a/beike/Shop/Services/TotalServices/ShippingService.php +++ b/beike/Shop/Services/TotalServices/ShippingService.php @@ -12,18 +12,19 @@ namespace Beike\Shop\Services\TotalServices; -use Beike\Shop\Services\TotalService; use Illuminate\Support\Str; +use Beike\Shop\Services\CheckoutService; class ShippingService { /** - * @param TotalService $totalService + * @param CheckoutService $checkout * @return array|null * @throws \Exception */ - public static function getTotal(TotalService $totalService): ?array + public static function getTotal(CheckoutService $checkout): ?array { + $totalService = $checkout->totalService; $shippingMethod = $totalService->shippingMethod; if (empty($shippingMethod)) { return null; diff --git a/beike/Shop/Services/TotalServices/SubtotalService.php b/beike/Shop/Services/TotalServices/SubtotalService.php index 09559cc4..520f1d2b 100644 --- a/beike/Shop/Services/TotalServices/SubtotalService.php +++ b/beike/Shop/Services/TotalServices/SubtotalService.php @@ -13,11 +13,17 @@ namespace Beike\Shop\Services\TotalServices; use Beike\Shop\Services\TotalService; +use Beike\Shop\Services\CheckoutService; class SubtotalService { - public static function getTotal(TotalService $totalService) + /** + * @param CheckoutService $checkout + * @return array + */ + public static function getTotal(CheckoutService $checkout) { + $totalService = $checkout->totalService; $amount = self::getAmount($totalService); $totalData = [ 'code' => 'sub_total', diff --git a/beike/Shop/Services/TotalServices/TaxService.php b/beike/Shop/Services/TotalServices/TaxService.php index 9ac40e21..52262260 100644 --- a/beike/Shop/Services/TotalServices/TaxService.php +++ b/beike/Shop/Services/TotalServices/TaxService.php @@ -12,13 +12,18 @@ namespace Beike\Shop\Services\TotalServices; +use Beike\Shop\Services\CheckoutService; use Beike\Admin\Repositories\TaxRateRepo; -use Beike\Shop\Services\TotalService; class TaxService { - public static function getTotal(TotalService $totalService): ?array + /** + * @param CheckoutService $checkout + * @return array|null + */ + public static function getTotal(CheckoutService $checkout): ?array { + $totalService = $checkout->totalService; $taxEnabled = system_setting('base.tax', false); if (!$taxEnabled) { return null;