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]); } //统计用户