|
|
@ -38,6 +38,7 @@ class CouponController extends BaseController |
|
|
|
|
|
|
|
|
$ids = array_merge($c_ids->toArray(), $cr_ids->toArray()); |
|
|
$ids = array_merge($c_ids->toArray(), $cr_ids->toArray()); |
|
|
|
|
|
|
|
|
|
|
|
//领过券的ID
|
|
|
$ids = collect($ids)->unique(); |
|
|
$ids = collect($ids)->unique(); |
|
|
|
|
|
|
|
|
$c = Db::table('ims_system_coupon_user as u') |
|
|
$c = Db::table('ims_system_coupon_user as u') |
|
|
@ -52,7 +53,9 @@ class CouponController extends BaseController |
|
|
->whereIn('u.id',$ids) |
|
|
->whereIn('u.id',$ids) |
|
|
->select('u.*','type.one_receive_number') |
|
|
->select('u.*','type.one_receive_number') |
|
|
->orderBy('u.weigh','desc') |
|
|
->orderBy('u.weigh','desc') |
|
|
|
|
|
// ->orderByRaw('FIELD(u.id, '.implode(", " , $ids).')')
|
|
|
->limit(4) |
|
|
->limit(4) |
|
|
|
|
|
|
|
|
->get(); |
|
|
->get(); |
|
|
return $this->success(['not_reveive'=>$c]); |
|
|
return $this->success(['not_reveive'=>$c]); |
|
|
} |
|
|
} |
|
|
@ -60,25 +63,20 @@ class CouponController extends BaseController |
|
|
//统计用户
|
|
|
//统计用户
|
|
|
public function userCouponAccount() |
|
|
public function userCouponAccount() |
|
|
{ |
|
|
{ |
|
|
$user_id = $this->request->input('user_id'); |
|
|
|
|
|
|
|
|
$userId = $this->request->input("user_id"); |
|
|
$nowTime = time(); |
|
|
$nowTime = time(); |
|
|
|
|
|
|
|
|
$userCouponCount = DB::table('ims_system_coupon_user_receive') |
|
|
|
|
|
->select(['ims_system_coupon_user_receive.number_remain']) |
|
|
|
|
|
->leftJoin('ims_system_coupon_user', |
|
|
|
|
|
'ims_system_coupon_user_receive.system_coupon_user_id', |
|
|
|
|
|
'=', |
|
|
|
|
|
'ims_system_coupon_user.id') |
|
|
|
|
|
->where('ims_system_coupon_user.usable_end_time','>',$nowTime) |
|
|
|
|
|
->where('ims_system_coupon_user_receive.user_id','=',$user_id) |
|
|
|
|
|
->whereIn('ims_system_coupon_user_receive.status',[0,1]) |
|
|
|
|
|
->get(); |
|
|
|
|
|
if (count($userCouponCount)){ |
|
|
|
|
|
$count = array_sum(array_column($userCouponCount->toArray(),'number_remain')); |
|
|
|
|
|
}else{ |
|
|
|
|
|
$count = 0; |
|
|
|
|
|
} |
|
|
|
|
|
return $this->success(['total' => $count]); |
|
|
|
|
|
|
|
|
$num = 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], |
|
|
|
|
|
['receive.number_remain','>',0], |
|
|
|
|
|
['u.usable_end_time','>',$nowTime], |
|
|
|
|
|
]) |
|
|
|
|
|
->whereIn('receive.status',[0,1]) |
|
|
|
|
|
->sum('receive.number_remain'); |
|
|
|
|
|
|
|
|
|
|
|
return $this->success(['total' => $num]); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -159,8 +157,11 @@ class CouponController extends BaseController |
|
|
->orderBy('u.weigh','desc') |
|
|
->orderBy('u.weigh','desc') |
|
|
->get(); |
|
|
->get(); |
|
|
|
|
|
|
|
|
|
|
|
$not_expired = []; |
|
|
|
|
|
$expired = []; |
|
|
|
|
|
|
|
|
foreach ($coupons as $key => $coupon) { |
|
|
foreach ($coupons as $key => $coupon) { |
|
|
if ($coupon->usable_end_time < $nowTime || $coupon->status != 1 || $coupon->number_remain <= 0) { |
|
|
|
|
|
|
|
|
if ($coupon->usable_end_time < $nowTime || $coupon->number_remain <= 0) { |
|
|
$expired[] = $coupon; |
|
|
$expired[] = $coupon; |
|
|
} else { |
|
|
} else { |
|
|
$not_expired[] = $coupon; |
|
|
$not_expired[] = $coupon; |
|
|
|