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.

37 lines
787 B

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