|
|
|
@ -149,20 +149,18 @@ class CouponController extends BaseController |
|
|
|
$userId = $this->request->input("user_id"); |
|
|
|
$nowTime = time(); |
|
|
|
|
|
|
|
$couponIds = CouponRec::where('user_id', $userId) |
|
|
|
->whereIn('status', [0, 1]) |
|
|
|
->orderBy('receive_time', 'desc') |
|
|
|
->get() |
|
|
|
->pluck('system_coupon_user_id'); |
|
|
|
|
|
|
|
$not_expired = []; |
|
|
|
$expired = []; |
|
|
|
|
|
|
|
$couponIds = $couponIds->toArray(); |
|
|
|
$coupons = Coupon::whereIn('id',$couponIds)->get(); |
|
|
|
$coupons = Db::table('ims_system_coupon_user_receive as receive') |
|
|
|
->join('ims_system_coupon_user as u', 'u.id', '=', 'receive.system_coupon_user_id') |
|
|
|
->where([ |
|
|
|
['receive.user_id','=',$userId], |
|
|
|
]) |
|
|
|
->whereIn('receive.status',[0,1]) |
|
|
|
->select('u.*','receive.number_remain') |
|
|
|
->orderBy('u.weigh','desc') |
|
|
|
->get(); |
|
|
|
|
|
|
|
foreach ($coupons as $key => $coupon) { |
|
|
|
if ($coupon->usable_end_time < $nowTime || $coupon->status != 1) { |
|
|
|
if ($coupon->usable_end_time < $nowTime || $coupon->status != 1 || $coupon->number_remain <= 0) { |
|
|
|
$expired[] = $coupon; |
|
|
|
} else { |
|
|
|
$not_expired[] = $coupon; |
|
|
|
|