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) { // 将抵扣总金额保存在订单优惠信息表中 $preOrderGoodsDiscount = new PreOrderGoodsDiscount([ 'discount_code' => $this->getCode(), 'amount' => $this->amount ?: 0, 'name' => $this->getName(), ]); $preOrderGoodsDiscount->setOrderGoods($this->orderGoods); } return $this->amount ?: 0; } /** * @return bool */ protected function orderDiscountCalculated() { return $this->orderGoods->order->getDiscount()->getAmountByCode($this->getCode())->calculated(); } /** * @return float */ abstract protected function _getAmount(); }