RecruitController.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <?php
  2. namespace App\Http\Controllers\Mobile\Health;
  3. use App\Http\Controllers\Mobile\MobileBaseController;
  4. use App\Services\Common\CategoryService;
  5. use App\Services\Common\HotWordService;
  6. use App\Services\Common\SearchService;
  7. use App\Services\Company\CompanyService;
  8. use App\Services\Company\JobsService;
  9. use App\Services\Company\PersonalJobsApplyService;
  10. use App\Services\Content\AdService;
  11. use App\Services\Content\FeedbackService;
  12. use App\Services\Content\ReportService;
  13. use App\Services\Content\TaskService;
  14. use App\Services\Person\PersonFavoriteService;
  15. use App\Services\Person\ResumeService;
  16. use Illuminate\Http\Request;
  17. use Illuminate\Support\Facades\Cache;
  18. class RecruitController extends MobileBaseController
  19. {
  20. protected $jobsService;
  21. protected $resumeService;
  22. protected $categoryService;
  23. protected $feedbackService;
  24. protected $reportService;
  25. protected $taskService;
  26. protected $personalJobsApplyService;
  27. protected $companyService;
  28. protected $personFavoriteService;
  29. protected $adService;
  30. protected $searchService;
  31. protected $hotWordService;
  32. /**
  33. * JobsController constructor.
  34. * @param $JobsService
  35. * @param $resumeService
  36. * @param $categoryService
  37. * @param $feedbackService
  38. * @param $reportService
  39. * @param $taskService
  40. * @param $personalJobsApplyService
  41. * @param $companyService
  42. * @param $personFavoriteService
  43. * @param $adService
  44. * @param $searchService
  45. * @param $hotWordService
  46. */
  47. public function __construct(JobsService $jobsService, ResumeService $resumeService, CategoryService $categoryService, FeedbackService $feedbackService, ReportService $reportService, TaskService $taskService, PersonalJobsApplyService $personalJobsApplyService, CompanyService $companyService, PersonFavoriteService $personFavoriteService, AdService $adService, SearchService $searchService, HotWordService $hotWordService)
  48. {
  49. $this->jobsService = $jobsService;
  50. $this->resumeService = $resumeService;
  51. $this->categoryService = $categoryService;
  52. $this->feedbackService = $feedbackService;
  53. $this->reportService = $reportService;
  54. $this->taskService = $taskService;
  55. $this->personalJobsApplyService = $personalJobsApplyService;
  56. $this->companyService = $companyService;
  57. $this->personFavoriteService = $personFavoriteService;
  58. $this->adService = $adService;
  59. $this->searchService = $searchService;
  60. $this->hotWordService = $hotWordService;
  61. }
  62. public function index()
  63. {
  64. return view('mobile.app.health.recruit.index');
  65. }
  66. public function list(Request $request)
  67. {
  68. if ($request->input('range-lng') != '' && $request->input('range-lat') != '') {
  69. $request->session()->put('range-lng', $request->input('range-lng'));
  70. $request->session()->put('range-lat', $request->input('range-lat'));
  71. $request->session()->put('range-laction', 1);
  72. };
  73. //查询条件
  74. $citycategory = $request->input('citycategory');
  75. $search_type = $request->input('search_type', 'jobs');
  76. if ($search_type == 'company') {
  77. return redirect(route('jobs.companyList', ['list_type' => 'AIX_companylist']));
  78. } else {
  79. session(['hotword_show_type' => 1]);
  80. //职位搜索
  81. $job_category = $this->categoryService->getJobsCategoryInfo(); //获取职位分类信息
  82. $filter_where = [
  83. 'AIX_wage' => 100,
  84. 'AIX_jobtag' => 100,
  85. 'AIX_trade' => 100,
  86. 'AIX_scale' => 100,
  87. 'AIX_jobs_nature' => 100,
  88. 'AIX_education' => 100,
  89. 'AIX_experience' => 100,
  90. ];
  91. $categories = $this->categoryService->getCategories($filter_where); //过滤条件信息
  92. //广告位
  93. $subsite_id = Cache::has('subsite_id') ? Cache::get('subsite_id') : 0;
  94. $ad_where = [
  95. 'theme' => 'default',
  96. 'org' => 'Home',
  97. 'alias' => 'AIX_jobs_list_right',
  98. 'num' => '1',
  99. ];
  100. $ad_infos = $this->adService->getAds($ad_where);
  101. $hotWords = $this->hotWordService->getHotWords(['type' => 1], 'list_order desc,w_hot desc', '21'); //热门关键词
  102. $job_hotwords = array_slice($hotWords->toArray(), 0, 10);
  103. $company_hotwords = $this->hotWordService->getHotWords(['type' => 2], 'list_order desc,w_hot desc', '10');
  104. $param_array = ['citycategory', 'keyword', 'wage', 'jobtag', 'trade', 'scale', 'nature', 'education', 'experience', 'settr', 'jobcategory', 'key', 'sort', 'search_cont', 'license', 'deliver', 'search_type', 'lng', 'lat', 'range', 'wa', 'range-lng', 'range-lat'];
  105. $params = [];
  106. if ($request->all()) {
  107. foreach ($request->all() as $k => $v) {
  108. if (in_array($k, $param_array) && $v) {
  109. $params[$k] = $v;
  110. }
  111. }
  112. }
  113. $map_data = [];
  114. if (array_has($params, 'lng') && array_has($params, 'lat') && (array_has($params, 'range') || array_has($params, 'wa'))) {
  115. if (array_has($params, 'range')) {
  116. $map_data = ['lng' => $params['lng'], 'lat' => $params['lat'], 'range' => $params['range']];
  117. } elseif (array_has($params, 'wa')) {
  118. $map_data = ['lng' => $params['lng'], 'lat' => $params['lat'], 'range' => round($params['wa'] / 1000, 2)];
  119. } else {
  120. $map_data = ['lng' => $params['lng'], 'lat' => $params['lat'], 'range' => config('aix.system.map.map.map_range')];
  121. }
  122. } elseif (array_has($params, 'range') && !array_has($params, 'citycategory') && session("range-laction")) {
  123. $map_data = ['lng' => session("range-lng"), 'lat' => session("range-lat"), 'range' => $params['range']];
  124. }
  125. $show_range = false;
  126. if ($map_data) {
  127. $show_range = true;
  128. }
  129. $hidden_all_result = 0;
  130. $show_login_notice = 0;
  131. $list_limit = '';
  132. $order_by = ['stime' => 'desc', 'refresh_time' => 'desc'];
  133. $search_key = '';
  134. $where = [];
  135. if ($params) {
  136. $search_key = array_has($params, 'key') ? $params['key'] : '';
  137. if (array_has($params, 'sort')) {
  138. if ($params['sort'] == 'rtime') {
  139. $order_by = 'refresh_time';
  140. } else {
  141. $order_by = $params['sort'];
  142. }
  143. } else {
  144. $order_by = ['stime' => 'desc', 'refresh_time' => 'desc'];
  145. }
  146. }
  147. $is_subsite = 0;
  148. $subsites = Cache::get('subsites_list');
  149. if ($subsites) {
  150. if (!array_has($params, 'citycategory')) {
  151. if (get_subsite_id() > 0) {
  152. $citycategory = $subsites[get_subsite_id()]['district'];
  153. }
  154. }
  155. $is_subsite = 1;
  156. }
  157. $citys = $this->categoryService->getCitys($citycategory); //获取地标地段
  158. $district_info = $this->categoryService->getDefaultDistrictInfo(); //获取默认地区信息
  159. $where = $this->setWhere($params, $citys, $job_category); //组合where条件
  160. if (config('aix.companyset.search_com.search_basic.jobs_search_login') == 1 && !auth('web-company')->check() && !auth('web-member')->check()) {
  161. $need_login_params = $param_array;
  162. if ($is_subsite == 1) {
  163. unset($need_login_params[array_search('citycategory', $need_login_params)]);
  164. };
  165. foreach ($params as $k => $v) {
  166. if (in_array($k, $need_login_params) && $v) {
  167. $hidden_all_result = 1;
  168. $where[] = ['id', '=', 0]; //设置该条件使查询结果为空
  169. break;
  170. }
  171. }
  172. $show_login_notice = 1;
  173. $list_limit = config('aix.companyset.search_com.search_basic.jobs_search_num_login');
  174. }
  175. $size = 20;
  176. $list = $this->searchService->search('Job', $where, $order_by, $search_key, $size);
  177. if ($list->total() > 0) {
  178. $list_items = $this->jobsService->dealjobFilelds($list->items(), $map_data);
  179. } else {
  180. $list_items = [];
  181. }
  182. $mobile_dropload = false;
  183. if ($list->total() > $size) {
  184. $mobile_dropload = true;
  185. }
  186. if ($request->ajax()) {
  187. if ($list->lastPage() < $list->currentPage()) {
  188. return response()->json(['status' => 0]);
  189. }
  190. return response()->json(['status' => 1, 'data' => view('mobile.app.content.jobs.ajax_job_list', ['params' => $params, 'list_items' => $list_items])->render()]);
  191. }
  192. $return_data = [
  193. 'search_type' => $search_type,
  194. 'city' => $citys,
  195. 'categories' => $categories,
  196. 'params' => $params,
  197. 'district_info' => $district_info,
  198. 'job_category' => $job_category,
  199. 'ad_info' => $ad_infos,
  200. 'hotWords' => $hotWords,
  201. 'job_hotwords' => $job_hotwords,
  202. 'company_hotwords' => $company_hotwords,
  203. 'list' => $list,
  204. 'list_items' => $list_items,
  205. 'show_login_notice' => $show_login_notice,
  206. 'hidden_all_result' => $hidden_all_result,
  207. 'limit' => $list_limit,
  208. 'mobile_dropload' => $mobile_dropload,
  209. 'show_range' => $show_range,
  210. 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
  211. ];
  212. return view('mobile.app.health.recruit.list', $return_data);
  213. }
  214. }
  215. public function will()
  216. {
  217. return view('mobile.app.health.recruit.will');
  218. }
  219. public function show()
  220. {
  221. return view('mobile.app.health.recruit.show');
  222. }
  223. public function apply()
  224. {
  225. $district = $this->categoryService->getDefaultDistrict();
  226. return view('mobile.app.health.recruit.apply', [
  227. 'defaultCity' => $district->defaultCity,
  228. ]);
  229. }
  230. public function setWhere($params, $citys, $job_category)
  231. {
  232. $where = [];
  233. //审核状态过滤
  234. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  235. $where[] = ['audit', '=', 1];
  236. } else {
  237. $where[] = ['audit', '<>', 3];
  238. }
  239. $where[] = ['valid', '=', 1];
  240. $where[] = ['display', '=', 1];
  241. if ($params) {
  242. foreach ($params as $k => $v) {
  243. if ($k == 'citycategory') {
  244. //地标地段
  245. $where[] = ['district', '=', $citys['select']['id']];
  246. } elseif ($k == 'jobcategory') {
  247. //职位分类
  248. if ($job_category && $v && array_get($job_category['spell'], $v)) {
  249. if ($job_category && $v && array_get($job_category['spell'], $v)) {
  250. $where[] = ['intention_jobs_id', '=', $job_category['spell'][$v]['id']];
  251. }
  252. }
  253. } elseif ($k == 'jobtag') {
  254. //职位亮点
  255. $where[] = ['tag', '=', $v];
  256. } elseif ($k == 'search_cont') {
  257. if ($v == 'setmeal') {
  258. //名企招聘
  259. $where[] = ['setmeal_id', '>', 1];
  260. }
  261. } elseif ($k == 'license') {
  262. //营业执照
  263. $where[] = ['company.certificate_img_audit', '=', 1];
  264. } elseif ($k == 'settr') {
  265. //更新时间
  266. $update_time = date('Y-m-d H:i:s', strtotime(date('Y-m-d', strtotime('-' . $v . ' day'))));
  267. $where[] = ['updated_at', '>=', $update_time];
  268. } elseif ($k == 'deliver') {
  269. $where['apply'] = $v;
  270. } elseif ($k == 'wa') {
  271. $where[] = ['range', '=', round($params['wa'] / 1000, 2)];
  272. if (!(array_has($params, 'lng') && array_has($params, 'lat'))) {
  273. $where[] = ['lng', '=', subsite_config('aix.system.map.map.map_x')];
  274. $where[] = ['lat', '=', subsite_config('aix.system.map.map.map_y')];
  275. }
  276. } elseif ($k == 'wage') {
  277. //获取薪资最大值和最小值
  278. $filter_where = ['AIX_wage' => 100];
  279. $categories = $this->categoryService->getCategories($filter_where);
  280. if ($categories) {
  281. $wage = $categories['AIX_wage'][$params['wage']]['origin_demand'];
  282. if ($wage) {
  283. $wage = format_wage($wage);
  284. }
  285. $wage_arr = explode_wage($wage);
  286. $where[] = $wage_arr[0];
  287. $where[] = $wage_arr[1];
  288. }
  289. } elseif ($k == 'range') {
  290. if (!array_has($params, 'citycategory')) {
  291. if (!(array_has($params, 'lng') && array_has($params, 'lat'))) {
  292. if (session('range-laction')) {
  293. $where[] = ['range', '=', $params['range']];
  294. $where[] = ['lng', '=', session('range-lng')];
  295. $where[] = ['lat', '=', session('range-lat')];
  296. }
  297. }
  298. }
  299. } elseif ($k == 'keyword') {
  300. $where[] = ['jobs_name', 'like', $v];
  301. } elseif ($k != 'sort' && $k != 'key' && $k != 'search_type' && $k != 'm_zoom' && $k != 'range-lng' && $k != 'range-lat') {
  302. $where[] = [$k, '=', $v];
  303. }
  304. }
  305. }
  306. return $where;
  307. }
  308. }