Recruit.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?php
  2. namespace app\operate\controller;
  3. use app\common\model\ChinaArea;
  4. use app\common\model\User;
  5. use library\Controller;
  6. use think\Db;
  7. /**
  8. * 招聘
  9. * Class Activity
  10. * @package app\operate\controller
  11. */
  12. class Recruit extends Controller
  13. {
  14. protected $table = 'Recruit';
  15. /**
  16. * 列表
  17. * @auth true
  18. * @menu true
  19. * @throws \think\Exception
  20. * @throws \think\db\exception\DataNotFoundException
  21. * @throws \think\db\exception\ModelNotFoundException
  22. * @throws \think\exception\DbException
  23. * @throws \think\exception\PDOException
  24. */
  25. public function index()
  26. {
  27. $this->title = '列表';
  28. $where = [];
  29. $where[] = ['f.is_deleted','=',0];
  30. if($title = input('title')) $where[] = ['f.title','like','%'.$title.'%'];
  31. $query = $this->_query($this->table)->alias('f')
  32. ->field('f.*')
  33. ->where($where)
  34. ->order('sort desc,f.id desc ')->page();
  35. }
  36. /**
  37. * 添加
  38. * @auth true
  39. * @menu true
  40. * @throws \think\Exception
  41. * @throws \think\db\exception\DataNotFoundException
  42. * @throws \think\db\exception\ModelNotFoundException
  43. * @throws \think\exception\DbException
  44. * @throws \think\exception\PDOException
  45. */
  46. public function add()
  47. {
  48. $this->title = '添加';
  49. $this->_form($this->table, 'form');
  50. }
  51. /**
  52. * 编辑
  53. * @auth true
  54. * @menu true
  55. * @throws \think\Exception
  56. * @throws \think\db\exception\DataNotFoundException
  57. * @throws \think\db\exception\ModelNotFoundException
  58. * @throws \think\exception\DbException
  59. * @throws \think\exception\PDOException
  60. */
  61. public function edit()
  62. {
  63. $this->title = '编辑';
  64. if(input('test'))
  65. {
  66. $this->_form($this->table, 'form2');
  67. }else{
  68. $this->_form($this->table, 'form');
  69. }
  70. }
  71. /**
  72. * 删除
  73. * @auth true
  74. * @throws \think\Exception
  75. * @throws \think\exception\PDOException
  76. */
  77. public function del()
  78. {
  79. $this->_save($this->table, ['is_deleted' => '1']);
  80. }
  81. /**
  82. * 表单数据处理
  83. * @param array $data
  84. */
  85. protected function _form_filter(&$data)
  86. {
  87. $this->education = ['不限','高中及以上','专科及以上','本科及以上','研究生及以上'];
  88. $all_area = $all_area = ChinaArea::where('level','<=',3)->select();
  89. $this->all_area = make_tree($all_area);
  90. $all_cate = \app\common\model\RecruitCate::where(['is_deleted'=>0])->order('sort desc ,id desc')->select();
  91. $this->cate_tree = make_tree($all_cate);
  92. if ($this->request->isGet() && $this->request->action() == 'add') {
  93. $this->isAddMode = 1;
  94. $this->ladder = [];
  95. }
  96. if ($this->request->isGet() && $this->request->action() == 'edit') {
  97. $this->isAddMode = 0;
  98. $this->ladder = isset_full($data,'ladder') ? json_decode($data['ladder'],true):[];
  99. }
  100. if($this->request->isPost())
  101. {
  102. list($post,$ladder_data) = [$this->request->post(),[]];
  103. if(!$data['longitude'] || !$data['latitude']) $this->error('请选择地图坐标');
  104. if(!empty($post['user_phone'])) {
  105. $user_id = User::where('phone|email',$post['user_phone'])->value('id');
  106. if(!$user_id) $this->error('账号未注册');
  107. $data['user_id'] = $user_id;
  108. }else{
  109. $data['user_id'] = '';
  110. }
  111. }
  112. }
  113. /**
  114. * 报名记录
  115. * @auth true
  116. * @menu true
  117. * @throws \think\Exception
  118. * @throws \think\db\exception\DataNotFoundException
  119. * @throws \think\db\exception\ModelNotFoundException
  120. * @throws \think\exception\DbException
  121. * @throws \think\exception\PDOException
  122. */
  123. public function apply()
  124. {
  125. $id = $this->request->get('act_id');
  126. $name = $this->request->get('name');
  127. $phone = $this->request->get('phone');
  128. $this->title = '报名记录';
  129. $where = [];
  130. $where[]= ['a.act_id','=' ,$id];
  131. $where[]= ['a.is_deleted','=' ,0];
  132. $where[]= ['a.status','=' ,1];
  133. $where[]= ['a.status','=' ,1];
  134. if($name) $where[]= ['a.name','like' ,'%'.$name.'%'];
  135. if($phone) $where[]= ['a.phone','like' ,'%'.$phone.'%'];
  136. $query = $this->_query('activity_apply')
  137. ->alias('a')
  138. ->field('a.*,u.name user_name,u.headimg')
  139. ->where($where)
  140. ->leftJoin('store_member u','u.id = a.user_id')
  141. ->order('a.id desc')->page();
  142. $this->fetch();
  143. }
  144. protected function _form_result(&$data)
  145. {
  146. $this->success('操作成功', 'javascript:history.back()');
  147. }
  148. /**
  149. * 上架
  150. * @auth true
  151. * @menu true
  152. * @throws \think\Exception
  153. * @throws \think\db\exception\DataNotFoundException
  154. * @throws \think\db\exception\ModelNotFoundException
  155. * @throws \think\exception\DbException
  156. * @throws \think\exception\PDOException
  157. */
  158. public function up()
  159. {
  160. $this->_save($this->table, ['status' => '1']);
  161. }
  162. /**
  163. * 取消
  164. * @auth true
  165. * @menu true
  166. * @throws \think\Exception
  167. * @throws \think\db\exception\DataNotFoundException
  168. * @throws \think\db\exception\ModelNotFoundException
  169. * @throws \think\exception\DbException
  170. * @throws \think\exception\PDOException
  171. */
  172. public function down()
  173. {
  174. $this->_save($this->table, ['status' => '2']);
  175. }
  176. }