|
|
|
@ -63,13 +63,18 @@ class CouponController extends BaseController |
|
|
|
// 当前用户可领的优惠券ID
|
|
|
|
$couponIds = array_diff($c_ids, $cr_ids); |
|
|
|
|
|
|
|
$c = Db::table('ims_system_coupon_user as u') |
|
|
|
->where([ |
|
|
|
$whereC = [ |
|
|
|
['u.end_time','>',$nowTime], |
|
|
|
['u.start_time','<=',$nowTime], |
|
|
|
['type.receive_type','=',$receive_type], |
|
|
|
['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($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)
|
|
|
|
@ -136,12 +141,16 @@ class CouponController extends BaseController |
|
|
|
//$cps = Coupon::whereIn('id', $ids)->sharedLock()->get();
|
|
|
|
|
|
|
|
foreach ($cps as $key => $cp) { |
|
|
|
$crt = CouponUserRecType::where( |
|
|
|
[ |
|
|
|
|
|
|
|
$where = [ |
|
|
|
'system_coupon_user_id' => $cp->id, |
|
|
|
'receive_type' => $receiveType |
|
|
|
] |
|
|
|
)->first(); |
|
|
|
]; |
|
|
|
|
|
|
|
if (env('SUB_CHANNEL') == 1) { |
|
|
|
$where['receive_type'] = $receiveType; |
|
|
|
} |
|
|
|
|
|
|
|
$crt = CouponUserRecType::where($where)->first(); |
|
|
|
|
|
|
|
$cr = new CouponRec; |
|
|
|
$cr->user_id = $userId; |
|
|
|
|