diff --git a/packages/coupon/src/Action/Init.php b/packages/coupon/src/Action/Init.php index 537fc19..ad2a477 100644 --- a/packages/coupon/src/Action/Init.php +++ b/packages/coupon/src/Action/Init.php @@ -160,15 +160,6 @@ class Init ->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 '核销失败,此优惠券已被使用'; } diff --git a/packages/coupon/src/Action/ysd/YsdVerification.php b/packages/coupon/src/Action/ysd/YsdVerification.php index c8fe440..5526b28 100644 --- a/packages/coupon/src/Action/ysd/YsdVerification.php +++ b/packages/coupon/src/Action/ysd/YsdVerification.php @@ -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: 检查卡券信息 * @Author: 玄尘 @@ -136,7 +97,7 @@ class YsdVerification extends Init { if (!$this->query_coupon->canRedemption()) { - return '核销失败,不可核销'; + return '核销失败,优惠券不可核销'; } 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(); + } + + } + } \ No newline at end of file