From a2417ae9909508c42a644e07714368f65928cbe1 Mon Sep 17 00:00:00 2001 From: weigang Date: Wed, 22 Jul 2020 17:30:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=B7=AE=E7=BC=BA=E8=A1=A5=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/CouponController.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/Controller/CouponController.php b/app/Controller/CouponController.php index 4565025..9b6c9ed 100644 --- a/app/Controller/CouponController.php +++ b/app/Controller/CouponController.php @@ -63,13 +63,18 @@ class CouponController extends BaseController // 当前用户可领的优惠券ID $couponIds = array_diff($c_ids, $cr_ids); + $whereC = [ + ['u.end_time','>',$nowTime], + ['u.start_time','<=',$nowTime], + ['u.status','=',1], + ]; + + if (env('SUB_CHANNEL') == 1) { + array_push($whereC, ['type.receive_type','=',$receive_type]); + } + $c = Db::table('ims_system_coupon_user as u') - ->where([ - ['u.end_time','>',$nowTime], - ['u.start_time','<=',$nowTime], - ['type.receive_type','=',$receive_type], - ['u.status','=',1], - ]) + ->where($whereC) ->join('ims_system_coupon_user_receivetype as type', 'u.id', '=', 'type.system_coupon_user_id') ->whereRaw('u.inventory_use <= u.inventory and u.inventory-u.inventory_use > type.one_receive_number') // ->whereIn('u.id',$c_ids) @@ -85,7 +90,7 @@ class CouponController extends BaseController $v->discounts = floatval($v->discounts); } } - return $this->success(['not_reveive'=>$c]); + return $this->success(['not_reveive'=>$c, 'c_ids' => $c_ids, 'cr_ids' => $cr_ids, 'couponIds' => $couponIds]); } //统计用户 From e29edd73fe18dc3b93b910ed318902c96e5bd8bd Mon Sep 17 00:00:00 2001 From: weigang Date: Wed, 22 Jul 2020 17:35:48 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8F=AF=E9=A2=86=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E5=8A=A0=E6=B8=A0=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/CouponController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controller/CouponController.php b/app/Controller/CouponController.php index 9b6c9ed..31e63a1 100644 --- a/app/Controller/CouponController.php +++ b/app/Controller/CouponController.php @@ -90,7 +90,7 @@ class CouponController extends BaseController $v->discounts = floatval($v->discounts); } } - return $this->success(['not_reveive'=>$c, 'c_ids' => $c_ids, 'cr_ids' => $cr_ids, 'couponIds' => $couponIds]); + return $this->success(['not_reveive'=>$c]); } //统计用户 From fd99d62feea79145c8a1bdfb5bad8b3afdca354b Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 23 Jul 2020 10:13:44 +0800 Subject: [PATCH 3/3] no message --- app/Controller/CouponController.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/Controller/CouponController.php b/app/Controller/CouponController.php index 31e63a1..26296c6 100644 --- a/app/Controller/CouponController.php +++ b/app/Controller/CouponController.php @@ -141,12 +141,16 @@ class CouponController extends BaseController //$cps = Coupon::whereIn('id', $ids)->sharedLock()->get(); foreach ($cps as $key => $cp) { - $crt = CouponUserRecType::where( - [ - 'system_coupon_user_id' => $cp->id, - 'receive_type' => $receiveType - ] - )->first(); + + $where = [ + 'system_coupon_user_id' => $cp->id, + ]; + + if (env('SUB_CHANNEL') == 1) { + $where['receive_type'] = $receiveType; + } + + $crt = CouponUserRecType::where($where)->first(); $cr = new CouponRec; $cr->user_id = $userId;