Sale.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2017/3/6
  6. * Time: 上午11:42
  7. */
  8. namespace app\common\models;
  9. use app\backend\modules\goods\observers\SaleObserver;
  10. /**
  11. * Class Sale
  12. * @package app\common\models
  13. * @property float ed_num
  14. * @property float ed_money
  15. */
  16. class Sale extends BaseModel
  17. {
  18. public $table = 'yz_goods_sale';
  19. public $attributes = [
  20. 'max_point_deduct' => '',
  21. 'min_point_deduct' => '',
  22. 'max_balance_deduct' => '',
  23. 'min_balance_deduct' => '',
  24. 'has_all_point_deduct' => 0,
  25. 'all_point_deduct' => 0,
  26. 'is_sendfree' => 0,
  27. 'ed_num' => '',
  28. 'ed_full' => 0,
  29. 'ed_reduction' => 0,
  30. 'ed_money' => '',
  31. 'point' => '',
  32. 'bonus' => 0,
  33. 'award_balance' => 0,
  34. 'pay_reward_balance' => 0,
  35. 'point_type' => 0,
  36. 'max_once_point' => 0,
  37. 'ed_areas' => '',
  38. 'push_goods_ids' => 0,
  39. 'is_push' => 0,
  40. ];
  41. protected $appends = ['point_deduct_type'];
  42. protected $guarded = [''];
  43. public function getPointDeductTypeAttribute()
  44. {
  45. if (isset($this->attributes['point_deduct_type'])) {
  46. return $this->attributes['point_deduct_type'];
  47. }
  48. if (strexists($this->getOriginal('max_point_deduct'), '%') || strexists($this->getOriginal('min_point_deduct'), '%')) {
  49. return 1;
  50. }
  51. return 0;
  52. }
  53. public static function boot()
  54. {
  55. parent::boot();
  56. //注册观察者
  57. static::observe(new SaleObserver);
  58. }
  59. }