JobsController.php 33 KB

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