去除3秒内

This commit is contained in:
2020-08-10 16:45:19 +08:00
parent 09efc1e323
commit f99da0c837
2 changed files with 40 additions and 49 deletions

View File

@@ -160,15 +160,6 @@ class Init
->where('status', 2) ->where('status', 2)
->first(); ->first();
if ($info) { if ($info) {
if ($info->created_at->gt(now()->subSecond(3))) {
return [
'name' => $info->couponName,
'total' => $info->total,
'price' => $info->price,
];
}
return '核销失败,此优惠券已被使用'; return '核销失败,此优惠券已被使用';
} }

View File

@@ -87,45 +87,6 @@ class YsdVerification extends Init
} }
/**
* Notes: 如可核销记录
* @Author: 玄尘
* @Date : 2020/7/21 15:03
* @return string
*/
public function AddCoupon()
{
DB::beginTransaction();
try {
$couponData = [
'user_id' => $this->user->id,
'type' => Coupon::TYPE_YSD,
'outletId' => $this->outletId,
'PaOutletId' => '',
'redemptionCode' => $this->redemptionCode,
'thirdPartyGoodsId' => $this->query_coupon->activity->rule->code,
'couponName' => $this->query_coupon->activity->title,
'price' => $this->ticket['price'],
'total' => $this->total,
'profit' => $this->ticket['profit'],
'status' => $this->query_coupon->status,
'startTime' => $this->query_coupon->start_at,
'endTime' => $this->query_coupon->end_at,
];
$this->coupon = Coupon::create($couponData);
DB::commit();
return $this->coupon;
} catch (Exception $e) {
DB::rollback();
return $e->getMessage();
}
}
/** /**
* Notes: 检查卡券信息 * Notes: 检查卡券信息
* @Author: 玄尘 * @Author: 玄尘
@@ -136,7 +97,7 @@ class YsdVerification extends Init
{ {
if (!$this->query_coupon->canRedemption()) { if (!$this->query_coupon->canRedemption()) {
return '核销失败,不可核销'; return '核销失败,优惠券不可核销';
} }
if ($this->query_coupon->activity->user_id > 0 && $this->user->id !== $this->query_coupon->activity->user_id) { if ($this->query_coupon->activity->user_id > 0 && $this->user->id !== $this->query_coupon->activity->user_id) {
@@ -193,4 +154,43 @@ class YsdVerification extends Init
} }
/**
* Notes: 如可核销记录
* @Author: 玄尘
* @Date : 2020/7/21 15:03
* @return string
*/
public function AddCoupon()
{
DB::beginTransaction();
try {
$couponData = [
'user_id' => $this->user->id,
'type' => Coupon::TYPE_YSD,
'outletId' => $this->outletId,
'PaOutletId' => '',
'redemptionCode' => $this->redemptionCode,
'thirdPartyGoodsId' => $this->query_coupon->activity->rule->code,
'couponName' => $this->query_coupon->activity->title,
'price' => $this->ticket['price'],
'total' => $this->total,
'profit' => $this->ticket['profit'],
'status' => $this->query_coupon->status,
'startTime' => $this->query_coupon->start_at,
'endTime' => $this->query_coupon->end_at,
];
$this->coupon = Coupon::create($couponData);
DB::commit();
return $this->coupon;
} catch (Exception $e) {
DB::rollback();
return $e->getMessage();
}
}
} }