调整红包使用逻辑
This commit is contained in:
parent
0b2b47ea4f
commit
ab074c4d8a
@ -643,16 +643,18 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||||||
$merchantPrice = 0;
|
$merchantPrice = 0;
|
||||||
foreach ($merchantCart['list'] as &$cart) {
|
foreach ($merchantCart['list'] as &$cart) {
|
||||||
$cart['total_price'] = bcadd($cart['total_price'], $cart['svip_discount'], 2);
|
$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);
|
unset($cart);
|
||||||
$merchantCart['order']['consumption_money'] = $useAmount ?? '0.00';
|
$merchantCart['order']['consumption_money'] = $useAmount ?? '0.00';
|
||||||
$merchantCart['order']['real_price'] = $merchantPrice;
|
$merchantCart['order']['real_price'] = $merchantPrice;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user