RecruitController.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <?php
  2. namespace App\Http\Controllers\Mobile\Health;
  3. use App\Http\Controllers\Mobile\MobileBaseController;
  4. use App\Models\Jobs;
  5. use App\Models\JyyxAppoint;
  6. use App\Models\PostAppoint;
  7. use App\Models\QjwjAppoint;
  8. use App\Services\Common\CategoryService;
  9. use App\Services\Company\JobsService;
  10. use Illuminate\Http\Request;
  11. class RecruitController extends MobileBaseController
  12. {
  13. protected $categoryService;
  14. protected $jobsService;
  15. /**
  16. * JobsController constructor.
  17. * @param $categoryService
  18. */
  19. public function __construct(CategoryService $categoryService, JobsService $jobsService)
  20. {
  21. $this->categoryService = $categoryService;
  22. $this->jobsService = $jobsService;
  23. }
  24. public function index()
  25. {
  26. return view('mobile.app.health.recruit.index');
  27. }
  28. public function list(Request $request)
  29. {
  30. //获取分类
  31. $filter_where = [
  32. 'AIX_education' => 100,
  33. 'AIX_experience' => 100,
  34. 'AIX_wage' => 100,
  35. ];
  36. $categories = $this->categoryService->getCategories($filter_where); //过滤条件信息
  37. //默认参数
  38. $param_array = ['keyword', 'wage', 'experience', 'education'];
  39. $params = [];
  40. if ($request->all()) {
  41. foreach ($request->all() as $k => $v) {
  42. if (in_array($k, $param_array) && $v) {
  43. $params[$k] = $v;
  44. }
  45. }
  46. }
  47. $params['health_type'] = $request->input('health_type', 1);
  48. //查询条件
  49. $size = 10;
  50. $where = [
  51. ['valid', '=', 1], //是否有效
  52. ['audit', '=', 1], //审核通过
  53. ['display', '=', 1], //是否显示
  54. ['is_health', '=', 1], //是否卫健
  55. ];
  56. if (!empty($params['keyword'])) {
  57. $where[] = ['jobs_name', 'like', '%' . $params['keyword'] . '%'];
  58. }
  59. if (!empty($params['wage'])) {
  60. $where[] = ['wage', '=', $params['wage']];
  61. }
  62. if (!empty($params['experience'])) {
  63. $where[] = ['experience', '=', $params['experience']];
  64. }
  65. if (!empty($params['education'])) {
  66. $where[] = ['education', '=', $params['education']];
  67. }
  68. if (!empty($params['health_type'])) {
  69. $where[] = ['health_type', '=', $params['health_type']];
  70. }
  71. $list = Jobs::where($where)->orderBy('updated_at', 'desc')->paginate($size);
  72. if ($list->total() > 0) {
  73. $list_items = $this->jobsService->dealjobFilelds($list->items());
  74. } else {
  75. $list_items = [];
  76. }
  77. $mobile_dropload = false;
  78. if ($list->total() > $size) {
  79. $mobile_dropload = true;
  80. }
  81. if ($request->ajax()) {
  82. if ($list->lastPage() < $list->currentPage()) {
  83. return response()->json(['status' => 0]);
  84. }
  85. return response()->json(['status' => 1, 'data' => view('mobile.app.content.jobs.ajax_job_list', ['params' => $params, 'list_items' => $list_items])->render()]);
  86. }
  87. $return_data = [
  88. 'categories' => $categories,
  89. 'list' => $list,
  90. 'list_items' => $list_items,
  91. 'params' => $params,
  92. 'mobile_dropload' => $mobile_dropload,
  93. 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
  94. ];
  95. return view('mobile.app.health.recruit.list', $return_data);
  96. }
  97. public function will()
  98. {
  99. return view('mobile.app.health.recruit.will');
  100. }
  101. public function willSave(Request $request)
  102. {
  103. $field = ['realname' => '姓名', 'sex' => '性别', 'mobile' => '联系方式', 'attachment' => '简历', 'remark' => '求职意向'];
  104. $data = $request->only(array_keys($field));
  105. foreach ($field as $k => $v) {
  106. if (empty($data[$k])) {
  107. return response()->json(['status' => 0, 'msg' => $v . '不能为空']);
  108. }
  109. }
  110. $check = JyyxAppoint::where('mobile', $data['mobile'])->first();
  111. if (!empty($check)) {
  112. return response()->json(['status' => 0, 'msg' => '您已提交过,请勿重复提交']);
  113. }
  114. JyyxAppoint::create($data);
  115. return response()->json(['status' => 1]);
  116. }
  117. public function quanji()
  118. {
  119. $district = $this->categoryService->getDefaultDistrict();
  120. return view('mobile.app.health.recruit.quanji', [
  121. 'defaultCity' => $district->defaultCity,
  122. ]);
  123. }
  124. public function quanjiSave(Request $request)
  125. {
  126. $empty_check = [
  127. 'realname' => '姓名',
  128. 'sex' => '性别',
  129. 'mobile' => '联系方式',
  130. 'birthday' => '出生年份',
  131. 'native_place' => '籍贯',
  132. 'education' => '学历',
  133. 'school' => '毕业学校',
  134. 'pro_type' => '专业',
  135. 'remark' => '求职意向',
  136. ];
  137. $field = array_merge($empty_check, [
  138. 'pro_text' => '具体专业',
  139. 'title' => '在校任职',
  140. 'attachment' => '简历',
  141. ]);
  142. $data = $request->only(array_keys($field));
  143. foreach ($empty_check as $k => $v) {
  144. if (empty($data[$k])) {
  145. return response()->json(['status' => 0, 'msg' => $v . '不能为空']);
  146. }
  147. }
  148. $check = QjwjAppoint::where('mobile', $data['mobile'])->first();
  149. if (!empty($check)) {
  150. return response()->json(['status' => 0, 'msg' => '您已提交过,请勿重复提交']);
  151. }
  152. QjwjAppoint::create($data);
  153. return response()->json(['status' => 1]);
  154. }
  155. public function show(Request $request)
  156. {
  157. $job_id = $request->input('id');
  158. $job_rst = $this->jobsService->getJobInfo(['id' => $job_id]); //获取job信息
  159. if ($job_rst['status'] == 0) {
  160. $back_url = \Illuminate\Support\Facades\URL::previous();
  161. return $this->showMessage($job_rst['error'], $back_url, true, '上一页', '3');
  162. }
  163. $job_info = $job_rst['job'];
  164. $return_data = [
  165. 'info' => $job_info,
  166. ];
  167. return view('mobile.app.health.recruit.show', $return_data);
  168. }
  169. public function apply(Request $request)
  170. {
  171. $job_id = $request->input('id');
  172. $job_rst = $this->jobsService->getJobInfo(['id' => $job_id]); //获取job信息
  173. if ($job_rst['status'] == 0) {
  174. $back_url = \Illuminate\Support\Facades\URL::previous();
  175. return $this->showMessage($job_rst['error'], $back_url, true, '上一页', '3');
  176. }
  177. $job_info = $job_rst['job'];
  178. $district = $this->categoryService->getDefaultDistrict();
  179. return view('mobile.app.health.recruit.apply', [
  180. 'defaultCity' => $district->defaultCity,
  181. 'info' => $job_info,
  182. ]);
  183. }
  184. public function applySave(Request $request)
  185. {
  186. $field = [
  187. 'realname' => '姓名',
  188. 'sex' => '性别',
  189. 'mobile' => '联系方式',
  190. 'birthday' => '出生年份',
  191. 'native_place' => '籍贯',
  192. 'education' => '学历',
  193. 'attachment' => '简历',
  194. 'remark' => '求职意向',
  195. 'job_id' => '岗位',
  196. 'company_id' => '公司',
  197. ];
  198. $data = $request->only(array_keys($field));
  199. foreach ($field as $k => $v) {
  200. if (empty($data[$k])) {
  201. return response()->json(['status' => 0, 'msg' => $v . '不能为空']);
  202. }
  203. }
  204. $check = PostAppoint::where('job_id', $data['job_id'])->where('mobile', $data['mobile'])->first();
  205. if (!empty($check)) {
  206. return response()->json(['status' => 0, 'msg' => '您已提交过,请勿重复提交']);
  207. }
  208. PostAppoint::create($data);
  209. return response()->json(['status' => 1]);
  210. }
  211. }