调整大礼包限购
This commit is contained in:
parent
776c662b69
commit
65da0fbcfe
@ -87,6 +87,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$merId = $user->getMerId();
|
||||
// 循环计算每个店铺的订单数据
|
||||
foreach ($merchantCartList as &$merchantCart) {
|
||||
$isPlatformCard = $this->checkBuyLimit($merchantCart['list'], $uid);
|
||||
//用户关联了商户id且下单店铺支持批发
|
||||
$isWholeSale = StoreOrder::isWholesale($merchantCart['wholesale'], $merId, $this->saleType);
|
||||
$postageRule = [];
|
||||
@ -112,28 +113,6 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
}
|
||||
$product_cart = [];
|
||||
|
||||
//大礼包限购
|
||||
$isPlatformCard = $merchantCart['list'][0]['product']->isPlatformCard();
|
||||
if ($isPlatformCard) {
|
||||
$merchantTypeId = Merchant::where('uid', $uid)->value('type_id');
|
||||
if (empty($merchantTypeId) || $merchantTypeId != 21) {
|
||||
throw new ValidateException('大礼包仅限种养殖户购买');
|
||||
}
|
||||
//平台购物卡仅能购买一次
|
||||
$productIds = ProductCate::where('mer_cate_id', env('PLATFORM_CARD_CATE_ID'))->column('product_id');
|
||||
$orderRecord = StoreOrder::alias('t1')
|
||||
->leftJoin('store_order_product t2', 't1.order_id = t2.order_id')
|
||||
->whereIn('product_id', $productIds)
|
||||
->where('t1.uid', $uid)
|
||||
->where('is_del', 0)
|
||||
->where('is_system_del', 0)
|
||||
->where('status', '<>', Enum::STATUS_REFUNDED)
|
||||
->count();
|
||||
if ($orderRecord > 0) {
|
||||
throw new ValidateException('大礼包仅能购买一次');
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($merchantCart['list'] as $k => $cart) {
|
||||
if ($isWholeSale) {
|
||||
$merchantCart['list'][$k]['productAttr']['price'] = $cart['productAttr']['wholesale_price'];
|
||||
@ -1523,6 +1502,43 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
}
|
||||
unset($merchantCart, $cart);
|
||||
}
|
||||
|
||||
/**
|
||||
* 大礼包限购校验
|
||||
* @param $carts
|
||||
* @param $uid
|
||||
* @return bool
|
||||
*/
|
||||
public function checkBuyLimit($carts, $uid)
|
||||
{
|
||||
$isPlatformCard = false;
|
||||
foreach ($carts as $cart) {
|
||||
if ($cart['product']->isPlatformCard() && !$isPlatformCard) {
|
||||
$isPlatformCard = true;
|
||||
}
|
||||
if ($cart['product']->isPlatformCard()) {
|
||||
$merchantTypeId = Merchant::where('uid', $uid)->value('type_id');
|
||||
if (empty($merchantTypeId) || $merchantTypeId != 21) {
|
||||
throw new ValidateException('大礼包仅限种养殖户购买');
|
||||
}
|
||||
//平台购物卡仅能购买一次
|
||||
$productIds = ProductCate::where('mer_cate_id', env('PLATFORM_CARD_CATE_ID'))->column('product_id');
|
||||
$orderRecord = StoreOrder::alias('t1')
|
||||
->leftJoin('store_order_product t2', 't1.order_id = t2.order_id')
|
||||
->whereIn('product_id', $productIds)
|
||||
->where('t1.uid', $uid)
|
||||
->where('is_del', 0)
|
||||
->where('is_system_del', 0)
|
||||
->where('status', '<>', Enum::STATUS_REFUNDED)
|
||||
->count();
|
||||
if ($orderRecord > 0) {
|
||||
throw new ValidateException('大礼包仅能购买一次');
|
||||
}
|
||||
}
|
||||
}
|
||||
return $isPlatformCard;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user