request->param(); $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('该人才信息已被绑定,请联系管理员确认'); } $userId = $this->getUserId(); UserModel::update(['talent_id' => $talent['id']], ['id' => $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'; $start_time = strtotime($date); $time = time(); if ($start_time - $time < 3600) { $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'), ]); TalentAppointmentLogModel::create([ 'appointment_id' => $appointment['id'], 'name' => '人才', 'content' => '提交了预约', 'create_time' => date('Y-m-d H:i:s'), ]); $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('成功'); } }