|
@@ -14,6 +14,7 @@ use app\common\model\AppointmentApplication;
|
|
|
use app\common\model\Appointment;
|
|
|
use app\common\model\Feedback;
|
|
|
use app\common\model\Webconfig;
|
|
|
+use time\DateHelper;
|
|
|
|
|
|
class User extends Permissions
|
|
|
{
|
|
@@ -45,6 +46,7 @@ class User extends Permissions
|
|
|
$this->json_error('提交失败:' . $validate->getError());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
$model = new AppointmentApplication();
|
|
|
|
|
|
//爽约多少次后,多少天内不能再预约
|
|
@@ -68,11 +70,31 @@ class User extends Permissions
|
|
|
$this->json_error("获取预约号失败");
|
|
|
}
|
|
|
|
|
|
+ //判断该时间段,存在于时间列表中才行
|
|
|
+ if ($post['appointment_period'] == 1) {
|
|
|
+ $timePeriods = DateHelper::splitTimePeriod($ticket->morning_start_time, $ticket->morning_end_time, $ticket->morning_num);
|
|
|
+ } elseif ($post['appointment_period'] == 2) {
|
|
|
+ $timePeriods = DateHelper::splitTimePeriod($ticket->afternoon_start_time, $ticket->afternoon_end_time, $ticket->afternoon_num);
|
|
|
+ } else {
|
|
|
+ $timePeriods = DateHelper::splitTimePeriod($ticket->night_start_time, $ticket->night_end_time, $ticket->night_num);
|
|
|
+ }
|
|
|
+ if (!in_array($post['appointment_time'], $timePeriods)) {
|
|
|
+ $this->json_error("该时间段不存在,请重新选择时间");
|
|
|
+ }
|
|
|
+
|
|
|
+ //排除过期时段
|
|
|
+ $timerang = explode(' - ', $post['appointment_time']);
|
|
|
+ $period_end = $timerang[1];
|
|
|
+
|
|
|
+ if (time() > strtotime($ticket->daytime . ' ' . $period_end)) {
|
|
|
+ $this->json_error("该时段已经过期,请重新选择时间");
|
|
|
+ }
|
|
|
+
|
|
|
//已经预约的时间段
|
|
|
$ticketPeriods = (new AppointmentApplication())->where('appointment_ticket_id', $ticket->id)->column('appointment_time');
|
|
|
foreach ($ticketPeriods as $period) {
|
|
|
if ($period == $post['appointment_time']) {
|
|
|
- $this->json_error("该时间已经被预约了,请重新选择时间");
|
|
|
+ $this->json_error("该时段已被预约,请重新选择时间");
|
|
|
}
|
|
|
}
|
|
|
|