PersonalJobsApplyService.php 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wuzhenke
  5. * Date: 2018/11/20
  6. * Time: 11:19
  7. */
  8. namespace App\Services\Company;
  9. use Aix\Sms\Contracts\Smser;
  10. use App\Exceptions\ResponseException;
  11. use App\Models\Company;
  12. use App\Models\CompanyDownResume;
  13. use App\Models\Member;
  14. use App\Models\PersonalJobsApply;
  15. use App\Models\Resume;
  16. use App\Repositories\CompanyDownResumeRepository;
  17. use App\Repositories\CompanyInterviewRepository;
  18. use App\Repositories\CompanyRepository;
  19. use App\Repositories\JobsRepository;
  20. use App\Repositories\MemberLogRepository;
  21. use App\Repositories\MemberRepository;
  22. use App\Repositories\MemberSetmealRepository;
  23. use App\Repositories\PersonalJobsApplyRepository;
  24. use App\Repositories\ResumeEducationRepository;
  25. use App\Repositories\ResumeRepository;
  26. use App\Repositories\ResumeTrainRepository;
  27. use App\Repositories\ResumeWorkRepository;
  28. use App\Repositories\JobsContactRepository;
  29. use App\Repositories\MemberPointRepository;
  30. use App\Services\Common\EmailService;
  31. use App\Services\Common\WechatService;
  32. use App\Services\Jobfair\JobfairPutJobService;
  33. use App\Repositories\Jobfair\JobfairPutJobRepository;
  34. use App\Repositories\SmsRepository;
  35. use App\Repositories\SmsRuleRepository;
  36. use App\Services\Common\TaskService;
  37. use Illuminate\Support\Facades\DB;
  38. use Illuminate\Support\Facades\Log;
  39. use Illuminate\Support\Facades\Storage;
  40. use Chumper\Zipper\Zipper;
  41. use App\Services\Common\SmsService;
  42. use App\Repositories\ResumeLanguageRepository;
  43. use App\Repositories\ResumeCredentRepository;
  44. class PersonalJobsApplyService
  45. {
  46. protected $personalJobsApplyRepository;
  47. protected $resumeRepository;
  48. protected $taskService;
  49. protected $jobsRepository;
  50. protected $companyDownResumeRepository;
  51. protected $companyRepository;
  52. protected $companyInterviewRepository;
  53. protected $memberSetmealRepository;
  54. protected $resumeEducationRepository;
  55. protected $resumeWorkRepository;
  56. protected $resumeTrainRepository;
  57. protected $memberRepository;
  58. protected $jobsContactRepository;
  59. protected $memberPointRepository;
  60. protected $companyService;
  61. protected $jobsfairPutJobService;
  62. protected $jobfairPutJobRepository;
  63. protected $smsRepository;
  64. protected $smsRuleRepository;
  65. protected $smsService;
  66. protected $ResumeLanguageRepository;
  67. protected $ResumeCredentRepository;
  68. protected $memberLogRepository;
  69. protected $serviceService;
  70. protected $emailService;
  71. protected $wechatService;
  72. /**
  73. * PersonalJobsApplyService constructor.
  74. * @param $personalJobsApplyRepository
  75. * @param $taskService
  76. * @param $jobsRepository
  77. * @param $companyDownResumeRepository
  78. * @param $resumeRepository
  79. * @param $companyRepository
  80. * @param $companyInterviewRepository
  81. * @param $memberSetmealRepository
  82. * @param $resumeEducationRepository
  83. * @param $resumeWorkRepository
  84. * @param $resumeTrainRepository
  85. * @param $memberRepository
  86. * @param $jobsContactRepository ;
  87. * @param $memberPointRepository ;
  88. * @param $companyService
  89. * @param $jobsfairPutJobService
  90. * @param $jobfairPutJobRepository
  91. * @param $smsRepository
  92. * @param $smsRuleRepository
  93. * @param $smsService
  94. * @param $ResumeLanguageRepository
  95. * @param $ResumeCredentRepository
  96. * @param $memberLogRepository
  97. * @param $serviceService
  98. */
  99. public function __construct(
  100. PersonalJobsApplyRepository $personalJobsApplyRepository,
  101. MemberSetmealRepository $memberSetmealRepository,
  102. CompanyInterviewRepository $companyInterviewRepository,
  103. CompanyRepository $companyRepository,
  104. ResumeRepository $resumeRepository,
  105. JobsRepository $jobsRepository,
  106. TaskService $taskService,
  107. CompanyDownResumeRepository $companyDownResumeRepository,
  108. ResumeEducationRepository $resumeEducationRepository,
  109. ResumeWorkRepository $resumeWorkRepository,
  110. ResumeTrainRepository $resumeTrainRepository,
  111. MemberRepository $memberRepository,
  112. JobsContactRepository $jobsContactRepository,
  113. MemberPointRepository $memberPointRepository,
  114. CompanyService $companyService,
  115. JobfairPutJobService $jobsfairPutJobService,
  116. JobfairPutJobRepository $jobfairPutJobRepository,
  117. SmsRepository $smsRepository,
  118. SmsRuleRepository $smsRuleRepository,
  119. SmsService $smsService,
  120. ResumeLanguageRepository $ResumeLanguageRepository,
  121. ResumeCredentRepository $ResumeCredentRepository,
  122. MemberLogRepository $memberLogRepository,
  123. ServiceService $serviceService,
  124. EmailService $emailService,
  125. WechatService $wechatService
  126. )
  127. {
  128. $this->personalJobsApplyRepository = $personalJobsApplyRepository;
  129. $this->taskService = $taskService;
  130. $this->jobsRepository = $jobsRepository;
  131. $this->companyDownResumeRepository = $companyDownResumeRepository;
  132. $this->resumeRepository = $resumeRepository;
  133. $this->companyRepository = $companyRepository;
  134. $this->companyInterviewRepository = $companyInterviewRepository;
  135. $this->memberSetmealRepository = $memberSetmealRepository;
  136. $this->resumeEducationRepository = $resumeEducationRepository;
  137. $this->resumeWorkRepository = $resumeWorkRepository;
  138. $this->resumeTrainRepository = $resumeTrainRepository;
  139. $this->memberRepository = $memberRepository;
  140. $this->jobsContactRepository = $jobsContactRepository;
  141. $this->memberPointRepository = $memberPointRepository;
  142. $this->companyService = $companyService;
  143. $this->jobsfairPutJobService = $jobsfairPutJobService;
  144. $this->jobfairPutJobRepository = $jobfairPutJobRepository;
  145. $this->smsRepository = $smsRepository;
  146. $this->smsRuleRepository = $smsRuleRepository;
  147. $this->smsService = $smsService;
  148. $this->ResumeLanguageRepository = $ResumeLanguageRepository;
  149. $this->ResumeCredentRepository = $ResumeCredentRepository;
  150. $this->memberLogRepository=$memberLogRepository;
  151. $this->serviceService=$serviceService;
  152. $this->emailService=$emailService;
  153. $this->wechatService=$wechatService;
  154. }
  155. public function resumeApply($request, $user)
  156. {
  157. $jobs_id = isset($request['jobs_id']) ? $request['jobs_id'] : '';
  158. $stop = isset($request['stop']) ? $request['stop'] : 0;
  159. $state = isset($request['state']) ? $request['state'] : 0;
  160. $is_reply = isset($request['is_reply']) ? $request['is_reply'] : 0;
  161. $is_apply = isset($request['is_apply']) ? $request['is_apply'] : 0;
  162. $settr = isset($request['settr']) ? $request['settr'] : 0;
  163. $where['company_id'] = $user->id;
  164. if ($is_reply == 0) {
  165. $where['is_reply'] = 0;
  166. } else {
  167. $where[] = ['is_reply', '>', 0];
  168. }
  169. if ($jobs_id) {
  170. $where['jobs_id'] = $jobs_id;
  171. }
  172. if ($is_apply) {
  173. $where['is_apply'] = $is_apply;
  174. }
  175. if ($settr) {
  176. $where[] = ['created_at', '>=', date('Y-m-d H:i:s', strtotime("-{$settr} day"))];
  177. }
  178. $condition['company_id'] = $user->id;
  179. if (!$stop) {
  180. $condition[] = ['valid', '=', 1];
  181. $condition[] = ['display', '=', 1];
  182. }
  183. if (!$stop && config('aix.companyset.comset.show_set.jobs_display') == 1) {
  184. $condition = ['audit' => 1];
  185. }
  186. $jobs = $this->jobsRepository->applyJobs($condition, $user->id);
  187. $jobs_list = array_column($jobs, 'jobs_name', 'id');
  188. $param_array = array('jobs_id', 'stop', 'state', 'is_reply', 'settr');
  189. $params = array();
  190. if ($request) {
  191. foreach ($request as $k => $v) {
  192. if (in_array($k, $param_array)) {
  193. $params[$k] = $v;
  194. }
  195. }
  196. }
  197. if ($state) {
  198. $where['is_reply'] = $state;
  199. }
  200. $page = 10;
  201. $apply_list = $this->personalJobsApplyRepository->getResume($where, $page);
  202. //是否回复(1:企业未查看,2:待反馈,3:合适,4:不合适,5:待定,6:未接通)
  203. $state_arr = ['1' => '合适', '2' => '不合适', '3' => '待定', '4' => '未接通'];
  204. $date1 = time();
  205. $date2 = $date1 - 3600 * 24 * 14;
  206. //近两周收到的简历
  207. $count1 = $this->personalJobsApplyRepository->twoWeeksTotal($user->id);
  208. //近两周处理收到的简历
  209. $count2 = $this->personalJobsApplyRepository->twoWeeksReplyTotal($user->id);
  210. //处理率
  211. $count = $count1 ? (round($count2 / $count1, 2) * 100) : 0;
  212. $count = $count2 ? $count : 0;
  213. $hasget=0;
  214. if ($params) {
  215. $hasget = 1;
  216. }
  217. $this->serviceService->freeSetmealIsOver($user);
  218. $res = [
  219. 'is_reply' => $is_reply,
  220. 'is_apply' => $is_apply,
  221. 'stop' => $stop,
  222. 'state' => $state,
  223. 'result' => $apply_list,
  224. 'state_arr' => $state_arr,
  225. 'jobs_id' => $jobs_id,
  226. 'jobs_list' => $jobs_list,
  227. 'date' => date('Y/m/d', $date2),
  228. 'params' => $params,
  229. 'count1' => $count1,
  230. 'count2' => $count2,
  231. 'count' => $count,
  232. 'hasget' => $hasget,
  233. 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
  234. ];
  235. return $res;
  236. }
  237. public function resumeApplyMobile($request, $user)
  238. {
  239. $jobs_id = isset($request['jobs_id']) ? $request['jobs_id'] : '';
  240. $stop = isset($request['stop']) ? $request['stop'] : 0;
  241. $state = isset($request['state']) ? $request['state'] : 0;
  242. $is_reply = isset($request['is_reply']) ? $request['is_reply'] : 0;
  243. $is_apply = isset($request['is_apply']) ? $request['is_apply'] : 0;
  244. $settr = isset($request['settr']) ? $request['settr'] : 0;
  245. $where['company_id'] = $user->id;
  246. if ($jobs_id) {
  247. $where['jobs_id'] = $jobs_id;
  248. }
  249. if ($is_apply) {
  250. $where['is_apply'] = $is_apply;
  251. }
  252. if ($settr) {
  253. $where[] = ['created_at', '>=', date('Y-m-d H:i:s', strtotime("-{$settr} day"))];
  254. }
  255. $condition['company_id'] = $user->id;
  256. if (!$stop) {
  257. $condition[] = ['valid', '=', 1];
  258. $condition[] = ['display', '=', 1];
  259. }
  260. if (!$stop && config('aix.companyset.comset.show_set.jobs_display') == 1) {
  261. $condition = ['audit' => 1];
  262. }
  263. $jobs = $this->jobsRepository->applyJobs($condition, $user->id);
  264. $jobs_list = array_column($jobs, 'jobs_name', 'id');
  265. $param_array = array('jobs_id', 'stop', 'state', 'is_reply', 'settr');
  266. $params = array();
  267. if ($request) {
  268. foreach ($request as $k => $v) {
  269. if (in_array($k, $param_array)) {
  270. $params[$k] = $v;
  271. }
  272. }
  273. }
  274. if ($state) {
  275. $where['is_reply'] = $state;
  276. }
  277. $page = 10;
  278. $apply_list = $this->personalJobsApplyRepository->getResume($where, $page);
  279. //是否回复(1:企业未查看,2:待反馈,3:合适,4:不合适,5:待定,6:未接通)
  280. $state_arr = ['1' => '合适', '2' => '不合适', '3' => '待定', '4' => '未接通'];
  281. $date1 = time();
  282. $date2 = $date1 - 3600 * 24 * 14;
  283. //近两周收到的简历
  284. $count1 = $this->personalJobsApplyRepository->twoWeeksTotal($user->id);
  285. //近两周处理收到的简历
  286. $count2 = $this->personalJobsApplyRepository->twoWeeksReplyTotal($user->id);
  287. //处理率
  288. $count = $count1 ? (round($count2 / $count1, 2) * 100) : 0;
  289. $count = $count2 ? $count : 0;
  290. $hasget=0;
  291. if ($params) {
  292. $hasget = 1;
  293. }
  294. $res = [
  295. 'is_reply' => $is_reply,
  296. 'is_apply' => $is_apply,
  297. 'stop' => $stop,
  298. 'state' => $state,
  299. 'result' => $apply_list,
  300. 'state_arr' => $state_arr,
  301. 'jobs_id' => $jobs_id,
  302. 'jobs_list' => $jobs_list,
  303. 'date' => date('Y/m/d', $date2),
  304. 'params' => $params,
  305. 'count1' => $count1,
  306. 'count2' => $count2,
  307. 'count' => $count,
  308. 'hasget' => $hasget,
  309. 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
  310. ];
  311. return $res;
  312. }
  313. public function labelApply($id, $state, $user)
  314. {
  315. if (!$id) {
  316. return response()->json(['status' => 0, 'msg' => '请选择简历!']);
  317. }
  318. $old_info = $this->personalJobsApplyRepository->find($id);
  319. DB::beginTransaction();//检查数据库事务
  320. try {
  321. $r = ['code'=>0];
  322. $data = [
  323. 'is_reply' => $state,
  324. 'personal_look' => 2,
  325. 'reply_time' => time()
  326. ];
  327. if (false == $this->personalJobsApplyRepository->companyLabelResume($id, $data)) {
  328. throw new \Exception('标记失败!');
  329. }
  330. if ($old_info && ((time() - strtotime($old_info->created_at)) <= 86400 * 3)) {
  331. $r = $this->taskService->doTask(28, $user->id, $user->utype);
  332. }
  333. //添加日志
  334. DB::commit();
  335. $this->memberLogRepository->createLog($user,1029,[$id,$state]);
  336. return response()->json(['status' => 1, 'msg' => '标记成功', 'data' => $r]);
  337. } catch (\Exception $e) {
  338. DB::rollback();
  339. return response()->json(['status' => 0, 'msg' => $e->getMessage()]);
  340. }
  341. }
  342. /**
  343. * 删除简历申请
  344. * @param $request
  345. * @return \Illuminate\Http\JsonResponse
  346. * @param $user
  347. */
  348. public function delJobsApply($request,Company $user)
  349. {
  350. $id = isset($request['id']) ? $request['id'] : 0;
  351. if (!$id) {
  352. return response()->json(['status' => 0, 'msg' => '参数错误!']);
  353. }
  354. $ids = is_array($id) ? $id : explode(',', $id);
  355. if (!$this->personalJobsApplyRepository->delJobsApply($ids,$user->id)) {
  356. return response()->json(['status' => 0, 'msg' => '删除失败!']);
  357. }
  358. return response()->json(['status' => 1, 'msg' => '删除成功!']);
  359. }
  360. /**
  361. * 返回面试邀请模态框
  362. * @param $request
  363. * @return \Illuminate\Http\JsonResponse
  364. * @throws \Throwable
  365. */
  366. public function getApply($request, $user)
  367. {
  368. $mySetmeal = $this->memberSetmealRepository->findWhere(['uid'=>$user->id]);
  369. if (config('aix.companyset.audit.checkset.login_com_audit_certificate') == 1) {
  370. if ($user->audit != 1) {
  371. return response()->json(['status' => 0, 'msg' => "请上传企业营业执照或审核通过后,再进行其他操作"]);
  372. }
  373. }
  374. //正确的套餐,已经过期,不免费,过期时间不为0
  375. if ($mySetmeal[0]->setmeal_id > 0 && $mySetmeal[0]->expire ==1 && $mySetmeal[0]->is_free == 0 && $mySetmeal[0]->endtime!=0) {
  376. return response()->json(['status' => 0, 'msg' => "会员套餐已到期,请续费"]);
  377. }
  378. //20200217 zmw 去掉单位性质 和产业类别
  379. //if (!$user->nature || !$user->scale || !$user->organization_code || !$user->unit_character || !$user->industry || !$user->economy || !$user->district || !$user->trade || !$user->contents) {
  380. if (!$user->nature || !$user->scale || !$user->organization_code || !$user->district || !$user->trade || !$user->contents) {
  381. return response()->json(['status' => 0, 'msg' => "请完善企业基本信息后,再进行其他操作"]);
  382. }
  383. $is_apply = 2;
  384. $resume_id = isset($request['resume_id'])?$request['resume_id']:0;
  385. if (!$resume_id) {
  386. return response()->json(['status' => 0, 'msg' => "请先下载简历!"]);
  387. }
  388. $jobs_id = isset($request['jobs_id'])?$request['jobs_id']:0;
  389. if ($jobs_id) {
  390. $contatin[] = ['jobs_id', '=', $jobs_id];
  391. }
  392. $contatin = [
  393. ['resume_id', '=', $resume_id],
  394. ['company_id', '=', $user->id],
  395. ];
  396. $apply = $this->personalJobsApplyRepository->getOne($contatin);
  397. if ($apply) {
  398. $is_apply = 1;
  399. }
  400. if (config('aix.personal_set.per_set.contact_set.show_resume_contact') == 2) {
  401. $downData = [
  402. 'resume_id' => $resume_id,
  403. 'company_uid' => $user->id,
  404. ];
  405. if (!$apply) {
  406. $apply = $this->companyDownResumeRepository->getDownResume($downData);
  407. $is_apply = 2;
  408. }
  409. if (!$apply) {
  410. return response()->json(['status' => 0, 'msg' => "请先下载简历!"]);
  411. }
  412. } elseif (!$apply) {
  413. $apply = $this->resumeRepository->find($resume_id, ['id as resume_id', 'uid as resume_uid', 'fullname as resume_name']);
  414. if ($apply) {
  415. $is_apply = 2;
  416. }
  417. }
  418. if ($apply) {
  419. $apply = $apply->toArray();
  420. }
  421. $companyInfo = $this->companyRepository->findWhere(['id' => $user->id], ['district', 'contact', 'mobile', 'landline_tel', 'address'])->toArray();
  422. $apply = array_merge($apply, $companyInfo[0]);
  423. $apply['fullname'] = $this->resumeRepository->find($resume_id, ['fullname']);
  424. $jobs_map['company_id'] = $user->id;
  425. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  426. $jobs_map['audit'] = 1;
  427. }
  428. $jobs_map['valid'] = 1;
  429. $jobs = $this->jobsRepository->jobsList($jobs_map);
  430. if ($jobs) {
  431. $jobs = $jobs->toArray();
  432. $jobs_idarr = array_column($jobs, 'id');
  433. if (!isset($apply['jobs_id']) || !in_array($apply['jobs_id'], $jobs_idarr)) {
  434. $is_apply = 2;
  435. }
  436. foreach ($jobs as $key => $val) {
  437. $jobslist[$val['id']] = $val;
  438. }
  439. } else {
  440. $jobslist = [];
  441. $is_apply = 2;
  442. }
  443. if (isset($jobslist)) {
  444. $temp = current($jobslist);
  445. $default_jobs['jobs_id'] = $temp['id'];
  446. $default_jobs['jobs_name'] = $temp['jobs_name'];
  447. } else {
  448. return response()->json(['status' => 0, 'msg' => '您还没有发布职位或没有审核通过的职位']);
  449. }
  450. $data = [
  451. 'jobs' => $jobslist,
  452. 'default_jobs' => $default_jobs,
  453. 'is_apply' => $is_apply,
  454. 'apply' => $apply,
  455. ];
  456. return response()->json(['status' => 1, 'msg' => '获取数据成功!', 'data' => view('app.company.ajax.ajax_interview', $data)->render()]);
  457. }
  458. public function saveApply($request,$user)
  459. {
  460. $data['jobs_id'] = $request->jobs_id ? $request->jobs_id : 0;
  461. $data['resume_id'] = $request->resume_id ? $request->resume_id : 0;
  462. $data['personal_jobs_id'] = $request->personal_jobs_id ? $request->personal_jobs_id : 0; //重复投递的功能,带上投递ID
  463. $date = $request->date ? $request->date : '';
  464. $type = $request->type;
  465. //验证这个简历我是否下载过和是否收到过
  466. $this->isCanInterview($data['resume_id'],$user->id);
  467. //职位状态是未发布中的。
  468. $jobs_map['company_id'] = auth('web-company')->user()->id;
  469. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  470. $jobs_map['audit'] = 1;
  471. }
  472. $jobs_map['valid'] = 1;
  473. $jobs_map['display'] = 1;
  474. $jobs = $this->jobsRepository->jobsList($jobs_map);
  475. if ($jobs) {
  476. $jobs = $jobs->toArray();
  477. }
  478. $jobs_idarr = array_column($jobs, 'id');
  479. if (!in_array($data['jobs_id'], $jobs_idarr)) {
  480. return response()->json(['status' => 0, 'msg' => '求职者投递的职位状态为未发布,请确认职位状态']);
  481. }
  482. if (!$date) {
  483. return response()->json(['status' => 0, 'msg' => '请选择面试日期']);
  484. }
  485. $ap = ($request->ap == 2 ? 0 : 1) ? "AM" : 'PM';
  486. $time = $request->time ? $request->time : 0;
  487. if (!$time) {
  488. return response()->json(['status' => 0, 'msg' => '请选择面试时间']);
  489. }
  490. $data['interview_time'] = strtotime($date . ' ' . $time . ":00:00" . $ap);
  491. if ($data['interview_time'] < time()) {
  492. return response()->json(['status' => 0, 'msg' => '面试时间不能早于当前时间']);
  493. }
  494. $data['address'] = $request->address ? $request->address : '';
  495. if(!$data['address']){
  496. return response()->json(['status' => 0, 'msg' => '面试地址不能为空!']);
  497. }
  498. $data['contact'] = $request->contact ? $request->contact : '';
  499. if(!$data['contact']){
  500. return response()->json(['status' => 0, 'msg' => '联系人不能为空!']);
  501. }
  502. $data['telephone'] = $request->telephone ? $request->telephone : '';
  503. if(!$data['telephone']){
  504. return response()->json(['status' => 0, 'msg' => '联系电话不能为空!']);
  505. }
  506. $data['notes'] = $request->notes ? $request->notes : '';
  507. $data['sms_notice'] = $request->sms_notice ? $request->sms_notice : 0;
  508. $res = $this->addInterview($data, auth('web-company')->user(),$type);
  509. $user = auth('web-company')->user();
  510. // if($res['status']){
  511. // if($data['resume_id']){
  512. // $resume = Resume::find($data['resume_id']);
  513. // if($resume){
  514. // $member = Member::find($resume->uid);
  515. // $this->wechatService->sendTemplateMessage($member, 'set_invite',[
  516. // 'job'=>[$res['jobs_name'],'#0000ff'],
  517. // 'company'=>[$user->companyname,'#0000ff'],
  518. // 'time'=>[date('Y-m-d H:i:s',$data['interview_time']),'#0000ff'],
  519. // 'address'=>[$data['address'],'#0000ff'],
  520. // 'contact'=>[$data['contact'],'#0000ff'],
  521. // 'tel'=>[$data['telephone'],'#0000ff']
  522. // ], route('mobile.person.jobs_interview'));
  523. // }
  524. // }
  525. // }
  526. if (!$this->memberLogRepository->createLog($user,1010,[$data['jobs_id'],$data['resume_id']])) {
  527. throw new \Exception('日志记录失败');
  528. }
  529. return response()->json(['status' => $res['status'], 'msg' => $res['msg']]);
  530. }
  531. /**
  532. * 是否可以邀请面试
  533. * @param $resume_id
  534. * @param $company_id
  535. */
  536. public function isCanInterview($resume_id,$company_id){
  537. $isOk_person=$this->personalJobsApplyRepository->findJobsApply($resume_id,$company_id);
  538. $isOK_down=$this->companyDownResumeRepository->findWhere(["company_uid"=>$company_id,'resume_id'=>$resume_id])->first();
  539. if (empty($isOK_down) && empty($isOk_person)){
  540. throw new ResponseException(AjaxError("没有下载或者没有收到过改简历"));
  541. }
  542. }
  543. public function addInterview($data, $user,$type)
  544. {
  545. $sms_notice = $data['sms_notice'];
  546. unset($data['sms_notice']);
  547. if ($user->user_status == 2) {
  548. return ['status' => 0, 'msg' => '您的账号处于暂停状态,请联系管理员设为正常后进行操作'];
  549. }
  550. if (!$data['resume_id']) {
  551. return ['status' => 0, 'msg' => '请选择简历'];
  552. }
  553. $user_jobs = $this->jobsRepository->countAuditJobsNum();
  554. if (!$user_jobs) {
  555. return ['status' => 0, 'msg' => '邀请失败,你没有发布招聘信息或者信息没有审核通过'];
  556. }
  557. if ($this->companyInterviewRepository->checkInterview($data['resume_id'], $user->id, $data['jobs_id'],$data['personal_jobs_id'])) {
  558. return ['status' => 0, 'msg' => '您已对该简历进行过面试邀请,不能重复邀请'];
  559. }
  560. $setmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, $user->utype);
  561. $resume = $this->resumeRepository->getResumeMemInfo($data['resume_id']);
  562. $pass = false;
  563. //检测是否申请过职位
  564. // $has = $this->personalJobsApplyRepository->checkJobsApply($data['resume_id'], $user->id, $data['jobs_id']);
  565. /**职位要是申请过的,而且还得当前id的,咱才能改变是否查看
  566. 下载简历也用到了邀请面试,personal_jobs_id就为0 查不到就不需要改变状态直接添加邀请记录就可以了
  567. **/
  568. $has=$this->personalJobsApplyRepository->getPersonalJobByID($data['personal_jobs_id']);
  569. $has && $pass = true;
  570. if ($setmeal->show_apply_contact == 0 && $pass == true) {
  571. $pass = false;
  572. }
  573. if (config('aix.personal_set.per_set.contact_set.show_resume_contact') == 2) {
  574. if ($pass == false && $user->id) {
  575. $where['resume_id'] = $data['resume_id'];
  576. $where['company_uid'] = $user->id;
  577. $info = $this->companyDownResumeRepository->getDownResume($where);
  578. $info && $pass = true;
  579. }
  580. if (false == $pass && $setmeal->show_apply_contact == 0) { //如果套餐是免费查看的不提示!!
  581. return ['status' => 0, 'msg' => '请先下载简历!'];
  582. }
  583. }
  584. $jobInfo = $this->jobsRepository->getAuditJobsOne(['id' => $data['jobs_id']]);
  585. $_resume_fullname = $resume->fullname;
  586. if ($resume->display_name == 0) {
  587. $data['resume_name'] = "N" . str_pad($resume->id, 7, "0", STR_PAD_LEFT);
  588. } elseif ($resume->display_name == 3) {
  589. if ($resume->sex == 1) {
  590. $data['resume_name'] = cut_str($resume->fullname, 1, 0, "先生");
  591. } elseif ($resume->sex == 2) {
  592. $data['resume_name'] = cut_str($resume->fullname, 1, 0, "女士");
  593. }
  594. } else {
  595. $data['resume_name'] = $resume['fullname'];
  596. }
  597. $data['resume_addtime'] = strtotime($resume->created_at);
  598. $data['resume_uid'] = $resume->uid;
  599. $data['jobs_name'] = $jobInfo->jobs_name;
  600. $data['company_id'] = $user->id;
  601. $data['jobs_addtime'] = strtotime($jobInfo->created_at);
  602. $data['company_name'] = $user->companyname;
  603. $data['company_addtime'] = strtotime($user->created_at);
  604. $data['interview_addtime'] = time();
  605. $data['explan'] = time();//注解字段
  606. DB::beginTransaction();//检查数据库事务
  607. try {
  608. if (false === $this->companyInterviewRepository->create($data)) {
  609. throw new \Exception('邀请面试失败!');
  610. }
  611. if($type==1){
  612. }else{
  613. CompanyDownResume::where(['resume_id'=>$resume->id,'company_uid'=>$user->id])->update(['is_reply'=>1]);
  614. }
  615. // $map['resume_id'] = $data['resume_id'];
  616. // $map['jobs_id'] = $data['jobs_id'];
  617. // $map['company_id'] = $user->id;
  618. $map['id'] = $data['personal_jobs_id'];
  619. if ($has) {
  620. if (!$this->personalJobsApplyRepository->updateApply($map)) {
  621. throw new \Exception('状态修改失败,邀请面试失败!');
  622. }
  623. }
  624. //短信
  625. if ($sms_notice) {
  626. $this->smsService->setCallback('App\Services\Company\CompanyService', 'sendSMSCallBack',[$user->id])
  627. ->sendSms($resume->memberInfos->phone, Smser::TEMPLATE_JOB_INVITE, ['sitename'=>subsite_config('aix.system.site.site.site_name'),'companyname'=>$user->companyname,'sitedomain'=>config('aix.system.site.site.site_domain')]);
  628. }
  629. //发送邮件邀请
  630. if($resume->memberInfos){
  631. if($resume->memberInfos->email){
  632. $this->emailService->sendMail($resume->memberInfos->email,EmailService::TEMPLATE_INVITE_INTERVIEWS,['companyname'=>$user->companyname], ['companyname'=>$user->companyname,'sitedomain'=>route('person.index')]);
  633. }
  634. }
  635. DB::commit();
  636. } catch (\Exception $e) {
  637. DB::rollback();
  638. return ['status' => 0, 'msg' => $e->getMessage()];
  639. }
  640. return array('status' => 1, 'msg' => '邀请面试成功','jobs_name'=>$jobInfo->jobs_name);//增加面试邀请
  641. }
  642. public function saveAsDoc($id, $model)
  643. {
  644. switch ($model) {
  645. case 'personaljobsapply':
  646. $needModel = $this->personalJobsApplyRepository;
  647. break;
  648. case 'downresume':
  649. $needModel = $this->companyDownResumeRepository;
  650. break;
  651. }
  652. $idArr = $needModel->getResumeId($id);
  653. $resume_ids = array_column($idArr, 'resume_id');
  654. array_unique($resume_ids);
  655. if (false == $resumeList = $this->resumeRepository->getResumeList($resume_ids)) {
  656. return false;
  657. }
  658. $list = array();
  659. foreach ($resumeList as $key) {
  660. $resume = $key;
  661. $resume->education_list = $this->resumeEducationRepository->getResumeEducationByResumeId($resume->id);
  662. $resume->work_list = $this->resumeWorkRepository->getResumeWorkByResumeId($resume->id);
  663. $resume->training_list = $this->resumeTrainRepository->getResumeTrainByResumeId($resume->id);
  664. $resume->language_list = $this->ResumeLanguageRepository->getResumeLanByResumeId($resume->id); //语言能力
  665. $resume->credent_list = $this->ResumeCredentRepository->getResumeCredentByResumeId($resume->id); //获得证书
  666. $resume->age = date('Y') - $resume->memberInfos->birthday;
  667. $resume->tagcn = preg_replace("/\d+/", '', $resume->tag);
  668. $resume->tagcn = preg_replace("/\,/", '', $resume->tagcn);
  669. $resume->tagcn = preg_replace("/\|/", '', $resume->tagcn);
  670. //最近登录时间
  671. $last_login_time = $this->memberRepository->getFields($resume->uid, ['last_login_time']);
  672. $resume->last_login_time = date('Y-m-d', $last_login_time['last_login_time']);
  673. if ($resume->display_name == '3') {
  674. if ($resume->sex == 1) {
  675. $resume->fullname = cut_str($resume->fullname, 1, 0, "先生");
  676. } elseif ($resume->sex == 2) {
  677. $resume->fullname = cut_str($resume->fullname, 1, 0, "女士");
  678. }
  679. }
  680. $resume->has_down = false;
  681. $resume->is_apply = false;
  682. $resume->label_id = 0;
  683. $resume->contact = $this->getShowContact($resume, auth('web-company')->user());
  684. if ($resume->show_contact === false) {
  685. $resume->telephone = contact_hide($resume->telephone, 2);
  686. $resume->email = contact_hide($resume->email, 3);
  687. }
  688. $avatar_default = $resume->sex == 1 ? "data/upload/resource/no_photo_male.png" : "data/upload/resource/no_photo_female.png";
  689. if ($resume->memberInfos->photo == 1 && ($resume->memberInfos->photo_audit == 2 || config('aix.personal_set.per_set.show_set.resume_img_display') == 2)) {
  690. $resume->photosrc = upload_asset($resume->memberInfos->images);
  691. } else {
  692. $resume->photosrc = asset($avatar_default);
  693. }
  694. $list[] = $resume;
  695. }
  696. //压缩文件路径
  697. $zip_path = Storage::disk('public')->path('down_resume/' . auth('web-company')->user()->id.'.zip');
  698. if (file_exists($zip_path)) {
  699. Storage::disk('public')->delete('down_resume/' . auth('web-company')->user()->id.'.zip');
  700. }
  701. $zipper = new Zipper();
  702. $zipper->make($zip_path);
  703. foreach ($list as $key => $val) {
  704. $html = view('app.company.resume.tpl_word_resume', ['resume' => $val])->render();
  705. $zipper->addString(($key+1).'_'.$val->fullname.'的简历.doc', $html);
  706. }
  707. $zipper->close();
  708. return ['status' => 1, 'msg' => '下载成功!', 'path' => $zip_path];
  709. }
  710. /**
  711. * 是否显示联系方式
  712. */
  713. protected function getShowContact(&$val, $user)
  714. {
  715. $show_contact = false;
  716. //情景1:游客访问
  717. if (!$user) {
  718. if (config('aix.personal_set.per_set.contact_set.show_resume_contact') == 0) {
  719. $show_contact = true;
  720. }
  721. } else if ($user->utype == 2 && $user->id == $val->uid) { //情景2:个人会员访问并且是该简历发布者
  722. $show_contact = true;
  723. } elseif ($user->utype == 1) { //情景3:企业会员访问
  724. //情景3-1:其他企业会员
  725. if (config('aix.personal_set.per_set.contact_set.show_resume_contact') == 1) {
  726. $show_contact = true;
  727. }
  728. //情景3-2:下载过该简历
  729. $data['resume_id'] = $val->id;
  730. $data['company_uid'] = $user->id;
  731. $down_resume = $this->companyDownResumeRepository->getDownResume($data);
  732. if ($down_resume) {
  733. $val->label_id = $down_resume->is_reply;
  734. $show_contact = true;
  735. $val->has_down = true;
  736. }
  737. //情景3-3:该简历申请过当前企业发布的职位
  738. $jobs_apply = $this->personalJobsApplyRepository->checkJobsApply($val->id, $user->id);
  739. $setmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, $user->utype);
  740. if ($jobs_apply && $setmeal->show_apply_contact == '0') {
  741. $show_contact = true;
  742. }
  743. }
  744. return $show_contact;
  745. }
  746. /*
  747. * 申请职位
  748. */
  749. //判断是否可以申请职位
  750. public function ifJobApply($jobs_id, $user = array())
  751. {
  752. //获取当天已投递的职位数量,判断当天是否可以还可以投递简历
  753. $today_time = date('Y-m-d H:i:s', strtotime(date('Y-m-d', time())));
  754. $apply_where = array(
  755. array('personal_uid', '=', $user->id),
  756. array('created_at', '>=', $today_time)
  757. );
  758. $applyJobs = $this->personalJobsApplyRepository->applyJobs($apply_where);
  759. $allow_count = config('aix.personal_set.per_set.per_set.apply_jobs_max');
  760. if ($allow_count < count($applyJobs) + count($jobs_id)) {
  761. throw new ResponseException("您每天可以投递" . $allow_count . "个职位,今天已投递了" . count($applyJobs) . "个");
  762. }
  763. //判断是否有可以投递的简历
  764. $resume_audit = config('aix.personal_set.per_set.show_set.resume_display');
  765. $resume_where = array(array('uid', '=', $user->id));
  766. if (config('aix.personal_set.per_set.show_set.resume_display') == '1') {
  767. $resume_where[] = array('audit', '=', '2');
  768. } else {
  769. $resume_where[] = array('audit', '<>', '0');
  770. }
  771. $resumes = $this->resumeRepository->getResumes($resume_where);
  772. if (count($resumes) == 0) {
  773. //判断是否有简历
  774. $user_resumes = $this->resumeRepository->getResumes(array('uid' => auth('web-member')->user()->id));
  775. if ($user_resumes->toArray()) {
  776. throw new ResponseException("您没有审核通过的简历!");
  777. } else {
  778. throw new ResponseException("请您先填写一份简历!");
  779. }
  780. } else if (count($resumes) == 1) {
  781. //直接进入投递环节
  782. $resumes_arr = $resumes->toArray();
  783. return $this->applyJobs($jobs_id, $resumes_arr[0]['id'], $user);
  784. } else {
  785. //获取默认简历信息
  786. $def_resume = array();
  787. foreach ($resumes as $k => $v) {
  788. if ($v->def == '1') {
  789. $def_resume = $v;
  790. }
  791. }
  792. if (!$def_resume) {
  793. $def_resume = $resumes[0];
  794. }
  795. //提示用户选择需要投递的简历
  796. return array('status' => 2, 'resumes' => $resumes, 'def_resume' => $def_resume);
  797. }
  798. }
  799. //申请职位
  800. public function applyJobs($jobs_id, $resume_id = '', $user)
  801. {
  802. //判断简历是否存在
  803. if ($resume_id) {
  804. $resume_where = array('uid' => $user->id, 'id' => $resume_id);
  805. } else {
  806. $resume_where = array('uid' => $user->id, 'def' => 1);
  807. }
  808. $resume_info = $this->resumeRepository->getResumeInfo($resume_where);
  809. if (!$resume_info) {
  810. throw new ResponseException("选择的简历不存在!");
  811. }
  812. //判断简历是否要求通过审核
  813. if (config('aix.personal_set.per_set.show_set.resume_display') == '1') {
  814. if ($resume_info->audit != 2) {
  815. throw new ResponseException("您选择投递的简历尚未审核通过!");
  816. }
  817. } else {
  818. if ($resume_info->audit == 0) {
  819. throw new ResponseException("您选择投递的简历尚未审核通过!");
  820. }
  821. }
  822. //检测职位匹配的简历完整度要求
  823. if (config('aix.personal_set.per_set.per_set.apply_job_min_percent')) {
  824. if ($resume_info->complete_percent < config('aix.personal_set.per_set.per_set.apply_job_min_percent')) {
  825. return array('status' => 0, 'error' => '您的简历完整度只有 ' . $resume_info->complete_percent . '%,该公司要求达到 ' . config('aix.personal_set.per_set.per_set.apply_job_min_percent') . '% 才可以申请,请继续完善吧~', 'complete' => array('id' => $resume_info->id, 'percent' => $resume_info->complete_percent), 'resume_id' => $resume_info->id);
  826. }
  827. }
  828. //获取简历的工作经历、教育经历
  829. $work_where = array(
  830. 'uid' => $user->id,
  831. 'resume_id' => $resume_info->id
  832. );
  833. $works = $this->resumeWorkRepository->getResumeWorks($work_where);
  834. if ($works->toArray()) {
  835. $resume_info->work = $works;
  836. }
  837. $edu_where = $work_where;
  838. $educations = $this->resumeEducationRepository->getResumeEducations($edu_where);
  839. if ($educations->toArray()) {
  840. $resume_info->educations = $educations;
  841. }
  842. //获取职位信息
  843. $job_where_in = $jobs_id;
  844. $jobs_res = $this->jobsRepository->getJobs($job_where_in);
  845. $jobs = $this->dealJobsInfo($jobs_res);
  846. $com_setmeals = $this->getJobCompanySetmeals($jobs); //当前所选职位对应的企业会员套餐信息
  847. $down_companys = $this->companyDownResumeRepository->getDowmResumes(array('resume_id' => $resume_info->id, 'resume_uid' => $resume_info->uid), array(), 'company_uid'); //获取所有下载当前简历的企业信息
  848. //获取当前用户申请过的职位
  849. $space_times = 1 - config('aix.personal_set.per_set.per_set.apply_job_space');
  850. $check_where = array(
  851. array('personal_uid', '=', $user->id)
  852. );
  853. if (config('aix.personal_set.per_set.per_set.apply_job_space')>0) {
  854. $check_time = strtotime(date('Y-m-d', strtotime($space_times . " day") - 1)) - 1;
  855. $check_where[] = array('created_at', '>', date('Y-m-d H:i:s', $check_time));
  856. }
  857. //$check_where = array('personal_uid'=>auth('web-member')->user()->id);
  858. //$check_jobs_res = $this->personalJobsApplyRepository->applyJobs($check_where, $jobs_id);
  859. $check_jobs_res = $this->personalJobsApplyRepository->checkApplyJobs($check_where, $jobs_id);
  860. $check_jobs = $this->dealCheckJobs($check_jobs_res);
  861. //申请职位
  862. $list = array();
  863. $success = 0;
  864. $points = 0;
  865. $space_days = config('aix.personal_set.per_set.per_set.apply_job_space');
  866. $fail_job_ids = [];
  867. foreach ($jobs_id as $val) {
  868. $jobs_name = $jobs[$val]->jobs_name;
  869. $list[$val] = array('id' => $val, 'jobs_name' => $jobs_name, 'company_id' => $jobs[$val]->company_id, 'company_name' => $jobs[$val]->company_name, 'status' => 0);
  870. //检测职位是否有效
  871. if ($jobs[$val]->valid == 0 || $jobs[$val]->display != 1) {
  872. $list[$val]['tip'] = '该职位已关闭';
  873. $list[$val]['status'] = 4;
  874. $fail_job_ids[] = $val;
  875. continue;
  876. }
  877. //判断是否申请过当前职位
  878. if (array_get($check_jobs, $val)) {
  879. if (config('aix.personal_set.per_set.per_set.apply_job_space')>0) {
  880. $list[$val]['tip'] = $space_days . '天内不允许重复申请';
  881. } else {
  882. $list[$val]['tip'] = '该职位已申请';
  883. }
  884. $list[$val]['status'] = 3;
  885. $fail_job_ids[] = $val;
  886. continue;
  887. }
  888. //申请职位
  889. $time = date('Y-m-d H:i:s', time());
  890. $apply_data = array(
  891. 'resume_id' => $resume_info->id,
  892. 'resume_name' => $resume_info->title,
  893. 'personal_uid' => $resume_info->uid,
  894. 'jobs_id' => $val,
  895. 'jobs_name' => $jobs[$val]->jobs_name,
  896. 'company_id' => $jobs[$val]->company_id,
  897. 'company_name' => $jobs[$val]->company_name,
  898. 'personal_look' => 1,
  899. 'notes' => '',
  900. 'is_reply' => 0,
  901. 'is_apply' => 1,
  902. 'created_at' => $time,
  903. 'updated_at' => $time
  904. );
  905. // $company = Company::find($jobs[$val]->company_id);
  906. // $this->wechatService->sendTemplateMessage($company, 'set_applyjobs',[
  907. // 'keyword1'=>[$jobs[$val]->jobs_name,'#0000ff'],
  908. // 'keyword2'=>[$user->username,'#0000ff'],
  909. // ],route('mobile.firm.resume.apply'));
  910. //
  911. // if($company->email){
  912. // $this->emailService->sendMail($company->email, EmailService::TEMPLATE_MAIL_APPLYJOBS, ['personalfullname'=>$resume_info->fullname,'jobsname'=>$jobs[$val]->jobs_name], ['jobsname'=>$jobs[$val]->jobs_name]);
  913. // }
  914. $apply_rst = $this->personalJobsApplyRepository->addData($apply_data);
  915. if ($apply_rst) {
  916. //判断会员套餐中投递的简历是否免费查看,如果免费查看则判断当前企业是否有下载过该简历,没有下载则添加下载对应关系
  917. if (array_has($com_setmeals, $jobs[$val]->company_id)) {
  918. $com_setmeal = $com_setmeals[$jobs[$val]->company_id];
  919. if ((!$down_companys) || ($down_companys && !array_has($down_companys, $jobs[$val]->company_id))) {
  920. if ($com_setmeal->expire == 0 && $com_setmeal->show_apply_contact == 1) {
  921. $down_data = array(
  922. 'resume_id' => $resume_info->id,
  923. 'resume_name' => $resume_info->title,
  924. 'resume_uid' => $resume_info->uid,
  925. 'company_uid' => $com_setmeal->uid,
  926. 'company_name' => $jobs[$val]->company_name,
  927. 'down_addtime' => time(),
  928. 'is_reply' => 0
  929. );
  930. $this->companyDownResumeRepository->create($down_data);
  931. }
  932. }
  933. }
  934. $insertid = $apply_rst->id;
  935. $list[$val]['tip'] = '投递成功';
  936. $list[$val]['status'] = 1;
  937. $success++;
  938. //修改任务记录、积分信息
  939. $task_rst = $this->taskService->doTask(4);
  940. if (array_get($task_rst, 'code') == 1) {
  941. $points += $task_rst['data']['points'];
  942. }
  943. //添加企业访客记录
  944. $this->companyService->addStatistics($jobs[$val]->company_id, $val, $user, 1);
  945. //职位联系信息
  946. $contacts = '';
  947. $contacts = $this->jobsContactRepository->getContactInfo(array('job_id' => $val));
  948. //简历基本信息
  949. $resume_basicinfo = $this->resumeRepository->getResumeBasic(auth('web-member')->user()->id, $resume_info->id);
  950. //发送站内信
  951. $replac_pms = array();
  952. $replac_pms['personalfullname'] = $resume_basicinfo->fullname;
  953. //TODO 发送邮件
  954. //发送短信 - 短信开关、短信模板、职位联系信息中notify_mobile
  955. $jobsContact = $jobs[$val]->jobsContact;
  956. $mobile = '';
  957. $notify_mobile = 0;
  958. if ($jobsContact) {
  959. $notify_mobile = $jobsContact->notify_mobile;
  960. $mobile = $jobsContact->telephone;
  961. }
  962. if ($mobile) {
  963. //获取短信接口是否开启
  964. $smss = $this->smsRepository->getUsefulSms();
  965. $sms_config = 0;
  966. if ($smss) {
  967. $sms_config = 1;
  968. }
  969. //判断申请职位短信通知是否开启
  970. $sms_apply_notice = 0;
  971. if ($this->smsRuleRepository->getSmsRule(['alias'=>'sms_applyjobs','status'=>1])) {
  972. $sms_apply_notice = 1;
  973. }
  974. if ($sms_config && $sms_apply_notice && $notify_mobile) {
  975. //发送短信
  976. $parmas = array(
  977. 'sitename' => subsite_config('aix.system.site.site.site_name'),
  978. 'sitedomain' => config('aix.system.site.site.site_domain'),
  979. 'jobsname' => $jobs[$val]->jobs_name,
  980. 'personalfullname' => $resume_basicinfo->fullname
  981. );
  982. $this->smsService->sendSms($mobile, Smser::TEMPLATE_JOB_APPLY, $parmas);
  983. }
  984. }
  985. //微信
  986. } else {
  987. $list[$val]['tip'] = '申请职位失败';
  988. }
  989. }
  990. //判断申请职位是否有任务
  991. $task_check = $this->taskService->checkTask(4);
  992. //获取会员积分信息
  993. $points_info = $this->memberPointRepository->getPointsOne($user->id, 2);
  994. return array('status' => 1, 'data' => array('count_jids' => count($jobs_id), 'list' => $list, 'total' => count($jobs_id), 'points' => $points, 'success' => $success, 'failure' => count($jobs_id) - $success), 'points_info' => $points_info, 'show_points' => $task_check, 'resume_id' => $resume_info->id, 'fail_job_ids' =>$fail_job_ids);
  995. }
  996. public function dealJobsInfo($jobs)
  997. {
  998. $list = array();
  999. if (count($jobs) > 0) {
  1000. foreach ($jobs as $k => $v) {
  1001. $list[$v->id] = $v;
  1002. }
  1003. }
  1004. return $list;
  1005. }
  1006. public function dealCheckJobs($jobs)
  1007. {
  1008. $list = array();
  1009. if (count($jobs) > 0) {
  1010. foreach ($jobs as $k => $v) {
  1011. $list[$v->jobs_id] = $v;
  1012. }
  1013. }
  1014. return $list;
  1015. }
  1016. public function getJobCompanySetmeals($jobs)
  1017. {
  1018. $com_ids = array();
  1019. $list = array();
  1020. if (count($jobs) > 0) {
  1021. foreach ($jobs as $k => $v) {
  1022. $com_ids[] = $v->company_id;
  1023. }
  1024. $rst = $this->memberSetmealRepository->getMemberSetmeals($com_ids);
  1025. if ($rst) {
  1026. foreach ($rst as $k => $v) {
  1027. $list[$v->uid] = $v;
  1028. }
  1029. }
  1030. }
  1031. return $list;
  1032. }
  1033. //手机端申请职位
  1034. public function ifMobileJobApply($jobs_id, $user, $resume_id = '', $is_apply = 2)
  1035. {
  1036. //获取当天已投递的职位数量,判断当天是否可以还可以投递简历
  1037. $today_time = date('Y-m-d H:i:s', strtotime(date('Y-m-d', time())));
  1038. $apply_where = array(
  1039. array('personal_uid', '=', $user->id),
  1040. array('created_at', '>=', $today_time)
  1041. );
  1042. $applyJobs = $this->personalJobsApplyRepository->applyJobs($apply_where);
  1043. $allow_count = config('aix.personal_set.per_set.per_set.apply_jobs_max');
  1044. if ($allow_count < count($applyJobs) + count($jobs_id)) {
  1045. return array('status'=>0,'error'=>"您每天可以投递" . $allow_count . "个职位,今天已投递了" . count($applyJobs) . "个");
  1046. }
  1047. //判断是否有可以投递的简历
  1048. $resume_audit = config('aix.personal_set.per_set.show_set.resume_display');
  1049. $resume_where = array(array('uid', '=', auth('web-member')->user()->id));
  1050. if (config('aix.personal_set.per_set.show_set.resume_display') == '1') {
  1051. $resume_where[] = array('audit', '=', '2');
  1052. } else {
  1053. $resume_where[] = array('audit', '<>', '0');
  1054. }
  1055. $resumes = $this->resumeRepository->getResumes($resume_where);
  1056. if (count($resumes) == 0) {
  1057. //判断是否有简历
  1058. $user_resumes = $this->resumeRepository->getResumes(array('uid' => auth('web-member')->user()->id));
  1059. if ($user_resumes->toArray()) {
  1060. return array('status'=>0,'error'=>"您没有审核通过的简历!");
  1061. } else {
  1062. return array('status'=>0,'error'=>"请您先填写一份简历!");
  1063. }
  1064. } else if (count($resumes) == 1) {
  1065. //直接进入投递环节
  1066. $resumes_arr = $resumes->toArray();
  1067. return $this->mobileApplyJobs($jobs_id, $resumes_arr[0]['id'], $user);
  1068. } else {
  1069. //获取默认简历信息
  1070. $def_resume = array();
  1071. foreach ($resumes as $k => $v) {
  1072. if ($v->def == '1') {
  1073. $def_resume = $v;
  1074. }
  1075. }
  1076. if (!$def_resume) {
  1077. $def_resume = $resumes[0];
  1078. }
  1079. //提示用户选择需要投递的简历
  1080. return array('status' => 2, 'resumes' => $resumes, 'def_resume' => $def_resume);
  1081. }
  1082. }
  1083. public function mobileApplyJobs($jobs_id, $resume_id = '', $user = array())
  1084. {
  1085. //判断简历是否存在
  1086. if ($resume_id) {
  1087. $resume_where = array('uid' => $user->id, 'id' => $resume_id);
  1088. } else {
  1089. $resume_where = array('uid' => $user->id, 'def' => 1);
  1090. }
  1091. $resume_info = $this->resumeRepository->getResumeInfo($resume_where);
  1092. if (!$resume_info) {
  1093. return array('status'=>0,'error'=>"选择的简历不存在!");
  1094. }
  1095. //判断简历是否要求通过审核
  1096. if (config('aix.personal_set.per_set.show_set.resume_display') == '1') {
  1097. if ($resume_info->audit != 2) {
  1098. return array('status'=>0,'error'=>"您选择投递的简历尚未审核通过!");
  1099. }
  1100. } else {
  1101. if ($resume_info->audit == 0) {
  1102. return array('status'=>0,'error'=>"您选择投递的简历尚未审核通过!");
  1103. }
  1104. }
  1105. //检测职位匹配的简历完整度要求
  1106. if (config('aix.personal_set.per_set.per_set.apply_job_min_percent')) {
  1107. if ($resume_info->complete_percent < config('aix.personal_set.per_set.per_set.apply_job_min_percent')) {
  1108. return array('status' => 0, 'error' => '您的简历完整度只有 ' . $resume_info->complete_percent . '%,该公司要求达到 ' . config('aix.personal_set.per_set.per_set.apply_job_min_percent') . '% 才可以申请,请继续完善吧~', 'complete' => array('id' => $resume_info->id, 'percent' => $resume_info->complete_percent), 'resume_id' => $resume_info->id);
  1109. }
  1110. }
  1111. //获取简历的工作经历、教育经历
  1112. $work_where = array(
  1113. 'uid' => $user->id,
  1114. 'resume_id' => $resume_info->id
  1115. );
  1116. $works = $this->resumeWorkRepository->getResumeWorks($work_where);
  1117. if ($works->toArray()) {
  1118. $resume_info->work = $works;
  1119. }
  1120. $edu_where = $work_where;
  1121. $educations = $this->resumeEducationRepository->getResumeEducations($edu_where);
  1122. if ($educations->toArray()) {
  1123. $resume_info->educations = $educations;
  1124. }
  1125. //获取职位信息
  1126. $job_where_in = $jobs_id;
  1127. $jobs_res = $this->jobsRepository->getJobs($job_where_in);
  1128. $jobs = $this->dealJobsInfo($jobs_res);
  1129. $com_setmeals = $this->getJobCompanySetmeals($jobs); //当前所选职位对应的企业会员套餐信息
  1130. $down_companys = $this->companyDownResumeRepository->getDowmResumes(array('resume_id' => $resume_info->id, 'resume_uid' => $resume_info->uid), array(), 'company_uid'); //获取所有下载当前简历的企业信息
  1131. //获取当前用户申请过的职位
  1132. $space_times = 1 - config('aix.personal_set.per_set.per_set.apply_job_space');
  1133. $check_time = strtotime(date('Y-m-d', strtotime($space_times . " day") - 1)) - 1;
  1134. $check_where = array(
  1135. array('personal_uid', '=', $user->id),
  1136. array('created_at', '>', date('Y-m-d H:i:s', $check_time)),
  1137. );
  1138. $check_jobs_res = $this->personalJobsApplyRepository->checkApplyJobs($check_where, $jobs_id);
  1139. $check_jobs = $this->dealCheckJobs($check_jobs_res);
  1140. //申请职位
  1141. $list = array();
  1142. $success = 0;
  1143. $points = 0;
  1144. $space_days = config('aix.personal_set.per_set.per_set.apply_job_space');
  1145. foreach ($jobs_id as $val) {
  1146. $jobs_name = $jobs[$val]->jobs_name;
  1147. $list[$val] = array('id' => $val, 'jobs_name' => $jobs_name, 'company_id' => $jobs[$val]->company_id, 'company_name' => $jobs[$val]->company_name, 'status' => 0);
  1148. //检测职位是否有效
  1149. if ($jobs[$val]->valid == 0 || $jobs[$val]->display != 1) {
  1150. if (count($jobs_id)==1) {
  1151. return array('status'=>0,'error'=>"该职位已关闭!");
  1152. } else {
  1153. $list[$val]['tip'] = '该职位已关闭';
  1154. $list[$val]['status'] = 4;
  1155. continue;
  1156. }
  1157. }
  1158. //判断是否申请过当前职位
  1159. if (array_get($check_jobs, $val)) {
  1160. if (count($jobs_id)==1) {
  1161. return array('status'=>0,'error'=>$space_days . '天内不允许重复申请!');
  1162. } else {
  1163. $list[$val]['tip'] = $space_days . '天内不允许重复申请';
  1164. $list[$val]['status'] = 3;
  1165. continue;
  1166. }
  1167. }
  1168. //申请职位
  1169. $time = date('Y-m-d H:i:s', time());
  1170. $apply_data = array(
  1171. 'resume_id' => $resume_info->id,
  1172. 'resume_name' => $resume_info->title,
  1173. 'personal_uid' => $resume_info->uid,
  1174. 'jobs_id' => $val,
  1175. 'jobs_name' => $jobs[$val]->jobs_name,
  1176. 'company_id' => $jobs[$val]->company_id,
  1177. 'company_name' => $jobs[$val]->company_name,
  1178. 'personal_look' => 1,
  1179. 'notes' => '',
  1180. 'is_reply' => 0,
  1181. 'is_apply' => 1,
  1182. 'created_at' => $time,
  1183. 'updated_at' => $time
  1184. );
  1185. $apply_rst = $this->personalJobsApplyRepository->addData($apply_data);
  1186. if ($apply_rst) {
  1187. //判断会员套餐中投递的简历是否免费查看,如果免费查看则判断当前企业是否有下载过该简历,没有下载则添加下载对应关系
  1188. if (array_has($com_setmeals, $jobs[$val]->company_id)) {
  1189. $com_setmeal = $com_setmeals[$jobs[$val]->company_id];
  1190. if ((!$down_companys) || ($down_companys && !array_has($down_companys, $jobs[$val]->company_id))) {
  1191. if ($com_setmeal->expire == 0 && $com_setmeal->show_apply_contact == 1) {
  1192. $down_data = array(
  1193. 'resume_id' => $resume_info->id,
  1194. 'resume_name' => $resume_info->title,
  1195. 'resume_uid' => $resume_info->uid,
  1196. 'company_uid' => $com_setmeal->uid,
  1197. 'company_name' => $jobs[$val]->company_name,
  1198. 'down_addtime' => time(),
  1199. 'is_reply' => 0
  1200. );
  1201. $this->companyDownResumeRepository->create($down_data);
  1202. }
  1203. }
  1204. }
  1205. /*if (count($jobs_id)==1) {
  1206. return array('status'=>1,'msg'=> '投递成功!');
  1207. }*/
  1208. $insertid = $apply_rst->id;
  1209. $list[$val]['tip'] = '投递成功';
  1210. $list[$val]['status'] = 1;
  1211. $success++;
  1212. //修改任务记录、积分信息
  1213. $task_rst = $this->taskService->doTask(4);
  1214. if (array_get($task_rst, 'code') == 1) {
  1215. $points += $task_rst['data']['points'];
  1216. }
  1217. //添加企业访客记录
  1218. $this->companyService->addStatistics($jobs[$val]->company_id, $val, $user, 1, 3);
  1219. //职位联系信息
  1220. $contacts = '';
  1221. $contacts = $this->jobsContactRepository->getContactInfo(array('job_id' => $val));
  1222. //简历基本信息
  1223. $resume_basicinfo = $this->resumeRepository->getResumeBasic(auth('web-member')->user()->id, $resume_info->id);
  1224. //发送站内信
  1225. $replac_pms = array();
  1226. $replac_pms['personalfullname'] = $resume_basicinfo->fullname;
  1227. //TODO 发送邮件
  1228. //发送短信
  1229. //微信
  1230. } else {
  1231. if (count($jobs_id)==1) {
  1232. return array('status'=>0,'error'=> '申请职位失败!');
  1233. }
  1234. $list[$val]['tip'] = '申请职位失败';
  1235. }
  1236. }
  1237. //判断申请职位是否有任务
  1238. $task_check = $this->taskService->checkTask(4);
  1239. //获取会员积分信息
  1240. $points_info = $this->memberPointRepository->getPointsOne($user->id, 2);
  1241. if (count($jobs_id)==1) {
  1242. return array('status'=>1,'msg'=> '投递成功!');
  1243. }
  1244. return array('status' => 1, 'data' => array('count_jids' => count($jobs_id), 'list' => $list, 'total' => count($jobs_id), 'points' => $points, 'success' => $success, 'failure' => count($jobs_id) - $success), 'points_info' => $points_info, 'show_points' => $task_check, 'resume_id' => $resume_info->id);
  1245. }
  1246. /*
  1247. * 平板邀请
  1248. */
  1249. public function padSaveApply($request,$user)
  1250. {
  1251. $data['jobs_id'] = $request->jobs_id ? $request->jobs_id : 0;
  1252. $data['resume_id'] = $request->resume_id ? $request->resume_id : 0;
  1253. $date = $request->date ? $request->date : '';
  1254. $type = $request->type ? $request->type : 1;
  1255. //职位状态是未发布中的。
  1256. $jobs_map['company_id'] = $user->id;
  1257. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  1258. $jobs_map['audit'] = 1;
  1259. }
  1260. $jobs_map['display'] = 1;
  1261. $jobs = $this->jobsRepository->jobsList($jobs_map);
  1262. if ($jobs) {
  1263. $jobs = $jobs->toArray();
  1264. }
  1265. $jobs_idarr = array_column($jobs, 'id');
  1266. if (!in_array($data['jobs_id'], $jobs_idarr)) {
  1267. return response()->json(['status' => 0, 'msg' => '求职者投递的职位状态为未发布,请确认职位状态']);
  1268. }
  1269. if (!$date) {
  1270. return response()->json(['status' => 0, 'msg' => '请选择面试日期']);
  1271. }
  1272. $ap = ($request->ap == 2 ? 0 : 1) ? "AM" : 'PM';
  1273. $time = $request->time ? $request->time : 0;
  1274. if (!$time) {
  1275. return response()->json(['status' => 0, 'msg' => '请选择面试时间']);
  1276. }
  1277. $data['interview_time'] = strtotime($date . ' ' . $time . ":00:00" . $ap);
  1278. if ($data['interview_time'] < time()) {
  1279. return response()->json(['status' => 0, 'msg' => '面试时间不能早于当前时间']);
  1280. }
  1281. $data['address'] = $request->address ? $request->address : '';
  1282. $data['contact'] = $request->contact ? $request->contact : '';
  1283. $data['telephone'] = $request->telephone ? $request->telephone : '';
  1284. $data['notes'] = $request->notes ? $request->notes : '';
  1285. $data['sms_notice'] = $request->sms_notice ? $request->sms_notice : 0;
  1286. $res = $this->padAddInterview($data, $user,$type);
  1287. return response()->json(['status' => $res['status'], 'msg' => $res['msg'],'back_url'=>$res['back_url'] ?? '']);
  1288. }
  1289. public function padAddInterview($data, $user,$type)
  1290. {
  1291. $sms_notice = $data['sms_notice'];
  1292. unset($data['sms_notice']);
  1293. if ($user->user_status == 2) {
  1294. return ['status' => 0, 'msg' => '您的账号处于暂停状态,请联系管理员设为正常后进行操作'];
  1295. }
  1296. if (!$data['resume_id']) {
  1297. return ['status' => 0, 'msg' => '请选择简历'];
  1298. }
  1299. $user_jobs = $this->jobsfairPutJobService->countAuditJobsNum($user);
  1300. if (!$user_jobs) {
  1301. return ['status' => 0, 'msg' => '邀请失败,你没有发布招聘信息或者信息没有审核通过'];
  1302. }
  1303. if ($this->companyInterviewRepository->checkInterview($data['resume_id'], $user->id, $data['jobs_id'])) {
  1304. return ['status' => 0, 'msg' => '您已对该简历进行过面试邀请,不能重复邀请'];
  1305. }
  1306. $setmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, $user->utype);
  1307. $resume = $this->resumeRepository->getResume($data['resume_id']);
  1308. $pass = false;
  1309. //检测是否申请过职位
  1310. $has = $this->personalJobsApplyRepository->checkJobsApply($data['resume_id'], $user->id, $data['jobs_id']);
  1311. $has && $pass = true;
  1312. if ($setmeal->show_apply_contact == 0 && $pass == true) {
  1313. $pass = false;
  1314. }
  1315. if (config('aix.personal_set.per_set.contact_set.show_resume_contact') == 2) {
  1316. if ($pass == false && $user->id) {
  1317. $where['resume_id'] = $data['resume_id'];
  1318. $where['company_uid'] = $user->id;
  1319. $info = $this->companyDownResumeRepository->getDownResume($where);
  1320. $info && $pass = true;
  1321. }
  1322. if (false == $pass && $type == 1) {
  1323. return ['status' => 0, 'msg' => '请先下载简历!'];
  1324. }
  1325. }
  1326. $jobInfo = $this->jobsRepository->getAuditJobsOne(['id' => $data['jobs_id']]);
  1327. $_resume_fullname = $resume->fullname;
  1328. if ($resume->display_name == 0) {
  1329. $data['resume_name'] = "N" . str_pad($resume->id, 7, "0", STR_PAD_LEFT);
  1330. } elseif ($resume->display_name == 3) {
  1331. if ($resume->sex == 1) {
  1332. $data['resume_name'] = cut_str($resume->fullname, 1, 0, "先生");
  1333. } elseif ($resume->sex == 2) {
  1334. $data['resume_name'] = cut_str($resume->fullname, 1, 0, "女士");
  1335. }
  1336. } else {
  1337. $data['resume_name'] = $resume['fullname'];
  1338. }
  1339. $data['resume_addtime'] = strtotime($resume->created_at);
  1340. $data['resume_uid'] = $resume->uid;
  1341. $data['jobs_name'] = $jobInfo->jobs_name;
  1342. $data['company_id'] = $user->id;
  1343. $data['jobs_addtime'] = strtotime($jobInfo->created_at);
  1344. $data['company_name'] = $user->companyname;
  1345. $data['company_addtime'] = strtotime($user->created_at);
  1346. $data['interview_addtime'] = time();
  1347. DB::beginTransaction();//检查数据库事务
  1348. try {
  1349. if (false === $this->companyInterviewRepository->create($data)) {
  1350. throw new \Exception('邀请面试失败!');
  1351. }
  1352. $map['resume_id'] = $data['resume_id'];
  1353. $map['jobs_id'] = $data['jobs_id'];
  1354. $map['company_id'] = $user->id;
  1355. if ($has) {
  1356. if (!$this->personalJobsApplyRepository->updateApply($map)) {
  1357. throw new \Exception('状态修改失败,邀请面试失败!');
  1358. }
  1359. }
  1360. //短信
  1361. if ($sms_notice) {
  1362. $this->smsService->sendSms($resume->memberInfos->phone, Smser::TEMPLATE_JOB_INVITE, ['sitename'=>subsite_config('aix.system.site.site.site_name'),'companyname'=>$user->companyname,'sitedomain'=>config('aix.system.site.site.site_domain')]);
  1363. }
  1364. DB::commit();
  1365. } catch (\Exception $e) {
  1366. DB::rollback();
  1367. return ['status' => 0, 'msg' => $e->getMessage()];
  1368. }
  1369. if($type == 1){
  1370. $back_url = route('hardware.pad.search.resume');
  1371. }elseif($type == 2 || $type == 5){
  1372. $back_url = route('hardware.pad.receive.list');
  1373. }else{
  1374. $back_url = route('hardware.pad.interview.list');
  1375. }
  1376. return array('status' => 1,'msg'=>'邀请面试成功','back_url'=>$back_url);//增加面试邀请
  1377. }
  1378. //判断下载的简历是否是已投简历
  1379. public function isOwn($y_id,$user,$column)
  1380. {
  1381. $idsArr = $this->personalJobsApplyRepository->getPluck(['company_id'=>$user->id],$column)->toArray();
  1382. if(array_diff($y_id,$idsArr))
  1383. {
  1384. throw new ResponseException('参数错误!');
  1385. }
  1386. }
  1387. }