order = $order; // 订单手续费集合 $order->setRelation('orderFees', new Collection()); } public function getFee() { if (!isset($this->orderFee)) { $this->orderFee = collect(); foreach (\app\common\modules\shop\ShopConfig::current()->get('shop-foundation.order-fee') as $configItem) { $class = call_user_func($configItem['class'], $this->order); if($class->enable()){ $this->orderFee->put($configItem['key'], $class); } } } return $this->orderFee; } public function getAmount() { return $this->getFee()->sum(function (BaseOrderFee $orderFee) { // 每一种手续费 return $orderFee->getAmount(); }); } }