JobfairController.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wuzhenke
  5. * Date: 2019/1/17
  6. * Time: 16:19
  7. */
  8. namespace App\Http\Controllers\Web\Jobfair;
  9. use App\Exceptions\ResponseException;
  10. use App\Http\Controllers\Web\WebBaseController;
  11. use App\Models\Subsite;
  12. use App\Repositories\Jobfair\JobfairCompanyRepository;
  13. use App\Repositories\Jobfair\JobfairFloorPlanRepository;
  14. use App\Repositories\Jobfair\JobfairFloorplanStandRepository;
  15. use App\Repositories\Jobfair\JobfairPersonalJobsApplyRepository;
  16. use App\Repositories\Jobfair\JobfairPutJobRepository;
  17. use App\Repositories\Jobfair\JobfairRepository;
  18. use App\Repositories\Jobfair\JobfairJobRepository;
  19. use App\Repositories\ResumeRepository;
  20. use App\Services\Jobfair\JobfairCompanyService;
  21. use App\Services\Jobfair\JobfairJobsService;
  22. use App\Services\Jobfair\JobfairPersonalJopApplyService;
  23. use App\Services\Jobfair\JobfairPutJobService;
  24. use App\Services\Jobfair\JobfairService;
  25. use App\Services\Person\ResumeService;
  26. use App\Services\Company\CompanyService;
  27. use App\Services\Company\CompanyDownResumeService;
  28. use Illuminate\Http\Request;
  29. use Illuminate\Support\Facades\DB;
  30. use App\Services\Content\ArticleService;
  31. use App\Repositories\ArticleRepository;
  32. class JobfairController extends WebBaseController
  33. {
  34. protected $jobfairJobsService;
  35. protected $jobfairCompanyRepository;
  36. protected $jobfairCompanyService;
  37. protected $jobfairService;
  38. protected $jobfairRepository;
  39. protected $jobfairPersonalJobsApplyRepository;
  40. protected $jobfairPersonalJopApplyService;
  41. protected $resumeService;
  42. protected $jobfairFloorplanStandRepository;
  43. protected $jobfairFloorPlanRepository;
  44. protected $jobfairPutJobRepository;
  45. protected $resumeRepository;
  46. protected $jobfairPutJobService;
  47. protected $companyService;
  48. protected $jobfairJobRepository;
  49. protected $companyDownResumeService;
  50. protected $articleService;
  51. protected $articleRepository;
  52. /*
  53. * 企业中心
  54. * */
  55. /**
  56. * JobfairController constructor.
  57. * @param $jobfairJobsService
  58. * @param $jobfairCompanyRepository
  59. * @param $jobfairCompanyService
  60. * @param $jobfairService
  61. * @param $jobfairRepository
  62. * @param $jobfairPersonalJobsApplyRepository
  63. * @param $jobfairPersonalJopApplyService
  64. * @param $resumeService
  65. * @param $jobfairFloorplanStandRepository
  66. * @param $jobfairFloorPlanRepository
  67. * @param $jobfairPutJobRepository
  68. * @param $resumeRepository
  69. * @param $jobfairPutJobService
  70. * @param $companyService
  71. * @param $jobfairJobRepository
  72. * @param $companyDownResumeService
  73. * @param $articleService
  74. * @param $articleRepository
  75. */
  76. public function __construct(
  77. ResumeService $resumeService,
  78. JobfairPutJobService $jobfairPutJobService,
  79. ResumeRepository $resumeRepository,
  80. JobfairPutJobRepository $jobfairPutJobRepository,
  81. JobfairJobsService $jobfairJobsService,
  82. JobfairFloorPlanRepository $jobfairFloorPlanRepository,
  83. JobfairFloorplanStandRepository $jobfairFloorplanStandRepository,
  84. JobfairPersonalJopApplyService $jobfairPersonalJopApplyService,
  85. JobfairPersonalJobsApplyRepository $jobfairPersonalJobsApplyRepository,
  86. JobfairRepository $jobfairRepository,
  87. JobfairService $jobfairService,
  88. JobfairCompanyService $jobfairCompanyService,
  89. JobfairCompanyRepository $jobfairCompanyRepository,
  90. CompanyService $companyService,
  91. JobfairJobRepository $jobfairJobRepository,
  92. CompanyDownResumeService $companyDownResumeService,
  93. ArticleRepository $articleRepository,
  94. ArticleService $articleService
  95. )
  96. {
  97. $this->jobfairJobsService = $jobfairJobsService;
  98. $this->jobfairCompanyRepository = $jobfairCompanyRepository;
  99. $this->jobfairCompanyService = $jobfairCompanyService;
  100. $this->jobfairService = $jobfairService;
  101. $this->jobfairRepository = $jobfairRepository;
  102. $this->jobfairPersonalJobsApplyRepository = $jobfairPersonalJobsApplyRepository;
  103. $this->jobfairPersonalJopApplyService = $jobfairPersonalJopApplyService;
  104. $this->resumeService = $resumeService;
  105. $this->jobfairFloorplanStandRepository = $jobfairFloorplanStandRepository;
  106. $this->jobfairFloorPlanRepository = $jobfairFloorPlanRepository;
  107. $this->jobfairPutJobRepository = $jobfairPutJobRepository;
  108. $this->resumeRepository = $resumeRepository;
  109. $this->jobfairPutJobService = $jobfairPutJobService;
  110. $this->companyService = $companyService;
  111. $this->jobfairJobRepository = $jobfairJobRepository;
  112. $this->companyDownResumeService = $companyDownResumeService;
  113. $this->articleService = $articleService;
  114. $this->articleRepository = $articleRepository;
  115. }
  116. /**近期招聘会
  117. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  118. */
  119. public function jobfairIndex()
  120. {
  121. $user = auth('web-company')->user();
  122. $res = $this->jobfairService->jobfairIndex($user);
  123. return view('app.jobfair.company.index', $res);
  124. }
  125. /**定展记录
  126. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  127. */
  128. public function jobfairEnact()
  129. {
  130. $user = auth('web-company')->user();
  131. $res = $this->jobfairCompanyService->jobfairEnact($user);
  132. return view('app.jobfair.company.jobfair_enact', $res);
  133. }
  134. /**招聘会职位库管理
  135. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  136. */
  137. public function jobfairJobsList()
  138. {
  139. $res = $this->jobfairJobsService->jobfairJobsList();
  140. return view('app.jobfair.company.jobfair_joblist', $res);
  141. }
  142. /**招聘会职位添加
  143. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  144. */
  145. public function jobfairJobsAdd()
  146. {
  147. $res = $this->jobfairJobsService->jobfairJobsAdd();
  148. $res['title'] = '发布招聘会职位';
  149. return view('app.jobfair.company.jobfair_job_add', $res);
  150. }
  151. /**招聘会职位修改
  152. * @param int $id
  153. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  154. */
  155. public function jobfairJobsEdit($id)
  156. {
  157. $user = auth('web-company')->user();
  158. $res = $this->jobfairJobsService->jobfairJobsEdit($id, $user);
  159. if (!$res) {
  160. return $this->showMessage('参数错误', route('jobfair.quarterslist'), true, '上一页');
  161. }
  162. $res['title'] = '编辑招聘会职位';
  163. return view('app.jobfair.company.jobfair_job_add', $res);
  164. }
  165. /**招聘会职位删除
  166. * @param Request $request
  167. * @return \Illuminate\Http\JsonResponse
  168. * @throws \Throwable
  169. */
  170. public function jobfairJobsDel(Request $request)
  171. {
  172. if ($request->method() == 'POST') {
  173. return $this->jobfairJobsService->jobfairJobsDel($request);
  174. }
  175. $tip = "被删除后将无法恢复,您确定要删除选中的职位吗?";
  176. return response()->json(['status'=>1,'data'=>['html'=>view('app.company.ajax.ajax_warning', ['tip'=>$tip])->render()]]);
  177. }
  178. /**
  179. * @param Request $request
  180. * @return \Illuminate\Http\JsonResponse
  181. * @throws \Throwable
  182. */
  183. public function jobfairJobsDis(Request $request)
  184. {
  185. if ($request->method() == 'POST') {
  186. return $this->jobfairJobsService->jobfairJobsDis($request);
  187. }
  188. if($request->display ==1 ){
  189. $tip = "您需要关闭职位吗?";
  190. }else{
  191. $tip = "您需要开启职位吗?";
  192. }
  193. return response()->json(['status'=>1,'data'=>['html'=>view('app.company.ajax.ajax_warning', ['tip'=>$tip])->render()]]);
  194. }
  195. /**招聘会职位修改和添加
  196. * @param Request $request
  197. * @return \Illuminate\Http\JsonResponse
  198. */
  199. public function jobfairJobsSave(Request $request)
  200. {
  201. $user = auth('web-company')->user();
  202. $data = $request->except(['_method', '_token']);
  203. return $this->jobfairJobsService->jobsSave($data, $user);
  204. }
  205. /**职位添加到招聘会中
  206. * @param Request $request
  207. * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View
  208. * @throws \Throwable
  209. */
  210. public function jobfairJobsToJobfair(Request $request)
  211. {
  212. $user = auth('web-company')->user();
  213. if ($request->method() == 'POST') {
  214. $jids = $request->y_id;
  215. if (!$jids || !$request->exid_list) {
  216. return $this->showMessage('请选择职位或加入的招聘会', route('jobfair.quarterslist'), true, '上一页');
  217. }
  218. $this->jobfairJobsService->isOwn($jids,$user);
  219. $exidArr = explode(',', $request->exid_list);
  220. $this->jobfairCompanyService->isOwnArr($exidArr,$user);
  221. $res = $this->jobfairJobsService->jobfairJobsToJobfair($request);
  222. if ($res['state']) {
  223. return $this->showMessage('添加成功!'.$res['error'], route('jobfair.quarterslist'), false, '上一页');
  224. }
  225. return $this->showMessage($res['msg'], route('jobfair.quarterslist'), true, '上一页');
  226. }
  227. //公司参加的招聘会
  228. $jobfairInfo = $this->jobfairCompanyRepository->getJobfair($user->id);
  229. if ($jobfairInfo->isEmpty()) {
  230. return response()->json(['status'=>0, 'msg'=>"您还没有参加招聘会或申请未通过审核,请点击右侧链接参加招聘会<a href='" .route('jobfair.lists'). "' style='color: #FF0000'>【点击参加】</a>"]);
  231. }
  232. return response()->json(['status'=>1,'data'=>['html'=>view('app.jobfair.company.ajax.ajax_jobfair_mod', ['jobfairInfo'=>$jobfairInfo])->render()]]);
  233. }
  234. /**参展职位
  235. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  236. */
  237. public function jobfairjob(Request $request)
  238. {
  239. $user = auth('web-company')->user();
  240. $jobfairid = $request->jobfairid?$request->jobfairid:'';
  241. $audit = $request->audit?$request->audit:'';
  242. $map = [];
  243. $map1['company_id'] = $user->id;
  244. if ($audit) {
  245. $map1['audit'] = $audit;
  246. }
  247. if ($jobfairid) {
  248. $map['jobfair_id'] = $jobfairid;
  249. }
  250. $param_array = array('jobfairid','audit');
  251. $params= array();
  252. if ($request->all()) {
  253. foreach ($request->all() as $k => $v) {
  254. if (in_array($k, $param_array)) {
  255. $params[$k] = $v;
  256. }
  257. }
  258. }
  259. $res = $this->jobfairPutJobService->jobfairPutJobsList($map,$map1);
  260. $jobfairArr = $this->jobfairCompanyRepository->findWhere(['company_id'=>$user->id], ['jobfair_id']);
  261. $jobfairList = [];
  262. if ($jobfairArr) {
  263. $list = $jobfairArr->toArray();
  264. $jobfairList = $this->jobfairRepository->findWhereIn('id', $list, ['id','title'])->toArray();
  265. }
  266. $res['jobfairid'] = $jobfairid;
  267. $res['audit'] = $audit;
  268. $res['params'] = $params;
  269. $res['jobfairList'] = array_column($jobfairList, 'title', 'id');
  270. $res['audtiArr'] = [1=>'审核通过',2=>'待审核',3=>'审核未通过'];
  271. return view('app.jobfair.company.jobfair_job', $res);
  272. }
  273. /*
  274. * 旧方法,废弃
  275. */
  276. // public function jobfairjobModify($id)
  277. // {
  278. // $user = auth('web-company')->user();
  279. // $res = $this->jobfairPutJobService->jobfairjobModify($id, $user);
  280. // return view('app.jobfair.company.job_jobfair_edit', $res);
  281. // }
  282. public function jobfairPutJobsSave(Request $request)
  283. {
  284. $data = $request->except(['_token', 'method']);
  285. $user = auth('web-company')->user();
  286. return $this->jobfairPutJobService->jobfairPutJobsSave($data, $user);
  287. }
  288. public function jobfairjobdel(Request $request)
  289. {
  290. $id = $request->y_id?$request->y_id:0;
  291. $ids = is_array($id)?$id:explode(',', $id);
  292. if ($request->method() == 'POST') {
  293. if (!$ids) {
  294. return response()->json(['status'=>0,'html'=>'参数错误']);
  295. }
  296. return $this->jobfairPutJobService->jobfairPutJobsDel($ids);
  297. }
  298. $tip = "被删除后将无法恢复,您确定要删除选中的职位吗?";
  299. return response()->json(['status'=>1,'data'=>['html'=>view('app.company.ajax.ajax_warning', ['tip'=>$tip])->render()]]);
  300. }
  301. /**收到的招聘会简历
  302. * @param Request $request
  303. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  304. */
  305. public function downResume(Request $request)
  306. {
  307. $user = auth('web-company')->user();
  308. $jobs_id = $request->input('jobs_id','');
  309. $jobfair_id = $request->input('jobfair_id','');
  310. $where['type'] = 2;
  311. $where1 = [];
  312. $result['jobfairList'] = $this->jobfairCompanyService->jobfairList($user);
  313. $result['jobs_name'] = '全部职位';
  314. if($jobs_id)
  315. {
  316. $where1['job_id'] = $jobs_id;
  317. $result['jobs_name'] = $this->jobfairJobRepository->find($jobs_id,['jobs_name'])->jobs_name;
  318. }
  319. $result['jobfair_name'] = '全部招聘会';
  320. if($jobfair_id)
  321. {
  322. $where['jobfair_id'] = $jobfair_id;
  323. $result['jobfair_name'] = $this->jobfairRepository->find($jobfair_id,['title'])->title;
  324. }
  325. $result['apply'] = $this->jobfairPersonalJobsApplyRepository->getResumeJobs($user->id,$where,$where1);
  326. $whereJob = [
  327. 'company_id' => $user->id,
  328. 'audit' => 1,
  329. 'type' => 1,
  330. ];
  331. $result['jobs'] = $this->jobfairJobRepository->getJobs($whereJob);
  332. $params= array();
  333. $param_array = array('jobs_id','jobfair_id');
  334. if ($request->all()) {
  335. foreach ($request->all() as $k => $v) {
  336. if (in_array($k, $param_array)) {
  337. $params[$k] = $v;
  338. }
  339. }
  340. }
  341. $result['params'] = $params;
  342. return view('app.jobfair.company.down_resume', $result);
  343. }
  344. public function downResumeDel(Request $request)
  345. {
  346. if ($request->method() == 'POST') {
  347. $user = $this->getUser();
  348. return $this->jobfairPersonalJopApplyService->downResumeDel($request,$user);
  349. }
  350. $tip = "被删除后将无法恢复,您确定要删除选中的简历吗?";
  351. return response()->json(['status'=>1,'data'=>['html'=>view('app.company.ajax.ajax_warning', ['tip'=>$tip])->render()]]);
  352. }
  353. /*
  354. * 前台页面
  355. * */
  356. /**招聘会列表
  357. * @param Request $request
  358. * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View
  359. * @throws \Throwable
  360. */
  361. public function index(Request $request)
  362. {
  363. $jobfairList = $this->jobfairService->index($request);
  364. if ($request->ajax()) {
  365. if ($jobfairList['allJobfair']->isNotEmpty()) {
  366. return response()->json(['status'=>1,'data'=>view('app.jobfair.ajax.ajax_jobfair_list', $jobfairList)->render()]);
  367. }
  368. return response()->json(['status'=>0]);
  369. }
  370. return view('app.jobfair.index', $jobfairList);
  371. }
  372. /*招聘会资讯
  373. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  374. */
  375. public function news()
  376. {
  377. $news = $this->articleRepository->getArticle(['keywords'=>'jobfair_news'],5);
  378. $other = $this->articleRepository->getArticle(['keywords'=>'jobfair_review'],5);
  379. return view('app.jobfair.jobfair_newslist',['type'=>'new','news'=>$news,'other'=>$other]);
  380. }
  381. /*招聘会回顾
  382. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  383. */
  384. public function review()
  385. {
  386. $news = $this->articleRepository->getArticle(['keywords'=>'jobfair_review'],5);
  387. $other = $this->articleRepository->getArticle(['keywords'=>'jobfair_news'],5);
  388. return view('app.jobfair.jobfair_newslist',['type'=>'review','news'=>$news,'other'=>$other]);
  389. }
  390. /*招聘会资讯、回顾详情
  391. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  392. */
  393. public function newShow($id)
  394. {
  395. if (!$id) {
  396. return $this->showMessage('参数错误!', route('jobfair'), true, '上一页');
  397. }
  398. $this->articleRepository->incrementData(array('id'=>$id), 1, 'click');
  399. $new = $this->articleService->getArticleInfo($id,1);
  400. $news = $this->articleRepository->getArticle(['keywords'=>'jobfair_news'],5);
  401. $reviews = $this->articleRepository->getArticle(['keywords'=>'jobfair_review'],5);
  402. return view('app.jobfair.jobfair_newshow',['new'=>$new,'news'=>$news,'reviews'=>$reviews]);
  403. }
  404. /**招聘会详情(废弃)
  405. * @param int $id
  406. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  407. */
  408. // public function jobfairShow($id = 0)
  409. // {
  410. // if (!$id) {
  411. // return $this->showMessage('参数错误!', route('jobfair'), true, '上一页');
  412. // }
  413. // $res = $this->jobfairService->jobfairShow($id);
  414. //
  415. // if (!$res['status']) {
  416. // return $this->showMessage($res['msg'], route('jobfair'), true, '上一页');
  417. // } else {
  418. // $res['jobfair']->sitename = Subsite::where('id',$res['jobfair']->subsite_id)->value('sitename');
  419. // if (array_has($res, 'jobfair')) {
  420. // $this->putSeoData('jobfair', $res['jobfair']);
  421. // }
  422. // return view('app.jobfair.jobfair_show', $res);
  423. // }
  424. // }
  425. /**招聘会企业
  426. * @param Request $request
  427. * @param int $id
  428. * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View
  429. * @throws \Throwable
  430. */
  431. public function jobfairShowCom(Request $request, $id = 0)
  432. {
  433. if (!$id) {
  434. return $this->showMessage('参数错误!', route('jobfair'), true, '上一页');
  435. }
  436. $res = $this->jobfairService->jobfairShowCom($request, $id);
  437. if ($request->ajax()) {
  438. if ($res['jobfairCompany']->isNotEmpty()) {
  439. return response()->json(['status'=>1,'data'=>view('app.jobfair.ajax.ajax_jobfair_com', $res)->render()]);
  440. }
  441. return response()->json(['status'=>0]);
  442. }
  443. if (!$res['status']) {
  444. return $this->showMessage($res['msg'], route('jobfair'), true, '上一页');
  445. } else {
  446. $res['jobfair']->sitename = Subsite::where('id',$res['jobfair']->subsite_id)->value('sitename');
  447. $res['reserve'] = $request->reserve ? $request->reserve : '';
  448. $this->putSeoData('jobfair', $res['jobfair']);
  449. return view('app.jobfair.jobfair_com', $res);
  450. }
  451. }
  452. /**招聘会职位详情
  453. * @param $jobfair_id
  454. * @param $job_id
  455. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  456. */
  457. public function jobfairShowJob($id)
  458. {
  459. $job = $this->jobfairService->jobfairShowJob($id);
  460. if (!$job['status']) {
  461. return $this->showMessage($job['msg'], route('jobfair'), true, '上一页');
  462. } else {
  463. $this->putSeoData('jobfair_job', $job['jobInfo']);
  464. return view('app.jobfair.jobfair_job', $job);
  465. }
  466. }
  467. public function jobfairAppointmentJobs(Request $request)
  468. {
  469. $user = $this->getLoginUser();
  470. $jid = $request->jobsfair_job_id;
  471. $jobfair_id = $request->jobfairid;
  472. $position_id = $request->position_id;
  473. $company_id = $request->company_id;
  474. $resume_id = $request->resume_id?$request->resume_id:0;
  475. $jobfair = $this->jobfairRepository->find($jobfair_id);
  476. // if ($jobfair->isEmpty || time() > $jobfair->holddate_end) {
  477. // return response()->json(['status'=>0, 'html'=>"招聘会已停止"]);
  478. // }
  479. // if ($jobfair->isEmpty || time() > $jobfair->holddate_start) {
  480. // return response()->json(['status'=>0, 'html'=>"招聘会已开始,请去现场投递"]);
  481. // }
  482. if ($resume_id) {
  483. $this->resumeService->isOwn($resume_id,$user);
  484. $this->jobfairPutJobService->isOwn($jid,$company_id);
  485. $this->jobfairCompanyService->isPositionOwn($position_id,$jobfair_id,$company_id,$jid);
  486. $data['resume_id'] = $resume_id;
  487. $data['personal_uid'] = $user->id;
  488. $data['jobs_id'] = $jid;
  489. $data['company_id'] = $company_id;
  490. $data['jobfair_id'] = $jobfair_id;
  491. $data['position_id'] = $position_id;
  492. if (!$jid || !$company_id || !$jobfair_id || !$position_id) {
  493. return response()->json(['status'=>0,'type'=>3,'html'=>'参数错误!']);
  494. }
  495. //简历完整度
  496. $res_complete = $this->resumeRepository->find($resume_id, ['complete_percent']);
  497. if ($res_complete->complete_percent < config('aix.personal_set.per_set.per_set.apply_job_min_percent')) {
  498. return response()->json(['status'=>0,'html'=>'请完善简历后再预约职位','resume_id'=>$resume_id]);
  499. }
  500. if ($this->jobfairPersonalJobsApplyRepository->findWhere(['personal_uid'=>$user->id, 'jobs_id'=>$jid, 'company_id'=>$company_id, 'jobfair_id'=>$jobfair_id, 'position_id'=>$position_id])->isNotEmpty()) {
  501. return response()->json(['status'=>0, 'html'=>"您已预约该职位,请勿重复预约!"]);
  502. }
  503. DB::beginTransaction();//检查数据库事务
  504. try {
  505. $this->jobfairPersonalJopApplyService->applyJob($data);
  506. $this->companyDownResumeService->addDownResumes($company_id,$resume_id);
  507. DB::commit();
  508. return response()->json(['status'=>1, 'html'=>"职位预约成功!"]);
  509. } catch (\Exception $e) {
  510. DB::rollback();
  511. return response()->json(['status'=>0,'type'=>0 , 'html'=>"职位预约失败!"]);
  512. }
  513. } else {
  514. if (!$jid || !$company_id || !$jobfair_id || !$position_id) {
  515. return response()->json(['status'=>0,'type'=>3,'html'=>'参数错误!']);
  516. }
  517. $result = $this->jobfairPersonalJopApplyService->ifJobApply($user);
  518. if ($result['status'] == 2) { //返回结果,让用户选择简历投递
  519. $page_data = array('status'=>array_get($result, 'status'),'resumes'=>array_get($result, 'resumes'),'def_resume'=>array_get($result, 'def_resume'),'jobs_id'=>$jid);
  520. $page_data['company_id'] = $company_id;
  521. $page_data['jobfair_id'] = $jobfair_id;
  522. $page_data['position_id'] = $position_id;
  523. $page_data['jobs_id'] = $jid;
  524. $html = view('app.jobfair.ajax.ajax_apply', $page_data)->render();
  525. return response()->json(['status'=>2,'html'=>$html]);
  526. } elseif ($result['status'] == 3) { //直接投递
  527. $this->jobfairPutJobService->isOwn($jid,$company_id);
  528. $this->jobfairCompanyService->isPositionOwn($position_id,$jobfair_id,$company_id,$jid);
  529. $resume = $result['resumes'][0];
  530. $data['resume_id'] = $resume->id;
  531. $data['personal_uid'] = $user->id;
  532. $data['jobs_id'] = $jid;
  533. $data['company_id'] = $company_id;
  534. $data['jobfair_id'] = $jobfair_id;
  535. $data['position_id'] = $position_id;
  536. $res_complete = $this->resumeRepository->find($resume->id, ['complete_percent']);
  537. if ($res_complete->complete_percent < config('aix.personal_set.per_set.per_set.apply_job_min_percent')) {
  538. return response()->json(['status'=>0,'html'=>'请完善简历后再预约职位','resume_id'=>$resume->id]);
  539. }
  540. if ($this->jobfairPersonalJobsApplyRepository->findWhere(['resume_id'=>$resume->id, 'jobs_id'=>$jid, 'company_id'=>$company_id, 'jobfair_id'=>$jobfair_id, 'position_id'=>$position_id,'type'=>1])->isNotEmpty()) {
  541. return response()->json(['status'=>0, 'html'=>"您已预约该职位,请勿重复预约!"]);
  542. }
  543. DB::beginTransaction();//检查数据库事务
  544. try {
  545. $this->jobfairPersonalJopApplyService->applyJob($data);
  546. $this->companyDownResumeService->addDownResumes($company_id,$resume->id);
  547. DB::commit();
  548. return response()->json(['status'=>1, 'html'=>"职位预约成功!"]);
  549. } catch (\Exception $e) {
  550. DB::rollback();
  551. return response()->json(['status'=>0,'type'=>0 , 'html'=>"职位预约失败!"]);
  552. }
  553. }
  554. }
  555. }
  556. /**异步查询职位
  557. * @param Request $request
  558. * @return \Illuminate\Http\JsonResponse
  559. * @throws \Throwable
  560. */
  561. public function jobfairAjaxJobs(Request $request)
  562. {
  563. $keyinput = $request->keyinput?$request->keyinput:'';
  564. $jobfair_id = $request->jobfair_id?$request->jobfair_id:0;
  565. if (!$jobfair_id) {
  566. return response()->json(['status'=>0,'msg'=>"招聘会ID不正确"]);
  567. }
  568. if($keyinput) {
  569. $where = [
  570. 'jobfair_id'=>$jobfair_id,
  571. 'audit'=>1
  572. ];
  573. $res = $this->jobfairCompanyRepository->findJob($where);
  574. foreach ($res as $key => $val) {
  575. $jobfairPutJob = $this->jobfairPutJobRepository->searchJob($jobfair_id, $keyinput, $val->company_id, $val->id);
  576. if ($jobfairPutJob->isNotEmpty()) {
  577. $val->jobfairPutJob = $jobfairPutJob;
  578. } else {
  579. unset($res[$key]);
  580. }
  581. }
  582. } else {
  583. $where = ['jobfair_companys.jobfair_id'=>$jobfair_id,'jobfair_companys.audit'=>1];
  584. $offset = isset($request->page)?$request->page:0;
  585. $limit = 20;
  586. $res = $this->jobfairCompanyRepository->findCompany($where, $offset, $limit);
  587. foreach ($res as $key => $val) {
  588. $val->jobfairPutJob = $this->jobfairPutJobRepository->getJobfairJob($val->id, $jobfair_id);
  589. }
  590. }
  591. if ($res->isEmpty()) {
  592. return response()->json(['status'=>0,'msg'=>"未查找到与【{$keyinput}】相似的职位或企业"]);
  593. }
  594. return response()->json(['status'=>1,'data'=>view('app.jobfair.ajax.ajax_jobfair_com_jobs', ['jobfairCompany'=>$res])->render()]);
  595. }
  596. /**在线预定(废弃)
  597. * @param $id
  598. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  599. */
  600. // public function jobfairAppointment($id)
  601. // {
  602. // if (!$id) {
  603. // return $this->showMessage('参数错误!', route('jobfair'), true, '上一页');
  604. // }
  605. // $res = $this->jobfairService->jobfairAppointment($id);
  606. // if (!$res['status']) {
  607. // return $this->showMessage($res['msg'], route('jobfair'), true, '上一页');
  608. // } else {
  609. // $res['jobfair']->sitename = Subsite::where('id',$res['jobfair']->subsite_id)->value('sitename');
  610. // $this->putSeoData('jobfair', $res['jobfair']);
  611. // return view('app.jobfair.jobfair_appointment', $res);
  612. // }
  613. // }
  614. public function personJobfair()
  615. {
  616. $resume = $this->resumeService->myResumeAjax(auth('web-member')->user());
  617. $jobApply = $this->jobfairPersonalJopApplyService->personJobfair();
  618. return view('app.jobfair.person.job_apply', ['resume' => $resume, 'interview' => $jobApply['interview']]);
  619. }
  620. public function personDelect()
  621. {
  622. if (request()->method()=='GET') {
  623. $html = view('app.person.ajax.resume_delete', ['tpis'=>'删除后将无法恢复,您确定要删除选择的预约职位吗?'])->render();
  624. return $this->sendSuccessResponse($html);
  625. } else {
  626. $user = auth('web-member')->user();
  627. $this->jobfairPersonalJopApplyService->isOwn(request()->id,$user);
  628. $res = $this->jobfairPersonalJopApplyService->personDelect(request()->id, auth('web-member')->user());
  629. if ($res) {
  630. return $this->sendSuccessResponse('删除成功!');
  631. } else {
  632. return $this->sendErrorResponse('删除失败!');
  633. }
  634. }
  635. }
  636. public function jobfairAppointmentSave(Request $request)
  637. {
  638. $user = $this->getLoginUser();
  639. if (!$user) {
  640. $jobfair_id = $request->jobfair_id?$request->jobfair_id:0;
  641. return response()->json(['status'=>0, 'type'=>1, 'html'=>view('app.common.ajax.com_login', ['redirect_url'=>route('jobfair.show.com', ['id'=>$jobfair_id])])->render(),'msg'=>'您还没有登录,请先登录再预约招聘会']);
  642. }
  643. if ($user->utype == 2) {
  644. return response()->json(['status'=>0,'type'=>0,'msg'=>'个人会员不允许预定招聘会!']);
  645. }
  646. //企业是否通过认证
  647. if ($user->audit!=1) {
  648. return response()->json(['status'=>0,'type'=>0,'msg'=>'企业或营业执照未通过审核!']);
  649. }
  650. $jobfair_id = $request->jobfair_id?$request->jobfair_id:0;
  651. $position_id = $request->position_id?$request->position_id:0;
  652. $floorplan_id = $request->floorplan_id?$request->floorplan_id:0;
  653. if (!$jobfair_id || !$jobfairInfo = $this->jobfairRepository->findOne(['id'=>$jobfair_id])) {
  654. return response()->json(['status'=>0,'msg'=>'查无此招聘会!']);
  655. }
  656. if (!$floorplan_id || !$floorplanInfo = $this->jobfairFloorPlanRepository->getOne($floorplan_id)) {
  657. return response()->json(['status'=>0,'msg'=>'查无此招聘会展位图!']);
  658. }
  659. if (!$position_id || !$positionInfo =$this->jobfairFloorplanStandRepository->getOne(['id'=>$position_id])) {
  660. return response()->json(['status'=>0,'msg'=>'查无此招聘会展位号!']);
  661. }
  662. if ($positionInfo->type == 2) {
  663. return response()->json(['status'=>0,'msg'=>'预留展位不可预定!']);
  664. }
  665. if ($jobfairInfo->more_stand == 0 && $this->jobfairCompanyRepository->findCom(['jobfair_id'=>$jobfair_id, 'company_id'=>$user->id,['audit','<>', 3]])) {
  666. return response()->json(['status'=>0,'msg'=>'本场招聘会不允许预定多个展位!']);
  667. }
  668. if($this->jobfairCompanyRepository->findCom(['jobfair_id'=>$jobfair_id, 'position_id'=>$position_id,['audit','<>', 3]])){
  669. return response()->json(['status'=>0,'msg'=>'该展位已被抢占,请重新刷新页面再预定']);
  670. }
  671. if ($request->method()=='POST') {
  672. return $this->jobfairService->jobfairAppointmentSave($jobfairInfo, $positionInfo, $user);
  673. }
  674. if ($jobfairInfo->is_commonweal == 3) {
  675. $msg = "本次招聘会为公益招聘会.<br><span style='color: red;'>请勿迟到,早退,违约不到场.</span><br>招聘会开始30分钟之后到场签到视为迟到,1小时之后还未到场视为违约,招聘会结束之前30分钟退出系统视为早退.<br>迟到早退三次,违约不到场一次,之后一个月内不能再次预定招聘会.<br>";
  676. } else {
  677. $msg ="<br><span style='color: red;'>请勿迟到,早退,违约不到场.</span><br>招聘会开始30分钟之后到场签到视为迟到,1小时之后还未到场视为违约,招聘会结束之前30分钟退出系统视为早退.<br>迟到早退三次,违约不到场一次,之后一个月内不能再次预定招聘会.<br />预定本场招聘会将消耗企业套餐招聘会<span style='color:#FC4C4E;'>".$jobfairInfo->jobsfair_num."次</span>或者企业<span style='color:#FC4C4E;'>积分".$jobfairInfo->predetermined_point."</span><br />";
  678. }
  679. return response()->json(['status'=>1,'msg'=>$msg]);
  680. }
  681. public function companyShow(Request $request)
  682. {
  683. //获取企业信息
  684. $jobfair_id = $request->input('jobfair_id');
  685. $company_id = $request->input('company_id');
  686. $is_job = $request->input('is_job','');
  687. $company_info = $this->companyService->getCompanyInfo(['id'=>$company_id]);
  688. $this->putSeoData('company', $company_info);
  689. //在招职位
  690. $put_jobs_where = array(
  691. array('company_id','=',$company_id),
  692. array('jobfair_id','=',$jobfair_id),
  693. );
  694. $jobs_where = array(
  695. array('audit','=',1),
  696. array('display','=',1)
  697. );
  698. $jobs = $this->jobfairPutJobRepository->getWhere($jobs_where,$put_jobs_where);
  699. $jobfair = $this->jobfairRepository->findOne(['id'=>$jobfair_id]);
  700. //看过该公司的人还看过(获取相同行业的企业)
  701. $company_where = array(
  702. 'trade' => $company_info->trade,
  703. 'except_id' =>$company_info->id
  704. );
  705. $other_companys = $this->companyService->getOtherCompanies($company_where, 5);
  706. $user = $this->getUser();
  707. if ($user && $user->utype==2) {
  708. //获取当前时间段内申请过的职位
  709. $space_time = (integer)config('aix.personal_set.per_set.per_set.apply_job_space');
  710. if ($space_time>0) {
  711. $stime = date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-".$space_time." day"))));
  712. $apply_where = array(array('personal_uid','=',auth('web-member')->user()->id),array('created_at','>=',$stime));
  713. } else {
  714. $apply_where = array(array('personal_uid','=',auth('web-member')->user()->id));
  715. }
  716. $applys = $this->jobfairPersonalJopApplyService->getApplyJobs($apply_where);
  717. } else {
  718. $applys = array();
  719. }
  720. $return_data = array(
  721. 'info'=>$company_info,
  722. 'jobs'=>$jobs,
  723. 'jobfair' => $jobfair,
  724. 'applys' => $applys,
  725. 'other_companys'=>$other_companys,
  726. 'company_img' => $company_info->img,
  727. );
  728. if($is_job){
  729. return view('app.jobfair.company.company_jobs', $return_data);
  730. }else{
  731. return view('app.jobfair.company.company_show', $return_data);
  732. }
  733. }
  734. /**发布职位
  735. * return \Illuminate\Http\JsonResponse
  736. */
  737. public function ajaxComJobs(Request $request)
  738. {
  739. if ($request->method() == 'POST') {
  740. $user = $this->getLoginUser();
  741. $jobs_arr= $request->input('check_jobs_id', '');
  742. $jobfair_id = $request->input('jobfair_id', '');
  743. $exid = $request->input('exid', '');
  744. $position_id = $request->input('position_id', '');
  745. $jobs = $this->jobfairJobRepository->getPluck(['company_id'=>$user->id,'type'=>1,'audit'=>1],'id')->toArray();
  746. if(array_diff($jobs_arr,$jobs)) {
  747. throw new ResponseException('参数错误!');
  748. }
  749. $this->jobfairCompanyService->isOwn($exid,$user);
  750. //获取列表
  751. $where = ['exid'=>$exid];
  752. $ids = $this->jobfairPutJobRepository->getJobIds($where);
  753. DB::beginTransaction();
  754. try {
  755. if($ids){
  756. if($jobs_arr){
  757. $add_array = array_diff($jobs_arr,$ids);
  758. if($add_array)
  759. {
  760. $this->jobfairPutJobService->addData($add_array,$exid,$jobfair_id,$position_id);
  761. }
  762. $del_array = array_diff($ids,$jobs_arr);
  763. $this->jobfairPutJobRepository->destroyArr($del_array);
  764. }else{
  765. $where = [
  766. 'exid'=>$exid
  767. ];
  768. $this->jobfairPutJobRepository->delList($where,$ids);
  769. }
  770. }else{
  771. if($jobs_arr)
  772. {
  773. $this->jobfairPutJobService->addData($jobs_arr,$exid,$jobfair_id);
  774. }else{
  775. throw new \Exception('请选择职位添加');
  776. }
  777. }
  778. DB::commit();
  779. $return_data = array('status'=>1, 'msg'=>'编辑成功');
  780. return response()->json($return_data);
  781. } catch (\Exception $e) {
  782. DB::rollback();
  783. $return_data = array('status'=>0, 'msg'=>$e->getMessage());
  784. return response()->json($return_data);
  785. }
  786. } else {
  787. $user = auth('web-company')->user();
  788. $jobfair_id = $request->input('jobfair_id', '');
  789. $exid = $request->input('exid', '');
  790. $position_id = $request->input('position_id', '');
  791. $jobs = $this->jobfairJobRepository->getJobs(['company_id'=>$user->id,'type'=>1,'audit'=>1]);
  792. if($jobs->isEmpty())
  793. {
  794. $return_data = array( 'status'=>2, 'msg' => '没有招聘会职位,请先添加职位');
  795. return response()->json($return_data);
  796. }else{
  797. $join_jobs = $this->jobfairPutJobRepository->getExidJobfairJob(['exid'=>$exid]);
  798. $html = view('app.jobfair.ajax.add_jobs', ['jobs'=>$jobs,'jobfair_id'=>$jobfair_id,'exid'=>$exid,'position_id'=>$position_id,'join_jobs'=>$join_jobs])->render();
  799. $return_data = array( 'status'=>1, 'data' => $html);
  800. return response()->json($return_data);
  801. }
  802. }
  803. }
  804. /**页面加载展位信息
  805. * @param Request $request
  806. * @return \Illuminate\Http\JsonResponse
  807. */
  808. public function ajaxGetData(Request $request)
  809. {
  810. $data = $request->all();
  811. return $this->jobfairService->ajaxGetData($data);
  812. }
  813. public function getUser()
  814. {
  815. $user = array();
  816. if (auth('web-member')->check()) {
  817. $user = auth('web-member')->user();
  818. } elseif (auth('web-company')->check()) {
  819. $user = auth('web-company')->user();
  820. }
  821. return $user;
  822. }
  823. }