You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.4 KiB
81 lines
2.4 KiB
<?php
|
|
/**
|
|
* 预约
|
|
*/
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\Appointment;
|
|
use App\Models\Config;
|
|
use App\Models\User;
|
|
use App\Notifications\MeetNotify;
|
|
use App\Repositories\DoorRepository;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Notification;
|
|
|
|
class SendAppoint implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
public $tries = 3;
|
|
public $timeout = 850;
|
|
|
|
public $appointmentModel;
|
|
public $appointmentConfig;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($appointmentModel, $AppointmentConfig)
|
|
{
|
|
$this->appointmentModel = $appointmentModel;
|
|
$this->appointmentConfig = $AppointmentConfig;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle()
|
|
{
|
|
// 预约车牌(有成功的就不会再次预约)
|
|
$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();
|
|
}
|
|
}
|