RecruitController.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. ['is_health', '=', 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. if (!empty($params['health_type'])) {
  66. $where[] = ['health_type', '=', $params['health_type']];
  67. }
  68. $list = Jobs::where($where)->orderBy('updated_at', 'desc')->paginate($size);
  69. if ($list->total() > 0) {
  70. $list_items = $this->jobsService->dealjobFilelds($list->items());
  71. } else {
  72. $list_items = [];
  73. }
  74. $mobile_dropload = false;
  75. if ($list->total() > $size) {
  76. $mobile_dropload = true;
  77. }
  78. if ($request->ajax()) {
  79. if ($list->lastPage() < $list->currentPage()) {
  80. return response()->json(['status' => 0]);
  81. }
  82. return response()->json(['status' => 1, 'data' => view('mobile.app.content.jobs.ajax_job_list', ['params' => $params, 'list_items' => $list_items])->render()]);
  83. }
  84. $return_data = [
  85. 'categories' => $categories,
  86. 'list' => $list,
  87. 'list_items' => $list_items,
  88. 'params' => $params,
  89. 'mobile_dropload' => $mobile_dropload,
  90. 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
  91. ];
  92. return view('mobile.app.health.recruit.list', $return_data);
  93. }
  94. public function will()
  95. {
  96. return view('mobile.app.health.recruit.will');
  97. }
  98. public function willSave(Request $request)
  99. {
  100. $field = ['realname' => '姓名', 'sex' => '性别', 'mobile' => '联系方式', 'attachment' => '简历', 'remark' => '求职意向'];
  101. $data = $request->only(array_keys($field));
  102. foreach ($field as $k => $v) {
  103. if (empty($data[$k])) {
  104. return response()->json(['status' => 0, 'msg' => $v . '不能为空']);
  105. }
  106. }
  107. $check = JyyxAppoint::where('mobile', $data['mobile'])->first();
  108. if (!empty($check)) {
  109. return response()->json(['status' => 0, 'msg' => '您已提交过,请勿重复提交']);
  110. }
  111. JyyxAppoint::create($data);
  112. return response()->json(['status' => 1]);
  113. }
  114. public function quanji()
  115. {
  116. $district = $this->categoryService->getDefaultDistrict();
  117. return view('mobile.app.health.recruit.quanji', [
  118. 'defaultCity' => $district->defaultCity,
  119. ]);
  120. }
  121. public function quanjiSave(Request $request)
  122. {
  123. $empty_check = [
  124. 'realname' => '姓名',
  125. 'sex' => '性别',
  126. 'mobile' => '联系方式',
  127. 'birthday' => '出生年份',
  128. 'native_place' => '籍贯',
  129. 'education' => '学历',
  130. 'school' => '毕业学校',
  131. 'pro_type' => '专业',
  132. 'remark' => '求职意向',
  133. ];
  134. $field = array_merge($empty_check, [
  135. 'pro_text' => '具体专业',
  136. 'title' => '在校任职',
  137. 'attachment' => '简历',
  138. ]);
  139. $data = $request->only(array_keys($field));
  140. foreach ($empty_check as $k => $v) {
  141. if (empty($data[$k])) {
  142. return response()->json(['status' => 0, 'msg' => $v . '不能为空']);
  143. }
  144. }
  145. $check = QjwjAppoint::where('mobile', $data['mobile'])->first();
  146. if (!empty($check)) {
  147. return response()->json(['status' => 0, 'msg' => '您已提交过,请勿重复提交']);
  148. }
  149. QjwjAppoint::create($data);
  150. return response()->json(['status' => 1]);
  151. }
  152. public function show(Request $request)
  153. {
  154. $job_id = $request->input('id');
  155. $job_rst = $this->jobsService->getJobInfo(['id' => $job_id]); //获取job信息
  156. if ($job_rst['status'] == 0) {
  157. $back_url = \Illuminate\Support\Facades\URL::previous();
  158. return $this->showMessage($job_rst['error'], $back_url, true, '上一页', '3');
  159. }
  160. $job_info = $job_rst['job'];
  161. $return_data = [
  162. 'info' => $job_info,
  163. ];
  164. return view('mobile.app.health.recruit.show', $return_data);
  165. }
  166. public function apply(Request $request)
  167. {
  168. $job_id = $request->input('id');
  169. $job_rst = $this->jobsService->getJobInfo(['id' => $job_id]); //获取job信息
  170. if ($job_rst['status'] == 0) {
  171. $back_url = \Illuminate\Support\Facades\URL::previous();
  172. return $this->showMessage($job_rst['error'], $back_url, true, '上一页', '3');
  173. }
  174. $job_info = $job_rst['job'];
  175. $district = $this->categoryService->getDefaultDistrict();
  176. return view('mobile.app.health.recruit.apply', [
  177. 'defaultCity' => $district->defaultCity,
  178. 'info' => $job_info,
  179. ]);
  180. }
  181. public function applySave(Request $request)
  182. {
  183. $field = [
  184. 'realname' => '姓名',
  185. 'sex' => '性别',
  186. 'mobile' => '联系方式',
  187. 'birthday' => '出生年份',
  188. 'native_place' => '籍贯',
  189. 'education' => '学历',
  190. 'attachment' => '简历',
  191. 'remark' => '求职意向',
  192. 'job_id' => '岗位',
  193. 'company_id' => '公司',
  194. ];
  195. $data = $request->only(array_keys($field));
  196. foreach ($field as $k => $v) {
  197. if (empty($data[$k])) {
  198. return response()->json(['status' => 0, 'msg' => $v . '不能为空']);
  199. }
  200. }
  201. $check = PostAppoint::where('job_id', $data['job_id'])->where('mobile', $data['mobile'])->first();
  202. if (!empty($check)) {
  203. return response()->json(['status' => 0, 'msg' => '您已提交过,请勿重复提交']);
  204. }
  205. PostAppoint::create($data);
  206. return response()->json(['status' => 1]);
  207. }
  208. }