diff --git a/app/controller/api/Coupon.php b/app/controller/api/Coupon.php index b238af2..5bd7d6b 100644 --- a/app/controller/api/Coupon.php +++ b/app/controller/api/Coupon.php @@ -93,7 +93,13 @@ class Coupon extends Base $res = CouponRepository::getInstance()->findList($whereMap, $fields, $page, $size,function ($q){ - return $q->with(["couponMain","scoreModel","business"]) + return $q->with([ + "couponMain", + "scoreModel", + "business" => function ($q) { + $q->field("code,id,business_name,business_subtitle"); + } + ]) ->where(function ($q){ $notUsedWhereMap = [];//未过期 未使用 $notUsedWhereMap[] = ['is_verificated', '=', self::BOOL_FALSE]; @@ -231,20 +237,16 @@ class Coupon extends Base }, "scoreModel", "business" => function ($q) { - $q->field("id,code,business_name"); + $q->field("id,code,business_name,business_subtitle"); } ]); }, $sortOrder); $res['list'] ->each(function ($item) use($time){ - //重置优惠券名称 - if(isset($item->couponMain) && $item->couponMain){ - $item->couponName = $item->couponMain->name; - } + //重置过期时间 $item->endTimeText = date("Y-m-d",strtotime($item->endTime)); - $status = CouponModel::status_success;//默认未使用 $endTime = strtotime($item->endTime); $ExpirationTime = abs(($endTime - $time) / 86400); diff --git a/app/model/Coupon.php b/app/model/Coupon.php index 6be63f6..66165da 100644 --- a/app/model/Coupon.php +++ b/app/model/Coupon.php @@ -20,7 +20,7 @@ class Coupon extends Base const status_success = 0;//未过期未使用 const status_used = 1;//已使用 - const status_be_overdue = 3;//已过期 + const status_be_overdue = 2;//已过期 public function couponBill()