id = $biddingId; $this->title = '选中竞标'; } protected function html() { $class = 'btn btn-sm btn-success'; $this->appendHtmlAttribute('class', $class); $this->defaultHtmlAttribute('href', 'javascript:;'); return "formatHtmlAttributes()}>{$this->title}"; } public function handle(Request $request) { $demandBiddingId = request('bidding_id',0); $demandBidding = DemandBidding::find($demandBiddingId); if (empty($demandBidding)) { return $this->response()->error('订单异常'); } $demand = \App\Models\Demand::find($demandBidding->demand_id); if (empty($demand)) { return $this->response()->error('订单异常'); } DB::beginTransaction(); try { $demandBidding->state = 1; $demandBidding->save(); //改变订单状态 $demand->bidding_id = $demandBidding->id; $demand->bidding_user_id = $demandBidding->bidding_user_id; $demand->state = DemandTraits::$stateKey[1]; $demand->save(); //如果是地接类型 绑定地接到订单 if ($demand->bidding_user_type == DemandTraits::$col[2]){ $agentProduct = AgentProduct::find($demand->agent_product_id); $agentProduct->guide_id = $demandBidding->bidding_user_id; $agentProduct->save(); } DB::commit(); return $this->response()->success("选中竞标成功")->refresh(); } catch (\Exception $e) { Log::error('选中竞标失败::'.$e->getTraceAsString()); DB::rollBack(); return $this->response()->error($e->getMessage()); } } public function confirm() { return ['确定要选中该竞标吗?', '']; } public function parameters() { return ['bidding_id' => $this->id]; } }