make('GoodsDeductionManager')->bound($this->getCode()); } //订单抵扣新增判断,抵扣虚拟币必须注册会员类 public function memberCoin($member) { if (app('CoinManager')->make('MemberCoinManager')->bound($this->getCode())) { return app('CoinManager')->make('MemberCoinManager')->make($this->getCode(), [$member]); } return false; } public function getId() { return $this->id; } public function getName() { return $this->getCoin()->getName(); } public function getCode() { return $this->code; } public function getCoin() { if (isset($this->coin)) { return $this->coin; } return $this->coin = app('CoinManager')->make($this->getCode()); } /** * @return bool | DeductionSettingCollection */ public function getSettingCollection() { if (isset($this->setting)) { return $this->setting; } if (!app('DeductionManager')->make('DeductionSettingManager')->bound($this->getCode())) { return false; } // todo 这里设计有错误, 没有区分订单范围内的抵扣设置项和全局范围内的抵扣设置项, 为了快速解决这个问题,在getDeductionSettingCollection方法中过滤掉 商品的抵扣设置 return $this->setting = app('DeductionManager')->make('DeductionSettingManager')->make($this->getCode())->getDeductionSettingCollection(new Goods()); } public function isEnableDeductDispatchPrice() { if (!$this->getSettingCollection()) { return false; } return $this->getSettingCollection()->isEnableDeductDispatchPrice(); } /** * todo 这里应该是全局范围内的抵扣设置项 * @return bool|mixed|string */ public function getAffectDeductionAmount() { if (!$this->getSettingCollection()) { return false; } return $this->getSettingCollection()->getAffectDeductionAmount(); } public function getEnable(){ if(ShopConfig::current()->get('shop-foundation.deduction.enable') == false){ return collect(); } return Deduction::where('enable', 1)->get(); } }