bztang-admin/app/frontend/models/orderGoods/PreOrderGoodsDiscount.php

44 lines
1.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Created by PhpStorm.
* User: shenyang
* Date: 2017/7/25
* Time: 下午7:10
*/
namespace app\frontend\models\orderGoods;
use app\common\models\orderGoods\OrderGoodsDiscount;
use app\common\modules\orderGoods\models\PreOrderGoods;
class PreOrderGoodsDiscount extends OrderGoodsDiscount
{
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->appends = array_merge(['show_style'],$this->appends);
}
public $orderGoods;
public function setOrderGoods(PreOrderGoods $orderGoods)
{
$this->orderGoods = $orderGoods;
$this->uid = $this->orderGoods->uid;
$orderGoods->getOrderGoodsDiscounts()->push($this);
}
/**
* 前端显示样式:1左右布局积分全额抵扣/兑换 xxx0文字叙述177.00积分a全额 抵扣66.02元)
* @return int
*/
public function getShowStyleAttribute()
{
if (in_array($this->discount_code,['coinExchange'])) {
return 1;
}
return 0;
}
}