|
|
@@ -0,0 +1,141 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace api\talent\controller;
|
|
|
+
|
|
|
+
|
|
|
+use api\common\Sms;
|
|
|
+use app\talent\model\TalentAdminModel;
|
|
|
+use app\talent\model\TalentAppointmentLogModel;
|
|
|
+use app\talent\model\TalentAppointmentModel;
|
|
|
+use app\talent\model\TalentModel;
|
|
|
+use cmf\controller\RestUserBaseController;
|
|
|
+
|
|
|
+class AdminController extends RestUserBaseController
|
|
|
+{
|
|
|
+ public function login()
|
|
|
+ {
|
|
|
+ $data = $this->request->param();
|
|
|
+ $admin = TalentAdminModel::where('account', $data['account'])->where('password', $data['password'])->find();
|
|
|
+ if (empty($admin)) {
|
|
|
+ $this->error('账号或密码错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('成功', $admin['id']);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function scan()
|
|
|
+ {
|
|
|
+ $code = $this->request->param('code', '');
|
|
|
+ $admin_id = $this->request->param('admin_id', 0);
|
|
|
+ if (empty($admin_id)) {
|
|
|
+ $this->error('暂无权限');
|
|
|
+ }
|
|
|
+ if (empty($code)) {
|
|
|
+ $this->error('二维码错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $appointment = TalentAppointmentModel::where('apply_code', $code)->find();
|
|
|
+ if (empty($appointment)) {
|
|
|
+ $this->error('二维码错误');
|
|
|
+ }
|
|
|
+ if ($appointment['status'] != 2) {
|
|
|
+ $this->error('该预约已接站,请勿重复扫码');
|
|
|
+ }
|
|
|
+
|
|
|
+ $appointment->status = 3;
|
|
|
+ $appointment->save();
|
|
|
+
|
|
|
+ //日志
|
|
|
+ $admin = TalentAdminModel::get($admin_id);
|
|
|
+ TalentAppointmentLogModel::create([
|
|
|
+ 'appointment_id' => $appointment['id'],
|
|
|
+ 'name' => '工作人员(' . $admin['name'] . ')',
|
|
|
+ 'content' => '通过扫码接站,接到了人才',
|
|
|
+ 'create_time' => date('Y-m-d H:i:s'),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $talent = TalentModel::get($appointment['talent_id']);
|
|
|
+
|
|
|
+ $this->success('成功', ['talent' => $talent, 'appointment' => $appointment]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function lists()
|
|
|
+ {
|
|
|
+ $data = $this->request->param();
|
|
|
+ $page = empty($param['page']) ? 1 : $param['page'];
|
|
|
+ $size = empty($param['size']) ? 10 : $param['size'];
|
|
|
+ $where = [['status', '=', $data['status']]];
|
|
|
+ if (!empty($data['keyword'])) {
|
|
|
+ $where[] = ['shift','like',"%{$data['keyword']}%"];
|
|
|
+ }
|
|
|
+
|
|
|
+ //搜索条件
|
|
|
+ $list = TalentAppointmentModel::with(['talent'])
|
|
|
+ ->where($where)
|
|
|
+ ->order('start_time desc')
|
|
|
+ ->page($page, $size)
|
|
|
+ ->append(['status_text'])
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ $this->success('成功', $list);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function confirm()
|
|
|
+ {
|
|
|
+ $data = $this->request->param();
|
|
|
+ TalentAppointmentModel::update(['status'=>2,'apply_code'=>uniqid()],['id'=>$data['id']]);
|
|
|
+
|
|
|
+ //日志
|
|
|
+ $admin = TalentAdminModel::get($data['admin_id']);
|
|
|
+ TalentAppointmentLogModel::create([
|
|
|
+ 'appointment_id' => $data['id'],
|
|
|
+ 'name' => '工作人员(' . $admin['name'] . ')',
|
|
|
+ 'content' => '确认了人才的预约',
|
|
|
+ 'create_time' => date('Y-m-d H:i:s'),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ //短信
|
|
|
+// $sms = new Sms();
|
|
|
+// $sms->send('13313826760','verification_code',['code'=>'123456']);
|
|
|
+
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function applyByMobile()
|
|
|
+ {
|
|
|
+ $mobile = $this->request->param('mobile', '');
|
|
|
+ $admin_id = $this->request->param('admin_id', 0);
|
|
|
+ $id = $this->request->param('id',0);
|
|
|
+ if (empty($admin_id)) {
|
|
|
+ $this->error('暂无权限');
|
|
|
+ }
|
|
|
+ if (empty($mobile)) {
|
|
|
+ $this->error('手机号错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $appointment = TalentAppointmentModel::with(['talent'])->where('id', $id)->find();
|
|
|
+ if (empty($appointment)) {
|
|
|
+ $this->error('系统异常,请联系管理员');
|
|
|
+ }
|
|
|
+ if ($appointment['status'] != 2) {
|
|
|
+ $this->error('该预约已接站,请勿重复接站');
|
|
|
+ }
|
|
|
+ if ($appointment['talent']['mobile'] != $mobile) {
|
|
|
+ $this->error('手机号输入错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $appointment->status = 3;
|
|
|
+ $appointment->save();
|
|
|
+
|
|
|
+ //日志
|
|
|
+ $admin = TalentAdminModel::get($admin_id);
|
|
|
+ TalentAppointmentLogModel::create([
|
|
|
+ 'appointment_id' => $appointment['id'],
|
|
|
+ 'name' => '工作人员(' . $admin['name'] . ')',
|
|
|
+ 'content' => '通过手机号接站,接到了人才',
|
|
|
+ 'create_time' => date('Y-m-d H:i:s'),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $this->success('成功');
|
|
|
+ }
|
|
|
+}
|