JobsController.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  1. <?php
  2. namespace App\Http\Controllers\Jkq\Content;
  3. use App\Http\Controllers\Jkq\JkqBaseController;
  4. use App\Repositories\MemberLogRepository;
  5. use App\Services\Common\CategoryService;
  6. use App\Services\Company\JobsService;
  7. use App\Services\Content\FeedbackService;
  8. use Illuminate\Http\Request;
  9. use App\Exceptions\ResponseException;
  10. use App\Services\Content\ReportService;
  11. use App\Services\Content\TaskService;
  12. use App\Services\Company\PersonalJobsApplyService;
  13. use App\Services\Company\CompanyService;
  14. use App\Services\Person\PersonFavoriteService;
  15. use App\Services\Content\AdService;
  16. use App\Services\Common\SearchService;
  17. use App\Services\Common\HotWordService;
  18. use App\Validators\Content\ReportValidatorRequest;
  19. use App\Validators\Content\MsgValidatorRequest;
  20. use Illuminate\Support\Facades\Cache;
  21. class JobsController extends JkqBaseController
  22. {
  23. protected $jobsService;
  24. protected $categoryService;
  25. protected $feedbackService;
  26. protected $reportService;
  27. protected $taskService;
  28. protected $personalJobsApplyService;
  29. protected $companyService;
  30. protected $personFavoriteService;
  31. protected $adService;
  32. protected $searchService;
  33. protected $hotWordService;
  34. protected $memberLogRepository;
  35. /**
  36. * JobsController constructor.
  37. * @param $JobsService
  38. * @param $categoryService
  39. * @param $feedbackService
  40. * @param $reportService
  41. * @param $taskService
  42. * @param $personalJobsApplyService
  43. * @param $companyService
  44. * @param $personFavoriteService
  45. * @param $adService
  46. * @param $searchService
  47. * @param $hotWordService
  48. */
  49. public function __construct(MemberLogRepository $memberLogRepository, JobsService $jobsService, CategoryService $categoryService, FeedbackService $feedbackService, ReportService $reportService, TaskService $taskService, PersonalJobsApplyService $personalJobsApplyService, CompanyService $companyService, PersonFavoriteService $personFavoriteService, AdService $adService, SearchService $searchService, HotWordService $hotWordService)
  50. {
  51. $this->jobsService = $jobsService;
  52. $this->categoryService = $categoryService;
  53. $this->feedbackService = $feedbackService;
  54. $this->reportService = $reportService;
  55. $this->taskService = $taskService;
  56. $this->personalJobsApplyService = $personalJobsApplyService;
  57. $this->companyService = $companyService;
  58. $this->personFavoriteService = $personFavoriteService;
  59. $this->adService = $adService;
  60. $this->searchService = $searchService;
  61. $this->hotWordService = $hotWordService;
  62. $this->memberLogRepository = $memberLogRepository;
  63. }
  64. public function index(Request $request)
  65. {
  66. $citycategory = 'jjkfq';
  67. $search_type = $request->input('search_type', 'jobs');
  68. if ($search_type == 'company') {
  69. return redirect(route('jobs.companyList', ['list_type' => 'AIX_companylist']));
  70. } else {
  71. session(['hotword_show_type' => 1]);
  72. //职位搜索
  73. $job_category = $this->categoryService->getJobsCategoryInfo(); //获取职位分类信息
  74. $filter_where = [
  75. 'AIX_wage' => 100,
  76. 'AIX_jobtag' => 100,
  77. 'AIX_trade' => 100,
  78. 'AIX_scale' => 100,
  79. 'AIX_jobs_nature' => 100,
  80. 'AIX_education' => 100,
  81. 'AIX_experience' => 100,
  82. ];
  83. $categories = $this->categoryService->getCategories($filter_where); //过滤条件信息
  84. //广告位
  85. $ad_where = [
  86. 'theme' => 'default',
  87. 'org' => 'Home',
  88. 'alias' => 'AIX_jobs_list_right',
  89. 'num' => '1',
  90. ];
  91. $ad_infos = $this->adService->getAds($ad_where);
  92. $hotWords = $this->hotWordService->getHotWords(['type' => 1], 'list_order desc,w_hot desc', '21'); //热门关键词
  93. $job_hotwords = array_slice($hotWords->toArray(), 0, 10);
  94. $company_hotwords = $this->hotWordService->getHotWords(['type' => 2], 'list_order desc,w_hot desc', '10');
  95. $param_array = ['citycategory', 'wage', 'jobtag', 'trade', 'scale', 'nature', 'education', 'experience', 'settr', 'jobcategory', 'key', 'sort', 'search_cont', 'license', 'apply', 'search_type', 'lng', 'lat', 'range', 'wa', 'wage_min', 'wage_max'];
  96. $params = [];
  97. if ($request->all()) {
  98. foreach ($request->all() as $k => $v) {
  99. if (in_array($k, $param_array) && $v) {
  100. $params[$k] = $v;
  101. }
  102. }
  103. }
  104. //处理薪资参数
  105. $deal_params = $params;
  106. $customize_params = $params;
  107. $nowage_params = $params;
  108. if (array_has($params, 'wage') && (array_has($params, 'wage_min') || array_has($params, 'wage_max'))) {
  109. unset($deal_params['wage']);
  110. unset($nowage_params['wage']);
  111. }
  112. if (array_has($customize_params, 'wage_min')) {
  113. unset($customize_params['wage_min']);
  114. unset($nowage_params['wage_min']);
  115. }
  116. if (array_has($customize_params, 'wage_max')) {
  117. unset($customize_params['wage_max']);
  118. unset($nowage_params['wage_max']);
  119. }
  120. $map_data = [];
  121. if (array_has($params, 'lng') && array_has($params, 'lat') && (array_has($params, 'range') || array_has($params, 'wa'))) {
  122. if (array_has($params, 'range')) {
  123. $map_data = ['lng' => $params['lng'], 'lat' => $params['lat'], 'range' => $params['range']];
  124. } elseif (array_has($params, 'wa')) {
  125. $map_data = ['lng' => $params['lng'], 'lat' => $params['lat'], 'range' => round($params['wa'] / 1000, 2)];
  126. } else {
  127. $map_data = ['lng' => $params['lng'], 'lat' => $params['lat'], 'range' => config('aix.system.map.map.map_range')];
  128. }
  129. }
  130. $show_filter = false;
  131. $filter_array = ['sort', 'search_cont', 'license', 'apply', 'search_type'];
  132. if ($params && (count($params) <= count($filter_array))) {
  133. foreach ($params as $k => $v) {
  134. if (!in_array($k, $filter_array)) {
  135. $show_filter = true;
  136. break;
  137. }
  138. }
  139. } elseif (count($params) > count($filter_array)) {
  140. $show_filter = true;
  141. }
  142. $hidden_all_result = 0;
  143. $show_login_notice = 0;
  144. $list_limit = '';
  145. $order_by = ['stime' => 'desc', 'refresh_time' => 'desc'];
  146. $search_key = '';
  147. if ($params) {
  148. $search_key = array_has($params, 'key') ? $params['key'] : '';
  149. if (array_has($params, 'sort')) {
  150. if ($params['sort'] == 'rtime') {
  151. $order_by = 'refresh_time';
  152. } else {
  153. $order_by = $params['sort'];
  154. }
  155. } else {
  156. $order_by = ['stime' => 'desc', 'refresh_time' => 'desc'];
  157. }
  158. }
  159. $is_subsite = 0;
  160. $subsites = Cache::get('subsites_list');
  161. if ($subsites) {
  162. if (!array_has($params, 'citycategory')) {
  163. if (get_subsite_id() > 0) {
  164. $citycategory = $subsites[get_subsite_id()]['district'];
  165. }
  166. }
  167. $is_subsite = 1;
  168. }
  169. $citys = $this->categoryService->getCitys($citycategory); //获取地标地段
  170. $district_info = $this->categoryService->getDefaultDistrictInfo(); //获取默认地区信息
  171. $where = $this->setWhere($deal_params, $citys, $job_category); //组合where条件
  172. if (config('aix.companyset.search_com.search_basic.jobs_search_login') == 1 && !auth('web-company')->check() && !auth('web-member')->check()) {
  173. $need_login_params = $param_array;
  174. if ($is_subsite == 1) {
  175. unset($need_login_params[array_search('citycategory', $need_login_params)]);
  176. };
  177. foreach ($params as $k => $v) {
  178. if (in_array($k, $need_login_params) && $v) {
  179. $hidden_all_result = 1;
  180. $where[] = ['id', '=', 0]; //设置该条件使查询结果为空
  181. break;
  182. }
  183. }
  184. $show_login_notice = 1;
  185. $list_limit = config('aix.companyset.search_com.search_basic.jobs_search_num_login');
  186. }
  187. $callback = function ($query) {
  188. $query->with(['company.membersSetmeal']);
  189. };
  190. $list = $this->searchService->search('Job', $where, $order_by, $search_key, '10', '', $callback);
  191. if ($list->total() > 0) {
  192. $list_items = $this->jobsService->dealjobFilelds($list->items(), $map_data);
  193. } else {
  194. $list_items = [];
  195. }
  196. $emergency_jobs = $this->searchService->searchEmergencyJobs(4); //紧急招聘
  197. $recommend_jobs = $this->searchService->searchRecommendJobs(5, $this->getUser()); //推荐职位
  198. //设置职位默认显示方式
  199. if (!session('jobs_show_type')) {
  200. $type = config('aix.companyset.comset.show_set.jobs_list_show_type');
  201. session(['jobs_show_type' => $type]);
  202. }
  203. //设置薪资视图显示
  204. $wage_info = '';
  205. if (array_has($params, 'wage_min') || array_has($params, 'wage_max')) {
  206. $wage_min = array_has($params, 'wage_min') ? array_get($params, 'wage_min') : 0;
  207. $wage_max = array_has($params, 'wage_max') ? array_get($params, 'wage_max') : 0;
  208. if ($wage_min > 0 && $wage_max == 0) {
  209. $wage_info = $wage_min . '以上/月';
  210. } elseif ($wage_min == 0 && $wage_max > 0) {
  211. $wage_info = $wage_min . '以下/月';
  212. } else {
  213. $wage_info = $wage_min . '-' . $wage_max . '/月';
  214. }
  215. //$wage_info = $this->jobsService->dealWage(0, $wage_min, $wage_max);
  216. } elseif (array_has($params, 'wage')) {
  217. if (array_has($categories, 'AIX_wage') && array_has($categories['AIX_wage'], $params['wage'])) {
  218. $wage_info = $categories['AIX_wage'][$params['wage']]['demand'];
  219. }
  220. }
  221. $return_data = [
  222. 'search_type' => $search_type,
  223. 'city' => $citys,
  224. 'categories' => $categories,
  225. 'params' => $params,
  226. 'wage_params' => $deal_params,
  227. 'customize_params' => $customize_params,
  228. 'nowage_params' => $nowage_params,
  229. 'wage_info' => $wage_info,
  230. 'district_info' => $district_info,
  231. 'job_category' => $job_category,
  232. 'ad_info' => $ad_infos,
  233. 'hotWords' => $hotWords,
  234. 'job_hotwords' => $job_hotwords,
  235. 'company_hotwords' => $company_hotwords,
  236. 'list' => $list,
  237. 'list_items' => $list_items,
  238. 'show_login_notice' => $show_login_notice,
  239. 'hidden_all_result' => $hidden_all_result,
  240. 'show_filter' => $show_filter,
  241. 'limit' => $list_limit,
  242. 'emergency_jobs' => $emergency_jobs,
  243. 'recommend_jobs' => $recommend_jobs,
  244. ];
  245. return view('jkq.jobs.list', $return_data);
  246. }
  247. }
  248. public function comList(Request $request)
  249. {
  250. session(['hotword_show_type' => 2]);
  251. $return_data = [];
  252. $search_key = $request->input('key', '');
  253. $trade = $request->input('trade');
  254. $nature = $request->input('nature');
  255. $param_array = ['key', 'trade', 'nature'];
  256. $params = [];
  257. $where = [];
  258. if ($request->all()) {
  259. foreach ($request->all() as $k => $v) {
  260. if (in_array($k, $param_array) && $v) {
  261. $params[$k] = $v;
  262. if ($k != 'key') {
  263. $where[] = [$k, '=', $v];
  264. }
  265. }
  266. }
  267. }
  268. $where[] = ['user_status', '=', 1];
  269. $where[] = ['subsite_ids', '=', get_subsite_id()];
  270. //$order_by = array('refresh_time'=>'desc','id'=>'desc');
  271. $order_by = '';
  272. $list = $this->searchService->search('Company', $where, $order_by, $search_key);
  273. if ($list->total() > 0) {
  274. //处理企业信息
  275. $list_items = $this->companyService->dealCompanyFields($list->items());
  276. } else {
  277. $list_items = [];
  278. }
  279. $filter_where = [
  280. 'AIX_trade' => 100,
  281. 'AIX_company_type' => 100,
  282. ];
  283. $categories = $this->categoryService->getCategories($filter_where);
  284. //热门关键字
  285. $job_hotwords = $this->hotWordService->getHotWords(['type' => 1], 'list_order desc,w_hot desc', '10');
  286. $company_hotwords = $this->hotWordService->getHotWords(['type' => 2], 'list_order desc,w_hot desc', '10');
  287. $return_data = [
  288. 'search_type' => 'company',
  289. 'params' => $params,
  290. 'categories' => $categories,
  291. 'list' => $list,
  292. 'list_items' => $list_items,
  293. 'job_hotwords' => $job_hotwords,
  294. 'company_hotwords' => $company_hotwords,
  295. ];
  296. //企业搜索
  297. return view('jkq.jobs.company_list', $return_data);
  298. }
  299. public function setWhere($params, $citys, $job_category)
  300. {
  301. $where = [];
  302. //审核状态过滤
  303. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  304. $where[] = ['audit', '=', 1];
  305. } else {
  306. $where[] = ['audit', '<>', 3];
  307. }
  308. $where[] = ['valid', '=', 1];
  309. $where[] = ['display', '=', 1];
  310. if ($params) {
  311. foreach ($params as $k => $v) {
  312. if ($k == 'citycategory') {
  313. //地标地段
  314. $where[] = ['district', '=', $citys['select']['id']];
  315. } elseif ($k == 'jobcategory') {
  316. //职位分类
  317. if ($job_category && $v && array_get($job_category['spell'], $v)) {
  318. if ($job_category && $v && array_get($job_category['spell'], $v)) {
  319. $where[] = ['intention_jobs_id', '=', $job_category['spell'][$v]['id']];
  320. }
  321. }
  322. } elseif ($k == 'jobtag') {
  323. //职位亮点
  324. $where[] = ['tag', '=', $v];
  325. } elseif ($k == 'search_cont') {
  326. if ($v == 'setmeal') {
  327. //名企招聘
  328. $where[] = ['setmeal_id', '>', 1];
  329. }
  330. } elseif ($k == 'license') {
  331. //营业执照
  332. $where[] = ['company.certificate_img_audit', '=', 1];
  333. } elseif ($k == 'settr') {
  334. //更新时间
  335. $update_time = date('Y-m-d H:i:s', strtotime(date('Y-m-d', strtotime('-' . $v . ' day'))));
  336. $where[] = ['updated_at', '>=', $update_time];
  337. } elseif ($k == 'apply') {
  338. $where['apply'] = $v;
  339. } elseif ($k == 'wa') {
  340. $where[] = ['range', '=', round($params['wa'] / 1000, 2)];
  341. if (!(array_has($params, 'lng') && array_has($params, 'lat'))) {
  342. $where[] = ['lng', '=', subsite_config('aix.system.map.map.map_x')];
  343. $where[] = ['lat', '=', subsite_config('aix.system.map.map.map_y')];
  344. }
  345. } elseif ($k == 'wage') {
  346. //获取薪资最大值和最小值
  347. $filter_where = ['AIX_wage' => 100];
  348. $categories = $this->categoryService->getCategories($filter_where);
  349. if ($categories) {
  350. $wage = $categories['AIX_wage'][$params['wage']]['origin_demand'];
  351. if ($wage) {
  352. $wage = format_wage($wage);
  353. }
  354. $wage_arr = explode_wage($wage);
  355. $where[] = $wage_arr[0];
  356. $where[] = $wage_arr[1];
  357. }
  358. } elseif ($k == 'wage_min') {
  359. $where[] = ['wage_min', '>=', $v];
  360. } elseif ($k == 'wage_max') {
  361. $where[] = ['wage_max', '<=', $v];
  362. } elseif ($k != 'sort' && $k != 'key' && $k != 'search_type' && $k != 'm_zoom') {
  363. $where[] = [$k, '=', $v];
  364. }
  365. }
  366. }
  367. $where[] = ['subsite_ids', '=', get_subsite_id()];
  368. return $where;
  369. }
  370. public function category()
  371. {
  372. session(['hotword_show_type' => 1]);
  373. $serch_type = null;
  374. $district_info = $this->categoryService->getDefaultDistrictInfo();
  375. //获取职位分类信息
  376. $job_cates = $this->categoryService->getJobsCategories();
  377. //dd($job_cates[0]);
  378. $citys = $this->categoryService->getCitys();
  379. $job_hotwords = $this->hotWordService->getHotWords(['type' => 1], 'list_order desc,w_hot desc', '10');
  380. $company_hotwords = $this->hotWordService->getHotWords(['type' => 2], 'list_order desc,w_hot desc', '10');
  381. $return_data = [
  382. 'search_type' => $serch_type,
  383. 'city' => $citys,
  384. 'district_info' => $district_info,
  385. 'job_hotwords' => $job_hotwords,
  386. 'company_hotwords' => $company_hotwords,
  387. 'job_cates' => $job_cates,
  388. ];
  389. return view('jkq.jobs.category', $return_data);
  390. }
  391. public function hotWord(Request $request)
  392. {
  393. $key = $request->input('query', '');
  394. $key = trim($key);
  395. if (!$key) {
  396. return response()->json(['status' => 0, 'msg' => '请输入关健字!']);
  397. }
  398. }
  399. public function getUser()
  400. {
  401. $user = [];
  402. if (auth('web-member')->check()) {
  403. $user = auth('web-member')->user();
  404. } elseif (auth('web-company')->check()) {
  405. $user = auth('web-company')->user();
  406. }
  407. return $user;
  408. }
  409. public function show(Request $request)
  410. {
  411. $job_id = $request->input('id');
  412. $job_rst = $this->jobsService->getJobInfo(['id' => $job_id], $this->getUser()); //获取job信息
  413. if ($job_rst['status'] == 0) {
  414. $back_url = \Illuminate\Support\Facades\URL::previous();
  415. return $this->showMessage($job_rst['error'], $back_url, true, '上一页', '3');
  416. }
  417. $job_info = $job_rst['job'];
  418. $cate_jobs = $this->searchService->searchCateJobs($job_info, 6); //看了此职位的人还会看(同类别6条其它职位)
  419. $this->putSeoData('job', $job_info);
  420. //当前公司的其它职位
  421. $other_where = [
  422. ['company_id', '=', $job_info->company_id],
  423. ['valid', '=', 1],
  424. ['display', '=', 1],
  425. ['id', '<>', $job_id],
  426. ];
  427. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  428. $other_where[] = ['audit', '=', 1];
  429. } else {
  430. $other_where[] = ['audit', '<>', 3];
  431. }
  432. $other_jobs = $this->jobsService->getOtherJobs($other_where, 6);
  433. $return_data = [
  434. 'info' => $job_info,
  435. 'other_jobs' => $other_jobs,
  436. 'cate_jobs' => $cate_jobs,
  437. 'redirect_url' => route('jobs.show', ['id' => $job_info->id]),
  438. ];
  439. return view('jkq.jobs.job_show', $return_data);
  440. }
  441. public function click(Request $request)
  442. {
  443. $id = $request->input('id');
  444. $rst = $this->jobsService->incrementData(['id' => $id], 1, 'click');
  445. $data = ['status' => 0];
  446. if ($rst) {
  447. $data = ['status' => 1];
  448. }
  449. return response()->json($data);
  450. }
  451. //留言
  452. public function sendMsg(MsgValidatorRequest $request)
  453. {
  454. $form_data = [
  455. 'parent_id' => $request->input('parent_id', '0'),
  456. 'touid' => $request->input('touid'),
  457. 'message' => $request->input('message'),
  458. 'ip' => ip2long($request->getClientIp()),
  459. 'subsite_id' => get_subsite_id(),
  460. 'ip_address' => '本机地址',
  461. ];
  462. $rst = $this->feedbackService->sendMsg($form_data, 3);
  463. if ($rst) {
  464. $data = ['status' => 1, 'msg' => '反馈成功,感谢您对本站的关注!', 'insert_id' => $rst['data']['id']];
  465. } else {
  466. $data = ['msg' => '数据保存失败!'];
  467. }
  468. return response()->json($data);
  469. }
  470. //收藏职位
  471. public function favor(Request $request)
  472. {
  473. $jid = $request->jid;
  474. $reg = $this->jobsService->jobFavor($jid);
  475. $return_data = ['status' => 0, 'msg' => '收藏失败!'];
  476. if ($reg) {
  477. $return_data = ['status' => 1, 'msg' => '收藏成功!'];
  478. }
  479. return response()->json($return_data);
  480. }
  481. public function loginDig(Request $request)
  482. {
  483. $html = '';
  484. $redirect_url = $request->input('redirect_url', route('home'));
  485. if ($request->input('type') == 'per') {
  486. $html = view('jkq.common.ajax.per_login', ['redirect_url' => $redirect_url])->render();
  487. } elseif ($request->input('type') == 'com') {
  488. $html = view('jkq.common.ajax.com_login', ['redirect_url' => $redirect_url])->render();
  489. }
  490. $return_data = ['status' => 1, 'html' => $html];
  491. return response()->json($return_data);
  492. }
  493. //职位举报
  494. public function report(Request $request)
  495. {
  496. $jobs_id = $request->input('jobs_id');
  497. if (!$jobs_id) {
  498. throw new ResponseException('请选择要举报的职位!');
  499. }
  500. $report_types = $this->reportService->getReportTypes('1');
  501. $taskInfo = $this->taskService->getTask('2', 'report_jobs'); //举报积分信息
  502. $page_data = ['type_arr' => $report_types, 'jobs_id' => $jobs_id, 'taskInfo' => $taskInfo];
  503. $html = view('jkq.common.ajax.report_job', $page_data)->render();
  504. $return_data = ['status' => 1, 'html' => $html];
  505. return response()->json($return_data);
  506. }
  507. public function reportJobs(ReportValidatorRequest $request)
  508. {
  509. $report_type = $request->input('report_type');
  510. $jobs_id = $request->input('jobs_id');
  511. $telephone = trim($request->input('telephone'));
  512. $content = trim($request->input('content'));
  513. if (!$content) {
  514. throw new ResponseException('请填写备注说明!');
  515. }
  516. if (!$telephone) {
  517. throw new ResponseException('请填写联系电话!');
  518. }
  519. //添加举报信息
  520. $report_data = [
  521. 'utype' => 1,
  522. 'utype_id' => $jobs_id,
  523. 'type_id' => $report_type,
  524. 'phone' => $telephone,
  525. 'content' => $content,
  526. 'audit' => 1,
  527. ];
  528. $rst = $this->reportService->addReport($report_data);
  529. if ($rst) {
  530. //添加会员日志
  531. $user_info = [
  532. 'uid' => auth('web-member')->user()->id,
  533. 'utype' => 2,
  534. 'username' => auth('web-member')->user()->username,
  535. 'ip' => ip2long($request->getClientIp()),
  536. 'log_address' => '本机地址',
  537. ];
  538. // $this->feedbackService->addMembersLog($user_info, '2042', '投诉职位(职位id:'.$jobs_id.')');
  539. if (!$this->memberLogRepository->createLog(auth('web-member')->user(), 2042, $jobs_id)) {
  540. throw new \Exception("日志记失败!");
  541. }
  542. $return_data = ['status' => 1, 'msg' => '投诉成功!请等待管理员核实!'];
  543. return response()->json($return_data);
  544. } else {
  545. throw new ResponseException('举报失败!');
  546. }
  547. }
  548. //职位申请
  549. public function apply(Request $request)
  550. {
  551. //判断个人资料是否完善
  552. $jobs_id = $request->input('jobs_id');
  553. $resume_id = $request->input('resume_id');
  554. if (!$jobs_id) {
  555. throw new ResponseException('请选择要投递的职位!');
  556. }
  557. if (!is_array($jobs_id)) {
  558. $jobs_id = explode(',', $jobs_id);
  559. }
  560. if ($resume_id) {
  561. //选择投递简历后
  562. $apply_rst = $this->personalJobsApplyService->applyJobs($jobs_id, $resume_id, $this->getUser());
  563. //完整度不够
  564. $return_data = [];
  565. if (array_get($apply_rst, 'status') == 0 && array_get($apply_rst, 'complete')) {
  566. $resume_complete = array_get($apply_rst, 'complete');
  567. $page_data = ['info' => $resume_complete];
  568. $html = view('jkq.common.ajax.apply_job_percent_tip', $page_data)->render();
  569. $return_data = [
  570. 'status' => array_get($apply_rst, 'status'),
  571. 'html' => $html,
  572. 'resume_id' => $resume_id,
  573. ];
  574. return response()->json($return_data);
  575. } else if (array_get($apply_rst, 'status') == 0) {
  576. return response()->json($return_data);
  577. }
  578. $tpl = 'jkq.common.ajax.batch_delivery_success';
  579. if ($apply_rst['data']['failure']) {
  580. $tpl = 'jkq.common.ajax.batch_delivery_fail';
  581. }
  582. //TODO 获取微信公众号名称
  583. $tpl_data = [
  584. 'jid' => $jobs_id,
  585. 'show_points' => $apply_rst['show_points'],
  586. 'apply' => $apply_rst['data'],
  587. 'user_points' => $apply_rst['points_info'],
  588. ];
  589. $tpl_html = view($tpl, $tpl_data)->render();
  590. $return_data = [
  591. 'status' => array_get($apply_rst, 'status'),
  592. 'html' => $tpl_html,
  593. 'fail_jids' => $apply_rst['fail_job_ids'],
  594. ];
  595. return response()->json($return_data);
  596. } else {
  597. //未选择投递简历前
  598. $rst = $this->personalJobsApplyService->ifJobApply($jobs_id, $this->getUser());
  599. //判断是否需要选择简历
  600. if (array_get($rst, 'status') == 2) {
  601. $page_data = ['status' => array_get($rst, 'status'), 'resumes' => array_get($rst, 'resumes'), 'def_resume' => array_get($rst, 'def_resume')];
  602. $html = view('jkq.common.ajax.apply_resume', $page_data)->render();
  603. $return_data = ['status' => 2, 'html' => $html];
  604. return response()->json($return_data);
  605. } else {
  606. //判断
  607. $return_data = [];
  608. if (array_get($rst, 'status') == 0 && array_get($rst, 'complete')) {
  609. $resume_complete = array_get($rst, 'complete');
  610. $page_data = ['info' => $resume_complete];
  611. $html = view('jkq.common.ajax.apply_job_percent_tip', $page_data)->render();
  612. $return_data = [
  613. 'status' => array_get($rst, 'status'),
  614. 'html' => $html,
  615. 'resume_id' => array_get($rst, 'resume_id'),
  616. ];
  617. return response()->json($return_data);
  618. }
  619. $tpl = 'jkq.common.ajax.batch_delivery_success';
  620. if ($rst['data']['failure']) {
  621. $tpl = 'jkq.common.ajax.batch_delivery_fail';
  622. }
  623. //获取微信公众号名称
  624. $tpl_data = [
  625. 'jid' => $jobs_id,
  626. 'show_points' => $rst['show_points'],
  627. 'apply' => $rst['data'],
  628. 'user_points' => $rst['points_info'],
  629. ];
  630. $tpl_html = view($tpl, $tpl_data)->render();
  631. $return_data = [
  632. 'status' => array_get($rst, 'status'),
  633. 'html' => $tpl_html,
  634. 'fail_jids' => $rst['fail_job_ids'],
  635. ];
  636. return response()->json($return_data);
  637. }
  638. }
  639. }
  640. public function jobMap(Request $request)
  641. {
  642. //设置职位默认显示方式
  643. if (!session('jobs_show_type')) {
  644. $type = config('aix.companyset.comset.show_set.jobs_list_show_type');
  645. session(['jobs_show_type' => $type]);
  646. }
  647. $params = $request->all();
  648. $param_array = ['key', 'wage', 'trade', 'scale', 'nature', 'education', 'experience', 'settr', 'lng', 'lat', 'range', 'wa', 'm_zoom', 'search_type', 'sort', 'license', "apply", 'search_cont'];
  649. $params = [];
  650. if ($request->all()) {
  651. foreach ($request->all() as $k => $v) {
  652. if (in_array($k, $param_array) && $v) {
  653. $params[$k] = $v;
  654. }
  655. }
  656. }
  657. $position_search = false;
  658. if ($request->input('search_type') == 'position') {
  659. $position_search = true;
  660. }
  661. $filter_array = ['sort', 'search_cont', 'license', 'apply', 'search_type', 'key', 'wa', 'lng', 'lat', 'm_zoom'];
  662. $show_filter = $this->showFilter($params, $filter_array);
  663. $filter_where = [
  664. 'AIX_wage' => 100,
  665. 'AIX_jobtag' => 100,
  666. 'AIX_trade' => 100,
  667. 'AIX_scale' => 100,
  668. 'AIX_jobs_nature' => 100,
  669. 'AIX_education' => 100,
  670. 'AIX_experience' => 100,
  671. ];
  672. $categories = $this->categoryService->getCategories($filter_where);
  673. $where = $this->setWhere($params, [], []); //组合where条件
  674. $order_by = ['stime' => 'desc', 'refresh_time' => 'desc'];
  675. $search_key = '';
  676. if ($params) {
  677. if (array_has($params, 'sort')) {
  678. if ($params['sort'] == 'rtime') {
  679. $order_by = ['refresh_time' => 'desc'];
  680. } else {
  681. $order_by = [$params['sort'] => 'desc'];
  682. }
  683. }
  684. if (array_has($params, 'key')) {
  685. $search_key = $params['key'] ? $params['key'] : '';
  686. }
  687. }
  688. $map_data = [];
  689. if (array_has($params, 'lng') && array_has($params, 'lat') && array_has($params, 'wa')) {
  690. $map_data = ['lng' => $params['lng'], 'lat' => $params['lat'], 'map' => 1];
  691. }
  692. $list = $this->searchService->search('Job', $where, $order_by, $search_key);
  693. $list_items = [];
  694. $job_companys = [];
  695. if ($list->total() > 0) {
  696. $list_items = $this->jobsService->dealjobFilelds($list->items(), $map_data);
  697. $job_companys = $this->jobsService->dealJobCompanies($list_items);
  698. }
  699. $emergency_jobs = $this->searchService->searchEmergencyJobs(4); //紧急招聘
  700. $recommend_jobs = $this->searchService->searchRecommendJobs(5, $this->getUser()); //推荐职位
  701. $map_info = $this->getMapInfo();
  702. $return_data = [
  703. 'params' => $params,
  704. 'categories' => $categories,
  705. 'show_filter' => $show_filter,
  706. 'list' => $list,
  707. 'list_items' => $list_items,
  708. 'job_companys' => $job_companys,
  709. 'emergency_jobs' => $emergency_jobs,
  710. 'position_search' => $position_search,
  711. 'recommend_jobs' => $recommend_jobs,
  712. 'map_info' => $map_info,
  713. ];
  714. return view('jkq.jobs.map', $return_data);
  715. }
  716. public function getMapInfo()
  717. {
  718. $m_zoom = subsite_config('aix.system.map.map.max_level');
  719. $map_center_x = subsite_config('aix.system.map.map.map_x');
  720. $map_center_y = subsite_config('aix.system.map.map.map_y');
  721. return ['m_zoom' => $m_zoom, 'map_center_x' => $map_center_x, 'map_center_y' => $map_center_y];
  722. }
  723. public function showFilter($params, $filter_array)
  724. {
  725. $show_filter = false;
  726. if ($params && (count($params) <= count($filter_array))) {
  727. foreach ($params as $k => $v) {
  728. if (!in_array($k, $filter_array)) {
  729. $show_filter = true;
  730. break;
  731. }
  732. }
  733. } elseif (count($params) > count($filter_array)) {
  734. $show_filter = true;
  735. }
  736. return $show_filter;
  737. }
  738. }