From 2899c4b4bf524714f748fb58b38527af6b785e8d Mon Sep 17 00:00:00 2001 From: wangxinglong <2371974647@qq.com> Date: Mon, 20 Dec 2021 15:53:05 +0800 Subject: [PATCH] settter --- app/controller/api/Coupon.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controller/api/Coupon.php b/app/controller/api/Coupon.php index 2ea9017..9877639 100644 --- a/app/controller/api/Coupon.php +++ b/app/controller/api/Coupon.php @@ -324,13 +324,13 @@ class Coupon extends Base if(!isset($coupon->couponMain) || empty($coupon->couponMain)){ return $this->json(4001, "商家优惠券信息错误"); } + if(strtotime($coupon->couponMain->end_time) < $time){ + return $this->json(4001, "优惠券已过期"); + } $usingRule = UsingRule::findOne(["coupon_id"=>$coupon->couponMain->id]); if(empty($usingRule)){ return $this->json(4001, "商家优惠券使用规则信息错误"); } - if(strtotime($coupon->couponMain->end_time) < $time){ - return $this->json(4001, "优惠券已过期"); - } //一天的开始时间 if(strtotime(date("Y-m-d " . $usingRule->day_start_time)) > $time){ @@ -341,6 +341,13 @@ class Coupon extends Base return $this->json(4001, "请在当天{$usingRule->day_start_time}-{$usingRule->day_start_time}使用"); } + //使用周期 周一到周天 + $newW = date("w"); + if(!in_array($newW,$usingRule->cycle)){ + return $this->json(4001, "请在".encodeCouponCycle($usingRule->cycle)."使用"); + } + + //签到距离 Config::load('extra/wechat', 'wechat'); $signDistance = config('wechat.signDistance') ?? 0;