PreOrderGoodsTaxFee.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2017/7/25
  6. * Time: 下午7:10
  7. */
  8. namespace app\frontend\models\orderGoods;
  9. use app\common\models\orderGoods\OrderGoodsTaxFee;
  10. use app\common\modules\orderGoods\models\PreOrderGoods;
  11. class PreOrderGoodsTaxFee extends OrderGoodsTaxFee
  12. {
  13. public function __construct(array $attributes = [])
  14. {
  15. parent::__construct($attributes);
  16. $this->appends = array_merge(['show_style'],$this->appends);
  17. }
  18. public $orderGoods;
  19. public function setOrderGoods(PreOrderGoods $orderGoods)
  20. {
  21. $this->orderGoods = $orderGoods;
  22. $this->uid = $this->orderGoods->uid;
  23. $orderGoods->getOrderGoodsTaxFees()->push($this);
  24. }
  25. /**
  26. * 前端显示样式:1左右布局(积分全额抵扣/兑换 xxx),0文字叙述(例:177.00积分a全额 抵扣66.02元)
  27. * @return int
  28. */
  29. public function getShowStyleAttribute()
  30. {
  31. if (in_array($this->discount_code,['coinExchange'])) {
  32. return 1;
  33. }
  34. return 0;
  35. }
  36. }