diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 59c2cffa..0f304845 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -624,9 +624,13 @@ class StoreOrderCreateRepository extends StoreOrderRepository $allow_no_address = false; } + // 计算红包总金额 $consumptionTotal = 0; if ($consumption_id > 0 && $this->store_consumption_user && $source == 103) { - if ($this->store_consumption_user['type'] == 2 && $order_total_price >= 6 && $this->payType != 'balance') { + if ($this->store_consumption_user['type'] == 2 && $order_total_price >= 6 && ) { + if ($this->payType != 'balance') { + throw new \Exception('余额支付时,不能使用抵扣红包'); + } $consumptionTotal = bcdiv($order_total_price, 6, 2); } if ($this->store_consumption_user['type'] == 1) { @@ -640,6 +644,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository 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);