RecruitController.php 7.9 KB

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