Compare commits
3 Commits
42cade8b99
...
09efc1e323
| Author | SHA1 | Date | |
|---|---|---|---|
| 09efc1e323 | |||
| ac9d3d9a25 | |||
| 02883d10c0 |
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
/tests/
|
||||||
|
/.idea
|
||||||
|
/.env
|
||||||
|
/.editorconfig
|
||||||
@@ -147,4 +147,33 @@ class Init
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 校验是否已经核销过。3秒内视为同一订单。不能提交订单id 只能这么办
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date : 2020/8/8 13:43
|
||||||
|
*/
|
||||||
|
public function HasCheck()
|
||||||
|
{
|
||||||
|
$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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ class Verification extends PingAnInit
|
|||||||
|
|
||||||
public function start()
|
public function start()
|
||||||
{
|
{
|
||||||
|
//检查是否已经核销过
|
||||||
|
$res = $this->HasCheck();
|
||||||
|
if ($res !== false) {
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
//检查可核销次数
|
//检查可核销次数
|
||||||
$ret = $this->CheckCount();
|
$ret = $this->CheckCount();
|
||||||
if ($ret !== true) {
|
if ($ret !== true) {
|
||||||
@@ -26,7 +32,6 @@ class Verification extends PingAnInit
|
|||||||
$this->query_coupon = (new Query)->setOutletId($this->outletId)
|
$this->query_coupon = (new Query)->setOutletId($this->outletId)
|
||||||
->setCode($this->redemptionCode)
|
->setCode($this->redemptionCode)
|
||||||
->start();
|
->start();
|
||||||
|
|
||||||
if (is_string($this->query_coupon)) {
|
if (is_string($this->query_coupon)) {
|
||||||
return $this->query_coupon;
|
return $this->query_coupon;
|
||||||
}
|
}
|
||||||
@@ -44,7 +49,6 @@ class Verification extends PingAnInit
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
'couponNo' => $coupon->redemptionCode,
|
'couponNo' => $coupon->redemptionCode,
|
||||||
'partnerOrderId' => date('ymdHis') . sprintf("%0" . strlen(999999) . "d", mt_rand(0, 999999)),
|
'partnerOrderId' => date('ymdHis') . sprintf("%0" . strlen(999999) . "d", mt_rand(0, 999999)),
|
||||||
|
|||||||
@@ -20,12 +20,21 @@ class YsdVerification extends Init
|
|||||||
*/
|
*/
|
||||||
public function start()
|
public function start()
|
||||||
{
|
{
|
||||||
|
//检查是否已经核销过
|
||||||
|
$res = $this->HasCheck();
|
||||||
|
if ($res !== false) {
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
//查询卡券信息
|
//查询卡券信息 返回model string 说明报错
|
||||||
$this->query_coupon = (new YsdQuery)->setOutletId($this->outletId)
|
$this->query_coupon = (new YsdQuery)->setOutletId($this->outletId)
|
||||||
->setCode($this->redemptionCode)
|
->setCode($this->redemptionCode)
|
||||||
->start();
|
->start();
|
||||||
//检查可核销次数
|
if (is_string($this->query_coupon)) {
|
||||||
|
return $this->query_coupon;
|
||||||
|
}
|
||||||
|
|
||||||
|
//检查可核销次数,100元为1次。
|
||||||
if ($this->query_coupon->activity && $this->query_coupon->activity->need_check) {
|
if ($this->query_coupon->activity && $this->query_coupon->activity->need_check) {
|
||||||
$ret = $this->CheckCount();
|
$ret = $this->CheckCount();
|
||||||
if ($ret !== true) {
|
if ($ret !== true) {
|
||||||
@@ -33,10 +42,6 @@ class YsdVerification extends Init
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($this->query_coupon)) {
|
|
||||||
return $this->query_coupon;
|
|
||||||
}
|
|
||||||
|
|
||||||
//校验卡券
|
//校验卡券
|
||||||
$ticket = $this->checkCoupon();
|
$ticket = $this->checkCoupon();
|
||||||
if (!is_array($ticket)) {
|
if (!is_array($ticket)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user