调整红包使用逻辑
This commit is contained in:
parent
fb2622738a
commit
47be191996
@ -624,9 +624,13 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||||||
$allow_no_address = false;
|
$allow_no_address = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 计算红包总金额
|
||||||
$consumptionTotal = 0;
|
$consumptionTotal = 0;
|
||||||
if ($consumption_id > 0 && $this->store_consumption_user && $source == 103) {
|
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);
|
$consumptionTotal = bcdiv($order_total_price, 6, 2);
|
||||||
}
|
}
|
||||||
if ($this->store_consumption_user['type'] == 1) {
|
if ($this->store_consumption_user['type'] == 1) {
|
||||||
@ -640,6 +644,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||||||
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) {
|
if ($consumptionTotal) {
|
||||||
|
// 按当前店铺的商品金额计算使用的红包金额
|
||||||
$rate = bcdiv($cart['total_price'], $order_total_price, 6);
|
$rate = bcdiv($cart['total_price'], $order_total_price, 6);
|
||||||
$useAmount = $isLast ? bcsub($consumptionTotal, $this->consumption_money, 2) : bcmul($consumptionTotal, $rate, 2);
|
$useAmount = $isLast ? bcsub($consumptionTotal, $this->consumption_money, 2) : bcmul($consumptionTotal, $rate, 2);
|
||||||
$merchantProductPrice = bcsub($cart['total_price'], $useAmount, 2);
|
$merchantProductPrice = bcsub($cart['total_price'], $useAmount, 2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user