Browse Source

优惠券字段拼接

master
Lemon 5 years ago
parent
commit
aa18b67918
  1. 8
      app/Model/v3/Coupon.php
  2. 3
      app/Service/v3/Implementations/CouponRecService.php

8
app/Model/v3/Coupon.php

@ -14,7 +14,8 @@ class Coupon extends Model
protected $appends = [ protected $appends = [
'full_amount_text', 'full_amount_text',
'discounts_text', 'discounts_text',
'time_text'
'time_text',
'effective_time_text'
]; ];
protected $casts = [ 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']); 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']);
}
} }

3
app/Service/v3/Implementations/CouponRecService.php

@ -440,12 +440,13 @@ class CouponRecService implements CouponRecServiceInterface
$cr = new CouponRec; $cr = new CouponRec;
$cr->user_id = $userId; $cr->user_id = $userId;
$cr->coupon_id = $cp->id;
$cr->coupon_id = $cp->id;
$cr->order_main_id = 0; $cr->order_main_id = 0;
$cr->receive_time = $now; $cr->receive_time = $now;
$cr->number = $oneReceiveNumber; $cr->number = $oneReceiveNumber;
$cr->number_remain = $oneReceiveNumber; $cr->number_remain = $oneReceiveNumber;
$cr->status = 0; $cr->status = 0;
$cr->update_time = $now;
$cr->receive_type = $receiveType; $cr->receive_type = $receiveType;
//如果优惠卷库存小于等于已领取的数量, 则返回领取失败的优惠券 //如果优惠卷库存小于等于已领取的数量, 则返回领取失败的优惠券
if ($cp->inventory<=$cp->inventory_use||$cp->inventory<($cp->inventory_use+$cr->number)){ if ($cp->inventory<=$cp->inventory_use||$cp->inventory<($cp->inventory_use+$cr->number)){

Loading…
Cancel
Save