|
@@ -6,7 +6,6 @@ use app\api\controller\base\Base;
|
|
|
use app\common\model\Address;
|
|
|
use app\common\model\Appointment as appointmentModel;
|
|
|
use app\common\model\AppointmentApplication;
|
|
|
-use app\common\model\AppointmentTicket;
|
|
|
use time\DateHelper;
|
|
|
|
|
|
class Appointment extends Base
|
|
@@ -29,7 +28,7 @@ class Appointment extends Base
|
|
|
$this->json_error("没有数据");
|
|
|
}
|
|
|
foreach ($datalist as $key => $item) {
|
|
|
- $item['thumb'] = geturl($item->thumb, '', true);
|
|
|
+ $item['thumb_url'] = geturl($item->thumb, '', true);
|
|
|
$datalist[$key] = $item;
|
|
|
}
|
|
|
$this->json_success("查询成功", $datalist);
|
|
@@ -49,7 +48,7 @@ class Appointment extends Base
|
|
|
}
|
|
|
|
|
|
$where = [];
|
|
|
- $addressIds = (new appointmentModel())->availableAddressIds();
|
|
|
+ $addressIds = (new appointmentModel())->where('daytime', '>=', strtotime(date('Y-m-d')))->distinct(true)->column('address_id');
|
|
|
$where['id'] = ['in', $addressIds];
|
|
|
$pagenum = $this->request->param('pagenum', 20, 'intval');
|
|
|
$datalist = (new Address())->where($where)->paginate($pagenum, true);
|
|
@@ -57,7 +56,7 @@ class Appointment extends Base
|
|
|
$this->json_error("没有数据");
|
|
|
}
|
|
|
foreach ($datalist as $key => $item) {
|
|
|
- $item['thumb'] = geturl($item->thumb, '', true);
|
|
|
+ $item['thumb_url'] = geturl($item->thumb, '', true);
|
|
|
$datalist[$key] = $item;
|
|
|
}
|
|
|
$this->json_success("查询成功", $datalist);
|
|
@@ -79,26 +78,22 @@ class Appointment extends Base
|
|
|
$address_id = $this->request->param('address_id');
|
|
|
$daytime = $this->request->param('daytime', date('Y-m-d'));
|
|
|
|
|
|
- $ticketModel = new AppointmentTicket();
|
|
|
- $tickets = $ticketModel->where('address_id', $address_id)->where('appointment_daytime', strtotime($daytime))->select();
|
|
|
+ $ticketModel = new appointmentModel();
|
|
|
+ $tickets = $ticketModel->where('address_id', $address_id)->where('daytime', strtotime($daytime))->select();
|
|
|
|
|
|
foreach ($tickets as $k => $item) {
|
|
|
- $appoint = $item->appointment;
|
|
|
- $item['price'] = $appoint->price;
|
|
|
-
|
|
|
- $item['appointment_daytime_text'] = date('Y-m-d', $item->appointment_daytime);
|
|
|
|
|
|
$item->specialist;
|
|
|
$item->specialist->head_pic = geturl($item->specialist->head_pic, '', true);
|
|
|
|
|
|
- $item['morning_remaining'] = $appoint->morning_num - $item->morning_use;
|
|
|
- $item['afternoon_remaining'] = $appoint->afternoon_num - $item->afternoon_use;
|
|
|
- $item['night_remaining'] = $appoint->night_num - $item->night_use;
|
|
|
+ $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');
|
|
|
- $item['morning_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($appoint->morning_start_time, $appoint->morning_end_time, $appoint->morning_num), $ticketPeriods);
|
|
|
- $item['afternoon_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($appoint->afternoon_start_time, $appoint->afternoon_end_time, $appoint->afternoon_num), $ticketPeriods);
|
|
|
- $item['night_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($appoint->night_start_time, $appoint->night_end_time, $appoint->night_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['night_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($item->night_start_time, $item->night_end_time, $item->night_num), $ticketPeriods);
|
|
|
|
|
|
$tickets[$k] = $item;
|
|
|
}
|
|
@@ -128,14 +123,7 @@ class Appointment extends Base
|
|
|
|
|
|
public function addressListByDayTime()
|
|
|
{
|
|
|
- appointmentModel::createTicketFromAllAppointment();
|
|
|
- $ticketModel = new AppointmentTicket();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ $ticketModel = new appointmentModel();
|
|
|
$post = $this->request->param();
|
|
|
$validate = new \think\Validate([
|
|
|
['daytime', 'date|dateFormat:Y-m-d'],
|
|
@@ -147,7 +135,7 @@ class Appointment extends Base
|
|
|
}
|
|
|
|
|
|
$daytime = $this->request->param('daytime', date('Y-m-d'));
|
|
|
- $addressIds = $ticketModel->where('appointment_daytime', strtotime($daytime))->column('address_id');
|
|
|
+ $addressIds = $ticketModel->where('daytime', strtotime($daytime))->distinct(true)->column('address_id');
|
|
|
|
|
|
$where = [];
|
|
|
$where['id'] = ['in', $addressIds];
|
|
@@ -156,6 +144,10 @@ class Appointment extends Base
|
|
|
if (empty($datalist)) {
|
|
|
$this->json_error("没有数据");
|
|
|
}
|
|
|
+ foreach ($datalist as $key => $item) {
|
|
|
+ $item['thumb_url'] = geturl($item->thumb, '', true);
|
|
|
+ $datalist[$key] = $item;
|
|
|
+ }
|
|
|
$this->json_success("查询成功", $datalist);
|
|
|
}
|
|
|
}
|