ifExitsTicket()) { $daylist = DateHelper::getDateList($this->start_time, $this->end_time); foreach ($daylist as $datetime) { (new AppointmentTicket())->save([ 'appointment_id' => $this->id, 'appointment_daytime' => strtotime($datetime), 'address_id' => $this->specialist->address_id ]); } $this->save(['ticket_status' => 1]); } } //是否已生成号源配置 public function ifExitsTicket() { return $this->ticket_status > 0; } //是否已存在预约订单 public function ifExitsAppointmentApplication() { } /** * 按地点获取预约列表 * @return false|\PDOStatement|string|\think\Collection */ public static function listByAddress() { //未结束的预约都保证生成了号源 $all = (new Appointment())->where('end_time', '>', time())->select(); /** @var $item Appointment */ foreach ($all as $item) { $item->createTicket(); } $addressIds = (new AppointmentTicket())->where('appointment_daytime', '>=', strtotime(date('Y-m-d')))->distinct('true')->column('address_id'); return (new Address())->where('id', 'in', $addressIds)->select(); } //关联专家 public function specialist() { return $this->belongsTo('Specialist', 'provider_id'); } }