|
|
@ -439,10 +439,16 @@ class CouponRecService implements CouponRecServiceInterface |
|
|
|
|
|
|
|
|
$oneReceiveNumber = CouponRecType::where($where)->value('one_receive_number'); |
|
|
$oneReceiveNumber = CouponRecType::where($where)->value('one_receive_number'); |
|
|
$couponInventory = $cp->inventory - $cp->inventory_use; |
|
|
$couponInventory = $cp->inventory - $cp->inventory_use; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($couponInventory < $oneReceiveNumber){ |
|
|
if($couponInventory < $oneReceiveNumber){ |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$couponReceiveExists = CouponRec::query()->where(['id'=>$cp->id,'user_id'=>$userId])->exists(); |
|
|
|
|
|
|
|
|
|
|
|
if($couponReceiveExists){ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
$cr = new CouponRec; |
|
|
$cr = new CouponRec; |
|
|
$cr->user_id = $userId; |
|
|
$cr->user_id = $userId; |
|
|
$cr->coupon_id = $cp->id; |
|
|
$cr->coupon_id = $cp->id; |
|
|
|