增加实物兑换校验

This commit is contained in:
2020-09-11 08:13:02 +08:00
parent 744e53a407
commit 6be99a2655
2 changed files with 205 additions and 199 deletions

View File

@@ -35,6 +35,9 @@ class Init
//订单id //订单id
public $orderid; public $orderid;
//查询到的卡券规则和商品id 只有平安券才有
public $queryData;
//设置渠道 //设置渠道
public function setUser($user) public function setUser($user)
{ {
@@ -136,6 +139,12 @@ class Init
//统一门店 相同金额 3分钟之内看作是一笔订单 //统一门店 相同金额 3分钟之内看作是一笔订单
public function CheckCount() public function CheckCount()
{ {
if ($this->queryData) {
if (isset($this->queryData['thirdPartyGoodsId']) && $this->queryData['thirdPartyGoodsId'] == 'YSD-full0-0') {
return true;
}
}
if ($this->orderid) { if ($this->orderid) {
$check_count = Coupon::where('orderid', $this->orderid) $check_count = Coupon::where('orderid', $this->orderid)
->where('outletId', $this->outletId) ->where('outletId', $this->outletId)
@@ -154,9 +163,9 @@ class Init
$count = floor($this->total / 100); $count = floor($this->total / 100);
if ($check_count > 0) { if ($check_count > 0) {
if ($this->total < 100) { // if ($this->total < 100) {
return '核销失败订单金额少于100只能核销一张优惠券。'; // return '核销失败订单金额少于100只能核销一张优惠券。';
} // }
if ($check_count >= $count) { if ($check_count >= $count) {
return "核销失败,此订单您只能使用 {$count} 张优惠券"; return "核销失败,此订单您只能使用 {$count} 张优惠券";
} }

View File

@@ -11,9 +11,6 @@ class Verification extends PingAnInit
public $ticket; public $ticket;
//查询到的卡券规则和商品id
public $queryData;
public function start() public function start()
{ {
//检查是否已经核销过 //检查是否已经核销过
@@ -22,12 +19,6 @@ class Verification extends PingAnInit
return $res; return $res;
} }
//检查可核销次数
$ret = $this->CheckCount();
if ($ret !== true) {
return $ret;
}
//查询卡券信息 //查询卡券信息
$this->query_coupon = (new Query)->setOutletId($this->outletId) $this->query_coupon = (new Query)->setOutletId($this->outletId)
->setCode($this->redemptionCode) ->setCode($this->redemptionCode)
@@ -42,6 +33,12 @@ class Verification extends PingAnInit
return $ticket; return $ticket;
} }
//检查可核销次数
$ret = $this->CheckCount();
if ($ret !== true) {
return $ret;
}
//增加核销记录 //增加核销记录
$coupon = $this->AddCoupon(); $coupon = $this->AddCoupon();
if (is_string($coupon)) { if (is_string($coupon)) {