调整红包使用逻辑

This commit is contained in:
luofei 2024-01-24 18:39:36 +08:00
parent 0ba2a41731
commit 1617d0ede6

View File

@ -648,7 +648,11 @@ class StoreOrderCreateRepository extends StoreOrderRepository
if ($consumptionTotal) {
// 按当前店铺的商品金额计算使用的红包金额
$rate = bcdiv($merchantCart['order']['total_price'], $order_total_price, 6);
$useAmount = $isLast ? bcsub($consumptionTotal, $this->consumption_money, 2) : bcmul($consumptionTotal, $rate, 2);
if ($consumptionTotal >= $order_total_price) {
$useAmount = $merchantCart['order']['total_price'];
} else {
$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);