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('未找到人才信息,请重新信息是否输入有误'); } $user = UserModel::where('talent_id', $talent['id'])->find(); if (!empty($user)) { $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(); } public function upload() { $file = $this->request->file('file'); $result = $file->validate([ 'ext' => 'jpg,jpeg,png', 'size' => 1024 * 1024, ])->move(WEB_ROOT . 'upload' . DIRECTORY_SEPARATOR . 'watermark' . DIRECTORY_SEPARATOR); if ($result) { $avatarSaveName = str_replace('//', '/', str_replace('\\', '/', $result->getSaveName())); $url = cmf_get_image_url('watermark/' . $avatarSaveName); $this->success('上传成功', $url); } else { $this->error($file->getError()); } } 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'), 'out_time' => $out_date, 'companion_num' => $data['companion_num'], 'comment' => $data['comment'], ]); TalentAppointmentLogModel::create([ 'appointment_id' => $appointment['id'], 'name' => '人才', 'content' => '提交了预约', 'create_time' => date('Y-m-d H:i:s'), ]); //短信 $sms = new Sms(); $option = cmf_get_option('talent_setting'); $sms->send($option['mobile'], 'talent_appointment_submit'); $this->success(); } public function lists() { $page = empty($param['page']) ? 1 : $param['page']; $size = empty($param['size']) ? 10 : $param['size']; //搜索条件 $where = [['talent_id', '=', $this->user['talent_id']]]; $list = TalentAppointmentModel::where($where) ->order('start_time desc') ->page($page, $size) ->append(['status_text']) ->select(); $this->success('成功', $list); } public function getAdminMobile() { $setting = cmf_get_option('talent_setting'); $this->success('成功', $setting); } public function rate() { $data = $this->request->param(); $data['status'] = 4; TalentAppointmentModel::update($data); TalentAppointmentLogModel::create([ 'appointment_id' => $data['id'], 'name' => '人才', 'content' => '评价了服务', 'create_time' => date('Y-m-d H:i:s'), ]); $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(); } }