master
wangxinglong 2021-12-20 15:53:05 +08:00
parent 80b257f06d
commit 2899c4b4bf
1 changed files with 10 additions and 3 deletions

View File

@ -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;