| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- namespace api\talent\controller;
- use api\applet\model\UserModel;
- use app\talent\model\TalentAppointmentLogModel;
- use app\talent\model\TalentAppointmentModel;
- use app\talent\model\TalentModel;
- use cmf\controller\RestUserBaseController;
- class AppointmentController extends RestUserBaseController
- {
- public function bind()
- {
- $data = $this->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('成功');
- }
- }
|