From 55423be5484faf6bb901ea7d6e0d40f9a5d0f611 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Mon, 5 Dec 2022 14:27:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E8=B4=AD=E7=89=A9=E8=BD=A6?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=80=BB=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beike/Shop/Services/TotalServices/SubtotalService.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/beike/Shop/Services/TotalServices/SubtotalService.php b/beike/Shop/Services/TotalServices/SubtotalService.php index 824f91f4..09559cc4 100644 --- a/beike/Shop/Services/TotalServices/SubtotalService.php +++ b/beike/Shop/Services/TotalServices/SubtotalService.php @@ -18,8 +18,7 @@ class SubtotalService { public static function getTotal(TotalService $totalService) { - $carts = $totalService->cartProducts; - $amount = collect($carts)->sum('subtotal'); + $amount = self::getAmount($totalService); $totalData = [ 'code' => 'sub_total', 'title' => trans('shop/carts.product_total'), @@ -32,4 +31,10 @@ class SubtotalService return $totalData; } + + public static function getAmount(TotalService $totalService) + { + $carts = $totalService->cartProducts; + return collect($carts)->sum('subtotal'); + } }