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;