HomeController.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. <?php
  2. namespace App\Http\Controllers\Web;
  3. use App\Models\Ad;
  4. use App\Models\Recruit;
  5. use App\Models\Recuperate;
  6. use App\Models\RecuperateCategory;
  7. use App\Models\ShortUrl;
  8. use App\Models\SubsiteAd;
  9. use App\Services\Content\LinkService;
  10. use App\Services\HomeService;
  11. use App\Services\Company\JobsService;
  12. use App\Services\Common\CategoryService;
  13. use App\Services\Company\CompanyDownResumeService;
  14. use App\Services\Common\SearchService;
  15. use App\Services\Person\ResumeService;
  16. use App\Services\Company\CompanyService;
  17. use App\Services\Jobfair\JobfairService;
  18. use App\Services\Content\NoticeServer;
  19. use App\Services\Content\ArticleService;
  20. use App\Services\SubsiteService;
  21. use App\Repositories\PersonalJobsApplyRepository;
  22. use App\Repositories\ViewJobRepository;
  23. use App\Repositories\PmsRepository;
  24. use App\Repositories\ResumeRepository;
  25. use App\Repositories\CompanyInterviewRepository;
  26. use App\Repositories\companyFavoriteRepository;
  27. use App\Repositories\ViewResumeRepository;
  28. use App\Repositories\TaskLogRepository;
  29. use App\Services\Content\PolicyService;
  30. use App\Models\Article;
  31. use App\Repositories\PersonFocusComRepository;
  32. use App\Repositories\MemberSetmealRepository;
  33. use App\Repositories\JobsRepository;
  34. use App\Repositories\MemberInfoRepository;
  35. use Illuminate\Http\Request;
  36. use Illuminate\Support\Facades\Cache;
  37. use Illuminate\Support\Facades\DB;
  38. use Illuminate\Support\Facades\View;
  39. class HomeController extends WebBaseController
  40. {
  41. protected $LinkService;
  42. protected $subsite_id;
  43. protected $homeService;
  44. protected $jobsService;
  45. protected $categoryService;
  46. protected $companyDownResumeService;
  47. protected $searchService;
  48. protected $resumeService;
  49. protected $companyService;
  50. protected $jobfairService;
  51. protected $noticeServer;
  52. protected $articleService;
  53. protected $subsiteService;
  54. protected $personalJobsApplyRepository;
  55. protected $viewJobRepository;
  56. protected $pmsRepository;
  57. protected $resumeRepository;
  58. protected $companyInterviewRepository;
  59. protected $companyFavoriteRepository;
  60. protected $viewResumeRepository;
  61. protected $taskLogRepository;
  62. protected $personFocusComRepository;
  63. protected $memberSetmealRepository;
  64. protected $jobsRepository;
  65. protected $policyService;
  66. protected $memberInfoRepository;
  67. /**
  68. * HomeController constructor.
  69. * @param $LinkService
  70. * @param $homeService
  71. * @param $jobsService
  72. * @param $categoryService
  73. * @param $companyDownResumeService
  74. * @param $searchService
  75. * @param $resumeService
  76. * @param $companyService
  77. * @param $jobfairService
  78. * @param $noticeServer
  79. * @param $articleService
  80. * @param $subsiteService
  81. */
  82. public function __construct(LinkService $LinkService, HomeService $homeService, JobsService $jobsService, CategoryService $categoryService, CompanyDownResumeService $companyDownResumeService, SearchService $searchService, ResumeService $resumeService, CompanyService $companyService, JobfairService $jobfairService, NoticeServer $noticeServer, ArticleService $articleService, SubsiteService $subsiteService, PersonalJobsApplyRepository $personalJobsApplyRepository, ViewJobRepository $viewJobRepository, PmsRepository $pmsRepository, ResumeRepository $resumeRepository, CompanyInterviewRepository $companyInterviewRepository, companyFavoriteRepository $companyFavoriteRepository, ViewResumeRepository $viewResumeRepository, TaskLogRepository $taskLogRepository, PersonFocusComRepository $personFocusComRepository, MemberSetmealRepository $memberSetmealRepository, JobsRepository $jobsRepository, PolicyService $policyService, MemberInfoRepository $memberInfoRepository)
  83. {
  84. $this->LinkService = $LinkService;
  85. $this->homeService = $homeService;
  86. $this->jobsService = $jobsService;
  87. $this->categoryService = $categoryService;
  88. $this->companyDownResumeService = $companyDownResumeService;
  89. $this->searchService = $searchService;
  90. $this->resumeService = $resumeService;
  91. $this->companyService = $companyService;
  92. $this->jobfairService = $jobfairService;
  93. $this->noticeServer = $noticeServer;
  94. $this->articleService = $articleService;
  95. $this->subsiteService = $subsiteService;
  96. $this->personalJobsApplyRepository = $personalJobsApplyRepository;
  97. $this->viewJobRepository = $viewJobRepository;
  98. $this->pmsRepository = $pmsRepository;
  99. $this->resumeRepository = $resumeRepository;
  100. $this->companyInterviewRepository = $companyInterviewRepository;
  101. $this->companyFavoriteRepository = $companyFavoriteRepository;
  102. $this->viewResumeRepository = $viewResumeRepository;
  103. $this->taskLogRepository = $taskLogRepository;
  104. $this->personFocusComRepository = $personFocusComRepository;
  105. $this->memberSetmealRepository = $memberSetmealRepository;
  106. $this->jobsRepository = $jobsRepository;
  107. $this->policyService = $policyService;
  108. $this->memberInfoRepository = $memberInfoRepository;
  109. }
  110. /**
  111. * Show the application dashboard.
  112. *
  113. * @return \Illuminate\Http\Response
  114. */
  115. public function index()
  116. {
  117. //分站
  118. $subsite_id = get_subsite_id();
  119. if ($subsite_id > 0) {
  120. return $this->_subsite();
  121. }
  122. $filter_data = [
  123. 'AIX_indexfocus' => 8, //首页轮播广告
  124. 'AIX_indextopimg' => 8, //首页上方横幅
  125. 'AIX_index_center' => 8, //首页中部横幅
  126. 'index_famous' => 8, //首页中部名企推荐广告 - 六栏格子广告
  127. 'index_famous1' => 8, //首页中部横幅
  128. 'index_famous2' => 8, //首页两栏广告
  129. 'index_famous3' => 8, //首页三栏广告
  130. 'index_famous4' => 8, //首页浮窗广告
  131. 'index_famous5' => 8, //首页浮窗广告
  132. 'index_famous6' => 8, //首页浮窗广告
  133. 'index_famous7' => 8, //首页浮窗广告
  134. ];
  135. $ads = $this->homeService->getAds($filter_data);
  136. // $seatmeal_companies = [];
  137. // $seatmeal_arr = array(
  138. // 0 => '',
  139. // 1 => '14',
  140. // 2 => '11',
  141. // 3 => '26,27,28',
  142. // 4 => '13,35,153',
  143. // 5 => '25',
  144. // 6 => '3,4,6,9,10,16,17,20,21,25,28,30,31,34,36,37,40,41,44,45,151,165,213,314'
  145. // );
  146. // foreach ($seatmeal_arr as $key => $val) {
  147. // $seatmeal_companies[]= $this->companyService->getSetmailCompanies(array('trade'=>$val));
  148. // }
  149. $links_logo = $this->getLinks('AIX_index', '2', '18');
  150. $links_url = $this->getLinks('AIX_index', '1', '50');
  151. if ($user = auth('web-member')->user()) {
  152. $userInfo = $this->homeService->getUserInfo($user);
  153. } elseif ($user = auth('web-company')->user()) {
  154. $userInfo = $this->homeService->getUserInfo($user);
  155. } else {
  156. $userInfo = [];
  157. }
  158. $time = $this->homeService->getTime();
  159. //公告公示
  160. $notice_filter = [
  161. 'titlelen' => 14,
  162. 'dot' => '...',
  163. 'size' => 9,
  164. ];
  165. $notices = $this->noticeServer->getNotices($notice_filter);
  166. //获取工作动态、校园招聘、重要通知的数据
  167. $article_map = [
  168. 'type_id' => [13, 14, 15, 16, 17, 18, 19, 25, 26, 27, 28, 29, 57, 58, 59],
  169. 'limit' => 12,
  170. 'titlelen' => 25,
  171. 'dot' => '...',
  172. ];
  173. $articles = $this->articleService->getArticleCache($article_map, 'home');
  174. $articles_img = $this->articleService->getArticlesByType(3, 5);
  175. //企业登录后需要展示的数据
  176. //当前时间
  177. $hour = date('G');
  178. if ($hour < 11) {
  179. $am_pm = '早上好';
  180. } else if ($hour < 13) {
  181. $am_pm = '中午好';
  182. } else if ($hour < 17) {
  183. $am_pm = '下午好';
  184. } else {
  185. $am_pm = '晚上好';
  186. }
  187. //是否签到
  188. $isSign = 0;
  189. //套餐职位数量
  190. $jobs_meanwhile = 0;
  191. //已经发布的职位数量
  192. $jobsCount = 0;
  193. //待处理简历数
  194. $resumesCount = 0;
  195. //谁关注我数量
  196. $concern = 0;
  197. //我的消息数量
  198. $pms = 0;
  199. //个人登录后需要显示的数据
  200. $resumeid = 0;
  201. //面试邀请数量
  202. $interview = 0;
  203. //谁关注我数量
  204. $viewResume = 0;
  205. //我的消息数量
  206. $mypms = 0;
  207. if ($this->getUser()) {
  208. //企业
  209. if ($this->getUser()->utype == 1) {
  210. //是否已签到
  211. $isSign = $this->taskLogRepository->getTaskLogCount($user->id, 18, $user->utype);
  212. //待处理简历
  213. $condition1 = [
  214. 'is_reply' => 0,
  215. 'company_id' => $this->getUser()->id,
  216. ];
  217. $resumesCount = $this->personalJobsApplyRepository->resumesCount($condition1);
  218. //谁看过我
  219. $map['company_id'] = auth('web-company')->user()->id;
  220. $concern = $this->personFocusComRepository->getFansCount($map);
  221. //我的消息
  222. $where['msgtouid'] = $this->getUser()->id;
  223. $where['utype'] = $this->getUser()->utype;
  224. $where['new'] = 1;
  225. $pms = $this->pmsRepository->getPmsCount($where);
  226. $company_setmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, $user->utype);//会员套餐
  227. $jobs_meanwhile = $company_setmeal->jobs_meanwhile;
  228. $jobsCountwhere[] = ['company_id', '=', $user->id];
  229. $jobsCount = $this->jobsRepository->getJobCount($jobsCountwhere);
  230. } else {
  231. //是否已签到
  232. $isSign = $this->taskLogRepository->getTaskLogCount($user->id, 3, $user->utype);
  233. $resume = $this->resumeRepository->getPersonInfo($this->getUser()->id);
  234. if ($resume) {
  235. $interview = $this->companyInterviewRepository->getInterview($this->getUser()->id, getJobsStatus());
  236. $viewResume = $this->companyFavoriteRepository->getAttentionByResume($resume->id);
  237. $resumeid = $resume->id;
  238. } else {
  239. $interview = 0;
  240. $viewResume = 0;
  241. }
  242. $mypms = $this->pmsRepository->getPmsCount(['msgtype' => 1, 'new' => 1, 'utype' => 2, 'msgtouid' => $this->getUser()->id]);
  243. }
  244. }
  245. //人才新闻
  246. // $ad_pic_where1[] = ['small_img', '<>', ''];
  247. // $ad_pic1 = Article::where($ad_pic_where1)->whereIn('type_id', [58, 59])->orderBy('list_order', 'asc')->orderBy('id', 'desc')->limit(1)->get();
  248. // $ad_pic1 = Article::whereNotNull('small_img')->orderBy('list_order', 'desc')->orderBy('id', 'desc')->limit(1)->get();
  249. //人才疗休养活动
  250. $ad_pic_where2[] = ['r_c_id', '!=', 0];
  251. $ad_pic_where2[] = ['deleted_at', '=', null];
  252. $ad_pic_where2[] = ['small_img', '<>', ''];
  253. $ad_pic2 = Recuperate::where($ad_pic_where2)->orderBy('list_order', 'desc')->orderBy('id', 'desc')->limit(4)->get();
  254. //人才疗休养分类
  255. $Recuperatecategory_arr = RecuperateCategory::where('deleted_at', null)->select('id', 'name')->get()->toArray();
  256. //人才新闻
  257. $ad_pic3 = Article::whereIn('type_id', [58, 59])->where('is_display', 1)->orderBy('list_order', 'desc')->orderBy('id', 'desc')->limit(12)->get();
  258. // $rcinfos = $this->policyService->getRcInfosByIndex();
  259. //招考系统
  260. $recruit = Recruit::where([['status', '=', 1]])->where('id','<>',126)->orderBy('ordid','desc')->orderBy(DB::raw('field(current,1,2,3,4,5,6,7,8,9,0)'))->orderBy('updated_at','desc')->limit(4)->get();
  261. if (!$recruit->isEmpty()) {
  262. foreach ($recruit as $k => $v) {
  263. $recruit[$k] = Recruit::parse_index($v);
  264. }
  265. }
  266. $return_data = [
  267. 'links_logo' => $links_logo,
  268. 'links_url' => $links_url,
  269. 'ads' => $ads,
  270. 'userInfo' => $userInfo,
  271. 'time' => $time,
  272. 'notices' => $notices,
  273. 'articles' => $articles,
  274. //'seatmeal_companies' => $seatmeal_companies,
  275. 'am_pm' => $am_pm,
  276. 'isSign' => $isSign,
  277. 'jobs_meanwhile' => $jobs_meanwhile,
  278. 'jobsCount' => $jobsCount,
  279. 'resumesCount' => $resumesCount,
  280. 'concern' => $concern,
  281. 'pms' => $pms,
  282. 'resumeid' => $resumeid,
  283. 'interview' => $interview,
  284. 'viewResume' => $viewResume,
  285. 'mypms' => $mypms,
  286. 'articles_img' => $articles_img,
  287. // 'ad_pic1' => $ad_pic1,
  288. 'ad_pic2' => $ad_pic2,
  289. 'ad_pic3' => $ad_pic3,
  290. // 'rcinfos' => $rcinfos,
  291. 'recuperate_category_arr' => $Recuperatecategory_arr,
  292. 'recruit' => $recruit,
  293. ];
  294. //获取分站模板信息
  295. if ($subsite_id > 0) {
  296. $tpl_name = $this->subsiteService->getSubsiteTpl($subsite_id);
  297. //判断模板是否存在
  298. if (View::exists('home.' . $tpl_name . '.index')) {
  299. return view('company.' . $tpl_name . '.index', $return_data);
  300. } else {
  301. return view('app.index', $return_data);
  302. }
  303. } else {
  304. return view('app.index', $return_data);
  305. }
  306. }
  307. public function getNewestCompanies($params)
  308. {
  309. $lists = Cache::get('newest_jobs_company_list_' . get_subsite_id());
  310. if ($lists === null) {
  311. $lists = $this->searchService->searchSeatmealCompanies($params);
  312. Cache::put('newest_jobs_company_list_' . get_subsite_id(), $lists, 5);
  313. }
  314. return $lists;
  315. }
  316. public function getLinks($alias, $type = '', $limit = 18)
  317. {
  318. $where = [
  319. 'alias' => $alias,
  320. 'type' => $type,
  321. 'limit' => $limit,
  322. ];
  323. $links = $this->LinkService->getLinks($where);
  324. return $links;
  325. }
  326. public function getUser()
  327. {
  328. $user = [];
  329. if (auth('web-member')->check()) {
  330. $user = auth('web-member')->user();
  331. } elseif (auth('web-company')->check()) {
  332. $user = auth('web-company')->user();
  333. }
  334. return $user;
  335. }
  336. //正在开发中
  337. public function developing()
  338. {
  339. return view('app.developing');
  340. }
  341. /*优秀人才申请*/
  342. public function declare(Request $request)
  343. {
  344. if ($this->getUser()) {
  345. if (!$user = auth('web-company')->user()) {
  346. return $this->showMessage('个人未开放申请优秀人才申报系统功能!', route('home'), true, '', '1');
  347. }
  348. $url = 'http://rc.jucai.gov.cn/api/jucaiInterface/login';
  349. $data = [
  350. 'username' => $user->username,
  351. 'userType' => 1,
  352. 'timestr' => time(),
  353. /* 'name'=>$user->companyname,
  354. 'idCard'=>$user->organization_code,
  355. 'type'=>1*/
  356. ];
  357. ksort($data);
  358. $sign_arr = array_merge($data, ['key' => 'rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi']);
  359. $sign = strtoupper(md5(http_build_query($sign_arr)));
  360. $data['sign'] = $sign;
  361. $data['name'] = htmlspecialchars($user->companyname);
  362. $data['idCard'] = $user->organization_code;
  363. $data['type'] = 1;
  364. return redirect()->away('http://rc.jucai.gov.cn/api/jucaiInterface/login?timestr=' . time() . '&userType=1&username=' . $user->username . '&sign=' . $sign . '&name=' . $user->companyname . '&idCard=' . $user->organization_code . '&type=1&id=' . $user->id);
  365. } else {
  366. return redirect()->away('http://rc.jucai.gov.cn/login');
  367. }
  368. }
  369. /**
  370. * 短链接生成
  371. */
  372. public function short_url($url)
  373. {
  374. $short_url = ShortUrl::where('key', $url)->first();
  375. if (empty($short_url)) {
  376. return redirect(route('home'));
  377. } else {
  378. return redirect($short_url['url']);
  379. }
  380. }
  381. /**
  382. * 分站
  383. */
  384. private function _subsite()
  385. {
  386. //特殊网站
  387. $site_module = explode('.', request()->server('HTTP_HOST'))[0];
  388. if (method_exists($this, $site_module)) {
  389. return $this->$site_module();
  390. }
  391. $return_data = [];
  392. $subsite_id = get_subsite_id();
  393. //公司
  394. $return_data['seatmeal_companies'] = $this->_dealCompany($subsite_id);
  395. //个人登录
  396. if (auth('web-member')->check()) {
  397. $return_data['memberInfo'] = $this->memberInfoRepository->getMemberInfo(auth('web-member')->id());
  398. }
  399. //首页轮播图
  400. $return_data['ad_list'] = [];
  401. $ad_ids = SubsiteAd::where('subsite_id', $subsite_id)->get(['ad_id'])->pluck('ad_id')->toArray();
  402. if (!empty($ad_ids)) {
  403. $return_data['ad_list'] = Ad::whereIn('id', $ad_ids)->get();
  404. }
  405. //文章列表
  406. $return_data['article_list'] = (new Article())->whereHas('subsites', function ($query) {
  407. $query->where('subsite_id', get_subsite_id());
  408. })->orderByRaw('list_order desc,created_at desc')->limit(10)->get();
  409. //办理人数
  410. $jkq_order = collect(DB::table('configs')->where('type_id', '=', 73)->get(['alias', 'value']))->keyBy('alias');
  411. $return_data['jkq_order'] = $jkq_order;
  412. return view('subsite.index', $return_data);
  413. }
  414. /**
  415. * 首页公司信息
  416. */
  417. private function _dealCompany($subsite_id)
  418. {
  419. $seatmeal_companies = $this->companyService->getCompaniesByConditions(['subsite_id' => $subsite_id], 20);
  420. $res = [];
  421. foreach ($seatmeal_companies as $v) {
  422. $jobs = [];
  423. if (!empty($v['jobs'])) {
  424. foreach ($v['jobs'] as $k => $job) {
  425. if ($k == 4) {
  426. break;
  427. }
  428. $jobs[] = [
  429. 'id' => $job['id'],
  430. 'jobs_name' => $job['jobs_name'],
  431. 'amount' => $job['amount'],
  432. ];
  433. }
  434. }
  435. $res[] = [
  436. 'id' => $v['id'],
  437. 'logo' => $v['logo'],
  438. 'companyname' => $v['companyname'],
  439. 'jobs' => $jobs,
  440. ];
  441. }
  442. return json_encode($res, JSON_UNESCAPED_UNICODE + JSON_UNESCAPED_SLASHES);
  443. }
  444. /**
  445. * 经开区分站
  446. */
  447. private function jkq()
  448. {
  449. $return_data = [];
  450. $subsite_id = get_subsite_id();
  451. //公司
  452. $return_data['seatmeal_companies'] = $this->_dealCompany($subsite_id);
  453. //个人登录
  454. if (auth('web-member')->check()) {
  455. $return_data['memberInfo'] = $this->memberInfoRepository->getMemberInfo(auth('web-member')->id());
  456. }
  457. //首页轮播图
  458. $return_data['ad_list'] = [];
  459. $ad_ids = SubsiteAd::where('subsite_id', $subsite_id)->get(['ad_id'])->pluck('ad_id')->toArray();
  460. if (!empty($ad_ids)) {
  461. $return_data['ad_list'] = Ad::whereIn('id', $ad_ids)->get();
  462. }
  463. //文章列表
  464. $return_data['article_list'] = (new Article())->whereHas('subsites', function ($query) {
  465. $query->where('subsite_id', get_subsite_id());
  466. })->orderByRaw('list_order desc,created_at desc')->limit(10)->get();
  467. //办理人数
  468. $jkq_order = collect(DB::table('configs')->where('type_id', '=', 73)->get(['alias', 'value']))->keyBy('alias');
  469. $return_data['jkq_order'] = $jkq_order;
  470. return view('subsite.jkq.index', $return_data);
  471. }
  472. }