|
@@ -18,7 +18,7 @@ use time\DateHelper;
|
|
|
|
|
|
class User extends Permissions
|
|
|
{
|
|
|
- //个人资料接口
|
|
|
+ //个人资料
|
|
|
public function info()
|
|
|
{
|
|
|
$user = $this->getUser();
|
|
@@ -49,20 +49,20 @@ class User extends Permissions
|
|
|
['appointment_ticket_id', 'require|number'],
|
|
|
['appointment_period', 'require|number|in:1,2,3'],
|
|
|
['appointment_time|预约时间段', 'require|dateFormat:H:i:s - H:i:s'],
|
|
|
- ['childs_num|子女数量', 'number|in:1,2,3'],
|
|
|
- ['childs_num_str|子女数量', 'max:255'],
|
|
|
['city|来自城市', 'max:50'],
|
|
|
['job|职业', 'max:50'],
|
|
|
['education_level|受教育程度', 'number|in:0,1,2,3,4'],
|
|
|
['home_address|家庭住址', 'max:255'],
|
|
|
['marriage|婚姻情况', 'number|in:0,1,2'],
|
|
|
['problem_type|咨询问题类别', 'number|in:0,1,2,3,4,5'],
|
|
|
- ['childs_age1|一孩年龄', 'number'],
|
|
|
- ['childs_age2|二孩年龄', 'number'],
|
|
|
- ['childs_age3|三孩年龄', 'number'],
|
|
|
- ['childs_sex1|一孩性别', 'number'],
|
|
|
- ['childs_sex2|二孩性别', 'number'],
|
|
|
- ['childs_sex3|三孩性别', 'number'],
|
|
|
+ ['childs_num_str|子女数量', 'max:255'],
|
|
|
+// ['childs_num|子女数量', 'number|in:1,2,3'],
|
|
|
+// ['childs_age1|一孩年龄', 'number'],
|
|
|
+// ['childs_age2|二孩年龄', 'number'],
|
|
|
+// ['childs_age3|三孩年龄', 'number'],
|
|
|
+// ['childs_sex1|一孩性别', 'number'],
|
|
|
+// ['childs_sex2|二孩性别', 'number'],
|
|
|
+// ['childs_sex3|三孩性别', 'number'],
|
|
|
]);
|
|
|
if (!$validate->check($post)) {
|
|
|
$this->json_error('提交失败:' . $validate->getError());
|
|
@@ -113,7 +113,7 @@ class User extends Permissions
|
|
|
}
|
|
|
|
|
|
//已经预约的时间段
|
|
|
- $ticketPeriods = (new AppointmentApplication())->where('appointment_ticket_id', $ticket->id)->column('appointment_time');
|
|
|
+ $ticketPeriods = (new AppointmentApplication())->where('appointment_ticket_id', $ticket->id)->where('finish_time', 0)->column('appointment_time');
|
|
|
foreach ($ticketPeriods as $period) {
|
|
|
if ($period == $post['appointment_time']) {
|
|
|
$this->json_error("该时段已被预约,请重新选择时间");
|
|
@@ -129,7 +129,6 @@ class User extends Permissions
|
|
|
'sex' => $post['sex']??0,
|
|
|
'phone' => $post['phone'],
|
|
|
'id_card' => $this->request->param('id_card', '', 'htmlspecialchars'),
|
|
|
- 'childs_num' => $post['childs_num']??0,
|
|
|
'problem_desc' => $this->request->param('problem_desc', '', 'htmlspecialchars'),
|
|
|
'requirement_desc' => $this->request->param('requirement_desc', '', 'htmlspecialchars'),
|
|
|
'address_id' => $ticket->address_id,
|
|
@@ -145,12 +144,13 @@ class User extends Permissions
|
|
|
'marriage' => $post['marriage']??0,
|
|
|
'problem_type' => $post['problem_type']??0,
|
|
|
'childs_num_str' => $this->request->param('childs_num_str', '', 'htmlspecialchars'),
|
|
|
- 'childs_age1' => $post['childs_age1']??0,
|
|
|
- 'childs_age2' => $post['childs_age2']??0,
|
|
|
- 'childs_age3' => $post['childs_age3']??0,
|
|
|
- 'childs_sex1' => $post['childs_sex1']??0,
|
|
|
- 'childs_sex2' => $post['childs_sex2']??0,
|
|
|
- 'childs_sex3' => $post['childs_sex3']??0,
|
|
|
+// 'childs_num' => $post['childs_num']??0,
|
|
|
+// 'childs_age1' => $post['childs_age1']??0,
|
|
|
+// 'childs_age2' => $post['childs_age2']??0,
|
|
|
+// 'childs_age3' => $post['childs_age3']??0,
|
|
|
+// 'childs_sex1' => $post['childs_sex1']??0,
|
|
|
+// 'childs_sex2' => $post['childs_sex2']??0,
|
|
|
+// 'childs_sex3' => $post['childs_sex3']??0,
|
|
|
];
|
|
|
if (false === $model->allowField(true)->save($data)) {
|
|
|
$this->json_error("预约入库失败");
|
|
@@ -160,7 +160,41 @@ class User extends Permissions
|
|
|
}
|
|
|
|
|
|
|
|
|
- //我的预约列表接口
|
|
|
+ //取消预约
|
|
|
+ public function cancelApplication()
|
|
|
+ {
|
|
|
+ $post = $this->request->param();
|
|
|
+ $validate = new \think\Validate([
|
|
|
+ ['id', 'require|number'],
|
|
|
+ ]);
|
|
|
+ if (!$validate->check($post)) {
|
|
|
+ $this->json_error('提交失败:' . $validate->getError());
|
|
|
+ }
|
|
|
+
|
|
|
+ $application = (new AppointmentApplication())->where(['id' => $post['id'], 'user_id' => $this->getUserId()])->find();
|
|
|
+ if (!$application) {
|
|
|
+ $this->json_error("预约不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($application->finish_time > 0) {
|
|
|
+ $this->json_error("已完成,不可取消");
|
|
|
+ }
|
|
|
+
|
|
|
+ // n 小时后不可取消
|
|
|
+ $cancel_appointment_time = Webconfig::getValue('cancel_appointment_time');
|
|
|
+ if ($cancel_appointment_time && time() > ($application->getData('create_time') + $cancel_appointment_time * 3600)) {
|
|
|
+ $this->json_error("超过{$cancel_appointment_time}小时后,不可取消");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (false === $application->save(['status' => AppointmentApplication::STATUS_CANCEL, 'finish_time' => time()])) {
|
|
|
+ $this->json_error("提交失败");
|
|
|
+ } else {
|
|
|
+ $this->json_success("提交成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //我的预约列表
|
|
|
public function applicationList()
|
|
|
{
|
|
|
$post = $this->request->param();
|
|
@@ -214,9 +248,9 @@ class User extends Permissions
|
|
|
'content' => $this->request->param('content', '', 'htmlspecialchars')
|
|
|
];
|
|
|
if (false === $model->allowField(true)->save($data)) {
|
|
|
- $this->json_error("失败");
|
|
|
+ $this->json_error("提交失败");
|
|
|
} else {
|
|
|
- $this->json_success("成功");
|
|
|
+ $this->json_success("提交成功");
|
|
|
}
|
|
|
}
|
|
|
}
|