diff --git a/app/Jobs/SendAppoint.php b/app/Jobs/SendAppoint.php index f926e1e..b571c16 100755 --- a/app/Jobs/SendAppoint.php +++ b/app/Jobs/SendAppoint.php @@ -45,21 +45,36 @@ class SendAppoint implements ShouldQueue */ public function handle() { - // 预约门禁 - $result = (new Appointment())->appointDoor($this->appointmentModel, $this->appointmentConfig); - if ($result) { - // 成功预约会议室 - $result = (new Appointment())->appointMeet($this->appointmentModel, $this->appointmentConfig); - } - if ($result) { - // 门禁会议预约成功,预约车牌 - Appointment::sendAppoinCar($this->appointmentModel); - // 预约成功 + // 预约车牌(有成功的就不会再次预约) + $carResult = Appointment::sendAppoinCar($this->appointmentModel); + // 预约会议室(有成功的就不会再次预约) + $meetResult = (new Appointment())->appointMeet($this->appointmentModel, $this->appointmentConfig); + // 预约门禁(每个学员一定会预约门禁) + $doorResult = (new Appointment())->appointDoor($this->appointmentModel, $this->appointmentConfig); + if ($doorResult) { + // 门禁预约成功 $this->appointmentModel->status = 1; } else { // 预约失败 $this->appointmentModel->status = 4; } $this->appointmentModel->save(); + + // 预约门禁 +// $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(); } } diff --git a/app/Models/Appointment.php b/app/Models/Appointment.php index 0cb6a38..48c0705 100755 --- a/app/Models/Appointment.php +++ b/app/Models/Appointment.php @@ -93,7 +93,7 @@ class Appointment extends SoftDeletesModel $meetIds = array_filter($meetIds); if ($meetIds) { foreach ($meetIds as $meetId) { - dispatch((new CancelAppointMeet($model,$meetId))); + dispatch((new CancelAppointMeet($model, $meetId))); } } // 取消预约车位 @@ -156,7 +156,14 @@ class Appointment extends SoftDeletesModel $result = false; $meetRepository = new MeetRepository(); foreach ($appointmentConfig as $config) { - if(empty($config->room)) continue; + if (empty($config->room)) { + continue; + }; + // 判断是否有预约成功记录,没有就重新预约 + $thirdMeetLog = $appointmentModel->thirdAppointmentLogs()->where('remark', '会议室预约')->where('finally', 1)->first(); + if ($thirdMeetLog) { + continue; + } $result = $meetRepository->appointment($appointmentModel, $config, $out); } return $result;