添加购物卡购买次数限制

This commit is contained in:
luofei 2024-02-22 16:09:55 +08:00
parent 2f34a03800
commit 31d5a68c21

View File

@ -7,6 +7,7 @@ use app\common\dao\store\order\StoreCartDao;
use app\common\dao\store\StoreActivityDao;
use app\common\model\store\order\StoreGroupOrder;
use app\common\model\store\order\StoreOrder;
use app\common\model\store\product\ProductCate;
use app\common\model\system\merchant\Merchant;
use app\common\repositories\community\CommunityRepository;
use app\common\repositories\store\coupon\StoreCouponRepository;
@ -81,6 +82,25 @@ class StoreOrderCreateRepository extends StoreOrderRepository
//检查商品类型, 活动商品只能单独购买
$allowDelivery = true;
$activityProductCount = 0;
//判断是否是平台购物卡,购物卡不允许使用任何优惠券
$merchantCate = $merchantCartList[0]['list'][0]->product->merCateId;
$isPlatformCard = false;
if (!empty($merchantCate) && in_array(env('PLATFORM_CARD_CATE_ID'), array_column($merchantCate->toArray(), 'mer_cate_id'))) {
$isPlatformCard = true;
}
if ($isPlatformCard) {
//平台购物卡仅能购买一次
$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('paid', 1)
->where('is_refund', 0)
->count();
if ($orderRecord > 0) {
throw new ValidateException('大礼包仅能购买一次');
}
}
foreach ($merchantCartList as $merchantCart) {
if (($merchantCart['type_id'] != Merchant::TypeSupplyChain) && $address && $merchantCart['list'][0]['product_type'] != 2 && $merchantCart['list'][0]['product']['type'] != 1) {
if ($merchantCart['street_id'] != $address['street_code'] && $createOrder && !in_array($merchantCart['mer_id'], $takes)) {
@ -168,12 +188,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository
}
$order_total_postage = 0;
$platformCoupon = [];
//判断是否是平台购物卡,购物卡不允许使用任何优惠券
$merchantCate = $merchantCartList[0]['list'][0]->product->merCateId;
$isPlatformCard = false;
if (!empty($merchantCate) && in_array(env('PLATFORM_CARD_CATE_ID'), array_column($merchantCate->toArray(), 'mer_cate_id'))) {
if ($isPlatformCard) {
$enabledPlatformCoupon = false;
$isPlatformCard = true;
}