RecruitController.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. // dd($job_rst);
  160. if ($job_rst['status'] == 0) {
  161. $back_url = \Illuminate\Support\Facades\URL::previous();
  162. return $this->showMessage($job_rst['error'], $back_url, true, '上一页', '3');
  163. }
  164. $job_info = $job_rst['job'];
  165. $return_data = [
  166. 'info' => $job_info,
  167. ];
  168. return view('mobile.app.health.recruit.show', $return_data);
  169. }
  170. public function apply(Request $request)
  171. {
  172. $job_id = $request->input('id');
  173. $job_rst = $this->jobsService->getJobInfo(['id' => $job_id]); //获取job信息
  174. if ($job_rst['status'] == 0) {
  175. $back_url = \Illuminate\Support\Facades\URL::previous();
  176. return $this->showMessage($job_rst['error'], $back_url, true, '上一页', '3');
  177. }
  178. $job_info = $job_rst['job'];
  179. $district = $this->categoryService->getDefaultDistrict();
  180. return view('mobile.app.health.recruit.apply', [
  181. 'defaultCity' => $district->defaultCity,
  182. 'info' => $job_info,
  183. ]);
  184. }
  185. public function applySave(Request $request)
  186. {
  187. $field = [
  188. 'realname' => '姓名',
  189. 'sex' => '性别',
  190. 'mobile' => '联系方式',
  191. 'birthday' => '出生年份',
  192. 'native_place' => '籍贯',
  193. 'education' => '学历',
  194. 'attachment' => '简历',
  195. 'remark' => '求职意向',
  196. 'job_id' => '岗位',
  197. 'company_id' => '公司',
  198. ];
  199. $data = $request->only(array_keys($field));
  200. foreach ($field as $k => $v) {
  201. if (empty($data[$k])) {
  202. return response()->json(['status' => 0, 'msg' => $v . '不能为空']);
  203. }
  204. }
  205. $check = PostAppoint::where('job_id', $data['job_id'])->where('mobile', $data['mobile'])->first();
  206. if (!empty($check)) {
  207. return response()->json(['status' => 0, 'msg' => '您已提交过,请勿重复提交']);
  208. }
  209. PostAppoint::create($data);
  210. return response()->json(['status' => 1]);
  211. }
  212. }