with('store')->where('id', $goodsId)->first(); // 商户歇业 if($data->store->is_rest == 1){ return ErrorCode::GOODS_ON_SALE_NO; } // 商品下架或已删除 if($data->on_sale == 0 || !is_null($data->deleted_at)){ return ErrorCode::GOODS_ON_SALE_NO; } // 商品库存不足 if($data->is_infinite != 1 && $data->inventory < $num){ return ErrorCode::GOODS_INVENTORY_ERROR; } return true; } public function undo() { // TODO: Implement undo() method. } public function getBanner($goodsId) { $banner = GoodsBanner::query()->where('goods_id',$goodsId)->orderByDesc('type')->get(); return $banner; } public function detail($goodsId) { $res = Goods::query()->with('store')->where('id',$goodsId)->first(); return $res; } }