diff --git a/app/controller/api/Coupon.php b/app/controller/api/Coupon.php index ff60c06..356be28 100644 --- a/app/controller/api/Coupon.php +++ b/app/controller/api/Coupon.php @@ -938,11 +938,25 @@ class Coupon extends Base ]; //$usingRule = input("using_rule/a"); + $businessModel = $account->business["model"]; + // 指定时间段内发布的优惠券个数 + $TimeListModeReleaseCount = BusinessRepository::getInstance() + ->getTimeListModeReleaseCount($account->business["code"],$account->business["time_limit_start"],$account->business["time_limit_end"]); - $validate = new CouponRelease(); + if($account->business["model"] == BusinessModel::model_time_limit){ + //如果到了时间 或者发布数量到达规定 更改商家模式 + if( strtotime($account->business["time_limit_end"] ) < $time + || + (($TimeListModeReleaseCount + 1) >= $account->business["time_limit_release_count"]) + ){ + $businessModel = BusinessModel::model_ordinary; + } + } + + $validate = new CouponRelease(); //普通商家要验证扣除金额 - if (!$validate->scene(($account->business["model"] == BusinessModel::model_ordinary )? "ordinary" : "")->check($couponMain)) { + if (!$validate->scene(($businessModel == BusinessModel::model_ordinary )? "ordinary" : "")->check($couponMain)) { return $this->json(4001, $validate->getError()); } @@ -1017,10 +1031,6 @@ class Coupon extends Base //未领取的优惠券 $NotClaimedMoney = CouponRepository::getInstance()->getBusinessNotClaimedCoupon($account->business["code"]); - // 指定时间段内发布的优惠券个数 - $TimeListModeReleaseCount = BusinessRepository::getInstance() - ->getTimeListModeReleaseCount($account->business["code"],$account->business["time_limit_start"],$account->business["time_limit_end"]); - if( $account->business["model"] == BusinessModel::model_ordinary || diff --git a/app/controller/manager/Coupon.php b/app/controller/manager/Coupon.php index ed79c5f..0c2d33d 100644 --- a/app/controller/manager/Coupon.php +++ b/app/controller/manager/Coupon.php @@ -186,9 +186,24 @@ class Coupon extends Base if($business->enable != BusinessModel::COMMON_OFF){ return $this->json(4001, "商家已禁用"); } + + // 指定时间段内发布的优惠券个数 + $TimeListModeReleaseCount = BusinessRepository::getInstance() + ->getTimeListModeReleaseCount($business["code"],$business["time_limit_start"],$business["time_limit_end"]); + + $businessModel = $business["model"]; + if($business["model"] == BusinessModel::model_time_limit){ + //如果到了时间 或者发布数量到达规定 更改商家模式 + if( strtotime($business["time_limit_end"] ) < $time + || + (($TimeListModeReleaseCount) >= $business["time_limit_release_count"]) + ){ + $businessModel = BusinessModel::model_ordinary; + } + } $validate = new CouponRelease(); //普通商家要验证扣除金额 - if (!$validate->scene(($business["model"] == BusinessModel::model_ordinary) ? "ordinary" : "")->check($data)) { + if (!$validate->scene(($businessModel == BusinessModel::model_ordinary) ? "ordinary" : "")->check($data)) { return $this->json(4001, $validate->getError()); } @@ -311,10 +326,6 @@ class Coupon extends Base //未领取的优惠券 $NotClaimedMoney = CouponRepository::getInstance()->getBusinessNotClaimedCoupon($business["code"]); - // 指定时间段内发布的优惠券个数 - $TimeListModeReleaseCount = BusinessRepository::getInstance() - ->getTimeListModeReleaseCount($business["code"],$business["time_limit_start"],$business["time_limit_end"]); - if( $business["model"] == BusinessModel::model_ordinary ||