AdminController.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. namespace api\talent\controller;
  3. use api\common\Sms;
  4. use app\talent\model\TalentAdminModel;
  5. use app\talent\model\TalentAppointmentLogModel;
  6. use app\talent\model\TalentAppointmentModel;
  7. use app\talent\model\TalentModel;
  8. use cmf\controller\RestUserBaseController;
  9. class AdminController extends RestUserBaseController
  10. {
  11. public function login()
  12. {
  13. $data = $this->request->param();
  14. $admin = TalentAdminModel::where('account', $data['account'])->where('password', $data['password'])->find();
  15. if (empty($admin)) {
  16. $this->error('账号或密码错误');
  17. }
  18. $this->success('成功', $admin['id']);
  19. }
  20. public function scan()
  21. {
  22. $code = $this->request->param('code', '');
  23. $admin_id = $this->request->param('admin_id', 0);
  24. if (empty($admin_id)) {
  25. $this->error('暂无权限');
  26. }
  27. if (empty($code)) {
  28. $this->error('二维码错误');
  29. }
  30. $appointment = TalentAppointmentModel::where('apply_code', $code)->find();
  31. if (empty($appointment)) {
  32. $this->error('二维码错误');
  33. }
  34. if ($appointment['status'] != 2) {
  35. $this->error('该预约已接站,请勿重复扫码');
  36. }
  37. $appointment->status = 3;
  38. $appointment->save();
  39. //日志
  40. $admin = TalentAdminModel::get($admin_id);
  41. TalentAppointmentLogModel::create([
  42. 'appointment_id' => $appointment['id'],
  43. 'name' => '工作人员(' . $admin['name'] . ')',
  44. 'content' => '通过扫码接站,接到了人才',
  45. 'create_time' => date('Y-m-d H:i:s'),
  46. ]);
  47. $talent = TalentModel::get($appointment['talent_id']);
  48. $this->success('成功', ['talent' => $talent, 'appointment' => $appointment]);
  49. }
  50. public function lists()
  51. {
  52. $data = $this->request->param();
  53. $page = empty($param['page']) ? 1 : $param['page'];
  54. $size = empty($param['size']) ? 10 : $param['size'];
  55. $where = [['status', '=', $data['status']]];
  56. if (!empty($data['keyword'])) {
  57. $where[] = ['shift','like',"%{$data['keyword']}%"];
  58. }
  59. //搜索条件
  60. $list = TalentAppointmentModel::with(['talent'])
  61. ->where($where)
  62. ->order('start_time desc')
  63. ->page($page, $size)
  64. ->append(['status_text'])
  65. ->select();
  66. $this->success('成功', $list);
  67. }
  68. public function confirm()
  69. {
  70. $data = $this->request->param();
  71. TalentAppointmentModel::update(['status'=>2,'apply_code'=>uniqid()],['id'=>$data['id']]);
  72. //日志
  73. $admin = TalentAdminModel::get($data['admin_id']);
  74. TalentAppointmentLogModel::create([
  75. 'appointment_id' => $data['id'],
  76. 'name' => '工作人员(' . $admin['name'] . ')',
  77. 'content' => '确认了人才的预约',
  78. 'create_time' => date('Y-m-d H:i:s'),
  79. ]);
  80. //短信
  81. // $sms = new Sms();
  82. // $sms->send('13313826760','verification_code',['code'=>'123456']);
  83. $this->success();
  84. }
  85. public function applyByMobile()
  86. {
  87. $mobile = $this->request->param('mobile', '');
  88. $admin_id = $this->request->param('admin_id', 0);
  89. $id = $this->request->param('id',0);
  90. if (empty($admin_id)) {
  91. $this->error('暂无权限');
  92. }
  93. if (empty($mobile)) {
  94. $this->error('手机号错误');
  95. }
  96. $appointment = TalentAppointmentModel::with(['talent'])->where('id', $id)->find();
  97. if (empty($appointment)) {
  98. $this->error('系统异常,请联系管理员');
  99. }
  100. if ($appointment['status'] != 2) {
  101. $this->error('该预约已接站,请勿重复接站');
  102. }
  103. if ($appointment['talent']['mobile'] != $mobile) {
  104. $this->error('手机号输入错误');
  105. }
  106. $appointment->status = 3;
  107. $appointment->save();
  108. //日志
  109. $admin = TalentAdminModel::get($admin_id);
  110. TalentAppointmentLogModel::create([
  111. 'appointment_id' => $appointment['id'],
  112. 'name' => '工作人员(' . $admin['name'] . ')',
  113. 'content' => '通过手机号接站,接到了人才',
  114. 'create_time' => date('Y-m-d H:i:s'),
  115. ]);
  116. $this->success('成功');
  117. }
  118. }