order = $order; $this->preOrderDeduction = $preOrderDeduction; parent::__construct($weight); } function getKey() { return $this->preOrderDeduction->getCode() . 'MinDeduction'; } /** * @return mixed * @throws \app\common\exceptions\AppException */ function getPrice() { $price = $this->order->getPriceBefore($this->getKey()) - $this->preOrderDeduction->getMinDeduction()->getMoney(); if ($price < 0) { throw new AppException("订单优惠后金额{$this->order->getPriceBefore($this->getKey())}元,不满足{$this->preOrderDeduction->getName()}最低抵扣{$this->preOrderDeduction->getMinDeduction()->getMoney()}元"); } return $price; } }