同一个券码,重复提交校验,3秒内视为同一笔订单。
This commit is contained in:
@@ -147,4 +147,37 @@ class Init
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 校验是否已经核销过。3秒内视为同一订单
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/8/8 13:43
|
||||
*/
|
||||
public function HasCheck()
|
||||
{
|
||||
$code = $this->redemptionCode;
|
||||
$total = $this->total;
|
||||
$outletId = $this->outletId;
|
||||
|
||||
$info = Coupon::where('redemptionCode', $this->redemptionCode)
|
||||
->where('outletId', $this->outletId)
|
||||
->where('total', $this->total)
|
||||
->where('status', 2)
|
||||
->first();
|
||||
if ($info) {
|
||||
if ($info->created_at->gt(now()->subSecond(3))) {
|
||||
return [
|
||||
'name' => $info->couponName,
|
||||
'total' => $info->total,
|
||||
'price' => $info->price,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
return '核销失败,此优惠券已被使用';
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user