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.

44 lines
1.0 KiB

6 years ago
6 years ago
5 years ago
5 years ago
5 years ago
6 years ago
  1. <?php
  2. namespace App\Model\v3;
  3. use App\Model\Model;
  4. class Coupon extends Model
  5. {
  6. const DISCOUNT_TYPE_CASH = 1;
  7. const DISCOUNT_TYPE_RATE = 2;
  8. protected $table = 'lanzu_coupon';
  9. protected $appends = [
  10. 'full_amount_text',
  11. 'discounts_text',
  12. 'time_text'
  13. ];
  14. protected $casts = [
  15. 'activity_available' => 'array',
  16. 'tags' => 'array'
  17. ];
  18. public function getFullAmountTextAttribute()
  19. {
  20. return '满'.$this->attributes['full_amount'].'可用';
  21. }
  22. public function getDiscountsTextAttribute()
  23. {
  24. if($this->attributes['discount_type'] == 1){
  25. return '¥'.$this->attributes['discounts'];
  26. }elseif($this->attributes['discount_type'] == 2){
  27. return floatval($this->attributes['discounts'])."";
  28. }
  29. }
  30. public function getTimeTextAttribute()
  31. {
  32. 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']);
  33. }
  34. }