|
|
@ -103,7 +103,7 @@ class CouponRecService implements CouponRecServiceInterface |
|
|
public function getListByUser($userId,$type,$page = 1,$pagesize = 5) |
|
|
public function getListByUser($userId,$type,$page = 1,$pagesize = 5) |
|
|
{ |
|
|
{ |
|
|
//查询优惠券
|
|
|
//查询优惠券
|
|
|
$builder = CouponRec::query()->join('lanzu_coupon', 'lanzu_coupon.id', '=', 'lanzu_coupon_receive.coupon_id') |
|
|
|
|
|
|
|
|
$builder = CouponRec::query()->join('lanzu_coupon', 'lanzu_coupon.id', '=', 'lanzu_coupon_receive.coupon_id')->with('coupon') |
|
|
->where([ |
|
|
->where([ |
|
|
['lanzu_coupon_receive.user_id' ,'=', $userId], |
|
|
['lanzu_coupon_receive.user_id' ,'=', $userId], |
|
|
]); |
|
|
]); |
|
|
@ -130,32 +130,11 @@ class CouponRecService implements CouponRecServiceInterface |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
$builder = $builder->select( |
|
|
$builder = $builder->select( |
|
|
'lanzu_coupon.title', |
|
|
|
|
|
'lanzu_coupon.discounts', |
|
|
|
|
|
'lanzu_coupon.full_amount', |
|
|
|
|
|
'lanzu_coupon.discount_type', |
|
|
|
|
|
'lanzu_coupon.introduce', |
|
|
|
|
|
'lanzu_coupon.tags', |
|
|
|
|
|
'lanzu_coupon.usable_start_time', |
|
|
|
|
|
'lanzu_coupon.usable_end_time', |
|
|
|
|
|
'lanzu_coupon_receive.number', |
|
|
|
|
|
'lanzu_coupon_receive.number_remain' |
|
|
|
|
|
|
|
|
'lanzu_coupon_receive.*' |
|
|
) |
|
|
) |
|
|
->orderBy('lanzu_coupon.weigh','desc'); |
|
|
->orderBy('lanzu_coupon.weigh','desc'); |
|
|
$paginate = $builder->paginate($pagesize); |
|
|
$paginate = $builder->paginate($pagesize); |
|
|
$couponList = $paginate->toArray(); |
|
|
$couponList = $paginate->toArray(); |
|
|
foreach ($couponList['data'] as $key => &$coupon) { |
|
|
|
|
|
//拼接满减文字提示
|
|
|
|
|
|
$coupon['full_amount_text'] = '满' . $coupon['full_amount'] . "可用"; |
|
|
|
|
|
//判断是折扣优惠券还是满减优惠券
|
|
|
|
|
|
if($coupon['discount_type'] == 1){ |
|
|
|
|
|
$coupon['discounts_text'] = '¥'.$coupon['discounts']; |
|
|
|
|
|
}elseif($coupon['discount_type'] == 2){ |
|
|
|
|
|
$coupon['discounts_text'] = floatval($coupon['discounts'])."折"; |
|
|
|
|
|
} |
|
|
|
|
|
//拼接时间文字提示
|
|
|
|
|
|
$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(), 'list' => $couponList['data']]; |
|
|
return ['has_more_pages' => $paginate->hasMorePages(), 'list' => $couponList['data']]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|