JobfairService.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wuzhenke
  5. * Date: 2019/1/24
  6. * Time: 17:26
  7. */
  8. namespace App\Services\Jobfair;
  9. use App\Models\Jobfair\JobfairBlacklist;
  10. use App\Repositories\CategoryRepository;
  11. use App\Repositories\Jobfair\JobfairBlackListRepository;
  12. use App\Repositories\Jobfair\JobfairCompanyRepository;
  13. use App\Repositories\Jobfair\JobfairFloorPlanRepository;
  14. use App\Repositories\Jobfair\JobfairFloorplanStandRepository;
  15. use App\Repositories\Jobfair\JobfairManagementRepository;
  16. use App\Repositories\Jobfair\JobfairPersonalJobsApplyRepository;
  17. use App\Repositories\Jobfair\JobfairPutJobRepository;
  18. use App\Repositories\Jobfair\JobfairRepository;
  19. use App\Repositories\MemberHandselRepository;
  20. use App\Repositories\MemberLogRepository;
  21. use App\Repositories\MemberPointRepository;
  22. use App\Repositories\MemberSetmealRepository;
  23. use App\Repositories\MembersSetmealLogRepository;
  24. use App\Repositories\ResumeRepository;
  25. use App\Services\Common\EmailService;
  26. use App\Services\SubsiteService;
  27. use Illuminate\Support\Facades\DB;
  28. use SimpleSoftwareIO\QrCode\Facades\QrCode;
  29. use App\Models\Subsite;
  30. use App\Repositories\Jobfairout\JobfairoutRepository;
  31. use App\Repositories\ArticleRepository;
  32. class JobfairService
  33. {
  34. protected $jobfairRepository;
  35. protected $jobfairFloorplanStandRepository;
  36. protected $jobfairCompanyRepository;
  37. protected $jobfairPutJobRepository;
  38. protected $jobfairFloorPlanRepository;
  39. protected $jobfairBlackListRepository;
  40. protected $memberSetmealRepository;
  41. protected $memberPointRepository;
  42. protected $memberHandselRepository;
  43. protected $membersSetmealLogRepository;
  44. protected $resumeRepository;
  45. protected $jobfairPersonalJobsApplyRepository;
  46. protected $jobfairManagementRepository;
  47. protected $subsiteService;
  48. protected $memberLogRepository;
  49. protected $jobfairoutRepository;
  50. protected $articleRepository;
  51. protected $emailService;
  52. /**
  53. * @var CategoryRepository
  54. */
  55. private $categoryRepository;
  56. /**
  57. * JobfairService constructor.
  58. * @param $jobfairRepository
  59. * @param $jobfairFloorplanStandRepository
  60. * @param $jobfairCompanyRepository
  61. * @param $jobfairPutJobRepository
  62. * @param $jobfairFloorPlanRepository
  63. * @param $jobfairBlackListRepository
  64. * @param $memberSetmealRepository
  65. * @param $memberPointRepository
  66. * @param $memberHandselRepository
  67. * @param $membersSetmealLogRepository
  68. * @param $resumeRepository
  69. * @param $jobfairPersonalJobsApplyRepository
  70. * @param $jobfairManagementRepository
  71. * @param $subsiteService
  72. * @param $articleRepository
  73. */
  74. public function __construct(
  75. JobfairRepository $jobfairRepository,
  76. SubsiteService $subsiteService,
  77. JobfairManagementRepository $jobfairManagementRepository,
  78. JobfairPersonalJobsApplyRepository $jobfairPersonalJobsApplyRepository,
  79. ResumeRepository $resumeRepository,
  80. MembersSetmealLogRepository $membersSetmealLogRepository,
  81. MemberHandselRepository $memberHandselRepository,
  82. MemberPointRepository $memberPointRepository,
  83. MemberSetmealRepository $memberSetmealRepository,
  84. JobfairBlackListRepository $jobfairBlackListRepository,
  85. JobfairPutJobRepository $jobfairPutJobRepository,
  86. JobfairCompanyRepository $jobfairCompanyRepository,
  87. JobfairFloorPlanRepository $jobfairFloorPlanRepository,
  88. JobfairFloorplanStandRepository $jobfairFloorplanStandRepository,
  89. MemberLogRepository $memberLogRepository,
  90. JobfairoutRepository $jobfairoutRepository,
  91. ArticleRepository $articleRepository,
  92. CategoryRepository $categoryRepository,
  93. EmailService $emailService
  94. ) {
  95. $this->jobfairRepository = $jobfairRepository;
  96. $this->jobfairFloorplanStandRepository = $jobfairFloorplanStandRepository;
  97. $this->jobfairCompanyRepository = $jobfairCompanyRepository;
  98. $this->jobfairPutJobRepository = $jobfairPutJobRepository;
  99. $this->jobfairFloorPlanRepository = $jobfairFloorPlanRepository;
  100. $this->jobfairBlackListRepository = $jobfairBlackListRepository;
  101. $this->memberSetmealRepository = $memberSetmealRepository;
  102. $this->memberPointRepository = $memberPointRepository;
  103. $this->memberHandselRepository = $memberHandselRepository;
  104. $this->membersSetmealLogRepository = $membersSetmealLogRepository;
  105. $this->resumeRepository = $resumeRepository;
  106. $this->jobfairPersonalJobsApplyRepository = $jobfairPersonalJobsApplyRepository;
  107. $this->jobfairManagementRepository = $jobfairManagementRepository;
  108. $this->subsiteService = $subsiteService;
  109. $this->memberLogRepository=$memberLogRepository;
  110. $this->jobfairoutRepository = $jobfairoutRepository;
  111. $this->articleRepository = $articleRepository;
  112. $this->categoryRepository = $categoryRepository;
  113. $this->emailService = $emailService;
  114. }
  115. /**近期招聘会
  116. * @return array
  117. */
  118. public function jobfairIndex($user)
  119. {
  120. $jobfairList = $this->jobfairRepository->getJobfairList($user->id);
  121. foreach ($jobfairList as $key => $val) {
  122. $val->predetermined_ok = 0;
  123. if ($val->predetermined_status == 1 && $val->predetermined_start && $val->predetermined_start < time() && $val->predetermined_end && $val->predetermined_end > time()) {
  124. $val->predetermined_ok = 1;
  125. }
  126. }
  127. $week = ['日','一','二','三','四','五','六'];
  128. return [
  129. 'jobfairList'=>$jobfairList,
  130. 'week'=>$week,
  131. ];
  132. }
  133. /**招聘会列表
  134. * @param $request
  135. * @return array
  136. */
  137. public function index($request)
  138. {
  139. $typeList = $this->jobfairManagementRepository->orderBy('order_list', 'desc')->get();
  140. $page = $request->page?$request->page:0;
  141. $search_type = $request->search_type ? $request->search_type : '';
  142. $key = $request->key ? $request->key : '';
  143. $firstwhere = [
  144. 'display'=>1,
  145. ];
  146. $firstJobfair = $this->jobfairRepository->firstJobfair($firstwhere);
  147. if ($firstJobfair) {
  148. if ($firstJobfair->predetermined_status == 1 && $firstJobfair->predetermined_start && $firstJobfair->predetermined_start < time() && $firstJobfair->predetermined_end && $firstJobfair->predetermined_end > time()) {
  149. $firstJobfair->predetermined_ok = 1;
  150. } else {
  151. $firstJobfair->predetermined_ok = 0;
  152. }
  153. }
  154. $jobfair_type = $request->type?$request->type:'';
  155. $pageCount = 10;
  156. $where['display']= 1;
  157. if ($jobfair_type != -1) {
  158. if($jobfair_type){
  159. $where['jobfair_type'] = $jobfair_type;
  160. }
  161. $allJobfair = $this->jobfairRepository->allJobfair($where, $page, $pageCount,$search_type,$key);
  162. }else{
  163. $allJobfair = $this->jobfairoutRepository->allJobfair($where, $page, $pageCount);
  164. }
  165. if ($allJobfair) {
  166. foreach ($allJobfair as $key => $val) {
  167. if ($val->predetermined_status == 1 && $val->predetermined_start && $val->predetermined_start < time() && $val->predetermined_end && $val->predetermined_end > time()) {
  168. $val->predetermined_ok = 1;
  169. } else {
  170. $val->predetermined_ok = 0;
  171. }
  172. }
  173. }
  174. $more = count($allJobfair) >= $pageCount ? true : false;
  175. $weekarray=array("日","一","二","三","四","五","六");
  176. if ($request->ajax()) {
  177. return [
  178. 'firstJobfair'=> $firstJobfair,
  179. 'page' => $page,
  180. 'allJobfair'=> $allJobfair,
  181. 'typeList'=> $typeList,
  182. 'weekarray'=>$weekarray
  183. ];
  184. }
  185. //资讯快报
  186. $news = $this->articleRepository->getArticles(['type_id'=>49],4);
  187. //招聘会回顾
  188. $jobfair_review = $this->articleRepository->getArticles(['type_id'=>50],4);
  189. return [
  190. 'firstJobfair'=> $firstJobfair,
  191. 'page' => $page,
  192. 'allJobfair'=> $allJobfair,
  193. 'typeList'=> $typeList,
  194. 'more'=> $more,
  195. 'news'=> $news,
  196. 'jobfair_review'=> $jobfair_review,
  197. 'weekarray'=>$weekarray
  198. ];
  199. }
  200. /**招聘会详情
  201. * @param $id
  202. * @return array
  203. */
  204. public function jobfairShow($id)
  205. {
  206. $map1 =[
  207. 'id'=>$id,
  208. ];
  209. $jobfair = $this->jobfairRepository->findOne($map1);
  210. if (!$jobfair) {
  211. return ['status'=>0, 'msg'=>'查无此招聘会'];
  212. }
  213. if ($jobfair->predetermined_status == 1 && $jobfair->predetermined_start && $jobfair->predetermined_start < time() && $jobfair->predetermined_end && $jobfair->predetermined_end > time()) {
  214. $jobfair->predetermined_ok =1;
  215. } else {
  216. $jobfair->predetermined_ok =0;
  217. }
  218. //总展位数
  219. $where = [
  220. 'jobfair_id'=>$id,
  221. ];
  222. $jobfair->standsTotal = $this->jobfairFloorplanStandRepository->standsTotal($where);
  223. $jobfair->phone_html = '';
  224. if($jobfair->phone){
  225. foreach (explode(',',$jobfair->phone) as $value){
  226. $jobfair->phone_html .= '<a href="tel:'.$value.'" style=" text-decoration: none;color: #0180CF; ">'.$value .'</a><br/><br/>';
  227. }
  228. }
  229. //空余展位数
  230. $map = [
  231. 'jobfair_id'=>$id,
  232. 'type'=>1
  233. ];
  234. $free_standsSurplus = $this->jobfairFloorplanStandRepository->standsTotal($map);
  235. if ($free_standsSurplus->isEmpty()) {
  236. $jobfair->standsSurplus = 0;
  237. } else {
  238. $free_standsSurplusCount = $free_standsSurplus->toArray();
  239. $free_count = count($free_standsSurplusCount);
  240. $positionArr = array_column($free_standsSurplusCount, 'id');
  241. $listCount = $this->jobfairCompanyRepository->findPositionCount($positionArr);
  242. if ($listCount->isNotEmpty()) {
  243. $positionCount = $listCount->count();
  244. foreach ($listCount as $key => $val) {
  245. if ($val->audit == 3) {
  246. $positionCount--;
  247. }
  248. }
  249. } else {
  250. $positionCount = 0;
  251. }
  252. $jobfair->standsSurplus = $free_count-$positionCount?$free_count-$positionCount:0;
  253. }
  254. $companyCount = $this->jobfairCompanyRepository->getComCount($id);
  255. return [
  256. 'status'=>1,
  257. 'jobfair'=>$jobfair,
  258. 'companyCount'=>$companyCount,
  259. ];
  260. }
  261. /**招聘会企业
  262. * @param $request
  263. * @param $id
  264. * @return JobfairCompanyRepository[]|array|\Illuminate\Database\Eloquent\Collection
  265. */
  266. public function jobfairShowCom($request, $id)
  267. {
  268. $where = ['jobfair_companys.jobfair_id'=>$id,'jobfair_companys.audit'=>1];
  269. $key = isset($request->key)?$request->key:0;
  270. $offset = isset($request->page)?$request->page:0;
  271. $limit = 20;
  272. //参会总数(分组)
  273. $companyCount = $this->jobfairCompanyRepository->getComCount($id);
  274. //参会总数(未分组)
  275. $comCount = $this->jobfairCompanyRepository->getCounts($id);
  276. $jobfair = $this->jobfairRepository->findJobfair(['id'=>$id]);
  277. if (!$jobfair) {
  278. return ['status'=>0, 'msg'=>'查无此招聘会'];
  279. }
  280. //总展位数
  281. $where1 = [
  282. 'jobfair_id'=>$id,
  283. ];
  284. $jobfair->standsTotal = $this->jobfairFloorplanStandRepository->standsTotal($where1);
  285. //空余展位数
  286. $map = [
  287. 'jobfair_id'=>$id,
  288. 'type'=>1
  289. ];
  290. if ($jobfair->predetermined_status == 1 && $jobfair->predetermined_start && $jobfair->predetermined_start < time() && $jobfair->predetermined_end && $jobfair->predetermined_end > time()) {
  291. $jobfair->predetermined_ok =1;
  292. } else {
  293. $jobfair->predetermined_ok =0;
  294. }
  295. $free_standsSurplus = $this->jobfairFloorplanStandRepository->standsTotal($map);
  296. if ($free_standsSurplus->isEmpty()) {
  297. $jobfair->standsSurplus = 0;
  298. } else {
  299. $free_standsSurplusCount = $free_standsSurplus->toArray();
  300. $free_count = count($free_standsSurplusCount);
  301. $positionArr = array_column($free_standsSurplusCount, 'id');
  302. $listCount = $this->jobfairCompanyRepository->findPositionCount($positionArr);
  303. if ($listCount->isNotEmpty()) {
  304. $positionCount = $listCount->count();
  305. foreach ($listCount as $key => $val) {
  306. if ($val->audit == 3) {
  307. $positionCount--;
  308. }
  309. }
  310. } else {
  311. $positionCount = 0;
  312. }
  313. $jobfair->standsSurplus = $free_count-$positionCount?$free_count-$positionCount:0;
  314. }
  315. $jobfairCompany = $this->jobfairCompanyRepository->findCompany($where, $offset, $limit);
  316. foreach ($jobfairCompany as $key => $val) {
  317. $val->jobfairPutJob = $this->jobfairPutJobRepository->getJobfairJob($val->id, $id);
  318. }
  319. if ($request->ajax()) {
  320. return [
  321. 'jobfairCompany'=>$jobfairCompany,
  322. 'jobfair'=>$jobfair,
  323. ];
  324. }
  325. $more = count($jobfairCompany) >= $limit ? true : false;
  326. $jobsSum = $this->jobfairPutJobRepository->getNeedPerson($id);
  327. $needPersonCount = isset($jobsSum['sum']) ? $jobsSum['sum'] : 0;
  328. $jobsCount = $this->jobfairPutJobRepository->getJobsCount($id);
  329. return [
  330. 'status'=>1,
  331. 'jobfair'=>$jobfair,
  332. 'jobfairCompany'=>$jobfairCompany,
  333. 'companyCount'=>$companyCount,
  334. 'more'=>$more,
  335. 'needPersonCount'=>$needPersonCount,
  336. 'jobsCount'=>$jobsCount,
  337. 'comCount'=>$comCount,
  338. ];
  339. }
  340. /**职位详情
  341. * @param $jobfair_id
  342. * @param $job_id
  343. * @return array
  344. */
  345. public function jobfairShowJob($id)
  346. {
  347. $jobInfo = $this->jobfairPutJobRepository->getOne(['id'=>$id]);
  348. if (!$jobInfo) {
  349. return ['status'=>0, 'msg'=>'查无此职位!'];
  350. }
  351. if ($jobInfo->jobs->ygxs == '363') {
  352. $jobInfo->jobs->wage_cn = $jobInfo->jobs->wage_min . '元/小时';
  353. }
  354. $other_categories = $this->categoryRepository->getCategories();
  355. //用工形式
  356. $company_ygxs = array_get($other_categories, 'AIX_ygxs');
  357. if ($company_ygxs) {
  358. $ygxs_cn = array_get($company_ygxs, $jobInfo->jobs->ygxs);
  359. if ($ygxs_cn) {
  360. $jobInfo->ygxs_cn = $ygxs_cn['demand'];
  361. } else {
  362. $jobInfo->ygxs_cn = '不限';
  363. }
  364. }
  365. //技能等级
  366. $techlevels = array_get($other_categories, 'AIX_techlevel');
  367. if ($techlevels) {
  368. $techlevel_cn = array_get($techlevels, $jobInfo->jobs->techlevel);
  369. if ($techlevel_cn) {
  370. $jobInfo->techlevel_cn = $techlevel_cn['demand'];
  371. } else {
  372. $jobInfo->techlevel_cn = '不限';
  373. }
  374. }
  375. //试用期
  376. $syqs = array_get($other_categories, 'zs_syq');
  377. if ($syqs) {
  378. if (empty($jobInfo->jobs->syq)) {
  379. $jobInfo->syq = 367;
  380. $jobInfo->jobs->syq=367;
  381. }
  382. $syq_cn = array_get($syqs, $jobInfo->jobs->syq);
  383. if ($syq_cn) {
  384. $jobInfo->syq_cn = $syq_cn['demand'];
  385. } else {
  386. $jobInfo->syq_cn = '无';
  387. }
  388. }
  389. //试用期工资:
  390. if ($jobInfo->wage == -1) {
  391. $jobInfo->syqxz_min_cn='面议';
  392. } else {
  393. $jobInfo->syqxz_min_cn=$jobInfo->jobs->syqxz_min.'元/月';
  394. }
  395. if ($jobInfo->jobfairs->holddate_end > time()) {
  396. $jobInfo->jobs->predetermined_ok = 1;
  397. } else {
  398. $jobInfo->jobs->predetermined_ok = 0;
  399. }
  400. if ($jobInfo->jobs->subclass) {
  401. $jobInfo->jobs->category_cn = get_job_category($jobInfo->jobs->subclass);
  402. }
  403. if ($jobInfo->jobs->tag_cn) {
  404. $jobInfo->jobs->tag_cn = explode(',',$jobInfo->jobs->tag_cn);
  405. }
  406. return [
  407. 'status'=>1,
  408. 'jobInfo'=>$jobInfo,
  409. ];
  410. }
  411. /**在线预定页面
  412. * @param $id
  413. * @return array
  414. */
  415. public function jobfairAppointment($id)
  416. {
  417. $jobfair = $this->jobfairRepository->findJobfair(['id'=>$id]);
  418. if (!$jobfair) {
  419. return ['status'=>0,'msg'=>"参数错误!"];
  420. }
  421. //总展位数
  422. $where1 = [
  423. 'jobfair_id'=>$id,
  424. ];
  425. $jobfair->standsTotal = $this->jobfairFloorplanStandRepository->standsTotal($where1);
  426. //空余展位数
  427. $map = [
  428. 'jobfair_id'=>$id,
  429. 'type'=>1
  430. ];
  431. $free_standsSurplus = $this->jobfairFloorplanStandRepository->standsTotal($map);
  432. if ($free_standsSurplus->isEmpty()) {
  433. $jobfair->standsSurplus = 0;
  434. } else {
  435. $free_standsSurplusCount = $free_standsSurplus->toArray();
  436. $free_count = count($free_standsSurplusCount);
  437. $positionArr = array_column($free_standsSurplusCount, 'id');
  438. $listCount = $this->jobfairCompanyRepository->findPositionCount($positionArr);
  439. if ($listCount->isNotEmpty()) {
  440. $positionCount = $listCount->count();
  441. foreach ($listCount as $key => $val) {
  442. if ($val->audit == 3) {
  443. $positionCount--;
  444. }
  445. }
  446. } else {
  447. $positionCount = 0;
  448. }
  449. $jobfair->standsSurplus = $free_count-$positionCount?$free_count-$positionCount:0;
  450. }
  451. //招聘企业数
  452. $companyList = $this->jobfairCompanyRepository->getComList(['jobfair_id'=>$id,'audit'=>1]);
  453. if ($companyList->isEmpty()) {
  454. $jobsCount = 0;
  455. $needPersonCount = 0;
  456. } else {
  457. //招聘职位数
  458. $companyIdArr = array_column($companyList->toArray(), 'company_id');
  459. $jobsCount = $this->jobfairPutJobRepository->getJobsCount($id, $companyIdArr);
  460. //需求人才数
  461. $jobsSum = $this->jobfairPutJobRepository->getNeedPerson($id, $companyIdArr);
  462. $needPersonCount = isset($jobsSum['sum']) ? $jobsSum['sum'] : 0;
  463. }
  464. if ($jobfair->predetermined_status == 1 && $jobfair->predetermined_start && $jobfair->predetermined_start < time() && $jobfair->predetermined_end && $jobfair->predetermined_end > time()) {
  465. $jobfair->predetermined_ok =1;
  466. } else {
  467. $jobfair->predetermined_ok =0;
  468. }
  469. return [
  470. 'status'=>1,
  471. 'jobfair'=>$jobfair,
  472. 'companyList'=>$companyList,
  473. 'jobsCount'=>$jobsCount,
  474. 'needPersonCount'=>$needPersonCount,
  475. ];
  476. }
  477. public function jobfairAppointmentSave($jobfairInfo, $positionInfo, $user)
  478. {
  479. //招聘会是否允许订多个展位
  480. //查看黑名单
  481. $blackInfo = $this->jobfairBlackListRepository->getOne(['company_id'=>$user->id]);
  482. if ($blackInfo && $blackInfo->status ==1 && $blackInfo->remove_time==0) {
  483. return response()->json(['status'=>0, 'msg'=>"很抱歉,无法预定招聘会。您在招聘会黑名单内!"]);
  484. }
  485. if ($this->jobfairCompanyRepository->findWhere(['company_id'=>$user->id,'jobfair_id'=>$jobfairInfo->id,'position_id'=>$positionInfo->id,['audit', '<>', 3]])->isNotEmpty()) {
  486. return response()->json(['status'=>0, 'msg'=>"您已预定过该展位,不能重复预定"]);
  487. }
  488. //允许预订 举办开始日期大于当前日期 预订结束时间大于当前时间 允许在线预订
  489. if ($jobfairInfo->predetermined_status == 2) {
  490. return response()->json(['status'=>0, 'msg'=>"很抱歉,招聘会已停止预定"]);
  491. }
  492. if (time() > $jobfairInfo->holddate_end) {
  493. return response()->json(['status'=>0, 'msg'=>"很抱歉,招聘会已结束"]);
  494. }
  495. // if ($jobfairInfo->predetermined_status == 1 && ($jobfairInfo->predetermined_start && time() < $jobfairInfo->predetermined_start)) {
  496. // return response()->json(['status'=>0, 'msg'=>"很抱歉,招聘会未到开始预定时间"]);
  497. // }
  498. // if ($jobfairInfo->predetermined_status == 1 && ($jobfairInfo->predetermined_end && time() > $jobfairInfo->predetermined_end)) {
  499. // return response()->json(['status'=>0, 'msg'=>"很抱歉,招聘会已结束预定"]);
  500. // }
  501. if ($jobfairInfo->is_commonweal == 1) {
  502. $num = $jobfairInfo->jobsfair_num;
  503. $mySetmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, 1);
  504. if ($mySetmeal->jobfair_num < $num) {
  505. return response()->json(['status' => 0, 'msg' => "很抱歉,您的会员招聘会场次不足。请先升级套餐!"]);
  506. }
  507. }
  508. if ($jobfairInfo->is_commonweal == 2) {
  509. $num = $jobfairInfo->predetermined_point;
  510. $myPoints = $this->memberPointRepository->getComPointsById($user->id, 1);
  511. if ($myPoints->points < $num) {
  512. return response()->json(['status' => 0, 'msg' => "很抱歉,您的会员积分不足。请先积分充值!"]);
  513. }
  514. }
  515. $insertData['company_id'] = $user->id;
  516. $insertData['jobfair_id'] = $jobfairInfo->id;
  517. $insertData['position_id'] = $positionInfo->id;
  518. $insertData['pay_type'] = $jobfairInfo->is_commonweal;
  519. $insertData['position'] = $positionInfo->name;
  520. DB::beginTransaction();
  521. try {
  522. if (!$this->jobfairCompanyRepository->create($insertData)) {
  523. throw new \Exception('招聘会预定失败!');
  524. }
  525. if ($jobfairInfo->is_commonweal != 3) {
  526. $res = $this->payType($jobfairInfo->is_commonweal, $num, $user);
  527. if (!$res['status']) {
  528. throw new \Exception($res['msg']);
  529. }
  530. }
  531. DB::commit();
  532. $this->memberLogRepository->createLog($user,1033,[$insertData['jobfair_id'],$insertData['position_id']]);
  533. return response()->json(['status'=>1, 'msg'=>"展位已保留,请关注审核结果并及时提交招聘会职位!",'data'=>['positionid'=>$positionInfo->id,'companyname'=>$user->companyname]]);
  534. } catch (\Exception $e) {
  535. DB::rollback();
  536. return response()->json(['status'=>0, 'msg'=>$e->getMessage()]);
  537. }
  538. }
  539. /**场次和积分预定招聘会
  540. * @param $payType
  541. * @param $num
  542. * @param $user
  543. * @return array
  544. */
  545. public function payType($payType, $num, $user)
  546. {
  547. //消耗场次
  548. $data = [];
  549. if ($payType == 1) {
  550. $mySetmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, 1);
  551. $data['jobfair_num'] = $mySetmeal->jobfair_num - $num?$mySetmeal->jobfair_num - $num:0;
  552. if (!$this->memberSetmealRepository->updateSetmeal($data, $mySetmeal->id)) {
  553. return ['status' => 0, 'msg' => '扣除招聘会场次失败!'];
  554. } else {
  555. $members_log['log_uid']=$user->id;
  556. $members_log['log_utype']=1;
  557. $members_log['log_username']=$user->username;
  558. $log_leave=$mySetmeal->jobfair_num-1;
  559. $members_log['log_leave'] = $log_leave<0?0:$log_leave;
  560. $members_log['log_value'] = '扣除招聘会场次';
  561. $members_log['log_source']='网页版';
  562. if (!$this->membersSetmealLogRepository->addNew($members_log)) {
  563. return ['status' => 0, 'msg' => '添加扣除招聘会场次记录失败!'];
  564. } else {
  565. return ['status' => 1,];
  566. }
  567. }
  568. } else {
  569. //消耗积分
  570. if (!$this->memberPointRepository->reportDeal($user->id, $user->utype, 2, $num)) {
  571. return ['status' => 0, 'msg' => '扣除积分失败!'];
  572. } else {
  573. $handsel['uid'] =$user->id;
  574. $handsel['utype'] = 1;
  575. $handsel['htype'] = 'yuyue_jobfair';
  576. $handsel['htype_cn'] = '扣除招聘会积分';
  577. $handsel['operate'] = 2;
  578. $handsel['points'] = $num;
  579. if (!$this->memberHandselRepository->addNew($handsel)) {
  580. return ['status' => 0, 'msg' => '添加扣除积分记录失败!'];
  581. } else {
  582. return ['status' => 1,];
  583. }
  584. }
  585. }
  586. }
  587. public function jobfairAppointmentJobs($request, $user)
  588. {
  589. $resume = $this->resumeRepository->getPersonInfo($user->id);
  590. if (!$resume) {
  591. return response()->json(['status'=>0,'type'=>0,'url'=>route('person.resumeAdd'), 'msg'=>"您还没有默认简历,请先去创建简历!"]);
  592. }
  593. $data['resume_id'] = $resume->id;
  594. $data['personal_uid'] = $user->id;
  595. $data['jobs_id'] = $request['jobsfair_job_id'];
  596. $data['company_id'] = $request['company_uid'];
  597. $data['jobfair_id'] = $request['jobfairid'];
  598. $data['position_id'] = $request['position_id'];
  599. $jobfair = $this->jobfairRepository->find($request['jobfairid']);
  600. if ($jobfair->isEmpty || $jobfair->holddate_end < time()) {
  601. return response()->json(['status'=>0, 'msg'=>"招聘会已停止"]);
  602. }
  603. if ($this->jobfairPersonalJobsApplyRepository->findWhere(['resume_id'=>$resume->id, 'jobs_id'=>$request['jobsfair_job_id'], 'company_id'=>$request['company_uid'], 'jobfair_id'=>$request['jobfairid'], 'position_id'=>$request['position_id']])->isNotEmpty()) {
  604. return response()->json(['status'=>0, 'msg'=>"您已预约该职位,请勿重复预约!"]);
  605. }
  606. if ($this->jobfairPersonalJobsApplyRepository->create($data)) {
  607. return response()->json(['status'=>1, 'msg'=>"职位预约成功!"]);
  608. }
  609. return response()->json(['status'=>0,'type'=>0 , 'msg'=>"职位预约失败!"]);
  610. }
  611. /**页面加载展位信息
  612. * @param $request
  613. * @return \Illuminate\Http\JsonResponse
  614. */
  615. public function ajaxGetData($data)
  616. {
  617. $jobfair_id = isset($data['jobfair_id'])?$data['jobfair_id']:0;
  618. $floorplan_id = isset($data['floorplan_id'])?$data['floorplan_id']:0;
  619. //后台传值,不区分预留展位
  620. $type = isset($data['type'])?$data['type']:0;
  621. if (!$jobfair_id || !$floorplan_id) {
  622. return response()->json(['status'=>0,'msg'=>"参数错误"]);
  623. }
  624. $jobfairFloorRes = $this->jobfairFloorPlanRepository->find($floorplan_id);
  625. $jobfairFloorplanStandResult = $this->jobfairFloorplanStandRepository->findWhere(['jobfair_id'=>$jobfair_id, 'floorplan_id'=>$floorplan_id], ['id', 'name','type','left', 'top']);
  626. if ($jobfairFloorplanStandResult) {
  627. $jobfairFloorplanStandResult = $jobfairFloorplanStandResult->toArray();
  628. }
  629. if (!$jobfairFloorplanStandResult || !$jobfairFloorRes) {
  630. return response()->json(['status'=>0,'msg'=>"参数错误"]);
  631. }
  632. if($type)
  633. {
  634. foreach ($jobfairFloorplanStandResult as $key => $val) {
  635. $audit = $this->jobfairCompanyRepository->findCom(['position_id'=>$val['id'], 'jobfair_id'=>$jobfair_id,['audit','<>', 3]]);
  636. if (!$audit) {
  637. $jobfairFloorplanStandResult[$key]['status'] =1;
  638. } else {
  639. if ($audit->audit == 1) {
  640. $jobfairFloorplanStandResult[$key]['status'] = 4;
  641. $jobfairFloorplanStandResult[$key]['company'] = $audit;
  642. } elseif ($audit->audit == 3) {
  643. $jobfairFloorplanStandResult[$key]['status'] = 1;
  644. } else {
  645. $jobfairFloorplanStandResult[$key]['status'] = 3;
  646. $jobfairFloorplanStandResult[$key]['company'] = $audit;
  647. }
  648. }
  649. }
  650. }else{
  651. foreach ($jobfairFloorplanStandResult as $key => $val) {
  652. if ($val['type'] == 2) {
  653. $jobfairFloorplanStandResult[$key]['status'] = 2;
  654. } else {
  655. $audit = $this->jobfairCompanyRepository->findComApi(['position_id'=>$val['id'], 'jobfair_id'=>$jobfair_id,['audit','<>', 3]]);
  656. if (!$audit) {
  657. $jobfairFloorplanStandResult[$key]['status'] =1;
  658. } else {
  659. if($audit->companys){
  660. unset($audit->companys->password);
  661. }
  662. if ($audit->audit == 1) {
  663. $jobfairFloorplanStandResult[$key]['status'] = 4;
  664. $jobfairFloorplanStandResult[$key]['company'] = $audit;
  665. } elseif ($audit->audit == 3) {
  666. $jobfairFloorplanStandResult[$key]['status'] = 1;
  667. } else {
  668. $jobfairFloorplanStandResult[$key]['status'] = 3;
  669. $jobfairFloorplanStandResult[$key]['company'] = $audit;
  670. }
  671. }
  672. }
  673. }
  674. }
  675. return response()->json(['status'=>1,'imageUrl'=>upload_asset($jobfairFloorRes->bg_images),'value'=>$jobfairFloorplanStandResult]);
  676. }
  677. public function getJobfairBlacklistCompany()
  678. {
  679. $need_array = [];
  680. $blacklistCompany = $this->jobfairCompanyRepository->getBlacklistCompany();
  681. if (!$blacklistCompany->isEmpty()) {
  682. foreach ($blacklistCompany as $key => $val) {
  683. $need_array[] = $val->company_id;
  684. }
  685. }
  686. $getManyBlackCompany = $this->jobfairCompanyRepository->getManyBlackCompany();
  687. if (!$getManyBlackCompany->isEmpty()) {
  688. foreach ($getManyBlackCompany as $key => $val) {
  689. if ($val->count>=3) {
  690. $need_array[] = $val->company_id;
  691. }
  692. }
  693. }
  694. $company_id = array_unique($need_array);
  695. return $company_id;
  696. }
  697. public function getJobfairCompany()
  698. {
  699. return $this->jobfairBlackListRepository->threeMonthBlackCompany();
  700. }
  701. public function getJobfairOpen()
  702. {
  703. $jonfair_id = [];
  704. $jobfair = $this->jobfairRepository->getJobfairOpen();
  705. foreach ($jobfair as $key => $val) {
  706. if ($val->predetermined_start) {
  707. if ($val->predetermined_start>time()||$val->predetermined_end<time()) {
  708. $jonfair_id[] = $val->id;
  709. }
  710. } else {
  711. if ($val->holddate_start<time()) {
  712. $jonfair_id[] = $val->id;
  713. }
  714. }
  715. }
  716. return $jonfair_id;
  717. }
  718. //首页招聘会列表
  719. public function getJobfairs($params)
  720. {
  721. $list = array();
  722. $where = array(
  723. array('display','=',1)
  724. );
  725. $limit = '';
  726. if (array_has($params, 'size')) {
  727. $limit = $params['size'];
  728. }
  729. $order = 'holddate_start DESC, if(holddate_end < unix_timestamp(now()),0,1) DESC ,holddate_start ASC';
  730. if (array_has($params, 'order')) {
  731. $order = $params['order'];
  732. }
  733. $res = $this->jobfairRepository->getJobfairs($where, $order, $limit);
  734. if ($res->isNotEmpty()) {
  735. $list = $res;
  736. }
  737. return $list;
  738. }
  739. //参会企业
  740. public function jobfairCompany($where,$limit = 20,$page = 1){
  741. $data = $this->jobfairCompanyRepository->getComPage($where,$limit,$page);
  742. if(!$data){
  743. return [];
  744. }
  745. return $data;
  746. }
  747. //所有职位
  748. public function jobfairJobs($where,$where1,$page = 20){
  749. return $this->jobfairPutJobRepository->getJobfairCompanyJobPage($where,$where1,$page);
  750. }
  751. //个人预约
  752. public function jobfairOrders($where,$limit = 20,$page = 1){
  753. return $this->jobfairPersonalJobsApplyRepository->getPersonApply($where,$limit,$page);
  754. }
  755. //面试邀请
  756. public function jobfairInterview($where,$limit = 20,$page = 1){
  757. return $this->jobfairPersonalJobsApplyRepository->applyJobsPage($where,$limit,$page);
  758. }
  759. public function userCode($user)
  760. {
  761. return QrCode::size(250)->generate(route('mobile.qrcode',['hashid'=>hashid_encode($user->id, $user->utype)]));
  762. }
  763. public function find($id)
  764. {
  765. return $this->jobfairRepository->find($id);
  766. }
  767. }