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.

38 lines
814 B

6 years ago
6 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. ];
  13. protected $casts = [
  14. 'activity_available' => 'array',
  15. 'tags' => 'array'
  16. ];
  17. public function getFullAmountTextAttribute()
  18. {
  19. return '满'.$this->attributes['full_amount'].'可用';
  20. }
  21. public function getDiscountsTextAttribute()
  22. {
  23. if($this->attributes['discount_type'] == 1){
  24. return '¥'.$this->attributes['discounts'];
  25. }elseif($this->attributes['discount_type'] == 2){
  26. return floatval($this->attributes['discounts'])."";
  27. }
  28. }
  29. }