order_info = $order_info; } public function getCorpId() { return $this->order_info['corpid'] ?? null; } /** * Execute the job. * * @return void */ public function handle() { try { // $corpId = $this->order_info['corpid']; (new DbService())->getConnectionNameByCorpId($corpId); // 创建任务记录 $this->Records = Records::create([ 'job_id' => $this->order_info['order_id'] . '_OrderDetailJobs', 'name' => static::class, 'payload' => json_encode($this->order_info), 'status' => 'processing', 'started_at' => now() ]); $result = (new LicenseClientService())->get_order_info($this->order_info['order_id']); // 如果获取结果失败 if (!$result) { //删除任务记录 $this->Records->delete(); Log::info('job_error', '同步订单详情失败', [$this->order_info]); return json_send(['code' => 'error', 'msg' => '获取失败']); } // 错误提示 if (isset($result['errcode'])) { Log::info('job_error', '同步订单详情失败',[$this->order_info]); } //删除任务记录 $this->Records->delete(); // 成功处理... } catch (\Exception $e) { // 失败处理... if ($this->Records) { $this->Records->delete(); } Log::error('job_error', 'OrderDetailJobs处理失败', ['data'=>$this->order_info,'error' => $e->getMessage()]); } } public function failed(\Throwable $exception) { Log::info('job_error', 'OrderDetailJobs彻底失败', ['data'=>$this->order_info,'error' => $exception]); // 失败处理... if ($this->Records) { $this->Records->delete(); } } }