调整店铺抵扣券使用规则
This commit is contained in:
parent
3ded469859
commit
2126e51e89
@ -251,10 +251,10 @@ class StoreCouponUserDao extends BaseDao
|
|||||||
public function getRate($profitRate)
|
public function getRate($profitRate)
|
||||||
{
|
{
|
||||||
$rateArray = [
|
$rateArray = [
|
||||||
'0.25' => 0.4,
|
25 => 0.4,
|
||||||
'0.2' => 0.3,
|
20 => 0.3,
|
||||||
'0.15' => 0.2,
|
15 => 0.2,
|
||||||
'0.1' => 0.1,
|
10 => 0.1,
|
||||||
];
|
];
|
||||||
$rate = 0;
|
$rate = 0;
|
||||||
foreach ($rateArray as $k => $item) {
|
foreach ($rateArray as $k => $item) {
|
||||||
|
@ -101,7 +101,7 @@ class StoreCartDao extends BaseDao
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'productAttr' => function (Relation $query) {
|
'productAttr' => function (Relation $query) {
|
||||||
$query->field('value_id,image,extension_one,extension_two,product_id,stock,price,unique,sku,volume,weight,ot_price,cost,svip_price')
|
$query->field('value_id,image,extension_one,extension_two,product_id,stock,price,unique,sku,volume,weight,ot_price,cost,svip_price,profit_rate')
|
||||||
->append(['bc_extension_one', 'bc_extension_two']);
|
->append(['bc_extension_one', 'bc_extension_two']);
|
||||||
},
|
},
|
||||||
'merchant' => function (Relation $query) use ($uid) {
|
'merchant' => function (Relation $query) use ($uid) {
|
||||||
|
@ -145,7 +145,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||||||
$down_price = bcadd($down_price, bcmul($cart['cart_num'], $cart['productPresellAttr']['down_price'], 2), 2);
|
$down_price = bcadd($down_price, bcmul($cart['cart_num'], $cart['productPresellAttr']['down_price'], 2), 2);
|
||||||
}
|
}
|
||||||
$merchantCate = $cart['product']->merCateId;
|
$merchantCate = $cart['product']->merCateId;
|
||||||
if ($cart['product']['type'] == 1 && !empty($merchantCate) && $merchantCate[0]['mer_cate_id'] == env('PLATFORM_CARD_TYPE_ID') && $enabledPlatformCoupon) {
|
if ($cart['product']['type'] == 1 && !empty($merchantCate) && $merchantCate[0]['mer_cate_id'] == env('PLATFORM_CARD_CATE_ID') && $enabledPlatformCoupon) {
|
||||||
$enabledPlatformCoupon = false;
|
$enabledPlatformCoupon = false;
|
||||||
$enabledCoupon = false;
|
$enabledCoupon = false;
|
||||||
}
|
}
|
||||||
@ -395,6 +395,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||||||
if (!in_array($coupon['coupon']['type'], [0, 2])) continue;
|
if (!in_array($coupon['coupon']['type'], [0, 2])) continue;
|
||||||
$coupon['checked'] = false;
|
$coupon['checked'] = false;
|
||||||
$coupon['disabled'] = $pay_price <= 0;
|
$coupon['disabled'] = $pay_price <= 0;
|
||||||
|
$couponUsed = 0;
|
||||||
if ($use_store_coupon || $pay_price <= 0) continue;
|
if ($use_store_coupon || $pay_price <= 0) continue;
|
||||||
if ($svip_coupon_merge != '1' && $use_svip) {
|
if ($svip_coupon_merge != '1' && $use_svip) {
|
||||||
$coupon['disabled'] = true;
|
$coupon['disabled'] = true;
|
||||||
@ -408,8 +409,21 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$use_store_coupon = $coupon;
|
$use_store_coupon = $coupon;
|
||||||
|
if ($coupon['coupon_type'] == StoreCouponRepository::TYPE_STORE_COUPON) {
|
||||||
|
foreach ($merchantCart['list'] as $cart) {
|
||||||
|
$storeCouponUserDao = new StoreCouponUserDao();
|
||||||
|
$storeCouponUserDao->orderProductPrice = $cart['total_price'];
|
||||||
|
$storeCouponUserDao->profitRate = $cart['productAttr']['profit_rate'];
|
||||||
|
$storeCouponUserDao->couponTotalAmount = $coupon['coupon_price'];
|
||||||
|
$storeCouponUserDao->couponUsed = $couponUsed;
|
||||||
|
[$payPrice, $useAmount, $couponUsed] = $storeCouponUserDao->couponByProduct($coupon['coupon_type']);
|
||||||
|
$coupon_price = bcadd($coupon_price, $useAmount, 2);
|
||||||
|
$_pay_price = bcsub($_pay_price, $useAmount, 2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$coupon_price = bcadd($coupon_price, $coupon['coupon_price'], 2);
|
$coupon_price = bcadd($coupon_price, $coupon['coupon_price'], 2);
|
||||||
$_pay_price = bcsub($_pay_price, $coupon['coupon_price'], 2);
|
$_pay_price = bcsub($_pay_price, $coupon['coupon_price'], 2);
|
||||||
|
}
|
||||||
$coupon['checked'] = true;
|
$coupon['checked'] = true;
|
||||||
} else {
|
} else {
|
||||||
$coupon['disabled'] = true;
|
$coupon['disabled'] = true;
|
||||||
|
@ -16,7 +16,7 @@ class OrderDeliveryListen implements ListenerInterface
|
|||||||
$order = $event['order'];
|
$order = $event['order'];
|
||||||
foreach ($order->orderProduct as $orderProduct) {
|
foreach ($order->orderProduct as $orderProduct) {
|
||||||
$merchantCate = $orderProduct->product->merCateId;
|
$merchantCate = $orderProduct->product->merCateId;
|
||||||
if (empty($merchantCate) || $merchantCate[0]['mer_cate_id'] != env('PLATFORM_CARD_TYPE_ID')) {
|
if (empty($merchantCate) || $merchantCate[0]['mer_cate_id'] != env('PLATFORM_CARD_CATE_ID')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/** @var StoreCouponRepository $repo */
|
/** @var StoreCouponRepository $repo */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user