From 504c48c71cdddd95be5c35251c287c9e34be9a03 Mon Sep 17 00:00:00 2001 From: wangxinglong <2371974647@qq.com> Date: Mon, 20 Dec 2021 10:24:29 +0800 Subject: [PATCH] setter --- app/controller/api/Coupon.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/app/controller/api/Coupon.php b/app/controller/api/Coupon.php index f4a6533..6bea7f9 100644 --- a/app/controller/api/Coupon.php +++ b/app/controller/api/Coupon.php @@ -57,7 +57,9 @@ class Coupon extends Base 'type_name', 'money', 'name as couponName', + 'business_code', 'business_code as businessCode', + 'coupon_id', 'end_time as endTime', 'consumer_name as consumerName', 'verificate_time as verificateTime', @@ -87,13 +89,16 @@ class Coupon extends Base } $res = CouponRepository::getInstance()->findList($whereMap, $fields, $page, $size,function ($q){ - return $q->with(["couponMain","scoreModel"]); + return $q->with(["couponMain","scoreModel","business"]); }, $sortOrder); $time = time(); $res['list'] ->each(function ($item) use($time){ //重置优惠券名称 if(isset($item->couponMain) && $item->couponMain){ $item->couponName = $item->couponMain->name; + $item->image_url = $item->couponMain->image_url; + }else{ + $item->image_url = ''; } //是否已经打分过了 if(isset($item->scoreModel) && $item->scoreModel){ @@ -105,9 +110,8 @@ class Coupon extends Base } - //到期状态 到期前7天!!!!!!!!没做完 + //到期状态 $expirationStr = ''; - $endTime = strtotime($item->endTime); $ExpirationTime = abs(($endTime - $time) / 86400); if (($endTime > $time) ) { @@ -115,9 +119,23 @@ class Coupon extends Base } else { $expirationStr = "到期" . ceil($ExpirationTime) . "天"; } - $item->expirationStr =$expirationStr; + + //商家简称 + if(!empty($item->business)){ + $item->business_subtitle = $item->business->business_subtitle; + }else{ + $item->business_subtitle = ''; + } + + //图片 + if(!empty($item->business)){ + $item->business_subtitle = $item->business->business_subtitle; + }else{ + $item->business_subtitle = ''; + } + }); $res['list'] = multiTwoArrayKeysExcludeFilter($res['list']->toArray(), ['sort_weight']);