Recruit.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace app\mobile\controller;
  3. use app\common\model\OutRecruit as OutRecruitModel;
  4. use app\common\model\OutRecruitReport;
  5. use app\mobile\MobileBaseController;
  6. use app\mobile\validate\RecruitValidate;
  7. use think\App;
  8. use think\exception\ValidateException;
  9. use think\facade\View;
  10. class Recruit extends MobileBaseController
  11. {
  12. private $_broker = null;
  13. public function __construct(App $app)
  14. {
  15. parent::__construct($app);
  16. $this->_broker = get_broker();
  17. View::assign('broker', $this->_broker);
  18. }
  19. /**
  20. * 招聘信息
  21. */
  22. public function index()
  23. {
  24. return view('recruit/index');
  25. }
  26. /**
  27. * 招聘信息列表
  28. */
  29. public function listRecruit()
  30. {
  31. $map = $this->dealLikeInput(['keyword' => 'title|company_name']);
  32. $map[] = ['status', '=', 1];
  33. $list = OutRecruitModel::where($map)
  34. ->order(['priority' => 'desc', 'id' => 'desc'])
  35. ->limit(input('limit', 10))
  36. ->page(input('page', 1))
  37. ->select();
  38. ajax_success($list);
  39. }
  40. /**
  41. * 详情
  42. */
  43. public function detail()
  44. {
  45. $id = input('id/d', 0);
  46. $info = OutRecruitModel::find($id);
  47. if (empty($info) || $info['status'] != 1) {
  48. jump('该信息不存在或已下架');
  49. }
  50. return view('recruit/detail', ['info' => $info]);
  51. }
  52. /**
  53. * 报备
  54. */
  55. public function report()
  56. {
  57. $id = input('id/d', 0);
  58. $info = OutRecruitModel::find($id);
  59. if (empty($info) || $info['status'] != 1) {
  60. jump('该信息不存在或已下架');
  61. }
  62. return view('recruit/report', ['info' => $info]);
  63. }
  64. /**
  65. * 报备提交
  66. */
  67. public function reportPost()
  68. {
  69. $data = input('post.');
  70. try {
  71. validate(RecruitValidate::class)->check($data);
  72. } catch (ValidateException $e) {
  73. ajax_return(1, $e->getError());
  74. }
  75. $mobile_check = OutRecruitReport::where('mobile', $data['mobile'])->where('recruit_id', $data['recruit_id'])->find();
  76. $mobile_check && ajax_return(1, '该手机号已报备,请勿重复报备!');
  77. $data['workerid'] = $this->_broker['workerid'];
  78. $data['agentid'] = $this->_broker['agentid'];
  79. $data['brokerid'] = $this->_broker['id'];
  80. $data['createtime'] = time();
  81. OutRecruitReport::create($data);
  82. ajax_return();
  83. }
  84. }