From 2651fe4fb7cdea94243a664f85009792eb5db2a4 Mon Sep 17 00:00:00 2001 From: weigang Date: Fri, 14 Aug 2020 20:27:34 +0800 Subject: [PATCH] hot_fix_3 --- app/Controller/CouponController.php | 12 ++++++++++++ app/Service/CouponService.php | 25 +++++++++---------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/app/Controller/CouponController.php b/app/Controller/CouponController.php index 648039a..e34cd85 100644 --- a/app/Controller/CouponController.php +++ b/app/Controller/CouponController.php @@ -158,6 +158,18 @@ class CouponController extends BaseController ->get(); foreach ($coupons 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)."折"; + } + //失效时间格式转换 + $usable_end_time = date('Y-m-d H:i:s',$coupon->usable_end_time); + $coupon->usable_end_time_text = '有效期至:'.$usable_end_time; + if ($coupon->usable_end_time < $nowTime || $coupon->number_remain <= 0) { $expired[] = $coupon; } else { diff --git a/app/Service/CouponService.php b/app/Service/CouponService.php index 01895a8..40b51af 100644 --- a/app/Service/CouponService.php +++ b/app/Service/CouponService.php @@ -108,23 +108,16 @@ class CouponService implements CouponServiceInterface ->orderBy('u.weigh','desc') ->get(); - foreach ($coupons 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)."折"; + foreach ($coupons as $k => &$v){ + + if($v->active_type == 1 && count($result['not_receive']) < 4){ + $result['not_receive'][] = $v; + }else if($v->active_type == 2 && in_array($v->id,$couponReceiveIds)){ + $result['jump_data']['coupons'][] = $v->id; } - //失效时间格式转换 - $usable_end_time = date('Y-m-d H:i:s',$coupon->usable_end_time); - $coupon->usable_end_time_text = '有效期至:'.$usable_end_time; - - if ($coupon->usable_end_time < $nowTime || $coupon->number_remain <= 0) { - $expired[] = $coupon; - } else { - $not_expired[] = $coupon; + + if($v->discount_type == 2){ + $v->discounts = floatval($v->discounts); } }