From ab074c4d8a763fa02a38f97b88004ae1356bb1dd Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Wed, 24 Jan 2024 18:36:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=BA=A2=E5=8C=85=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/StoreOrderCreateRepository.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index e74d2ce3..46ec8996 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -643,16 +643,18 @@ class StoreOrderCreateRepository extends StoreOrderRepository $merchantPrice = 0; foreach ($merchantCart['list'] as &$cart) { $cart['total_price'] = bcadd($cart['total_price'], $cart['svip_discount'], 2); - if ($consumptionTotal) { - // 按当前店铺的商品金额计算使用的红包金额 - $rate = bcdiv($cart['total_price'], $order_total_price, 6); - $useAmount = $isLast ? bcsub($consumptionTotal, $this->consumption_money, 2) : bcmul($consumptionTotal, $rate, 2); - $merchantProductPrice = bcsub($cart['total_price'], $useAmount, 2); - $merchantPrice = bcadd($merchantPrice, $merchantProductPrice, 2); - $this->consumption_money = bcadd($this->consumption_money, $useAmount, 2); - $this->balance = bcsub($this->balance, $useAmount, 2); - } } + + if ($consumptionTotal) { + // 按当前店铺的商品金额计算使用的红包金额 + $rate = bcdiv($merchantCart['order']['total_price'], $order_total_price, 6); + $useAmount = $isLast ? bcsub($consumptionTotal, $this->consumption_money, 2) : bcmul($consumptionTotal, $rate, 2); + $merchantProductPrice = bcsub($merchantCart['order']['total_price'], $useAmount, 2); + $merchantPrice = bcadd($merchantPrice, $merchantProductPrice, 2); + $this->consumption_money = bcadd($this->consumption_money, $useAmount, 2); + $this->balance = bcsub($this->balance, $useAmount, 2); + } + unset($cart); $merchantCart['order']['consumption_money'] = $useAmount ?? '0.00'; $merchantCart['order']['real_price'] = $merchantPrice;