123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482 |
- <?php
- /**
- * Created by PhpStorm.
- * User: wuzhenke
- * Date: 2018/11/20
- * Time: 11:19
- */
- namespace App\Services\Company;
- use Aix\Sms\Contracts\Smser;
- use App\Exceptions\ResponseException;
- use App\Models\Company;
- use App\Models\CompanyDownResume;
- use App\Models\Member;
- use App\Models\PersonalJobsApply;
- use App\Models\Resume;
- use App\Repositories\CompanyDownResumeRepository;
- use App\Repositories\CompanyInterviewRepository;
- use App\Repositories\CompanyRepository;
- use App\Repositories\JobsRepository;
- use App\Repositories\MemberLogRepository;
- use App\Repositories\MemberRepository;
- use App\Repositories\MemberSetmealRepository;
- use App\Repositories\PersonalJobsApplyRepository;
- use App\Repositories\ResumeEducationRepository;
- use App\Repositories\ResumeRepository;
- use App\Repositories\ResumeTrainRepository;
- use App\Repositories\ResumeWorkRepository;
- use App\Repositories\JobsContactRepository;
- use App\Repositories\MemberPointRepository;
- use App\Services\Common\EmailService;
- use App\Services\Common\WechatService;
- use App\Services\Jobfair\JobfairPutJobService;
- use App\Repositories\Jobfair\JobfairPutJobRepository;
- use App\Repositories\SmsRepository;
- use App\Repositories\SmsRuleRepository;
- use App\Services\Common\TaskService;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\Storage;
- use Chumper\Zipper\Zipper;
- use App\Services\Common\SmsService;
- use App\Repositories\ResumeLanguageRepository;
- use App\Repositories\ResumeCredentRepository;
- class PersonalJobsApplyService
- {
- protected $personalJobsApplyRepository;
- protected $resumeRepository;
- protected $taskService;
- protected $jobsRepository;
- protected $companyDownResumeRepository;
- protected $companyRepository;
- protected $companyInterviewRepository;
- protected $memberSetmealRepository;
- protected $resumeEducationRepository;
- protected $resumeWorkRepository;
- protected $resumeTrainRepository;
- protected $memberRepository;
- protected $jobsContactRepository;
- protected $memberPointRepository;
- protected $companyService;
- protected $jobsfairPutJobService;
- protected $jobfairPutJobRepository;
- protected $smsRepository;
- protected $smsRuleRepository;
- protected $smsService;
- protected $ResumeLanguageRepository;
- protected $ResumeCredentRepository;
- protected $memberLogRepository;
- protected $serviceService;
- protected $emailService;
- protected $wechatService;
- /**
- * PersonalJobsApplyService constructor.
- * @param $personalJobsApplyRepository
- * @param $taskService
- * @param $jobsRepository
- * @param $companyDownResumeRepository
- * @param $resumeRepository
- * @param $companyRepository
- * @param $companyInterviewRepository
- * @param $memberSetmealRepository
- * @param $resumeEducationRepository
- * @param $resumeWorkRepository
- * @param $resumeTrainRepository
- * @param $memberRepository
- * @param $jobsContactRepository ;
- * @param $memberPointRepository ;
- * @param $companyService
- * @param $jobsfairPutJobService
- * @param $jobfairPutJobRepository
- * @param $smsRepository
- * @param $smsRuleRepository
- * @param $smsService
- * @param $ResumeLanguageRepository
- * @param $ResumeCredentRepository
- * @param $memberLogRepository
- * @param $serviceService
- */
- public function __construct(
- PersonalJobsApplyRepository $personalJobsApplyRepository,
- MemberSetmealRepository $memberSetmealRepository,
- CompanyInterviewRepository $companyInterviewRepository,
- CompanyRepository $companyRepository,
- ResumeRepository $resumeRepository,
- JobsRepository $jobsRepository,
- TaskService $taskService,
- CompanyDownResumeRepository $companyDownResumeRepository,
- ResumeEducationRepository $resumeEducationRepository,
- ResumeWorkRepository $resumeWorkRepository,
- ResumeTrainRepository $resumeTrainRepository,
- MemberRepository $memberRepository,
- JobsContactRepository $jobsContactRepository,
- MemberPointRepository $memberPointRepository,
- CompanyService $companyService,
- JobfairPutJobService $jobsfairPutJobService,
- JobfairPutJobRepository $jobfairPutJobRepository,
- SmsRepository $smsRepository,
- SmsRuleRepository $smsRuleRepository,
- SmsService $smsService,
- ResumeLanguageRepository $ResumeLanguageRepository,
- ResumeCredentRepository $ResumeCredentRepository,
- MemberLogRepository $memberLogRepository,
- ServiceService $serviceService,
- EmailService $emailService,
- WechatService $wechatService
- )
- {
- $this->personalJobsApplyRepository = $personalJobsApplyRepository;
- $this->taskService = $taskService;
- $this->jobsRepository = $jobsRepository;
- $this->companyDownResumeRepository = $companyDownResumeRepository;
- $this->resumeRepository = $resumeRepository;
- $this->companyRepository = $companyRepository;
- $this->companyInterviewRepository = $companyInterviewRepository;
- $this->memberSetmealRepository = $memberSetmealRepository;
- $this->resumeEducationRepository = $resumeEducationRepository;
- $this->resumeWorkRepository = $resumeWorkRepository;
- $this->resumeTrainRepository = $resumeTrainRepository;
- $this->memberRepository = $memberRepository;
- $this->jobsContactRepository = $jobsContactRepository;
- $this->memberPointRepository = $memberPointRepository;
- $this->companyService = $companyService;
- $this->jobsfairPutJobService = $jobsfairPutJobService;
- $this->jobfairPutJobRepository = $jobfairPutJobRepository;
- $this->smsRepository = $smsRepository;
- $this->smsRuleRepository = $smsRuleRepository;
- $this->smsService = $smsService;
- $this->ResumeLanguageRepository = $ResumeLanguageRepository;
- $this->ResumeCredentRepository = $ResumeCredentRepository;
- $this->memberLogRepository=$memberLogRepository;
- $this->serviceService=$serviceService;
- $this->emailService=$emailService;
- $this->wechatService=$wechatService;
- }
- public function resumeApply($request, $user)
- {
- $jobs_id = isset($request['jobs_id']) ? $request['jobs_id'] : '';
- $stop = isset($request['stop']) ? $request['stop'] : 0;
- $state = isset($request['state']) ? $request['state'] : 0;
- $is_reply = isset($request['is_reply']) ? $request['is_reply'] : 0;
- $is_apply = isset($request['is_apply']) ? $request['is_apply'] : 0;
- $settr = isset($request['settr']) ? $request['settr'] : 0;
- $where['company_id'] = $user->id;
- if ($is_reply == 0) {
- $where['is_reply'] = 0;
- } else {
- $where[] = ['is_reply', '>', 0];
- }
- if ($jobs_id) {
- $where['jobs_id'] = $jobs_id;
- }
- if ($is_apply) {
- $where['is_apply'] = $is_apply;
- }
- if ($settr) {
- $where[] = ['created_at', '>=', date('Y-m-d H:i:s', strtotime("-{$settr} day"))];
- }
- $condition['company_id'] = $user->id;
- if (!$stop) {
- $condition[] = ['valid', '=', 1];
- $condition[] = ['display', '=', 1];
- }
- if (!$stop && config('aix.companyset.comset.show_set.jobs_display') == 1) {
- $condition = ['audit' => 1];
- }
- $jobs = $this->jobsRepository->applyJobs($condition, $user->id);
- $jobs_list = array_column($jobs, 'jobs_name', 'id');
- $param_array = array('jobs_id', 'stop', 'state', 'is_reply', 'settr');
- $params = array();
- if ($request) {
- foreach ($request as $k => $v) {
- if (in_array($k, $param_array)) {
- $params[$k] = $v;
- }
- }
- }
- if ($state) {
- $where['is_reply'] = $state;
- }
- $page = 10;
- $apply_list = $this->personalJobsApplyRepository->getResume($where, $page);
- //是否回复(1:企业未查看,2:待反馈,3:合适,4:不合适,5:待定,6:未接通)
- $state_arr = ['1' => '合适', '2' => '不合适', '3' => '待定', '4' => '未接通'];
- $date1 = time();
- $date2 = $date1 - 3600 * 24 * 14;
- //近两周收到的简历
- $count1 = $this->personalJobsApplyRepository->twoWeeksTotal($user->id);
- //近两周处理收到的简历
- $count2 = $this->personalJobsApplyRepository->twoWeeksReplyTotal($user->id);
- //处理率
- $count = $count1 ? (round($count2 / $count1, 2) * 100) : 0;
- $count = $count2 ? $count : 0;
- $hasget=0;
- if ($params) {
- $hasget = 1;
- }
- $this->serviceService->freeSetmealIsOver($user);
- $res = [
- 'is_reply' => $is_reply,
- 'is_apply' => $is_apply,
- 'stop' => $stop,
- 'state' => $state,
- 'result' => $apply_list,
- 'state_arr' => $state_arr,
- 'jobs_id' => $jobs_id,
- 'jobs_list' => $jobs_list,
- 'date' => date('Y/m/d', $date2),
- 'params' => $params,
- 'count1' => $count1,
- 'count2' => $count2,
- 'count' => $count,
- 'hasget' => $hasget,
- 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
- ];
- return $res;
- }
- public function resumeApplyMobile($request, $user)
- {
- $jobs_id = isset($request['jobs_id']) ? $request['jobs_id'] : '';
- $stop = isset($request['stop']) ? $request['stop'] : 0;
- $state = isset($request['state']) ? $request['state'] : 0;
- $is_reply = isset($request['is_reply']) ? $request['is_reply'] : 0;
- $is_apply = isset($request['is_apply']) ? $request['is_apply'] : 0;
- $settr = isset($request['settr']) ? $request['settr'] : 0;
- $where['company_id'] = $user->id;
- if ($jobs_id) {
- $where['jobs_id'] = $jobs_id;
- }
- if ($is_apply) {
- $where['is_apply'] = $is_apply;
- }
- if ($settr) {
- $where[] = ['created_at', '>=', date('Y-m-d H:i:s', strtotime("-{$settr} day"))];
- }
- $condition['company_id'] = $user->id;
- if (!$stop) {
- $condition[] = ['valid', '=', 1];
- $condition[] = ['display', '=', 1];
- }
- if (!$stop && config('aix.companyset.comset.show_set.jobs_display') == 1) {
- $condition = ['audit' => 1];
- }
- $jobs = $this->jobsRepository->applyJobs($condition, $user->id);
- $jobs_list = array_column($jobs, 'jobs_name', 'id');
- $param_array = array('jobs_id', 'stop', 'state', 'is_reply', 'settr');
- $params = array();
- if ($request) {
- foreach ($request as $k => $v) {
- if (in_array($k, $param_array)) {
- $params[$k] = $v;
- }
- }
- }
- if ($state) {
- $where['is_reply'] = $state;
- }
- $page = 10;
- $apply_list = $this->personalJobsApplyRepository->getResume($where, $page);
- //是否回复(1:企业未查看,2:待反馈,3:合适,4:不合适,5:待定,6:未接通)
- $state_arr = ['1' => '合适', '2' => '不合适', '3' => '待定', '4' => '未接通'];
- $date1 = time();
- $date2 = $date1 - 3600 * 24 * 14;
- //近两周收到的简历
- $count1 = $this->personalJobsApplyRepository->twoWeeksTotal($user->id);
- //近两周处理收到的简历
- $count2 = $this->personalJobsApplyRepository->twoWeeksReplyTotal($user->id);
- //处理率
- $count = $count1 ? (round($count2 / $count1, 2) * 100) : 0;
- $count = $count2 ? $count : 0;
- $hasget=0;
- if ($params) {
- $hasget = 1;
- }
- $res = [
- 'is_reply' => $is_reply,
- 'is_apply' => $is_apply,
- 'stop' => $stop,
- 'state' => $state,
- 'result' => $apply_list,
- 'state_arr' => $state_arr,
- 'jobs_id' => $jobs_id,
- 'jobs_list' => $jobs_list,
- 'date' => date('Y/m/d', $date2),
- 'params' => $params,
- 'count1' => $count1,
- 'count2' => $count2,
- 'count' => $count,
- 'hasget' => $hasget,
- 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
- ];
- return $res;
- }
- public function labelApply($id, $state, $user)
- {
- if (!$id) {
- return response()->json(['status' => 0, 'msg' => '请选择简历!']);
- }
- $old_info = $this->personalJobsApplyRepository->find($id);
- DB::beginTransaction();//检查数据库事务
- try {
- $r = ['code'=>0];
- $data = [
- 'is_reply' => $state,
- 'personal_look' => 2,
- 'reply_time' => time()
- ];
- if (false == $this->personalJobsApplyRepository->companyLabelResume($id, $data)) {
- throw new \Exception('标记失败!');
- }
- if ($old_info && ((time() - strtotime($old_info->created_at)) <= 86400 * 3)) {
- $r = $this->taskService->doTask(28, $user->id, $user->utype);
- }
- //添加日志
- DB::commit();
- $this->memberLogRepository->createLog($user,1029,[$id,$state]);
- return response()->json(['status' => 1, 'msg' => '标记成功', 'data' => $r]);
- } catch (\Exception $e) {
- DB::rollback();
- return response()->json(['status' => 0, 'msg' => $e->getMessage()]);
- }
- }
- /**
- * 删除简历申请
- * @param $request
- * @return \Illuminate\Http\JsonResponse
- * @param $user
- */
- public function delJobsApply($request,Company $user)
- {
- $id = isset($request['id']) ? $request['id'] : 0;
- if (!$id) {
- return response()->json(['status' => 0, 'msg' => '参数错误!']);
- }
- $ids = is_array($id) ? $id : explode(',', $id);
- if (!$this->personalJobsApplyRepository->delJobsApply($ids,$user->id)) {
- return response()->json(['status' => 0, 'msg' => '删除失败!']);
- }
- return response()->json(['status' => 1, 'msg' => '删除成功!']);
- }
- /**
- * 返回面试邀请模态框
- * @param $request
- * @return \Illuminate\Http\JsonResponse
- * @throws \Throwable
- */
- public function getApply($request, $user)
- {
- $mySetmeal = $this->memberSetmealRepository->findWhere(['uid'=>$user->id]);
- if (config('aix.companyset.audit.checkset.login_com_audit_certificate') == 1) {
- if ($user->audit != 1) {
- return response()->json(['status' => 0, 'msg' => "请上传企业营业执照或审核通过后,再进行其他操作"]);
- }
- }
- //正确的套餐,已经过期,不免费,过期时间不为0
- if ($mySetmeal[0]->setmeal_id > 0 && $mySetmeal[0]->expire ==1 && $mySetmeal[0]->is_free == 0 && $mySetmeal[0]->endtime!=0) {
- return response()->json(['status' => 0, 'msg' => "会员套餐已到期,请续费"]);
- }
- //20200217 zmw 去掉单位性质 和产业类别
- //if (!$user->nature || !$user->scale || !$user->organization_code || !$user->unit_character || !$user->industry || !$user->economy || !$user->district || !$user->trade || !$user->contents) {
- if (!$user->nature || !$user->scale || !$user->organization_code || !$user->district || !$user->trade || !$user->contents) {
- return response()->json(['status' => 0, 'msg' => "请完善企业基本信息后,再进行其他操作"]);
- }
- $is_apply = 2;
- $resume_id = isset($request['resume_id'])?$request['resume_id']:0;
- if (!$resume_id) {
- return response()->json(['status' => 0, 'msg' => "请先下载简历!"]);
- }
- $jobs_id = isset($request['jobs_id'])?$request['jobs_id']:0;
- if ($jobs_id) {
- $contatin[] = ['jobs_id', '=', $jobs_id];
- }
- $contatin = [
- ['resume_id', '=', $resume_id],
- ['company_id', '=', $user->id],
- ];
- $apply = $this->personalJobsApplyRepository->getOne($contatin);
- if ($apply) {
- $is_apply = 1;
- }
- if (config('aix.personal_set.per_set.contact_set.show_resume_contact') == 2) {
- $downData = [
- 'resume_id' => $resume_id,
- 'company_uid' => $user->id,
- ];
- if (!$apply) {
- $apply = $this->companyDownResumeRepository->getDownResume($downData);
- $is_apply = 2;
- }
- if (!$apply) {
- return response()->json(['status' => 0, 'msg' => "请先下载简历!"]);
- }
- } elseif (!$apply) {
- $apply = $this->resumeRepository->find($resume_id, ['id as resume_id', 'uid as resume_uid', 'fullname as resume_name']);
- if ($apply) {
- $is_apply = 2;
- }
- }
- if ($apply) {
- $apply = $apply->toArray();
- }
- $companyInfo = $this->companyRepository->findWhere(['id' => $user->id], ['district', 'contact', 'mobile', 'landline_tel', 'address'])->toArray();
- $apply = array_merge($apply, $companyInfo[0]);
- $apply['fullname'] = $this->resumeRepository->find($resume_id, ['fullname']);
- $jobs_map['company_id'] = $user->id;
- if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
- $jobs_map['audit'] = 1;
- }
- $jobs_map['valid'] = 1;
- $jobs = $this->jobsRepository->jobsList($jobs_map);
- if ($jobs) {
- $jobs = $jobs->toArray();
- $jobs_idarr = array_column($jobs, 'id');
- if (!isset($apply['jobs_id']) || !in_array($apply['jobs_id'], $jobs_idarr)) {
- $is_apply = 2;
- }
- foreach ($jobs as $key => $val) {
- $jobslist[$val['id']] = $val;
- }
- } else {
- $jobslist = [];
- $is_apply = 2;
- }
- if (isset($jobslist)) {
- $temp = current($jobslist);
- $default_jobs['jobs_id'] = $temp['id'];
- $default_jobs['jobs_name'] = $temp['jobs_name'];
- } else {
- return response()->json(['status' => 0, 'msg' => '您还没有发布职位或没有审核通过的职位']);
- }
- $data = [
- 'jobs' => $jobslist,
- 'default_jobs' => $default_jobs,
- 'is_apply' => $is_apply,
- 'apply' => $apply,
- ];
- return response()->json(['status' => 1, 'msg' => '获取数据成功!', 'data' => view('app.company.ajax.ajax_interview', $data)->render()]);
- }
- public function saveApply($request,$user)
- {
- $data['jobs_id'] = $request->jobs_id ? $request->jobs_id : 0;
- $data['resume_id'] = $request->resume_id ? $request->resume_id : 0;
- $data['personal_jobs_id'] = $request->personal_jobs_id ? $request->personal_jobs_id : 0; //重复投递的功能,带上投递ID
- $date = $request->date ? $request->date : '';
- $type = $request->type;
- //验证这个简历我是否下载过和是否收到过
- $this->isCanInterview($data['resume_id'],$user->id);
- //职位状态是未发布中的。
- $jobs_map['company_id'] = auth('web-company')->user()->id;
- if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
- $jobs_map['audit'] = 1;
- }
- $jobs_map['valid'] = 1;
- $jobs_map['display'] = 1;
- $jobs = $this->jobsRepository->jobsList($jobs_map);
- if ($jobs) {
- $jobs = $jobs->toArray();
- }
- $jobs_idarr = array_column($jobs, 'id');
- if (!in_array($data['jobs_id'], $jobs_idarr)) {
- return response()->json(['status' => 0, 'msg' => '求职者投递的职位状态为未发布,请确认职位状态']);
- }
- if (!$date) {
- return response()->json(['status' => 0, 'msg' => '请选择面试日期']);
- }
- $ap = ($request->ap == 2 ? 0 : 1) ? "AM" : 'PM';
- $time = $request->time ? $request->time : 0;
- if (!$time) {
- return response()->json(['status' => 0, 'msg' => '请选择面试时间']);
- }
- $data['interview_time'] = strtotime($date . ' ' . $time . ":00:00" . $ap);
- if ($data['interview_time'] < time()) {
- return response()->json(['status' => 0, 'msg' => '面试时间不能早于当前时间']);
- }
- $data['address'] = $request->address ? $request->address : '';
- if(!$data['address']){
- return response()->json(['status' => 0, 'msg' => '面试地址不能为空!']);
- }
- $data['contact'] = $request->contact ? $request->contact : '';
- if(!$data['contact']){
- return response()->json(['status' => 0, 'msg' => '联系人不能为空!']);
- }
- $data['telephone'] = $request->telephone ? $request->telephone : '';
- if(!$data['telephone']){
- return response()->json(['status' => 0, 'msg' => '联系电话不能为空!']);
- }
- $data['notes'] = $request->notes ? $request->notes : '';
- $data['sms_notice'] = $request->sms_notice ? $request->sms_notice : 0;
- $res = $this->addInterview($data, auth('web-company')->user(),$type);
- $user = auth('web-company')->user();
- // if($res['status']){
- // if($data['resume_id']){
- // $resume = Resume::find($data['resume_id']);
- // if($resume){
- // $member = Member::find($resume->uid);
- // $this->wechatService->sendTemplateMessage($member, 'set_invite',[
- // 'job'=>[$res['jobs_name'],'#0000ff'],
- // 'company'=>[$user->companyname,'#0000ff'],
- // 'time'=>[date('Y-m-d H:i:s',$data['interview_time']),'#0000ff'],
- // 'address'=>[$data['address'],'#0000ff'],
- // 'contact'=>[$data['contact'],'#0000ff'],
- // 'tel'=>[$data['telephone'],'#0000ff']
- // ], route('mobile.person.jobs_interview'));
- // }
- // }
- // }
- if (!$this->memberLogRepository->createLog($user,1010,[$data['jobs_id'],$data['resume_id']])) {
- throw new \Exception('日志记录失败');
- }
- return response()->json(['status' => $res['status'], 'msg' => $res['msg']]);
- }
- /**
- * 是否可以邀请面试
- * @param $resume_id
- * @param $company_id
- */
- public function isCanInterview($resume_id,$company_id){
- $isOk_person=$this->personalJobsApplyRepository->findJobsApply($resume_id,$company_id);
- $isOK_down=$this->companyDownResumeRepository->findWhere(["company_uid"=>$company_id,'resume_id'=>$resume_id])->first();
- if (empty($isOK_down) && empty($isOk_person)){
- throw new ResponseException(AjaxError("没有下载或者没有收到过改简历"));
- }
- }
- public function addInterview($data, $user,$type)
- {
- $sms_notice = $data['sms_notice'];
- unset($data['sms_notice']);
- if ($user->user_status == 2) {
- return ['status' => 0, 'msg' => '您的账号处于暂停状态,请联系管理员设为正常后进行操作'];
- }
- if (!$data['resume_id']) {
- return ['status' => 0, 'msg' => '请选择简历'];
- }
- $user_jobs = $this->jobsRepository->countAuditJobsNum();
- if (!$user_jobs) {
- return ['status' => 0, 'msg' => '邀请失败,你没有发布招聘信息或者信息没有审核通过'];
- }
- if ($this->companyInterviewRepository->checkInterview($data['resume_id'], $user->id, $data['jobs_id'],$data['personal_jobs_id'])) {
- return ['status' => 0, 'msg' => '您已对该简历进行过面试邀请,不能重复邀请'];
- }
- $setmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, $user->utype);
- $resume = $this->resumeRepository->getResumeMemInfo($data['resume_id']);
- $pass = false;
- //检测是否申请过职位
- // $has = $this->personalJobsApplyRepository->checkJobsApply($data['resume_id'], $user->id, $data['jobs_id']);
- /**职位要是申请过的,而且还得当前id的,咱才能改变是否查看
- 下载简历也用到了邀请面试,personal_jobs_id就为0 查不到就不需要改变状态直接添加邀请记录就可以了
- **/
- $has=$this->personalJobsApplyRepository->getPersonalJobByID($data['personal_jobs_id']);
- $has && $pass = true;
- if ($setmeal->show_apply_contact == 0 && $pass == true) {
- $pass = false;
- }
- if (config('aix.personal_set.per_set.contact_set.show_resume_contact') == 2) {
- if ($pass == false && $user->id) {
- $where['resume_id'] = $data['resume_id'];
- $where['company_uid'] = $user->id;
- $info = $this->companyDownResumeRepository->getDownResume($where);
- $info && $pass = true;
- }
- if (false == $pass && $setmeal->show_apply_contact == 0) { //如果套餐是免费查看的不提示!!
- return ['status' => 0, 'msg' => '请先下载简历!'];
- }
- }
- $jobInfo = $this->jobsRepository->getAuditJobsOne(['id' => $data['jobs_id']]);
- $_resume_fullname = $resume->fullname;
- if ($resume->display_name == 0) {
- $data['resume_name'] = "N" . str_pad($resume->id, 7, "0", STR_PAD_LEFT);
- } elseif ($resume->display_name == 3) {
- if ($resume->sex == 1) {
- $data['resume_name'] = cut_str($resume->fullname, 1, 0, "先生");
- } elseif ($resume->sex == 2) {
- $data['resume_name'] = cut_str($resume->fullname, 1, 0, "女士");
- }
- } else {
- $data['resume_name'] = $resume['fullname'];
- }
- $data['resume_addtime'] = strtotime($resume->created_at);
- $data['resume_uid'] = $resume->uid;
- $data['jobs_name'] = $jobInfo->jobs_name;
- $data['company_id'] = $user->id;
- $data['jobs_addtime'] = strtotime($jobInfo->created_at);
- $data['company_name'] = $user->companyname;
- $data['company_addtime'] = strtotime($user->created_at);
- $data['interview_addtime'] = time();
- $data['explan'] = time();//注解字段
- DB::beginTransaction();//检查数据库事务
- try {
- if (false === $this->companyInterviewRepository->create($data)) {
- throw new \Exception('邀请面试失败!');
- }
- if($type==1){
- }else{
- CompanyDownResume::where(['resume_id'=>$resume->id,'company_uid'=>$user->id])->update(['is_reply'=>1]);
- }
- // $map['resume_id'] = $data['resume_id'];
- // $map['jobs_id'] = $data['jobs_id'];
- // $map['company_id'] = $user->id;
- $map['id'] = $data['personal_jobs_id'];
- if ($has) {
- if (!$this->personalJobsApplyRepository->updateApply($map)) {
- throw new \Exception('状态修改失败,邀请面试失败!');
- }
- }
- //短信
- if ($sms_notice) {
- $this->smsService->setCallback('App\Services\Company\CompanyService', 'sendSMSCallBack',[$user->id])
- ->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')]);
- }
- //发送邮件邀请
- if($resume->memberInfos){
- if($resume->memberInfos->email){
- $this->emailService->sendMail($resume->memberInfos->email,EmailService::TEMPLATE_INVITE_INTERVIEWS,['companyname'=>$user->companyname], ['companyname'=>$user->companyname,'sitedomain'=>route('person.index')]);
- }
- }
- DB::commit();
- } catch (\Exception $e) {
- DB::rollback();
- return ['status' => 0, 'msg' => $e->getMessage()];
- }
- return array('status' => 1, 'msg' => '邀请面试成功','jobs_name'=>$jobInfo->jobs_name);//增加面试邀请
- }
- public function saveAsDoc($id, $model)
- {
- switch ($model) {
- case 'personaljobsapply':
- $needModel = $this->personalJobsApplyRepository;
- break;
- case 'downresume':
- $needModel = $this->companyDownResumeRepository;
- break;
- }
- $idArr = $needModel->getResumeId($id);
- $resume_ids = array_column($idArr, 'resume_id');
- array_unique($resume_ids);
- if (false == $resumeList = $this->resumeRepository->getResumeList($resume_ids)) {
- return false;
- }
- $list = array();
- foreach ($resumeList as $key) {
- $resume = $key;
- $resume->education_list = $this->resumeEducationRepository->getResumeEducationByResumeId($resume->id);
- $resume->work_list = $this->resumeWorkRepository->getResumeWorkByResumeId($resume->id);
- $resume->training_list = $this->resumeTrainRepository->getResumeTrainByResumeId($resume->id);
- $resume->language_list = $this->ResumeLanguageRepository->getResumeLanByResumeId($resume->id); //语言能力
- $resume->credent_list = $this->ResumeCredentRepository->getResumeCredentByResumeId($resume->id); //获得证书
- $resume->age = date('Y') - $resume->memberInfos->birthday;
- $resume->tagcn = preg_replace("/\d+/", '', $resume->tag);
- $resume->tagcn = preg_replace("/\,/", '', $resume->tagcn);
- $resume->tagcn = preg_replace("/\|/", '', $resume->tagcn);
- //最近登录时间
- $last_login_time = $this->memberRepository->getFields($resume->uid, ['last_login_time']);
- $resume->last_login_time = date('Y-m-d', $last_login_time['last_login_time']);
- if ($resume->display_name == '3') {
- if ($resume->sex == 1) {
- $resume->fullname = cut_str($resume->fullname, 1, 0, "先生");
- } elseif ($resume->sex == 2) {
- $resume->fullname = cut_str($resume->fullname, 1, 0, "女士");
- }
- }
- $resume->has_down = false;
- $resume->is_apply = false;
- $resume->label_id = 0;
- $resume->contact = $this->getShowContact($resume, auth('web-company')->user());
- if ($resume->show_contact === false) {
- $resume->telephone = contact_hide($resume->telephone, 2);
- $resume->email = contact_hide($resume->email, 3);
- }
- $avatar_default = $resume->sex == 1 ? "data/upload/resource/no_photo_male.png" : "data/upload/resource/no_photo_female.png";
- if ($resume->memberInfos->photo == 1 && ($resume->memberInfos->photo_audit == 2 || config('aix.personal_set.per_set.show_set.resume_img_display') == 2)) {
- $resume->photosrc = upload_asset($resume->memberInfos->images);
- } else {
- $resume->photosrc = asset($avatar_default);
- }
- $list[] = $resume;
- }
- //压缩文件路径
- $zip_path = Storage::disk('public')->path('down_resume/' . auth('web-company')->user()->id.'.zip');
- if (file_exists($zip_path)) {
- Storage::disk('public')->delete('down_resume/' . auth('web-company')->user()->id.'.zip');
- }
- $zipper = new Zipper();
- $zipper->make($zip_path);
- foreach ($list as $key => $val) {
- $html = view('app.company.resume.tpl_word_resume', ['resume' => $val])->render();
- $zipper->addString(($key+1).'_'.$val->fullname.'的简历.doc', $html);
- }
- $zipper->close();
- return ['status' => 1, 'msg' => '下载成功!', 'path' => $zip_path];
- }
- /**
- * 是否显示联系方式
- */
- protected function getShowContact(&$val, $user)
- {
- $show_contact = false;
- //情景1:游客访问
- if (!$user) {
- if (config('aix.personal_set.per_set.contact_set.show_resume_contact') == 0) {
- $show_contact = true;
- }
- } else if ($user->utype == 2 && $user->id == $val->uid) { //情景2:个人会员访问并且是该简历发布者
- $show_contact = true;
- } elseif ($user->utype == 1) { //情景3:企业会员访问
- //情景3-1:其他企业会员
- if (config('aix.personal_set.per_set.contact_set.show_resume_contact') == 1) {
- $show_contact = true;
- }
- //情景3-2:下载过该简历
- $data['resume_id'] = $val->id;
- $data['company_uid'] = $user->id;
- $down_resume = $this->companyDownResumeRepository->getDownResume($data);
- if ($down_resume) {
- $val->label_id = $down_resume->is_reply;
- $show_contact = true;
- $val->has_down = true;
- }
- //情景3-3:该简历申请过当前企业发布的职位
- $jobs_apply = $this->personalJobsApplyRepository->checkJobsApply($val->id, $user->id);
- $setmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, $user->utype);
- if ($jobs_apply && $setmeal->show_apply_contact == '0') {
- $show_contact = true;
- }
- }
- return $show_contact;
- }
- /*
- * 申请职位
- */
- //判断是否可以申请职位
- public function ifJobApply($jobs_id, $user = array())
- {
- //获取当天已投递的职位数量,判断当天是否可以还可以投递简历
- $today_time = date('Y-m-d H:i:s', strtotime(date('Y-m-d', time())));
- $apply_where = array(
- array('personal_uid', '=', $user->id),
- array('created_at', '>=', $today_time)
- );
- $applyJobs = $this->personalJobsApplyRepository->applyJobs($apply_where);
- $allow_count = config('aix.personal_set.per_set.per_set.apply_jobs_max');
- if ($allow_count < count($applyJobs) + count($jobs_id)) {
- throw new ResponseException("您每天可以投递" . $allow_count . "个职位,今天已投递了" . count($applyJobs) . "个");
- }
- //判断是否有可以投递的简历
- $resume_audit = config('aix.personal_set.per_set.show_set.resume_display');
- $resume_where = array(array('uid', '=', $user->id));
- if (config('aix.personal_set.per_set.show_set.resume_display') == '1') {
- $resume_where[] = array('audit', '=', '2');
- } else {
- $resume_where[] = array('audit', '<>', '0');
- }
- $resumes = $this->resumeRepository->getResumes($resume_where);
- if (count($resumes) == 0) {
- //判断是否有简历
- $user_resumes = $this->resumeRepository->getResumes(array('uid' => auth('web-member')->user()->id));
- if ($user_resumes->toArray()) {
- throw new ResponseException("您没有审核通过的简历!");
- } else {
- throw new ResponseException("请您先填写一份简历!");
- }
- } else if (count($resumes) == 1) {
- //直接进入投递环节
- $resumes_arr = $resumes->toArray();
- return $this->applyJobs($jobs_id, $resumes_arr[0]['id'], $user);
- } else {
- //获取默认简历信息
- $def_resume = array();
- foreach ($resumes as $k => $v) {
- if ($v->def == '1') {
- $def_resume = $v;
- }
- }
- if (!$def_resume) {
- $def_resume = $resumes[0];
- }
- //提示用户选择需要投递的简历
- return array('status' => 2, 'resumes' => $resumes, 'def_resume' => $def_resume);
- }
- }
- //申请职位
- public function applyJobs($jobs_id, $resume_id = '', $user)
- {
- //判断简历是否存在
- if ($resume_id) {
- $resume_where = array('uid' => $user->id, 'id' => $resume_id);
- } else {
- $resume_where = array('uid' => $user->id, 'def' => 1);
- }
- $resume_info = $this->resumeRepository->getResumeInfo($resume_where);
- if (!$resume_info) {
- throw new ResponseException("选择的简历不存在!");
- }
- //判断简历是否要求通过审核
- if (config('aix.personal_set.per_set.show_set.resume_display') == '1') {
- if ($resume_info->audit != 2) {
- throw new ResponseException("您选择投递的简历尚未审核通过!");
- }
- } else {
- if ($resume_info->audit == 0) {
- throw new ResponseException("您选择投递的简历尚未审核通过!");
- }
- }
- //检测职位匹配的简历完整度要求
- if (config('aix.personal_set.per_set.per_set.apply_job_min_percent')) {
- if ($resume_info->complete_percent < config('aix.personal_set.per_set.per_set.apply_job_min_percent')) {
- 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);
- }
- }
- //获取简历的工作经历、教育经历
- $work_where = array(
- 'uid' => $user->id,
- 'resume_id' => $resume_info->id
- );
- $works = $this->resumeWorkRepository->getResumeWorks($work_where);
- if ($works->toArray()) {
- $resume_info->work = $works;
- }
- $edu_where = $work_where;
- $educations = $this->resumeEducationRepository->getResumeEducations($edu_where);
- if ($educations->toArray()) {
- $resume_info->educations = $educations;
- }
- //获取职位信息
- $job_where_in = $jobs_id;
- $jobs_res = $this->jobsRepository->getJobs($job_where_in);
- $jobs = $this->dealJobsInfo($jobs_res);
- $com_setmeals = $this->getJobCompanySetmeals($jobs); //当前所选职位对应的企业会员套餐信息
- $down_companys = $this->companyDownResumeRepository->getDowmResumes(array('resume_id' => $resume_info->id, 'resume_uid' => $resume_info->uid), array(), 'company_uid'); //获取所有下载当前简历的企业信息
- //获取当前用户申请过的职位
- $space_times = 1 - config('aix.personal_set.per_set.per_set.apply_job_space');
- $check_where = array(
- array('personal_uid', '=', $user->id)
- );
- if (config('aix.personal_set.per_set.per_set.apply_job_space')>0) {
- $check_time = strtotime(date('Y-m-d', strtotime($space_times . " day") - 1)) - 1;
- $check_where[] = array('created_at', '>', date('Y-m-d H:i:s', $check_time));
- }
- //$check_where = array('personal_uid'=>auth('web-member')->user()->id);
- //$check_jobs_res = $this->personalJobsApplyRepository->applyJobs($check_where, $jobs_id);
- $check_jobs_res = $this->personalJobsApplyRepository->checkApplyJobs($check_where, $jobs_id);
- $check_jobs = $this->dealCheckJobs($check_jobs_res);
- //申请职位
- $list = array();
- $success = 0;
- $points = 0;
- $space_days = config('aix.personal_set.per_set.per_set.apply_job_space');
- $fail_job_ids = [];
- foreach ($jobs_id as $val) {
- $jobs_name = $jobs[$val]->jobs_name;
- $list[$val] = array('id' => $val, 'jobs_name' => $jobs_name, 'company_id' => $jobs[$val]->company_id, 'company_name' => $jobs[$val]->company_name, 'status' => 0);
- //检测职位是否有效
- if ($jobs[$val]->valid == 0 || $jobs[$val]->display != 1) {
- $list[$val]['tip'] = '该职位已关闭';
- $list[$val]['status'] = 4;
- $fail_job_ids[] = $val;
- continue;
- }
- //判断是否申请过当前职位
- if (array_get($check_jobs, $val)) {
- if (config('aix.personal_set.per_set.per_set.apply_job_space')>0) {
- $list[$val]['tip'] = $space_days . '天内不允许重复申请';
- } else {
- $list[$val]['tip'] = '该职位已申请';
- }
- $list[$val]['status'] = 3;
- $fail_job_ids[] = $val;
- continue;
- }
- //申请职位
- $time = date('Y-m-d H:i:s', time());
- $apply_data = array(
- 'resume_id' => $resume_info->id,
- 'resume_name' => $resume_info->title,
- 'personal_uid' => $resume_info->uid,
- 'jobs_id' => $val,
- 'jobs_name' => $jobs[$val]->jobs_name,
- 'company_id' => $jobs[$val]->company_id,
- 'company_name' => $jobs[$val]->company_name,
- 'personal_look' => 1,
- 'notes' => '',
- 'is_reply' => 0,
- 'is_apply' => 1,
- 'created_at' => $time,
- 'updated_at' => $time
- );
- // $company = Company::find($jobs[$val]->company_id);
- // $this->wechatService->sendTemplateMessage($company, 'set_applyjobs',[
- // 'keyword1'=>[$jobs[$val]->jobs_name,'#0000ff'],
- // 'keyword2'=>[$user->username,'#0000ff'],
- // ],route('mobile.firm.resume.apply'));
- //
- // if($company->email){
- // $this->emailService->sendMail($company->email, EmailService::TEMPLATE_MAIL_APPLYJOBS, ['personalfullname'=>$resume_info->fullname,'jobsname'=>$jobs[$val]->jobs_name], ['jobsname'=>$jobs[$val]->jobs_name]);
- // }
- $apply_rst = $this->personalJobsApplyRepository->addData($apply_data);
- if ($apply_rst) {
- //判断会员套餐中投递的简历是否免费查看,如果免费查看则判断当前企业是否有下载过该简历,没有下载则添加下载对应关系
- if (array_has($com_setmeals, $jobs[$val]->company_id)) {
- $com_setmeal = $com_setmeals[$jobs[$val]->company_id];
- if ((!$down_companys) || ($down_companys && !array_has($down_companys, $jobs[$val]->company_id))) {
- if ($com_setmeal->expire == 0 && $com_setmeal->show_apply_contact == 1) {
- $down_data = array(
- 'resume_id' => $resume_info->id,
- 'resume_name' => $resume_info->title,
- 'resume_uid' => $resume_info->uid,
- 'company_uid' => $com_setmeal->uid,
- 'company_name' => $jobs[$val]->company_name,
- 'down_addtime' => time(),
- 'is_reply' => 0
- );
- $this->companyDownResumeRepository->create($down_data);
- }
- }
- }
- $insertid = $apply_rst->id;
- $list[$val]['tip'] = '投递成功';
- $list[$val]['status'] = 1;
- $success++;
- //修改任务记录、积分信息
- $task_rst = $this->taskService->doTask(4);
- if (array_get($task_rst, 'code') == 1) {
- $points += $task_rst['data']['points'];
- }
- //添加企业访客记录
- $this->companyService->addStatistics($jobs[$val]->company_id, $val, $user, 1);
- //职位联系信息
- $contacts = '';
- $contacts = $this->jobsContactRepository->getContactInfo(array('job_id' => $val));
- //简历基本信息
- $resume_basicinfo = $this->resumeRepository->getResumeBasic(auth('web-member')->user()->id, $resume_info->id);
- //发送站内信
- $replac_pms = array();
- $replac_pms['personalfullname'] = $resume_basicinfo->fullname;
- //TODO 发送邮件
- //发送短信 - 短信开关、短信模板、职位联系信息中notify_mobile
- $jobsContact = $jobs[$val]->jobsContact;
- $mobile = '';
- $notify_mobile = 0;
- if ($jobsContact) {
- $notify_mobile = $jobsContact->notify_mobile;
- $mobile = $jobsContact->telephone;
- }
- if ($mobile) {
- //获取短信接口是否开启
- $smss = $this->smsRepository->getUsefulSms();
- $sms_config = 0;
- if ($smss) {
- $sms_config = 1;
- }
- //判断申请职位短信通知是否开启
- $sms_apply_notice = 0;
- if ($this->smsRuleRepository->getSmsRule(['alias'=>'sms_applyjobs','status'=>1])) {
- $sms_apply_notice = 1;
- }
- if ($sms_config && $sms_apply_notice && $notify_mobile) {
- //发送短信
- $parmas = array(
- 'sitename' => subsite_config('aix.system.site.site.site_name'),
- 'sitedomain' => config('aix.system.site.site.site_domain'),
- 'jobsname' => $jobs[$val]->jobs_name,
- 'personalfullname' => $resume_basicinfo->fullname
- );
- $this->smsService->sendSms($mobile, Smser::TEMPLATE_JOB_APPLY, $parmas);
- }
- }
- //微信
- } else {
- $list[$val]['tip'] = '申请职位失败';
- }
- }
- //判断申请职位是否有任务
- $task_check = $this->taskService->checkTask(4);
- //获取会员积分信息
- $points_info = $this->memberPointRepository->getPointsOne($user->id, 2);
- 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);
- }
- public function dealJobsInfo($jobs)
- {
- $list = array();
- if (count($jobs) > 0) {
- foreach ($jobs as $k => $v) {
- $list[$v->id] = $v;
- }
- }
- return $list;
- }
- public function dealCheckJobs($jobs)
- {
- $list = array();
- if (count($jobs) > 0) {
- foreach ($jobs as $k => $v) {
- $list[$v->jobs_id] = $v;
- }
- }
- return $list;
- }
- public function getJobCompanySetmeals($jobs)
- {
- $com_ids = array();
- $list = array();
- if (count($jobs) > 0) {
- foreach ($jobs as $k => $v) {
- $com_ids[] = $v->company_id;
- }
- $rst = $this->memberSetmealRepository->getMemberSetmeals($com_ids);
- if ($rst) {
- foreach ($rst as $k => $v) {
- $list[$v->uid] = $v;
- }
- }
- }
- return $list;
- }
- //手机端申请职位
- public function ifMobileJobApply($jobs_id, $user, $resume_id = '', $is_apply = 2)
- {
- //获取当天已投递的职位数量,判断当天是否可以还可以投递简历
- $today_time = date('Y-m-d H:i:s', strtotime(date('Y-m-d', time())));
- $apply_where = array(
- array('personal_uid', '=', $user->id),
- array('created_at', '>=', $today_time)
- );
- $applyJobs = $this->personalJobsApplyRepository->applyJobs($apply_where);
- $allow_count = config('aix.personal_set.per_set.per_set.apply_jobs_max');
- if ($allow_count < count($applyJobs) + count($jobs_id)) {
- return array('status'=>0,'error'=>"您每天可以投递" . $allow_count . "个职位,今天已投递了" . count($applyJobs) . "个");
- }
- //判断是否有可以投递的简历
- $resume_audit = config('aix.personal_set.per_set.show_set.resume_display');
- $resume_where = array(array('uid', '=', auth('web-member')->user()->id));
- if (config('aix.personal_set.per_set.show_set.resume_display') == '1') {
- $resume_where[] = array('audit', '=', '2');
- } else {
- $resume_where[] = array('audit', '<>', '0');
- }
- $resumes = $this->resumeRepository->getResumes($resume_where);
- if (count($resumes) == 0) {
- //判断是否有简历
- $user_resumes = $this->resumeRepository->getResumes(array('uid' => auth('web-member')->user()->id));
- if ($user_resumes->toArray()) {
- return array('status'=>0,'error'=>"您没有审核通过的简历!");
- } else {
- return array('status'=>0,'error'=>"请您先填写一份简历!");
- }
- } else if (count($resumes) == 1) {
- //直接进入投递环节
- $resumes_arr = $resumes->toArray();
- return $this->mobileApplyJobs($jobs_id, $resumes_arr[0]['id'], $user);
- } else {
- //获取默认简历信息
- $def_resume = array();
- foreach ($resumes as $k => $v) {
- if ($v->def == '1') {
- $def_resume = $v;
- }
- }
- if (!$def_resume) {
- $def_resume = $resumes[0];
- }
- //提示用户选择需要投递的简历
- return array('status' => 2, 'resumes' => $resumes, 'def_resume' => $def_resume);
- }
- }
- public function mobileApplyJobs($jobs_id, $resume_id = '', $user = array())
- {
- //判断简历是否存在
- if ($resume_id) {
- $resume_where = array('uid' => $user->id, 'id' => $resume_id);
- } else {
- $resume_where = array('uid' => $user->id, 'def' => 1);
- }
- $resume_info = $this->resumeRepository->getResumeInfo($resume_where);
- if (!$resume_info) {
- return array('status'=>0,'error'=>"选择的简历不存在!");
- }
- //判断简历是否要求通过审核
- if (config('aix.personal_set.per_set.show_set.resume_display') == '1') {
- if ($resume_info->audit != 2) {
- return array('status'=>0,'error'=>"您选择投递的简历尚未审核通过!");
- }
- } else {
- if ($resume_info->audit == 0) {
- return array('status'=>0,'error'=>"您选择投递的简历尚未审核通过!");
- }
- }
- //检测职位匹配的简历完整度要求
- if (config('aix.personal_set.per_set.per_set.apply_job_min_percent')) {
- if ($resume_info->complete_percent < config('aix.personal_set.per_set.per_set.apply_job_min_percent')) {
- 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);
- }
- }
- //获取简历的工作经历、教育经历
- $work_where = array(
- 'uid' => $user->id,
- 'resume_id' => $resume_info->id
- );
- $works = $this->resumeWorkRepository->getResumeWorks($work_where);
- if ($works->toArray()) {
- $resume_info->work = $works;
- }
- $edu_where = $work_where;
- $educations = $this->resumeEducationRepository->getResumeEducations($edu_where);
- if ($educations->toArray()) {
- $resume_info->educations = $educations;
- }
- //获取职位信息
- $job_where_in = $jobs_id;
- $jobs_res = $this->jobsRepository->getJobs($job_where_in);
- $jobs = $this->dealJobsInfo($jobs_res);
- $com_setmeals = $this->getJobCompanySetmeals($jobs); //当前所选职位对应的企业会员套餐信息
- $down_companys = $this->companyDownResumeRepository->getDowmResumes(array('resume_id' => $resume_info->id, 'resume_uid' => $resume_info->uid), array(), 'company_uid'); //获取所有下载当前简历的企业信息
- //获取当前用户申请过的职位
- $space_times = 1 - config('aix.personal_set.per_set.per_set.apply_job_space');
- $check_time = strtotime(date('Y-m-d', strtotime($space_times . " day") - 1)) - 1;
- $check_where = array(
- array('personal_uid', '=', $user->id),
- array('created_at', '>', date('Y-m-d H:i:s', $check_time)),
- );
- $check_jobs_res = $this->personalJobsApplyRepository->checkApplyJobs($check_where, $jobs_id);
- $check_jobs = $this->dealCheckJobs($check_jobs_res);
- //申请职位
- $list = array();
- $success = 0;
- $points = 0;
- $space_days = config('aix.personal_set.per_set.per_set.apply_job_space');
- foreach ($jobs_id as $val) {
- $jobs_name = $jobs[$val]->jobs_name;
- $list[$val] = array('id' => $val, 'jobs_name' => $jobs_name, 'company_id' => $jobs[$val]->company_id, 'company_name' => $jobs[$val]->company_name, 'status' => 0);
- //检测职位是否有效
- if ($jobs[$val]->valid == 0 || $jobs[$val]->display != 1) {
- if (count($jobs_id)==1) {
- return array('status'=>0,'error'=>"该职位已关闭!");
- } else {
- $list[$val]['tip'] = '该职位已关闭';
- $list[$val]['status'] = 4;
- continue;
- }
- }
- //判断是否申请过当前职位
- if (array_get($check_jobs, $val)) {
- if (count($jobs_id)==1) {
- return array('status'=>0,'error'=>$space_days . '天内不允许重复申请!');
- } else {
- $list[$val]['tip'] = $space_days . '天内不允许重复申请';
- $list[$val]['status'] = 3;
- continue;
- }
- }
- //申请职位
- $time = date('Y-m-d H:i:s', time());
- $apply_data = array(
- 'resume_id' => $resume_info->id,
- 'resume_name' => $resume_info->title,
- 'personal_uid' => $resume_info->uid,
- 'jobs_id' => $val,
- 'jobs_name' => $jobs[$val]->jobs_name,
- 'company_id' => $jobs[$val]->company_id,
- 'company_name' => $jobs[$val]->company_name,
- 'personal_look' => 1,
- 'notes' => '',
- 'is_reply' => 0,
- 'is_apply' => 1,
- 'created_at' => $time,
- 'updated_at' => $time
- );
- $apply_rst = $this->personalJobsApplyRepository->addData($apply_data);
- if ($apply_rst) {
- //判断会员套餐中投递的简历是否免费查看,如果免费查看则判断当前企业是否有下载过该简历,没有下载则添加下载对应关系
- if (array_has($com_setmeals, $jobs[$val]->company_id)) {
- $com_setmeal = $com_setmeals[$jobs[$val]->company_id];
- if ((!$down_companys) || ($down_companys && !array_has($down_companys, $jobs[$val]->company_id))) {
- if ($com_setmeal->expire == 0 && $com_setmeal->show_apply_contact == 1) {
- $down_data = array(
- 'resume_id' => $resume_info->id,
- 'resume_name' => $resume_info->title,
- 'resume_uid' => $resume_info->uid,
- 'company_uid' => $com_setmeal->uid,
- 'company_name' => $jobs[$val]->company_name,
- 'down_addtime' => time(),
- 'is_reply' => 0
- );
- $this->companyDownResumeRepository->create($down_data);
- }
- }
- }
- /*if (count($jobs_id)==1) {
- return array('status'=>1,'msg'=> '投递成功!');
- }*/
- $insertid = $apply_rst->id;
- $list[$val]['tip'] = '投递成功';
- $list[$val]['status'] = 1;
- $success++;
- //修改任务记录、积分信息
- $task_rst = $this->taskService->doTask(4);
- if (array_get($task_rst, 'code') == 1) {
- $points += $task_rst['data']['points'];
- }
- //添加企业访客记录
- $this->companyService->addStatistics($jobs[$val]->company_id, $val, $user, 1, 3);
- //职位联系信息
- $contacts = '';
- $contacts = $this->jobsContactRepository->getContactInfo(array('job_id' => $val));
- //简历基本信息
- $resume_basicinfo = $this->resumeRepository->getResumeBasic(auth('web-member')->user()->id, $resume_info->id);
- //发送站内信
- $replac_pms = array();
- $replac_pms['personalfullname'] = $resume_basicinfo->fullname;
- //TODO 发送邮件
- //发送短信
- //微信
- } else {
- if (count($jobs_id)==1) {
- return array('status'=>0,'error'=> '申请职位失败!');
- }
- $list[$val]['tip'] = '申请职位失败';
- }
- }
- //判断申请职位是否有任务
- $task_check = $this->taskService->checkTask(4);
- //获取会员积分信息
- $points_info = $this->memberPointRepository->getPointsOne($user->id, 2);
- if (count($jobs_id)==1) {
- return array('status'=>1,'msg'=> '投递成功!');
- }
- 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);
- }
- /*
- * 平板邀请
- */
- public function padSaveApply($request,$user)
- {
- $data['jobs_id'] = $request->jobs_id ? $request->jobs_id : 0;
- $data['resume_id'] = $request->resume_id ? $request->resume_id : 0;
- $date = $request->date ? $request->date : '';
- $type = $request->type ? $request->type : 1;
- //职位状态是未发布中的。
- $jobs_map['company_id'] = $user->id;
- if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
- $jobs_map['audit'] = 1;
- }
- $jobs_map['display'] = 1;
- $jobs = $this->jobsRepository->jobsList($jobs_map);
- if ($jobs) {
- $jobs = $jobs->toArray();
- }
- $jobs_idarr = array_column($jobs, 'id');
- if (!in_array($data['jobs_id'], $jobs_idarr)) {
- return response()->json(['status' => 0, 'msg' => '求职者投递的职位状态为未发布,请确认职位状态']);
- }
- if (!$date) {
- return response()->json(['status' => 0, 'msg' => '请选择面试日期']);
- }
- $ap = ($request->ap == 2 ? 0 : 1) ? "AM" : 'PM';
- $time = $request->time ? $request->time : 0;
- if (!$time) {
- return response()->json(['status' => 0, 'msg' => '请选择面试时间']);
- }
- $data['interview_time'] = strtotime($date . ' ' . $time . ":00:00" . $ap);
- if ($data['interview_time'] < time()) {
- return response()->json(['status' => 0, 'msg' => '面试时间不能早于当前时间']);
- }
- $data['address'] = $request->address ? $request->address : '';
- $data['contact'] = $request->contact ? $request->contact : '';
- $data['telephone'] = $request->telephone ? $request->telephone : '';
- $data['notes'] = $request->notes ? $request->notes : '';
- $data['sms_notice'] = $request->sms_notice ? $request->sms_notice : 0;
- $res = $this->padAddInterview($data, $user,$type);
- return response()->json(['status' => $res['status'], 'msg' => $res['msg'],'back_url'=>$res['back_url'] ?? '']);
- }
- public function padAddInterview($data, $user,$type)
- {
- $sms_notice = $data['sms_notice'];
- unset($data['sms_notice']);
- if ($user->user_status == 2) {
- return ['status' => 0, 'msg' => '您的账号处于暂停状态,请联系管理员设为正常后进行操作'];
- }
- if (!$data['resume_id']) {
- return ['status' => 0, 'msg' => '请选择简历'];
- }
- $user_jobs = $this->jobsfairPutJobService->countAuditJobsNum($user);
- if (!$user_jobs) {
- return ['status' => 0, 'msg' => '邀请失败,你没有发布招聘信息或者信息没有审核通过'];
- }
- if ($this->companyInterviewRepository->checkInterview($data['resume_id'], $user->id, $data['jobs_id'])) {
- return ['status' => 0, 'msg' => '您已对该简历进行过面试邀请,不能重复邀请'];
- }
- $setmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, $user->utype);
- $resume = $this->resumeRepository->getResume($data['resume_id']);
- $pass = false;
- //检测是否申请过职位
- $has = $this->personalJobsApplyRepository->checkJobsApply($data['resume_id'], $user->id, $data['jobs_id']);
- $has && $pass = true;
- if ($setmeal->show_apply_contact == 0 && $pass == true) {
- $pass = false;
- }
- if (config('aix.personal_set.per_set.contact_set.show_resume_contact') == 2) {
- if ($pass == false && $user->id) {
- $where['resume_id'] = $data['resume_id'];
- $where['company_uid'] = $user->id;
- $info = $this->companyDownResumeRepository->getDownResume($where);
- $info && $pass = true;
- }
- if (false == $pass && $type == 1) {
- return ['status' => 0, 'msg' => '请先下载简历!'];
- }
- }
- $jobInfo = $this->jobsRepository->getAuditJobsOne(['id' => $data['jobs_id']]);
- $_resume_fullname = $resume->fullname;
- if ($resume->display_name == 0) {
- $data['resume_name'] = "N" . str_pad($resume->id, 7, "0", STR_PAD_LEFT);
- } elseif ($resume->display_name == 3) {
- if ($resume->sex == 1) {
- $data['resume_name'] = cut_str($resume->fullname, 1, 0, "先生");
- } elseif ($resume->sex == 2) {
- $data['resume_name'] = cut_str($resume->fullname, 1, 0, "女士");
- }
- } else {
- $data['resume_name'] = $resume['fullname'];
- }
- $data['resume_addtime'] = strtotime($resume->created_at);
- $data['resume_uid'] = $resume->uid;
- $data['jobs_name'] = $jobInfo->jobs_name;
- $data['company_id'] = $user->id;
- $data['jobs_addtime'] = strtotime($jobInfo->created_at);
- $data['company_name'] = $user->companyname;
- $data['company_addtime'] = strtotime($user->created_at);
- $data['interview_addtime'] = time();
- DB::beginTransaction();//检查数据库事务
- try {
- if (false === $this->companyInterviewRepository->create($data)) {
- throw new \Exception('邀请面试失败!');
- }
- $map['resume_id'] = $data['resume_id'];
- $map['jobs_id'] = $data['jobs_id'];
- $map['company_id'] = $user->id;
- if ($has) {
- if (!$this->personalJobsApplyRepository->updateApply($map)) {
- throw new \Exception('状态修改失败,邀请面试失败!');
- }
- }
- //短信
- if ($sms_notice) {
- $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')]);
- }
- DB::commit();
- } catch (\Exception $e) {
- DB::rollback();
- return ['status' => 0, 'msg' => $e->getMessage()];
- }
- if($type == 1){
- $back_url = route('hardware.pad.search.resume');
- }elseif($type == 2 || $type == 5){
- $back_url = route('hardware.pad.receive.list');
- }else{
- $back_url = route('hardware.pad.interview.list');
- }
- return array('status' => 1,'msg'=>'邀请面试成功','back_url'=>$back_url);//增加面试邀请
- }
- //判断下载的简历是否是已投简历
- public function isOwn($y_id,$user,$column)
- {
- $idsArr = $this->personalJobsApplyRepository->getPluck(['company_id'=>$user->id],$column)->toArray();
- if(array_diff($y_id,$idsArr))
- {
- throw new ResponseException('参数错误!');
- }
- }
- }
|