diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index cc3ecbb5..345e7d29 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -4,8 +4,9 @@ namespace app\common\repositories\store\order; use app\common\dao\store\coupon\StoreCouponUserDao; use app\common\Enum; +use app\common\model\store\coupon\StoreCoupon; +use app\common\model\store\coupon\StoreCouponUser; use app\common\model\store\order\StoreOrder; -use app\common\model\store\product\ProductCate; use app\common\model\store\product\Spu; use app\common\model\system\merchant\Merchant; use app\common\repositories\system\form\FormRepository; @@ -1514,7 +1515,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository { $hasPlatformCard = false; foreach ($carts as $cart) { - if ($cart['product']->isPlatformCard() && !$hasPlatformCard) { + if ($cart['product']->isPlatformCard()) { $hasPlatformCard = true; break; } @@ -1525,16 +1526,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository 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) { + $couponId = StoreCoupon::where('type', StoreCouponRepository::TYPE_PLATFORM_CARD)->value('coupon_id'); + $userCoupon = StoreCouponUser::where('coupon_id', $couponId)->where('uid', $uid)->value('coupon_user_id'); + if ($userCoupon > 0) { throw new ValidateException('大礼包仅能购买一次'); } }