| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 | 
							- <?php
 
- /**
 
-  * Created by PhpStorm.
 
-  * User: wuzhenke
 
-  * Date: 2019/1/27
 
-  * Time: 10:42
 
-  */
 
- namespace App\Services\Jobfair;
 
- use App\Exceptions\ResponseException;
 
- use App\Models\Jobfair\JobfairPersonalJobsApply;
 
- use App\Repositories\Jobfair\JobfairPersonalJobsApplyRepository;
 
- use App\Repositories\ResumeRepository;
 
- use App\Services\Company\CompanyDownResumeService;
 
- class JobfairPersonalJopApplyService
 
- {
 
-     protected $jobfairPersonalJobsApplyRepository;
 
-     protected $resumeRepository;
 
-     protected $companyDownResumeService;
 
-     /**
 
-      * JobfairPersonalJopApplyService constructor.
 
-      * @param $resumeRepository
 
-      * @param $companyDownResumeService
 
-      */
 
-     public function __construct(JobfairPersonalJobsApplyRepository $jobfairPersonalJobsApplyRepository, ResumeRepository $resumeRepository,CompanyDownResumeService $companyDownResumeService)
 
-     {
 
-         $this->jobfairPersonalJobsApplyRepository = $jobfairPersonalJobsApplyRepository;
 
-         $this->resumeRepository = $resumeRepository;
 
-         $this->companyDownResumeService = $companyDownResumeService;
 
-     }
 
-     public function downResumeDel($request,$user)
 
-     {
 
-         $id = $request->y_id;
 
-         if (!$id) {
 
-             return response()->json(['status'=>0, 'msg'=>'请选择操作的项目!']);
 
-         }
 
-         if (!is_array($id)) {
 
-             $ids = explode(',', $id);
 
-         } else {
 
-             $ids = $id;
 
-         }
 
-         $this->isComOwn($ids,$user);
 
-         if ($this->jobfairPersonalJobsApplyRepository->downResumeDel($ids)) {
 
-             return response()->json(['status'=>1,'msg'=>'简历删除成功!']);
 
-         }
 
-         return response()->json(['status'=>0,'msg'=>'简历删除失败!']);
 
-     }
 
-     public function personJobfair()
 
-     {
 
-         $data[] = ['personal_uid','=',auth('web-member')->user()->id];
 
-         if (request()->resume_id) {
 
-             $data[] = ['resume_id','=',request()->resume_id];
 
-         }
 
-         $interview = $this->jobfairPersonalJobsApplyRepository->personJobfair($data);
 
-         return ['interview'=>$interview];
 
-     }
 
-     public function personDelect($id,$user)
 
-     {
 
-         if (empty($id)) {
 
-             throw new ResponseException('请选择预约职位!');
 
-         }
 
-         $res = JobfairPersonalJobsApply::where(['personal_uid'=>$user->id])->get()->toArray();
 
-         $array_id = array_column($res,'id');
 
-         $arr_id = string_to_array(',', $id);
 
-         foreach ($arr_id as $key=>$val){
 
-             if(!in_array($val,$array_id)){
 
-                 throw new ResponseException('预约职位不存在!');
 
-             }
 
-         }
 
-         return $this->jobfairPersonalJobsApplyRepository->downResumeDel(string_to_array(',', $id));
 
-     }
 
-     public function ifJobApply($user)
 
-     {
 
-         //判断是否有可以投递的简历
 
-         $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' => $user->id));
 
-             if ($user_resumes->toArray()) {
 
-                 throw new ResponseException("您没有审核通过的简历!");
 
-             } else {
 
-                 throw new ResponseException("请您先填写一份简历!");
 
-             }
 
-         } else if (count($resumes) == 1) {
 
-             //直接进入投递环节
 
-             return ['status'=>3, 'resumes'=>$resumes];
 
-         } 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 applyJob($data)
 
-     {
 
-         return $this->jobfairPersonalJobsApplyRepository->create($data);
 
-     }
 
-     //发送面试邀请
 
-     public function interview($request,$user){
 
-         $type = $request->input('type');
 
-         if($type == 2){
 
-             //直接修改状态
 
-             if(empty($request->input('apply_id'))){
 
-                 return response()->json(array('status'=>0,'msg'=>'邀请失败'));
 
-             }
 
-             $ret = $this->jobfairPersonalJobsApplyRepository->interviewEdit($request->input('apply_id'));
 
-             $msg2 = '邀请成功';
 
-             $msg3 = '邀请失败,请稍后重试';
 
-         }else{
 
-             if($type == 3 || $type == 5){
 
-                 $data['jobs_id'] = $request->input('job_id');
 
-                 $data['personal_uid'] = $request->input('personal_uid');
 
-                 $data['company_id'] = $user->id;
 
-                 $data['position_id'] = session('floorplan_stands.id');
 
-                 $data['jobfair_id'] = session('floorplan_stands.jobfair_id');
 
-             }
 
-             $res = $this->jobfairPersonalJobsApplyRepository->applyFind($data);
 
-             if ($type == 3){
 
-                 $data['is_apply'] = 2;
 
-                 $msg = '您已对该简历进行过面试邀请,不能重复邀请';
 
-                 $msg2 = '邀请成功';
 
-                 $msg3 = '邀请失败,请稍后重试';
 
-             }elseif ($type == 5){
 
-                 $data['is_apply'] = 1;
 
-                 $msg = '恭喜您已被面试邀请';
 
-                 $msg1 = '您已投递该职位,不能重复投递';
 
-                 $msg2 = '投递成功';
 
-                 $msg3 = '投递失败,请稍后重试';
 
-             }
 
-             if(!$res){
 
-                 $data['resume_id'] = $request->input('resume_id');
 
-                 $ret = $this->jobfairPersonalJobsApplyRepository->interviewAdd($data);
 
-                 //判断企业套餐是否允许查看
 
-                 $this->companyDownResumeService->addDownResumes($user->id,$data['resume_id']);
 
-             }else{
 
-                 if($res->is_apply == 2 || ($res->is_apply == 1 && $res->is_interview == 1)){
 
-                     return response()->json(array('status'=>0,'msg'=>$msg));
 
-                 }elseif($res->is_apply == 1 && $res->is_interview == 2){
 
-                     if($type == 5){
 
-                         return response()->json(array('status'=>0,'msg'=>$msg1));
 
-                     }else{
 
-                         $ret = $this->jobfairPersonalJobsApplyRepository->interviewEdit($res->id);
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         if ($ret) {
 
-             return response()->json(array('status'=>1,'msg'=>$msg2));
 
-         } else {
 
-             return response()->json(array('status'=>0,'msg'=>$msg3));
 
-         }
 
-     }
 
-     public function getApplyJobs($where, $field = 'jobs_id')
 
-     {
 
-         $rst = $this->jobfairPersonalJobsApplyRepository->getJobsApply($where);
 
-         $list = array();
 
-         if ($rst->toArray()) {
 
-             foreach ($rst as $key => $val) {
 
-                 $list[$val->$field] = $val;
 
-             }
 
-         }
 
-         return $list;
 
-     }
 
-     //判断是否有过面试
 
-     public function isApply($where)
 
-     {
 
-         return $this->jobfairPersonalJobsApplyRepository->applyFind($where);
 
-     }
 
-     //个人判断
 
-     public function isOwn($id,$user)
 
-     {
 
-         $apply = $this->jobfairPersonalJobsApplyRepository->applyFind(['id'=>$id]);
 
-         if(!$apply)
 
-         {
 
-             throw new ResponseException('参数错误!');
 
-         }
 
-         if($apply->personal_uid != $user->id)
 
-         {
 
-             throw new ResponseException('抱歉,您只能操作自己的招聘会!');
 
-         }
 
-     }
 
-     //企业判断
 
-     public function isComOwn($idsArr,$user)
 
-     {
 
-         $idsArr = is_array($idsArr)?$idsArr:explode(',',$idsArr);
 
-         $allIdsArr = $this->jobfairPersonalJobsApplyRepository->getPluck(['company_id'=>$user->id],'id')->toArray();
 
-         if(array_diff($idsArr,$allIdsArr))
 
-         {
 
-             throw new ResponseException('抱歉,您只能操作自己的招聘会数据!');
 
-         }
 
-     }
 
- }
 
 
  |