|
|
|
@ -155,7 +155,7 @@ class CouponRecService implements CouponRecServiceInterface |
|
|
|
//拼接时间文字提示
|
|
|
|
$coupon['time_text'] = date("Y-m-d H:i:s",$coupon['usable_start_time']). ' - ' .date("Y-m-d H:i:s",$coupon['usable_end_time']); |
|
|
|
} |
|
|
|
return ['has_more_pages' => $paginate->hasMorePages(), 'coupon_list' => $couponList['data']]; |
|
|
|
return ['has_more_pages' => $paginate->hasMorePages(), 'list' => $couponList['data']]; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -285,12 +285,29 @@ class CouponRecService implements CouponRecServiceInterface |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @inheritDoc |
|
|
|
* @param $userId |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function countAvailableByUser($userId) |
|
|
|
public function statistics($userId) |
|
|
|
{ |
|
|
|
$coupons = $this->getListByUser($userId,'unused',1,9999); |
|
|
|
$numberRemain= (array_column($coupons['coupon_list'], 'number_remain')); |
|
|
|
return array_sum($numberRemain); |
|
|
|
//未使用
|
|
|
|
$res['unused'] = 0; |
|
|
|
//已使用
|
|
|
|
$res['used'] = 0; |
|
|
|
//已过期
|
|
|
|
$res['expired'] = 0; |
|
|
|
$coupons = CouponRec::query() |
|
|
|
->with('coupon') |
|
|
|
->where('user_id',$userId) |
|
|
|
->get(); |
|
|
|
foreach ($coupons as $coupon){ |
|
|
|
if($coupon->coupon->usable_end_time < time() || $coupon->coupon->status != 1){ |
|
|
|
$res['expired'] += $coupon->number_remain; |
|
|
|
}else{ |
|
|
|
$res['unused'] += $coupon->number_remain; |
|
|
|
} |
|
|
|
$res['used'] += $coupon->used_num; |
|
|
|
} |
|
|
|
return $res; |
|
|
|
} |
|
|
|
} |