调整店铺抵扣券使用
This commit is contained in:
parent
7d67779fea
commit
35eb3d2010
@ -686,4 +686,52 @@ class StoreCouponRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤不可用的店铺券
|
||||||
|
* @param $merchantCart
|
||||||
|
* @param $product_price
|
||||||
|
* @param $svip_coupon_merge
|
||||||
|
* @param $use_svip
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function filterStoreCoupon($merchantCart, $product_price, $svip_coupon_merge, $use_svip)
|
||||||
|
{
|
||||||
|
foreach ($merchantCart['coupon'] as &$coupon) {
|
||||||
|
if ($coupon['coupon']['type'] == self::TYPE_STORE_ALL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$coupon['disabled'] = false;
|
||||||
|
$coupon['checked'] = false;
|
||||||
|
if ($coupon['coupon']['type'] == self::TYPE_STORE_COUPON) {
|
||||||
|
$coupon['disabled'] = true;
|
||||||
|
foreach ($merchantCart['list'] as $cart) {
|
||||||
|
if ($cart['productAttr']['profit_rate'] >= 10) {
|
||||||
|
$coupon['disabled'] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (count(array_intersect(array_column($coupon['product'], 'product_id'), array_keys($product_price))) == 0) {
|
||||||
|
$coupon['disabled'] = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($svip_coupon_merge != '1' && $use_svip) {
|
||||||
|
$coupon['disabled'] = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$flag = false;
|
||||||
|
foreach ($coupon['product'] as $_product) {
|
||||||
|
if (isset($product_price[$_product['product_id']]) && $product_price[$_product['product_id']] >= $coupon['use_min_price']) {
|
||||||
|
$flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$flag) {
|
||||||
|
$coupon['disabled'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $merchantCart;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -330,36 +330,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
//过滤不可用店铺优惠券
|
//过滤不可用店铺优惠券
|
||||||
foreach ($merchantCart['coupon'] as &$coupon) {
|
/** @var StoreCouponRepository $storeCouponRepo */
|
||||||
if (in_array($coupon['coupon']['type'], [0, 2])) continue;
|
$storeCouponRepo = app()->make(StoreCouponRepository::class);
|
||||||
|
$merchantCart = $storeCouponRepo->filterStoreCoupon($merchantCart, $product_price, $svip_coupon_merge, $use_svip);
|
||||||
$coupon['disabled'] = false;
|
|
||||||
$coupon['checked'] = false;
|
|
||||||
|
|
||||||
if (count(array_intersect(array_column($coupon['product'], 'product_id'), array_keys($product_price))) == 0) {
|
|
||||||
$coupon['disabled'] = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($svip_coupon_merge != '1' && $use_svip) {
|
|
||||||
$coupon['disabled'] = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$flag = false;
|
|
||||||
foreach ($coupon['product'] as $_product) {
|
|
||||||
if (isset($product_price[$_product['product_id']]) && $product_price[$_product['product_id']] >= $coupon['use_min_price']) {
|
|
||||||
$flag = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$flag) {
|
|
||||||
$coupon['disabled'] = true;
|
|
||||||
}
|
|
||||||
// if (!$coupon['disabled']) {
|
|
||||||
// $all_coupon_product[] = $coupon['coupon_user_id'];
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
unset($coupon);
|
|
||||||
|
|
||||||
//if ($useCouponFlag && count(array_diff($all_coupon_product, $use_coupon_product))) {
|
//if ($useCouponFlag && count(array_diff($all_coupon_product, $use_coupon_product))) {
|
||||||
// throw new ValidateException('请选择有效的商品券');
|
// throw new ValidateException('请选择有效的商品券');
|
||||||
@ -394,6 +367,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||||||
//计算店铺券
|
//计算店铺券
|
||||||
foreach ($merchantCart['coupon'] as &$coupon) {
|
foreach ($merchantCart['coupon'] as &$coupon) {
|
||||||
if (!in_array($coupon['coupon']['type'], [0, 2])) continue;
|
if (!in_array($coupon['coupon']['type'], [0, 2])) continue;
|
||||||
|
if (isset($coupon['disabled']) && $coupon['disabled']) continue;
|
||||||
$coupon['checked'] = false;
|
$coupon['checked'] = false;
|
||||||
$coupon['disabled'] = $pay_price <= 0;
|
$coupon['disabled'] = $pay_price <= 0;
|
||||||
$couponUsed = 0;
|
$couponUsed = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user