You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.2 KiB
50 lines
1.2 KiB
<?php
|
|
|
|
namespace App\Model\v3;
|
|
|
|
use App\Model\Model;
|
|
|
|
class Coupon extends Model
|
|
{
|
|
const DISCOUNT_TYPE_CASH = 1;
|
|
const DISCOUNT_TYPE_RATE = 2;
|
|
|
|
protected $table = 'lanzu_coupon';
|
|
|
|
protected $appends = [
|
|
'full_amount_text',
|
|
'discounts_text',
|
|
'time_text',
|
|
'effective_time_text'
|
|
];
|
|
|
|
protected $casts = [
|
|
'activity_available' => 'array',
|
|
'tags' => 'array'
|
|
];
|
|
|
|
public function getFullAmountTextAttribute()
|
|
{
|
|
return '满'.$this->attributes['full_amount'].'可用';
|
|
}
|
|
|
|
public function getDiscountsTextAttribute()
|
|
{
|
|
if($this->attributes['discount_type'] == 1){
|
|
return '¥'.$this->attributes['discounts'];
|
|
}elseif($this->attributes['discount_type'] == 2){
|
|
return floatval($this->attributes['discounts'])."折";
|
|
}
|
|
}
|
|
|
|
public function getTimeTextAttribute()
|
|
{
|
|
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']);
|
|
}
|
|
|
|
}
|