RecruitController.php 7.7 KB

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