HomeController.php 15 KB

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