orderGoods = $orderGoods; } public function setWeight($weight) { $this->weight = $weight; } public function getWeight() { return $this->weight; } public function getCode() { return $this->code; } public function getName() { return $this->name; } /** * 获取总金额 * @return float|int */ public function getAmount() { if (isset($this->amount)) { return $this->amount; } $this->amount = $this->_getAmount(); if ($this->amount) { // 将抵扣总金额保存在订单优惠信息表中 $preOrderGoodsTaxFee = new PreOrderGoodsTaxFee([ 'uniacid' => \YunShop::app()->uniacid, 'fee_code' => $this->getCode(), 'amount' => $this->amount ?: 0, 'name' => $this->getName(), ]); $preOrderGoodsTaxFee->setOrderGoods($this->orderGoods); } return $this->amount ?: 0; } /** * @return float */ abstract protected function _getAmount(); }