|
|
@@ -9,12 +9,22 @@ use app\talent\model\TalentAppointmentLogModel;
|
|
|
use app\talent\model\TalentAppointmentModel;
|
|
|
use app\talent\model\TalentModel;
|
|
|
use cmf\controller\RestUserBaseController;
|
|
|
+use think\facade\Cache;
|
|
|
|
|
|
class AppointmentController extends RestUserBaseController
|
|
|
{
|
|
|
public function bind()
|
|
|
{
|
|
|
- $data = $this->request->param();
|
|
|
+ $data = $this->request->param();
|
|
|
+
|
|
|
+ $verify = Cache::get('verify' . $this->userId);
|
|
|
+ if (empty($verify)) {
|
|
|
+ $this->error('验证码已过期,请重新获取');
|
|
|
+ }
|
|
|
+ if ($verify != $data['verify']) {
|
|
|
+ $this->error('验证码错误');
|
|
|
+ }
|
|
|
+
|
|
|
$talent = TalentModel::where('name', $data['name'])->where('card_no', $data['card_no'])->find();
|
|
|
if (empty($talent)) {
|
|
|
$this->error('未找到人才信息,请重新信息是否输入有误');
|
|
|
@@ -25,8 +35,13 @@ class AppointmentController extends RestUserBaseController
|
|
|
$this->error('该人才信息已被绑定,请联系管理员确认');
|
|
|
}
|
|
|
|
|
|
+ //手机号绑定
|
|
|
+ $talent->mobile = $data['mobile'];
|
|
|
+ $talent->save();
|
|
|
+
|
|
|
$userId = $this->getUserId();
|
|
|
UserModel::update(['talent_id' => $talent['id']], ['id' => $userId]);
|
|
|
+ Cache::rm('verify' . $this->userId);
|
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
@@ -50,21 +65,39 @@ class AppointmentController extends RestUserBaseController
|
|
|
public function book()
|
|
|
{
|
|
|
$data = $this->request->param();
|
|
|
+
|
|
|
+ //时间
|
|
|
$date = $data['date'] . ' ' . $data['time'] . ':00';
|
|
|
+ $out_date = $data['date'] . ' ' . $data['out_time'] . ':00';
|
|
|
$start_time = strtotime($date);
|
|
|
+ $out_time = strtotime($out_date);
|
|
|
$time = time();
|
|
|
if ($start_time - $time < 3600) {
|
|
|
$this->error('只能预约一小时后的班次');
|
|
|
}
|
|
|
+ if ($out_time - $start_time > 0) {
|
|
|
+ $this->error('到站时间必须早于出发时间');
|
|
|
+ }
|
|
|
+
|
|
|
+ //班次
|
|
|
+ if (!empty($data['shift'])) {
|
|
|
+ $shift_check = TalentAppointmentModel::where('talent_id',$this->user['talent_id'])->where('shift',$data['shift'])->find();
|
|
|
+ if (!empty($shift_check)) {
|
|
|
+ $this->error('您已预约过该班次,请勿重复预约');
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ //预约成功和日志
|
|
|
$appointment = TalentAppointmentModel::create([
|
|
|
- 'talent_id' => $this->user['talent_id'],
|
|
|
- 'shift' => $data['shift'],
|
|
|
- 'start_time' => $date,
|
|
|
- 'image' => $data['image'],
|
|
|
- 'create_time' => date('Y-m-d H:i:s'),
|
|
|
+ 'talent_id' => $this->user['talent_id'],
|
|
|
+ 'shift' => $data['shift'],
|
|
|
+ 'start_time' => $date,
|
|
|
+ 'image' => $data['image'],
|
|
|
+ 'create_time' => date('Y-m-d H:i:s'),
|
|
|
+ 'out_time' => $out_date,
|
|
|
+ 'companion_num' => $data['companion_num'],
|
|
|
+ 'comment' => $data['comment'],
|
|
|
]);
|
|
|
-
|
|
|
TalentAppointmentLogModel::create([
|
|
|
'appointment_id' => $appointment['id'],
|
|
|
'name' => '人才',
|
|
|
@@ -73,9 +106,9 @@ class AppointmentController extends RestUserBaseController
|
|
|
]);
|
|
|
|
|
|
//短信
|
|
|
- $sms = new Sms();
|
|
|
+ $sms = new Sms();
|
|
|
$option = cmf_get_option('talent_setting');
|
|
|
- $sms->send($option['mobile'],'talent_appointment_submit');
|
|
|
+ $sms->send($option['mobile'], 'talent_appointment_submit');
|
|
|
|
|
|
$this->success();
|
|
|
}
|
|
|
@@ -116,4 +149,47 @@ class AppointmentController extends RestUserBaseController
|
|
|
|
|
|
$this->success('成功');
|
|
|
}
|
|
|
+
|
|
|
+ public function getVerify()
|
|
|
+ {
|
|
|
+ $data = $this->request->param();
|
|
|
+ $verify = mt_rand(100000, 999999);
|
|
|
+ Cache::set('verify' . $this->userId, $verify, 600);
|
|
|
+
|
|
|
+ //短信
|
|
|
+ $sms = new Sms();
|
|
|
+ $sms->send($data['mobile'], 'verification_code', ['code' => $verify]);
|
|
|
+
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function route()
|
|
|
+ {
|
|
|
+ $setting = cmf_get_option('talent_setting');
|
|
|
+ $this->success('成功',['route_image'=>cmf_get_image_preview_url($setting['route_image'])]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function talentInfo()
|
|
|
+ {
|
|
|
+ $talent = TalentModel::where('id',$this->user['talent_id'])->find();
|
|
|
+ $this->success('成功',$talent);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function changeMobile()
|
|
|
+ {
|
|
|
+ $data = $this->request->param();
|
|
|
+
|
|
|
+ $verify = Cache::get('verify' . $this->userId);
|
|
|
+ if (empty($verify)) {
|
|
|
+ $this->error('验证码已过期,请重新获取');
|
|
|
+ }
|
|
|
+ if ($verify != $data['verify']) {
|
|
|
+ $this->error('验证码错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ TalentModel::update(['mobile'=>$data['mobile']],['id'=>$this->user['talent_id']]);
|
|
|
+ Cache::rm('verify' . $this->userId);
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
}
|