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.

32 lines
713 B

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