setter
parent
c445c5fcc2
commit
4f75f51d50
|
@ -76,7 +76,7 @@ class Consumer extends Base
|
|||
if (($params['businessCircleId']) > 0 ) {
|
||||
$whereMap[] = ['business_circle_id', '=', $params['businessCircleId']];
|
||||
}
|
||||
|
||||
|
||||
if ($params['dis'] > 0) {
|
||||
$pointList = getEarthSquareRangePoint($params['lat'],$params['lng'], $params['dis']);
|
||||
$latRange[] = ['lat', 'BETWEEN', [$pointList['lat_min'], $pointList['lat_max']]];
|
||||
|
|
|
@ -188,12 +188,14 @@ class Coupon extends Base
|
|||
return $q->with("business")->lock(true);
|
||||
});
|
||||
|
||||
//检查优惠券状态
|
||||
$checkCouponMainReceiveStatus = CouponRepository::getInstance()->checkCouponMainReceiveStatus($couponMain);
|
||||
if( $checkCouponMainReceiveStatus !== true ){
|
||||
return $checkCouponMainReceiveStatus;
|
||||
try {
|
||||
//检查优惠券状态
|
||||
CouponRepository::getInstance()->checkCouponMainReceiveStatus($couponMain);
|
||||
}catch (RepositoryException $e){
|
||||
return $this->json(4001,$e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
//检查是否可以领取 0可领取 1已领取
|
||||
AccountRepository::getInstance()->getCouponReceiveStatusText($account,$couponMain);//领取状态
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace app\traits;
|
||||
|
||||
use app\exception\RepositoryException;
|
||||
use app\model\CouponMain;
|
||||
use app\model\UsingRule;
|
||||
use app\model\Coupon;
|
||||
|
@ -15,25 +16,25 @@ trait CouponMainTrait
|
|||
*/
|
||||
public function checkCouponMainReceiveStatus(CouponMain $couponMain){
|
||||
if (empty($couponMain)) {
|
||||
return $this->json(4001, "优惠券不存在");
|
||||
throw new RepositoryException("优惠券不存在");
|
||||
}
|
||||
if ($couponMain->status != CouponMain::status_on) {
|
||||
return $this->json(4002, "优惠券已停用");
|
||||
throw new RepositoryException("优惠券已停用");
|
||||
}
|
||||
if ($couponMain->on_shelf != CouponMain::on_shelf_on) {
|
||||
return $this->json(4003, "优惠券已下架");
|
||||
throw new RepositoryException("优惠券已下架");
|
||||
}
|
||||
$time = time();
|
||||
if (strtotime($couponMain->start_time) > $time) {
|
||||
return $this->json(4004, "优惠券还未发行");
|
||||
throw new RepositoryException("优惠券还未到开始使用时间");
|
||||
}
|
||||
|
||||
if (strtotime($couponMain->end_time) < $time) {
|
||||
return $this->json(4004, "优惠券已结束使用");
|
||||
throw new RepositoryException("优惠券已结束使用");
|
||||
}
|
||||
|
||||
if ($couponMain->using_count <= 0) {
|
||||
return $this->json(4004, "优惠券已经被领完了");
|
||||
throw new RepositoryException("优惠券已经被领完了");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue