增加实物兑换校验
This commit is contained in:
@@ -35,6 +35,9 @@ class Init
|
||||
//订单id
|
||||
public $orderid;
|
||||
|
||||
//查询到的卡券规则和商品id 只有平安券才有
|
||||
public $queryData;
|
||||
|
||||
//设置渠道
|
||||
public function setUser($user)
|
||||
{
|
||||
@@ -136,27 +139,33 @@ class Init
|
||||
//统一门店 相同金额 3分钟之内看作是一笔订单
|
||||
public function CheckCount()
|
||||
{
|
||||
if ($this->queryData) {
|
||||
if (isset($this->queryData['thirdPartyGoodsId']) && $this->queryData['thirdPartyGoodsId'] == 'YSD-full0-0') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->orderid) {
|
||||
$check_count = Coupon::where('orderid', $this->orderid)
|
||||
->where('outletId', $this->outletId)
|
||||
->where('total', $this->total)
|
||||
->where('status', 2)
|
||||
->where('created_at', '>=', now()->subMinutes(3)->format('Y-m-d H:i:s'))
|
||||
->count();
|
||||
->where('outletId', $this->outletId)
|
||||
->where('total', $this->total)
|
||||
->where('status', 2)
|
||||
->where('created_at', '>=', now()->subMinutes(3)->format('Y-m-d H:i:s'))
|
||||
->count();
|
||||
} else {
|
||||
$check_count = Coupon::where('outletId', $this->outletId)
|
||||
->where('total', $this->total)
|
||||
->where('status', 2)
|
||||
->where('created_at', '>=', now()->subMinutes(3)->format('Y-m-d H:i:s'))
|
||||
->count();
|
||||
->where('total', $this->total)
|
||||
->where('status', 2)
|
||||
->where('created_at', '>=', now()->subMinutes(3)->format('Y-m-d H:i:s'))
|
||||
->count();
|
||||
}
|
||||
|
||||
$count = floor($this->total / 100);
|
||||
|
||||
if ($check_count > 0) {
|
||||
if ($this->total < 100) {
|
||||
return '核销失败,订单金额少于100只能核销一张优惠券。';
|
||||
}
|
||||
// if ($this->total < 100) {
|
||||
// return '核销失败,订单金额少于100只能核销一张优惠券。';
|
||||
// }
|
||||
if ($check_count >= $count) {
|
||||
return "核销失败,此订单您只能使用 {$count} 张优惠券";
|
||||
}
|
||||
@@ -173,10 +182,10 @@ class Init
|
||||
public function HasCheck()
|
||||
{
|
||||
$info = Coupon::where('redemptionCode', $this->redemptionCode)
|
||||
->where('outletId', $this->outletId)
|
||||
->where('total', $this->total)
|
||||
->where('status', 2)
|
||||
->first();
|
||||
->where('outletId', $this->outletId)
|
||||
->where('total', $this->total)
|
||||
->where('status', 2)
|
||||
->first();
|
||||
if ($info) {
|
||||
return '核销失败,此优惠券已被使用';
|
||||
}
|
||||
|
||||
@@ -11,9 +11,6 @@ class Verification extends PingAnInit
|
||||
|
||||
public $ticket;
|
||||
|
||||
//查询到的卡券规则和商品id
|
||||
public $queryData;
|
||||
|
||||
public function start()
|
||||
{
|
||||
//检查是否已经核销过
|
||||
@@ -22,16 +19,10 @@ class Verification extends PingAnInit
|
||||
return $res;
|
||||
}
|
||||
|
||||
//检查可核销次数
|
||||
$ret = $this->CheckCount();
|
||||
if ($ret !== true) {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
//查询卡券信息
|
||||
$this->query_coupon = (new Query)->setOutletId($this->outletId)
|
||||
->setCode($this->redemptionCode)
|
||||
->start();
|
||||
->setCode($this->redemptionCode)
|
||||
->start();
|
||||
if (is_string($this->query_coupon)) {
|
||||
return $this->query_coupon;
|
||||
}
|
||||
@@ -42,6 +33,12 @@ class Verification extends PingAnInit
|
||||
return $ticket;
|
||||
}
|
||||
|
||||
//检查可核销次数
|
||||
$ret = $this->CheckCount();
|
||||
if ($ret !== true) {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
//增加核销记录
|
||||
$coupon = $this->AddCoupon();
|
||||
if (is_string($coupon)) {
|
||||
|
||||
Reference in New Issue
Block a user