| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace app\frontend\models\order;
- use app\common\models\order\OrderTaxFee;
- use app\frontend\models\Order;
- use app\frontend\modules\order\models\PreOrder;
- use app\frontend\modules\order\taxFee\BaseOrderTaxFee;
- class PreOrderTaxFee extends OrderTaxFee
- {
- protected $appends = ['checked', 'show','show_name'];
- /**
- * @var Order
- */
- public $order;
- /**
- * @var BaseOrderTaxFee
- */
- protected $taxFee;
- public function init(BaseOrderTaxFee $taxFee, PreOrder $order)
- {
- $this->taxFee = $taxFee;
- $this->setOrder($order);
- }
- public function setOrder(PreOrder $order)
- {
- $this->order = $order;
- $this->uniacid = \YunShop::app()->uniacid;
- $this->uid = $order->uid;
- $this->fee_code = $this->getTaxFee()->getCode();
- $this->name = $this->getTaxFee()->getName();
- $this->rate = $this->getTaxFee()->getRate();
- $this->amount = sprintf('%.2f', $this->getTaxFee()->getAmount());
- $order->orderTaxFees->push($this);
- }
- public function getTaxFee()
- {
- return $this->taxFee;
- }
- /**
- * 调用当前类不存在方法时 查询 BaseOrderTaxFee 类存在代替处理
- * @param string $method
- * @param array $parameters
- * @return mixed
- */
- public function __call($method, $parameters)
- {
- if (method_exists($this->getTaxFee(), $method)) {
- return $this->getTaxFee()->$method($parameters);
- }
- return parent::__call($method, $parameters); // TODO: Change the autogenerated stub
- }
- public function getCheckedAttribute()
- {
- return $this->getTaxFee()->isChecked();
- }
- public function getShowAttribute()
- {
- return $this->getTaxFee()->isShow();
- }
- public function getShowNameAttribute()
- {
- return $this->getTaxFee()->getShowName();
- }
- /**
- * @return bool
- */
- public function beforeSaving()
- {
- if (!$this->getTaxFee()->isChecked()) {
- return false;
- }
- return parent::beforeSaving();
- }
- }
|