HomeController.php 16 KB

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