|
@@ -85,20 +85,19 @@ class Appointment extends Base
|
|
//专家信息
|
|
//专家信息
|
|
$item->specialist;
|
|
$item->specialist;
|
|
$item->specialist->head_pic = geturl($item->specialist->head_pic, '', true);
|
|
$item->specialist->head_pic = geturl($item->specialist->head_pic, '', true);
|
|
- //剩余预约号码
|
|
|
|
- $item['morning_remaining'] = $item->morning_num - $item->morning_use;
|
|
|
|
- $item['afternoon_remaining'] = $item->afternoon_num - $item->afternoon_use;
|
|
|
|
- $item['night_remaining'] = $item->night_num - $item->night_use;
|
|
|
|
//拆分预约时段
|
|
//拆分预约时段
|
|
$ticketPeriods = (new AppointmentApplication())->where('appointment_ticket_id', $item->id)->column('appointment_time');
|
|
$ticketPeriods = (new AppointmentApplication())->where('appointment_ticket_id', $item->id)->column('appointment_time');
|
|
$item['morning_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($item->morning_start_time, $item->morning_end_time, $item->morning_num), $ticketPeriods);
|
|
$item['morning_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($item->morning_start_time, $item->morning_end_time, $item->morning_num), $ticketPeriods);
|
|
$item['afternoon_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($item->afternoon_start_time, $item->afternoon_end_time, $item->afternoon_num), $ticketPeriods);
|
|
$item['afternoon_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($item->afternoon_start_time, $item->afternoon_end_time, $item->afternoon_num), $ticketPeriods);
|
|
$item['night_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($item->night_start_time, $item->night_end_time, $item->night_num), $ticketPeriods);
|
|
$item['night_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($item->night_start_time, $item->night_end_time, $item->night_num), $ticketPeriods);
|
|
-
|
|
|
|
|
|
+ //剩余预约号码
|
|
|
|
+ $item['morning_remaining'] = count($item['morning_time_period']);
|
|
|
|
+ $item['afternoon_remaining'] = count($item['afternoon_time_period']);
|
|
|
|
+ $item['night_remaining'] = count($item['night_time_period']);
|
|
$tickets[$k] = $item;
|
|
$tickets[$k] = $item;
|
|
}
|
|
}
|
|
|
|
|
|
- $this->json_success($tickets);
|
|
|
|
|
|
+ $this->json_success("查询成功", $tickets);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -109,8 +108,17 @@ class Appointment extends Base
|
|
*/
|
|
*/
|
|
private function setPeriodStatus($timePeriods, $ticketPeriods)
|
|
private function setPeriodStatus($timePeriods, $ticketPeriods)
|
|
{
|
|
{
|
|
|
|
+ $daytime = $this->request->param('daytime', date('Y-m-d'));
|
|
$arr = [];
|
|
$arr = [];
|
|
|
|
+ $now = time();
|
|
foreach ($timePeriods as $ticket => $period) {
|
|
foreach ($timePeriods as $ticket => $period) {
|
|
|
|
+ //排除过期时段
|
|
|
|
+ $timerang = explode(' - ', $period);
|
|
|
|
+ $period_end = $timerang[1];
|
|
|
|
+ if ($now > strtotime($daytime . ' ' . $period_end)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //标记预约状态
|
|
if (in_array($period, $ticketPeriods)) {
|
|
if (in_array($period, $ticketPeriods)) {
|
|
$arr[] = ['period' => $period, 'status' => 1];
|
|
$arr[] = ['period' => $period, 'status' => 1];
|
|
} else {
|
|
} else {
|