FudaController.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. namespace App\Http\Controllers\Mobile\Active;
  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\JobsService;
  8. use App\Services\Content\AdService;
  9. use Illuminate\Http\Request;
  10. class FudaController extends MobileBaseController
  11. {
  12. protected $categoryService;
  13. protected $adService;
  14. protected $hotWordService;
  15. protected $jobsService;
  16. protected $searchService;
  17. /**
  18. * JobsController constructor.
  19. * @param $JobsService
  20. */
  21. public function __construct(CategoryService $categoryService, AdService $adService, HotWordService $hotWordService, JobsService $jobsService, SearchService $searchService)
  22. {
  23. $this->categoryService = $categoryService;
  24. $this->adService = $adService;
  25. $this->hotWordService = $hotWordService;
  26. $this->jobsService = $jobsService;
  27. $this->searchService = $searchService;
  28. }
  29. public function index(Request $request)
  30. {
  31. if ($request->input('range-lng') != '' && $request->input('range-lat') != '') {
  32. $request->session()->put('range-lng', $request->input('range-lng'));
  33. $request->session()->put('range-lat', $request->input('range-lat'));
  34. $request->session()->put('range-laction', 1);
  35. };
  36. //查询条件
  37. $citycategory = $request->input('citycategory');
  38. $search_type = $request->input('search_type', 'jobs');
  39. //职位搜索
  40. $job_category = $this->categoryService->getJobsCategoryInfo(); //获取职位分类信息
  41. $filter_where = [
  42. 'AIX_wage' => 100,
  43. 'AIX_jobtag' => 100,
  44. 'AIX_trade' => 100,
  45. 'AIX_scale' => 100,
  46. 'AIX_jobs_nature' => 100,
  47. 'AIX_education' => 100,
  48. 'AIX_experience' => 100,
  49. ];
  50. $categories = $this->categoryService->getCategories($filter_where); //过滤条件信息
  51. //广告位
  52. $ad_where = [
  53. 'theme' => 'default',
  54. 'org' => 'Home',
  55. 'alias' => 'AIX_jobs_list_right',
  56. 'num' => '1',
  57. ];
  58. $ad_infos = $this->adService->getAds($ad_where);
  59. $hotWords = $this->hotWordService->getHotWords(['type' => 1], 'list_order desc,w_hot desc', '21'); //热门关键词
  60. $job_hotwords = array_slice($hotWords->toArray(), 0, 10);
  61. $company_hotwords = $this->hotWordService->getHotWords(['type' => 2], 'list_order desc,w_hot desc', '10');
  62. $param_array = ['citycategory', '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', 'keyword'];
  63. $params = [];
  64. if ($request->all()) {
  65. foreach ($request->all() as $k => $v) {
  66. if (in_array($k, $param_array) && $v) {
  67. $params[$k] = $v;
  68. }
  69. }
  70. }
  71. $map_data = [];
  72. if (array_has($params, 'lng') && array_has($params, 'lat') && (array_has($params, 'range') || array_has($params, 'wa'))) {
  73. if (array_has($params, 'range')) {
  74. $map_data = ['lng' => $params['lng'], 'lat' => $params['lat'], 'range' => $params['range']];
  75. } elseif (array_has($params, 'wa')) {
  76. $map_data = ['lng' => $params['lng'], 'lat' => $params['lat'], 'range' => round($params['wa'] / 1000, 2)];
  77. } else {
  78. $map_data = ['lng' => $params['lng'], 'lat' => $params['lat'], 'range' => config('aix.system.map.map.map_range')];
  79. }
  80. } elseif (array_has($params, 'range') && !array_has($params, 'citycategory') && session("range-laction")) {
  81. $map_data = ['lng' => session("range-lng"), 'lat' => session("range-lat"), 'range' => $params['range']];
  82. }
  83. $show_range = false;
  84. if ($map_data) {
  85. $show_range = true;
  86. }
  87. $hidden_all_result = 0;
  88. $show_login_notice = 0;
  89. $list_limit = '';
  90. $order_by = ['stime' => 'desc', 'refresh_time' => 'desc'];
  91. $search_key = '';
  92. if ($params) {
  93. $search_key = array_has($params, 'key') ? $params['key'] : '';
  94. if (array_has($params, 'sort')) {
  95. if ($params['sort'] == 'rtime') {
  96. $order_by = 'refresh_time';
  97. } else {
  98. $order_by = $params['sort'];
  99. }
  100. } else {
  101. $order_by = ['stime' => 'desc', 'refresh_time' => 'desc'];
  102. }
  103. }
  104. $citys = $this->categoryService->getCitys($citycategory); //获取地标地段
  105. $district_info = $this->categoryService->getDefaultDistrictInfo(); //获取默认地区信息
  106. $where = $this->setWhere($params, $citys, $job_category); //组合where条件
  107. $size = 20;
  108. $list = $this->searchService->search('Job', $where, $order_by, $search_key, $size);
  109. if ($list->total() > 0) {
  110. $list_items = $this->jobsService->dealjobFilelds($list->items(), $map_data);
  111. } else {
  112. $list_items = [];
  113. }
  114. $mobile_dropload = false;
  115. if ($list->total() > $size) {
  116. $mobile_dropload = true;
  117. }
  118. if ($request->ajax()) {
  119. if ($list->lastPage() < $list->currentPage()) {
  120. return response()->json(['status' => 0]);
  121. }
  122. return response()->json(['status' => 1, 'data' => view('mobile.app.content.jobs.ajax_job_list', ['params' => $params, 'list_items' => $list_items])->render()]);
  123. }
  124. $return_data = [
  125. 'search_type' => $search_type,
  126. 'city' => $citys,
  127. 'categories' => $categories,
  128. 'params' => $params,
  129. 'district_info' => $district_info,
  130. 'job_category' => $job_category,
  131. 'ad_info' => $ad_infos,
  132. 'hotWords' => $hotWords,
  133. 'job_hotwords' => $job_hotwords,
  134. 'company_hotwords' => $company_hotwords,
  135. 'list' => $list,
  136. 'list_items' => $list_items,
  137. 'show_login_notice' => $show_login_notice,
  138. 'hidden_all_result' => $hidden_all_result,
  139. 'limit' => $list_limit,
  140. 'mobile_dropload' => $mobile_dropload,
  141. 'show_range' => $show_range,
  142. 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
  143. 'wap_title' => '福州大学招聘会',
  144. ];
  145. return view('mobile.app.active.fuda', $return_data);
  146. }
  147. public function setWhere($params, $citys, $job_category)
  148. {
  149. $where = [];
  150. //审核状态过滤
  151. $where[] = ['audit', '=', 1];
  152. $where[] = ['valid', '=', 1];
  153. $where[] = ['display', '=', 1];
  154. $where[] = ['created_at', '>=', '2024-04-06 00:00:00'];
  155. if ($params) {
  156. foreach ($params as $k => $v) {
  157. if ($k == 'citycategory') {
  158. //地标地段
  159. $where[] = ['district', '=', $citys['select']['id']];
  160. } elseif ($k == 'jobcategory') {
  161. //职位分类
  162. if ($job_category && $v && array_get($job_category['spell'], $v)) {
  163. if ($job_category && $v && array_get($job_category['spell'], $v)) {
  164. $where[] = ['intention_jobs_id', '=', $job_category['spell'][$v]['id']];
  165. }
  166. }
  167. } elseif ($k == 'jobtag') {
  168. //职位亮点
  169. $where[] = ['tag', '=', $v];
  170. } elseif ($k == 'search_cont') {
  171. if ($v == 'setmeal') {
  172. //名企招聘
  173. $where[] = ['setmeal_id', '>', 1];
  174. }
  175. } elseif ($k == 'license') {
  176. //营业执照
  177. $where[] = ['company.certificate_img_audit', '=', 1];
  178. } elseif ($k == 'settr') {
  179. //更新时间
  180. $update_time = date('Y-m-d H:i:s', strtotime(date('Y-m-d', strtotime('-' . $v . ' day'))));
  181. $where[] = ['updated_at', '>=', $update_time];
  182. } elseif ($k == 'deliver') {
  183. $where['apply'] = $v;
  184. } elseif ($k == 'wa') {
  185. $where[] = ['range', '=', round($params['wa'] / 1000, 2)];
  186. if (!(array_has($params, 'lng') && array_has($params, 'lat'))) {
  187. $where[] = ['lng', '=', subsite_config('aix.system.map.map.map_x')];
  188. $where[] = ['lat', '=', subsite_config('aix.system.map.map.map_y')];
  189. }
  190. } elseif ($k == 'wage') {
  191. //获取薪资最大值和最小值
  192. $filter_where = ['AIX_wage' => 100];
  193. $categories = $this->categoryService->getCategories($filter_where);
  194. if ($categories) {
  195. $wage = $categories['AIX_wage'][$params['wage']]['origin_demand'];
  196. if ($wage) {
  197. $wage = format_wage($wage);
  198. }
  199. $wage_arr = explode_wage($wage);
  200. $where[] = $wage_arr[0];
  201. $where[] = $wage_arr[1];
  202. }
  203. } elseif ($k == 'range') {
  204. if (!array_has($params, 'citycategory')) {
  205. if (!(array_has($params, 'lng') && array_has($params, 'lat'))) {
  206. if (session('range-laction')) {
  207. $where[] = ['range', '=', $params['range']];
  208. $where[] = ['lng', '=', session('range-lng')];
  209. $where[] = ['lat', '=', session('range-lat')];
  210. }
  211. }
  212. }
  213. } elseif ($k == 'keyword') {
  214. $where[] = ['jobs_name', 'like', "*{$params['keyword']}*"];
  215. } elseif ($k != 'sort' && $k != 'key' && $k != 'search_type' && $k != 'm_zoom' && $k != 'range-lng' && $k != 'range-lat') {
  216. $where[] = [$k, '=', $v];
  217. }
  218. }
  219. }
  220. return $where;
  221. }
  222. }