From 9451ab57a6f972ee37b086f18dc97a82ebcc868b Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Mon, 5 Dec 2022 17:40:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=BA=E5=AE=9A=E8=BF=90?= =?UTF-8?q?=E8=B4=B9=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beike/Shop/Services/TotalServices/ShippingService.php | 4 ++-- plugins/FlatShipping/Bootstrap.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/beike/Shop/Services/TotalServices/ShippingService.php b/beike/Shop/Services/TotalServices/ShippingService.php index f14d1c94..427448c6 100644 --- a/beike/Shop/Services/TotalServices/ShippingService.php +++ b/beike/Shop/Services/TotalServices/ShippingService.php @@ -35,9 +35,9 @@ class ShippingService $className = "Plugin\\{$pluginCode}\\Bootstrap"; if (!method_exists($className, 'getShippingFee')) { - throw new \Exception("请在插件 {$className} 实现方法: public function getShippingFee(\$totalService)"); + throw new \Exception("请在插件 {$className} 实现方法: public function getShippingFee(CheckoutService \$checkout)"); } - $amount = (float)(new $className)->getShippingFee($totalService); + $amount = (float)(new $className)->getShippingFee($checkout); $totalData = [ 'code' => 'shipping', 'title' => trans('shop/carts.shipping_fee'), diff --git a/plugins/FlatShipping/Bootstrap.php b/plugins/FlatShipping/Bootstrap.php index 7bd3ae9e..58b9c3fc 100644 --- a/plugins/FlatShipping/Bootstrap.php +++ b/plugins/FlatShipping/Bootstrap.php @@ -41,11 +41,12 @@ class Bootstrap /** * 计算固定运费 * - * @param $totalService + * @param CheckoutService $checkout * @return float|int */ - public function getShippingFee($totalService): float|int + public function getShippingFee(CheckoutService $checkout): float|int { + $totalService = $checkout->totalService; $amount = $totalService->amount; $shippingType = plugin_setting('flat_shipping.type', 'fixed'); $shippingValue = plugin_setting('flat_shipping.value', 0);