RecruitController.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. namespace App\Http\Controllers\Mobile\Ic;
  3. use App\Http\Controllers\Mobile\MobileBaseController;
  4. use App\Models\Jobs;
  5. use App\Models\PostAppointIc;
  6. use App\Services\Common\CategoryService;
  7. use App\Services\Company\JobsService;
  8. use Illuminate\Http\Request;
  9. class RecruitController extends MobileBaseController
  10. {
  11. protected $categoryService;
  12. protected $jobsService;
  13. /**
  14. * JobsController constructor.
  15. * @param $categoryService
  16. */
  17. public function __construct(CategoryService $categoryService, JobsService $jobsService)
  18. {
  19. $this->categoryService = $categoryService;
  20. $this->jobsService = $jobsService;
  21. }
  22. public function index()
  23. {
  24. return view('mobile.app.ic.recruit.index');
  25. }
  26. public function list(Request $request)
  27. {
  28. //获取分类
  29. $filter_where = [
  30. 'AIX_education' => 100,
  31. 'AIX_experience' => 100,
  32. 'AIX_wage' => 100,
  33. ];
  34. $categories = $this->categoryService->getCategories($filter_where); //过滤条件信息
  35. //默认参数
  36. $param_array = ['keyword', 'wage', 'experience', 'education'];
  37. $params = [];
  38. if ($request->all()) {
  39. foreach ($request->all() as $k => $v) {
  40. if (in_array($k, $param_array) && $v) {
  41. $params[$k] = $v;
  42. }
  43. }
  44. }
  45. //查询条件
  46. $size = 10;
  47. $where = [
  48. ['is_ic', '=', 1],
  49. ['valid', '=', 1],
  50. ['audit', '=', 1],
  51. ['display', '=', 1],
  52. ];
  53. if (!empty($params['keyword'])) {
  54. $where[] = ['jobs_name', 'like', '%' . $params['keyword'] . '%'];
  55. }
  56. if (!empty($params['wage'])) {
  57. $where[] = ['wage', '=', $params['wage']];
  58. }
  59. if (!empty($params['experience'])) {
  60. $where[] = ['experience', '=', $params['experience']];
  61. }
  62. if (!empty($params['education'])) {
  63. $where[] = ['education', '=', $params['education']];
  64. }
  65. $list = Jobs::where($where)->orderBy('updated_at', 'desc')->paginate($size);
  66. if ($list->total() > 0) {
  67. $list_items = $this->jobsService->dealjobFilelds($list->items());
  68. } else {
  69. $list_items = [];
  70. }
  71. $mobile_dropload = false;
  72. if ($list->total() > $size) {
  73. $mobile_dropload = true;
  74. }
  75. if ($request->ajax()) {
  76. if ($list->lastPage() < $list->currentPage()) {
  77. return response()->json(['status' => 0]);
  78. }
  79. return response()->json(['status' => 1, 'data' => view('mobile.app.content.jobs.ajax_job_list', ['params' => $params, 'list_items' => $list_items])->render()]);
  80. }
  81. $return_data = [
  82. 'categories' => $categories,
  83. 'list' => $list,
  84. 'list_items' => $list_items,
  85. 'params' => $params,
  86. 'mobile_dropload' => $mobile_dropload,
  87. 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
  88. ];
  89. return view('mobile.app.ic.recruit.list', $return_data);
  90. }
  91. public function will()
  92. {
  93. return view('mobile.app.ic.recruit.will');
  94. }
  95. public function quanji()
  96. {
  97. return view('mobile.app.ic.recruit.quanji');
  98. }
  99. public function show(Request $request)
  100. {
  101. $job_id = $request->input('id');
  102. $job_rst = $this->jobsService->getJobInfo(['id' => $job_id]); //获取job信息
  103. if ($job_rst['status'] == 0) {
  104. $back_url = \Illuminate\Support\Facades\URL::previous();
  105. return $this->showMessage($job_rst['error'], $back_url, true, '上一页', '3');
  106. }
  107. $job_info = $job_rst['job'];
  108. $return_data = [
  109. 'info' => $job_info,
  110. ];
  111. return view('mobile.app.ic.recruit.show', $return_data);
  112. }
  113. public function apply(Request $request)
  114. {
  115. $job_id = $request->input('id');
  116. $job_rst = $this->jobsService->getJobInfo(['id' => $job_id]); //获取job信息
  117. if ($job_rst['status'] == 0) {
  118. $back_url = \Illuminate\Support\Facades\URL::previous();
  119. return $this->showMessage($job_rst['error'], $back_url, true, '上一页', '3');
  120. }
  121. $job_info = $job_rst['job'];
  122. $district = $this->categoryService->getDefaultDistrict();
  123. return view('mobile.app.ic.recruit.apply', [
  124. 'defaultCity' => $district->defaultCity,
  125. 'info' => $job_info,
  126. ]);
  127. }
  128. public function applySave(Request $request)
  129. {
  130. $field = [
  131. 'realname' => '姓名',
  132. 'sex' => '性别',
  133. 'mobile' => '联系方式',
  134. 'birthday' => '出生年份',
  135. 'native_place' => '籍贯',
  136. 'education' => '学历',
  137. 'attachment' => '简历',
  138. 'remark' => '求职意向',
  139. 'job_id' => '岗位',
  140. 'company_id' => '公司',
  141. ];
  142. $data = $request->only(array_keys($field));
  143. foreach ($field as $k => $v) {
  144. if (empty($data[$k])) {
  145. return response()->json(['status' => 0, 'msg' => $v . '不能为空']);
  146. }
  147. }
  148. $check = PostAppointIc::where('job_id', $data['job_id'])->where('mobile', $data['mobile'])->first();
  149. if (!empty($check)) {
  150. return response()->json(['status' => 0, 'msg' => '您已提交过,请勿重复提交']);
  151. }
  152. PostAppointIc::create($data);
  153. return response()->json(['status' => 1]);
  154. }
  155. }