appointmentModel = $appointmentModel; $this->appointmentConfig = $AppointmentConfig; $this->traceId = $traceId ?: uniqid('appointment-job-', true); } /** * Execute the job. * * @return void */ public function handle() { $startedAt = microtime(true); $context = ['trace_id' => $this->traceId, 'appointment_id' => $this->appointmentModel->id]; Log::info('appointment.retry.job.started', $context); try { Log::info('appointment.retry.car.begin', $context); $carResult = Appointment::sendAppoinCar($this->appointmentModel); Log::info('appointment.retry.car.completed', $context + ['result' => $carResult]); Log::info('appointment.retry.meet.begin', $context); $meetResult = (new Appointment())->appointMeet($this->appointmentModel, $this->appointmentConfig); Log::info('appointment.retry.meet.completed', $context + ['result' => $meetResult]); Log::info('appointment.retry.door.begin', $context); $doorResult = (new Appointment())->appointDoor($this->appointmentModel, $this->appointmentConfig); Log::info('appointment.retry.door.completed', $context + ['result' => $doorResult]); $this->appointmentModel->status = $doorResult ? 1 : 4; $this->appointmentModel->save(); Log::info('appointment.retry.job.completed', $context + [ 'status' => $this->appointmentModel->status, 'elapsed_ms' => (int) ((microtime(true) - $startedAt) * 1000), ]); } catch (\Throwable $exception) { Log::error('appointment.retry.job.failed', $context + [ 'elapsed_ms' => (int) ((microtime(true) - $startedAt) * 1000), 'exception' => $exception, ]); throw $exception; } // 预约门禁 // $result = (new Appointment())->appointDoor($this->appointmentModel, $this->appointmentConfig); // if ($result) { // // 成功预约会议室 // $result = (new Appointment())->appointMeet($this->appointmentModel, $this->appointmentConfig); // } // if ($result) { // // 门禁会议预约成功,预约车牌 // Appointment::sendAppoinCar($this->appointmentModel); // // 预约成功 // $this->appointmentModel->status = 1; // } else { // // 预约失败 // $this->appointmentModel->status = 4; // } // $this->appointmentModel->save(); } }