From aa18b67918a001ceb959dcac1a154223d783fbb5 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Mon, 19 Oct 2020 11:06:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E6=8B=BC=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/v3/Coupon.php | 8 +++++++- app/Service/v3/Implementations/CouponRecService.php | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Model/v3/Coupon.php b/app/Model/v3/Coupon.php index 2af1594..206c889 100644 --- a/app/Model/v3/Coupon.php +++ b/app/Model/v3/Coupon.php @@ -14,7 +14,8 @@ class Coupon extends Model protected $appends = [ 'full_amount_text', 'discounts_text', - 'time_text' + 'time_text', + 'effective_time_text' ]; protected $casts = [ @@ -41,4 +42,9 @@ class Coupon extends Model return date("Y-m-d H:i:s",$this->attributes['usable_start_time']). ' - ' .date("Y-m-d H:i:s",$this->attributes['usable_end_time']); } + public function getEffectiveTimeTextAttribute() + { + return '有效期:'.date("Y-m-d",$this->attributes['usable_start_time']). ' - ' .date("Y-m-d",$this->attributes['usable_end_time']); + } + } diff --git a/app/Service/v3/Implementations/CouponRecService.php b/app/Service/v3/Implementations/CouponRecService.php index b4a1baf..b6cb27a 100644 --- a/app/Service/v3/Implementations/CouponRecService.php +++ b/app/Service/v3/Implementations/CouponRecService.php @@ -440,12 +440,13 @@ class CouponRecService implements CouponRecServiceInterface $cr = new CouponRec; $cr->user_id = $userId; - $cr->coupon_id = $cp->id; + $cr->coupon_id = $cp->id; $cr->order_main_id = 0; $cr->receive_time = $now; $cr->number = $oneReceiveNumber; $cr->number_remain = $oneReceiveNumber; $cr->status = 0; + $cr->update_time = $now; $cr->receive_type = $receiveType; //如果优惠卷库存小于等于已领取的数量, 则返回领取失败的优惠券 if ($cp->inventory<=$cp->inventory_use||$cp->inventory<($cp->inventory_use+$cr->number)){