HomeController.php1 15 KB

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