diff --git a/app/Controller/v3/CouponController.php b/app/Controller/v3/CouponController.php index dd2f4ba..3cc0722 100644 --- a/app/Controller/v3/CouponController.php +++ b/app/Controller/v3/CouponController.php @@ -103,7 +103,7 @@ class CouponController extends BaseController return $this->success( [ 'status' => 'error', - 'message' => '优惠券已经被抢光了', + 'message' => '未满足领取条件', 'text'=>'关注懒族菜市微信公众号,更多精彩活动一手掌握!' ] ); diff --git a/app/Service/v3/Implementations/CouponRecService.php b/app/Service/v3/Implementations/CouponRecService.php index 692bc52..d1aaf9c 100644 --- a/app/Service/v3/Implementations/CouponRecService.php +++ b/app/Service/v3/Implementations/CouponRecService.php @@ -439,10 +439,16 @@ class CouponRecService implements CouponRecServiceInterface $oneReceiveNumber = CouponRecType::where($where)->value('one_receive_number'); $couponInventory = $cp->inventory - $cp->inventory_use; - + if($couponInventory < $oneReceiveNumber){ continue; } + + $couponReceiveExists = CouponRec::query()->where(['id'=>$cp->id,'user_id'=>$userId])->exists(); + + if($couponReceiveExists){ + continue; + } $cr = new CouponRec; $cr->user_id = $userId; $cr->coupon_id = $cp->id;