PersonFavoriteRepository = $PersonFavoriteRepository; $this->CategoryRepository = $CategoryRepository; $this->CategoryDistrictRepository = $CategoryDistrictRepository; $this->JobsRepository = $JobsRepository; $this->resumeRepository = $resumeRepository; $this->TaskService = $TaskService; $this->PersonJobsApplyRepository = $PersonJobsApplyRepository; $this->PersonFocusComRepository = $PersonFocusComRepository; $this->PersonJobsSubRepository = $PersonJobsSubRepository; $this->CategoryJobsRepository = $CategoryJobsRepository; $this->memberLogRepository=$memberLogRepository; } public function jobsF($user) { $settr[] = ['uid','=',$user->id]; if (request()->settr) { switch (request()->settr) { case '3': $settr[] = ['created_at' ,'>=' ,date('Y-m-d H:i:s', strtotime("-3 day"))]; break; case '7': $settr[]= ['created_at' ,'>=' ,date('Y-m-d H:i:s', strtotime("-7 day"))]; break; case '15': $settr[] = ['created_at' ,'>=' ,date('Y-m-d H:i:s', strtotime("-15 day"))]; break; case '30': $settr[] = ['created_at' ,'>=' ,date('Y-m-d H:i:s', strtotime("-30 day"))]; break; default: $settr[] = ['created_at' ,'>=' ,date('Y-m-d H:i:s', strtotime("-3 day"))]; break; } } $res = $this->PersonFavoriteRepository->jobsF($settr, getJobsStatus(),$user->id); $getCategoriess = $this->CategoryRepository->getCategoriess(); foreach ($res as $key => $val) { if (isset($val->jobs->wage_max)) { if($val->jobs->wage_max){ $res[$key]['jobs']['wage_cn'] = $val->jobs->wage_min.'~'.$val->jobs->wage_max.'/月'; }else{ if ($val->jobs->wage==-1) { $res[$key]['jobs']['wage_cn'] = '面议'; }else{ $res[$key]['jobs']['wage_cn'] = $val->jobs->wage_min.'以上/月'; } } } if (isset($val->jobs->experience)) { $res[$key]['jobs']['experience_cn'] = isset($getCategoriess['AIX_experience'][$val->jobs->experience]['demand']) ? $getCategoriess['AIX_experience'][$val->jobs->experience]['demand'] : '经验不限'; } if (isset($val->jobs->trade)) { $res[$key]['jobs']['trade_cn'] = isset($getCategoriess['AIX_trade'][$val->jobs->trade]['demand']) ? $getCategoriess['AIX_trade'][$val->jobs->trade]['demand'] : '行业不限'; } if (isset($val->jobs->education)) { $res[$key]['jobs']['education_cn'] = isset($getCategoriess['AIX_education'][$val->jobs->education]['demand']) ? $getCategoriess['AIX_education'][$val->jobs->education]['demand'] : '学历不限'; } if (isset($val->jobs->age)) { if ($val->jobs->age) { $ageDe = $val->jobs->age; if ($ageDe[0] && $ageDe[1]) { $age_cn = $ageDe[0].'-'.$ageDe[1].'岁'; } elseif ($ageDe[0] && !$ageDe[1]) { $age_cn = $ageDe[0].'岁以上'; } elseif (!$ageDe[0] && $ageDe[1]) { $age_cn = $ageDe[1].'岁以下'; } else { $age_cn = '年龄不限'; } } else { $age_cn = '年龄不限'; } $res[$key]['jobs']['age_cn'] = $age_cn; } if (isset($val->jobs->district)) { $districtArr = $this->CategoryDistrictRepository->getManydistrict(explode('.', $val->jobs->district)); foreach ($districtArr as $key1 => $val1) { $res[$key]['jobs']['district_cn'].=$val1->name.'+'; } $res[$key]['jobs']['district_cn'] = isset($res[$key]['jobs']['district_cn']) ? rtrim($res[$key]['jobs']['district_cn'], '+') : '未知'; } } return $res; } public function delPersonFavorite($id,$user) { if (empty($id)) { throw new ResponseException('收藏职位不存在!', '', 400); } $res = PersonFavorite::where(['uid'=>$user->id])->get()->toArray(); $array_id = array_column($res,'id'); $res_k = string_to_array(',',$id); foreach ($res_k as $key=>$val){ if(!in_array($val,$array_id)){ throw new ResponseException('收藏职位不存在', '', 400); } } if(!$this->memberLogRepository->createLog($user,2035,$id)){ throw new \Exception("日志记失败!"); } return $this->PersonFavoriteRepository->delPersonFavorite(explode(',', $id)); } public function resumeApply($input, $user) { $resume_id = array_get($input,'resume_id'); $res = Resume::where(['uid'=>$user->id])->get()->toArray(); $array_id = array_column($res,'id'); if(!in_array($resume_id,$array_id)){ throw new ResponseException('简历不存在!'); } if (empty($input['jobs_id'])) { throw new ResponseException('职位不存在!', '', 400); } if (empty($resume_id)) { throw new ResponseException('简历不存在!', '', 400); } $resume = $this->resumeRepository->find($resume_id); $defaultPre = config('aix.personal_set.per_set.per_set.apply_job_min_percent'); if ($defaultPre) { if ($resume->complete_percent<$defaultPre) { throw new ResponseException('您的简历完整度小于'.$defaultPre.'%', '', 400); } } $id = array_filter(explode(',', $input['jobs_id'])); $num_id = count($id); if($num_id>config('aix.personal_set.per_set.per_set.apply_jobs_max')){ throw new ResponseException("您每天可以投递".config('aix.personal_set.per_set.per_set.apply_jobs_max')."个职位"); } $todayCount = $this->PersonJobsApplyRepository->getTodayCount($user->id); if(($num_id+$todayCount)>config('aix.personal_set.per_set.per_set.apply_jobs_max')){ throw new ResponseException("您每天可以投递".config('aix.personal_set.per_set.per_set.apply_jobs_max')."个职位,今天已投递了{$todayCount}个", '', 400); } if ($todayCount>=config('aix.personal_set.per_set.per_set.apply_jobs_max')) { throw new ResponseException("您每天可以投递".config('aix.personal_set.per_set.per_set.apply_jobs_max')."个职位,今天已投递了{$todayCount}个", '', 400); } $displayJobs = $this->JobsRepository->getDisplayJobs($id, 2); if (!empty($displayJobs)) { $disJobs = array_diff($id, array_column($displayJobs, 'id')); if (empty($disJobs)) { throw new ResponseException('您投递的职位已关闭!', '', 400); } $id = $disJobs; } $jobsApply = $this->PersonJobsApplyRepository->personApplyByTime( $id, $user->id, config('aix.personal_set.per_set.per_set.apply_job_space') ); if (!empty($jobsApply)) { $disApply = array_diff($id, array_column($jobsApply, 'jobs_id')); if (empty($disApply)) { throw new ResponseException('您已经申请过这个职位了!', '', 400); } $id = $disApply; } $jobs = $this->JobsRepository->getJobs($id); $arr = []; foreach ($jobs as $key => $val) { $arr[$key]['resume_id'] = $resume->id; $arr[$key]['resume_name'] = $resume->title; $arr[$key]['personal_uid'] = $user->id; $arr[$key]['jobs_id'] = $val->id; $arr[$key]['jobs_name'] = $val->jobs_name; $arr[$key]['company_id'] = $val->company_id; $arr[$key]['company_name'] = $val->company_name; $arr[$key]['created_at'] = date('Y-m-d H:i:s', time()); $arr[$key]['updated_at'] = date('Y-m-d H:i:s', time()); } $result = $this->PersonJobsApplyRepository->applyJons($arr); if ($result) { $this->TaskService->doTask(4); return ['code'=>1, 'info'=>'投递成功']; } else { return ['code'=>0, 'info'=>'投递失败']; } } public function attentionCom($user) { $settr[] = ['uid','=',$user->id]; $res = $this->PersonFocusComRepository->getAttionCom($settr, getJobsStatus()); return $res; } public function deleteCompany($id,$user) { if (!$id) { throw new ResponseException('数据异常!'); } $res = PersonFocusCompany::where(['uid'=>$user->id])->get()->toArray(); $array_id = array_column($res,'id'); if(!in_array($id,$array_id)){ throw new ResponseException('数据异常!'); } if(!$this->memberLogRepository->createLog($user,2038,$id)){ throw new \Exception("日志记失败!"); } return $this->PersonFocusComRepository->delete($id); } public function getJobsSub() { $settr[] = ['uid','=',auth('web-member')->user()->id]; return $this->PersonJobsSubRepository->getJobsSub($settr); } public function getJobsSubAdd($date, $user) { $jobsArr = explode(',', $date['intention_jobs_id']); $jobArrId = []; foreach ($jobsArr as $key => $val) { $jobArrId[] = explode('.', $val)[2] ? explode('.', $val)[2] : explode('.', $val)[1]; } $jobsRes = $this->CategoryJobsRepository->getManyJobs($jobArrId); $date['intention_jobs'] = ''; foreach ($jobsRes as $key => $val) { $date['intention_jobs'].=$val->name.'/'; } $date['intention_jobs'] = rtrim($date['intention_jobs'], '/'); $districtArr = explode(',', $date['district']); $resumrArrId = []; foreach ($districtArr as $key => $val) { $resumrArrId[] = explode('.', $val)[2] ? explode('.', $val)[2] : explode('.', $val)[1]; } $resumeRes = $this->CategoryDistrictRepository->getManydistrict($resumrArrId); $date['district_cn'] = ''; foreach ($resumeRes as $key => $val) { $date['district_cn'].=$val->name.'+'; } $date['district_cn'] = rtrim($date['district_cn'], '+'); if ($date['wage']) { $wageArr = $this->CategoryRepository->getCategory($date['wage']); $date['wage_cn'] = $wageArr['demand']; } if ($date['trade']) { $tradeArr = $this->CategoryRepository->getCategory($date['trade']); $date['trade_cn'] = $tradeArr['demand']; } if ($date['sendTime']) { $sendTimeArr = $this->CategoryRepository->getCategory($date['sendTime']); $date['sendTime_cn'] = $sendTimeArr['demand']; } if ($date['experience']) { $experienceArr = $this->CategoryRepository->getCategory($date['experience']); $date['experience_cn'] = $experienceArr['demand']; } if ($date['education']) { $educationArr = $this->CategoryRepository->getCategory($date['education']); $date['education_cn'] = $educationArr['demand']; } if ($date['rate']) { $rateArr = $this->CategoryRepository->getCategory($date['rate']); $date['rate_cn'] = $rateArr['demand']; if ($date['rate']==832) { $date['updated_at'] = date('Y-m-d H:i:s',time()+86400); } elseif ($date['rate']==833) { $date['updated_at'] = date('Y-m-d H:i:s',time()+259200); } elseif ($date['rate']==834) { $date['updated_at'] = date('Y-m-d H:i:s',time()+604800); } elseif ($date['rate']==835) { $date['updated_at'] = date('Y-m-d H:i:s',time()+1209600); } } if ($date['send_jobs']) { $send_jobsArr = $this->CategoryRepository->getCategory($date['send_jobs']); $date['send_jobs_cn'] = $send_jobsArr['demand']; } if ($date['nature']) { $natureArr = $this->CategoryRepository->getCategory($date['nature']); $date['nature_cn'] = $natureArr['demand']; } $date['uid'] = $user->id; if (empty($date['id'])) { $jobs=$this->PersonJobsSubRepository->getJobsSubAdd($date); if(!$this->memberLogRepository->createLog($user,2039,$jobs->id)){ throw new \Exception("日志记失败!"); } return $jobs; } else { if(!$this->memberLogRepository->createLog($user,2039,$date['id'])){ throw new \Exception("日志记失败!"); } return $this->PersonJobsSubRepository->getJobsSubUpdate($date, $date['id']); } } public function getJobsSubEdit($id) { if (empty($id)) { return ['sub'=>[]]; } else { $res = $this->PersonJobsSubRepository->getJobsById($id); return ['sub'=>$res]; } } public function getJobsSubout($data) { $id = $data['id']; $status = $data['status']; if (empty($id)) { throw new ResponseException('职位订阅不存在!', '', 400); } if ($status) { $arr['status'] = 0; } else { $arr['status'] = 1; } $user=auth('web-member')->user(); //订阅是0 退定是1 if ($status==0){ $hJobs =$this->PersonJobsSubRepository->getJobsById($id); if(!$this->memberLogRepository->createLog($user,2041,$id)){ throw new \Exception("日志记失败!"); } }else{ $hJobs =$this->PersonJobsSubRepository->getJobsById($id); if(!$this->memberLogRepository->createLog($user,2040,$id)){ throw new \Exception("日志记失败!"); } } $result = $this->PersonJobsSubRepository->getJobsSubUpdate($arr, $id); if ($result) { return ['code'=>1, 'info'=>'','data'=>['code'=>$arr['status'],'info'=>$hJobs->rate_cn]]; } else { if(!$this->memberLogRepository->createLog($user,2040,$id)){ throw new \Exception("日志记失败!"); } return ['code'=>0, 'info'=>'']; } } public function getJobsAddVar() { $data['uid'] = auth('web-member')->user()->id; $result = $this->PersonJobsSubRepository->getJobsAddVar($data); if ($result<5) { return true; } else { return false; } } public function getCount() { $data['uid'] = auth('web-member')->user()->id; return $this->PersonJobsSubRepository->getJobsAddVar($data); } public function getJobsSubDel($id) { if (empty($id)) { throw new ResponseException('职位订阅不存在!', '', 400); } return $this->PersonJobsSubRepository->getJobsSubDel($id); } public function subscribe() { $jobs = []; $res = $this->PersonJobsSubRepository->rateDate(['status'=>1]); if (!$res->isEmpty()) { foreach ($res as $key=>$val) { $parm = []; $array = string_to_array(['.',','], $val->intention_jobs_id); $nuk = 1; $inter_array = []; foreach ($array as $k1=>$v1) { if($k1==$nuk){ $inter_array[] = $v1; $nuk = $nuk+3; } } $jobs_id = array_unique($inter_array); if ($val->trade) { $parm[] =['trade','=',$val->trade]; } if ($val->experience) { $parm[] =['experience','=',$val->experience]; } if ($val->wage) { $parm[] =['wage','=',$val->wage]; } if ($val->education) { $parm[] =['education','=',$val->education]; } if ($val->nature) { $parm[] =['nature','=',$val->nature]; } $parm[] =['district','=',$val->district]; $count = 0; if ($val->send_jobs==317) { $count = 5; } elseif ($val->send_jobs==318) { $count = 20; }elseif ($val->send_jobs==319) { $count = 30; }elseif ($val->send_jobs==320) { $count = 50; } if ($val->sendTime) { if ($val->sendTime==321) { $parm[] =['created_at','>=',date('Y-m-d H:i:s', strtotime("-1 day"))]; } elseif ($val->sendTime==322) { $parm[] =['created_at','>=',date('Y-m-d H:i:s', strtotime("-3 day"))]; }elseif ($val->sendTime==323) { $parm[] =['created_at','>=',date('Y-m-d H:i:s', strtotime("-7 day"))]; }elseif ($val->sendTime==324) { $parm[] =['created_at','>=',date('Y-m-d H:i:s', strtotime("-30 day"))]; } } if ($count) { if ($val->email) { $member = Member::find($val->uid); $username = isset($member->username) ? $member->username : 'XX'; $result = Jobs::where($parm)->where(function ($query) use ($jobs_id) { if ($jobs_id) { $query->whereIn('category', $jobs_id); } $query->whereIn('audit', getJobsStatus())->where('display', 1)->where('valid', 1); })->select([ 'id', 'company_id', 'jobs_name', 'company_name', 'district', 'wage', 'wage_min', 'wage_max', 'created_at' ])->orderBy('id', 'desc')->offset(0)->limit($count)->get()->toArray(); if ($result) { $jobs[$key] = $result; $jobs[$key]['email'] = $val->email; $jobs[$key]['username'] = $username; $jobs[$key]['subscribe_id'] = $val->id; $jobs[$key]['subscribe_rate'] = $val->rate; } } } } } return $jobs; } public function isOwn($id,$user) { $jobsSub = $this->PersonJobsSubRepository->getPersonJobsSub(['id'=>$id]); if(!$jobsSub) { throw new ResponseException('该职位订阅不存在!'); } if($jobsSub->uid != $user->id) { throw new ResponseException('对不起,您只能操作自己的职位订阅!'); } } }