From f7c8dc2b4ec70f295ff8da4018b760f9abaf95d6 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Mon, 19 Oct 2020 19:11:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=86=E5=88=B8=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/CouponController.php | 2 +- app/Service/v3/Implementations/CouponRecService.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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;