jobsRepository = $jobsRepository; $this->jobsContactRepository = $jobsContactRepository; $this->companyRepository = $companyRepository; $this->membersSetmealRepository = $memberSetmealRepository; $this->personalJobsApplyRepository = $personalJobsApplyRepository; $this->auditReasonsRepository = $auditReasonsRepository; $this->refreshLogRepository = $refreshLogRepository; $this->memberPointRepository = $memberPointRepository; $this->setmealRepository = $setmealRepository; $this->memberHandselRepository = $memberHandselRepository; $this->membersSetmealLogRepository = $membersSetmealLogRepository; $this->categoryRepository = $categoryRepository; $this->categoryJobsRepository = $categoryJobsRepository; $this->categoryDistrictRepository = $categoryDistrictRepository; $this->resumeRepository = $resumeRepository; $this->viewJobRepository = $viewJobRepository; $this->personFavoriteRepository = $personFavoriteRepository; $this->queueAutoRefreshRepository = $queueAutoRefreshRepository; $this->orderRepository = $orderRepository; $this->companyStatisticsRepository = $companyStatisticsRepository; $this->jobfairJobRepository = $jobfairJobRepository; $this->jobfairJobsContactRepository = $jobfairJobsContactRepository; $this->subsiteJobRepository = $subsiteJobRepository; $this->paymentService = $paymentService; $this->orderService = $orderService; $this->payService = $payService; $this->serviceService = $serviceService; $this->ResumePrivacyRepository = $ResumePrivacyRepository; $this->memberLogRepository=$memberLogRepository; } /** * 职位管理 * @param $type * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator */ public function list($type, $user) { $where = []; $orwhere = []; $where['company_id'] =$user->id; if ($type == 1) { $where['display'] = 1; if (config('aix.companyset.comset.show_set.jobs_display') == 2) { $where[] = ['audit', '<>', 3]; } else { $where['audit'] = 1; } $where['valid'] = 1; } elseif ($type == 2) { $orwhere[] = 2; //显示状态 $orwhere[] = 0; //是否有效 $orwhere[] = 1; //审核状态 if (config('aix.companyset.comset.show_set.jobs_display') == 2) { $orwhere[] = 2; } } $page = 5; $jobs_list = $this->jobsRepository->list($page, $where, $orwhere); //获取职位分类信息 $job_cates = $this->categoryJobsRepository->getJobCategories(); foreach ($jobs_list as $key => $val) { $jobs_list[$key]->jobcategory = ''; if ($job_cates) { if ($val->subclass) { if (array_has($job_cates, $val->category) && array_has($job_cates[$val->category], $val->subclass)) { $jobs_list[$key]->jobcategory = $job_cates[$val->category][$val->subclass]['spell']; } elseif (array_has($job_cates, $val->category)) { $jobs_list[$key]->jobcategory = $job_cates[$val->topclass][$val->category]['spell']; } else { $jobs_list[$key]->jobcategory = ''; } } else { if ($val->category && array_has($job_cates, $val->category)) { $jobs_list[$key]->jobcategory = $job_cates[$val->topclass][$val->category]['spell']; } else { $jobs_list[$key]->jobcategory = ''; } } } if (!empty($val->promotion)) { foreach ($val->promotion as $k => $v) { if ($v->ptype == 1) { $jobs_list[$key]->stickDays = 0; if($v->endtime > time()){ $jobs_list[$key]->stickDays = ceil(($v->endtime-time())/86400); } $jobs_list[$key]->stickarr = $v; } if ($v->ptype == 2) { $jobs_list[$key]->emergencyDays = 0; if($v->endtime > time()){ $jobs_list[$key]->emergencyDays = ceil(($v->endtime-time())/86400); } $jobs_list[$key]->emergencyarr = $v; } } } $val->auto_refresh = 0; $auto_refresh = $this->queueAutoRefreshRepository->findData(['type'=>1, 'pid'=>$val->id]); if ($auto_refresh) { $order_list = $this->orderRepository->findByField(['uid'=>$val->company_id,'order_type'=>12]); foreach ($order_list as $k => $v) { $order_params = unserialize($v->params); if ($order_params['jobs_id']==$val->id) { $val->auto_refresh = 1; $val->auto_refresh_starttime = date('Y-m-d', $order_params['starttime']); $val->auto_refresh_endtime = date('Y-m-d', $order_params['endtime']); break; } } } if ($val->audit == 2) { $val->_audit = config('aix.companyset.comset.show_set.jobs_display') == 2 ? 1 : $val->audit; } else { $val->_audit = $val->audit; } if ($val->_audit == 2) { $val->status_cn = '审核中'; } elseif ($val->_audit == 3) { $val->status_cn = '审核未通过'; $val->reason = $this->auditReasonsRepository->getAuditReasons($val->id, 3); } elseif ($val->_audit == 1 && $val->audit == 2) { $val->status_cn = '审核中'; } if ($val->display == 2 || ($val->deadline > 0 && $val->deadline < time())) { $val->status_cn = '已关闭'; } $val->resumeCount = $this->personalJobsApplyRepository->getApplyResume($val->id); } return $jobs_list; } /**发布职位总数 * @return mixed */ public function jobsTotal($id) { $where['company_id'] = $id; $where['display'] = 1; $where['valid'] = 1; $where[] = ['audit','<>',3]; return $this->jobsRepository->jobsTotal($where); } /** * 根据jobsid获取职位信息 * @param $id * @return mixed */ public function jobsInfo($id) { return $this->jobsRepository->getJobsById($id); } /** * 职位保存 * @param $request * @return JsonResponse * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function jobsSave($data, $user) { $jid = 0; $iscustomize = $data['iscustomize']; unset($data['iscustomize']); //分站关系 if (isset($data['subsite_id'])) { $subsite_id = $data['subsite_id']; } else { $subsite_id = []; } $jobsExist=$this->jobsRepository->jobsTotal(['company_id'=>$user->id,'id'=>$data['id']]); if (empty($jobsExist) && !empty($data['id'])){ return response()->json(['status'=>0, 'msg'=>"没有这个职位"]); } unset($data['subsite_id']); if (isset($data['id']) && $data['id']) { $jid = $data['id']; $job_info = $this->jobsRepository->find($jid); unset($data['id']); } else { //查询企业已发布多少职位数 $condition['company_id'] = $user->id; $condition['display'] = 1; $condition['valid'] = 1; $condition[] = ['audit','<>',3];//加入把审核失败的去除 $jobsCount = $this->jobsRepository->jobsTotal($condition); //查询企业套餐内可发布职位数 $mySetmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype); if (isExpire($mySetmeal)){ return response()->json(['status'=>0, 'msg'=>"提醒:您的套餐已到期,请及时到我的套餐处升级套餐"]); } if ($mySetmeal->jobs_meanwhile <= $jobsCount) { return response()->json(['status'=>0, 'msg'=>"当前显示的职位已经达到最大限制,请升级服务套餐!"]); } } $basis_contact = $data['basis_contact']; unset($data['basis_contact']); $jobData = []; $contactData = []; foreach ($data as $key => $val) { if ($key == 'contact') { $contactData['contact'] = $val; } elseif ($key == 'telephone') { $contactData['telephone'] = $val; } elseif ($key == 'landline_tel') { if ($jid) { $contactData['landline_tel'] = $val; } else { $list1 = explode('-', $val); foreach ($list1 as $ke => $vo) { if ($vo) { $contactData['landline_tel'][$ke] = $vo; } else { $contactData['landline_tel'][$ke] = ''; } } } } elseif ($key == 'email') { $contactData['email'] = $val; } elseif ($key == 'address') { $contactData['address'] = $val; } elseif ($key == 'telephone_show') { $contactData['telephone_show'] = $val; } elseif ($key == 'contact_show') { $contactData['contact_show'] = $val; } elseif ($key == 'landline_tel_show') { $contactData['landline_tel_show'] = $val; } elseif ($key == 'email_show') { $contactData['email_show'] = $val; } elseif ($key == 'notify_mobile') { $contactData['notify_mobile'] = $val; } elseif ($key == 'notify') { $contactData['notify'] = $val; } else { if ($key == 'jobcategory') { $category = explode('.', $val); $jobData['topclass'] = $category[0]; $jobData['category'] = $category[1]; $jobData['subclass'] = $category[2]; } elseif ($key == 'deadline') { if ($val) { $jobData[$key] = time() + ($val * 86400); } else { //职位有效期多少天 $job_expire=config('aix.companyset.comset.com_set.job_expire'); $jobData[$key] = time() + $job_expire* 86400; if($job_expire==0){ $jobData[$key]=0; } } } elseif ($key == 'tag') { $jobData[$key] = explode(',', $val); } elseif ($key == 'district') { $district = getCityInfo($val); $jobData[$key] = $district['district']; } else { $jobData[$key] = $val; } } } $com_info = $this->companyRepository->getCompanyColumn($user->id, ['*']); $setmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype); if (!$jid) { $jobData['audit']= 2; } else { if ($com_info['audit']==1) { $jobData['audit'] = config('aix.companyset.audit.audit_type.audit_verifycom_editjob') == 1?$job_info->audit:2; } else { $jobData['audit'] = config('aix.companyset.audit.audit_type.audit_unexaminedcom_editjob')==1?$job_info->audit:2; } } $jobArr = ['map_zoom', 'scale', 'companyname', 'created_at', 'audit','trade','subsite_id']; foreach ($jobArr as $key => $val) { if ($val == 'companyname') { $jobData['company_name'] = $com_info['companyname']; } elseif ($val == 'created_at') { $jobData['company_addtime'] = strtotime($com_info['created_at']); } elseif ($val == 'audit') { $jobData['company_audit'] = $com_info['audit']; } else { $jobData[$val] = $com_info[$val]; } } if ($data['wage']==-1) { $jobData['wage'] = -1; $jobData['wage_min']=0; $jobData['wage_max']=0; } else { if (intval($data['wage'])==0) { $jobData['wage'] = 0; $jobData['wage_min']=$data['wage_min']; $jobData['wage_max']=$data['wage_max']; } else { $wage = explode('~', format_wage(get_category($jobData['wage']))); $jobData['wage_max'] =0; if (isset($wage[1])) { $jobData['wage_max'] =intval($wage[1]); } $jobData['wage_min'] =intval($wage[0]); } } // $jobData['syq']=$data['syq']; // $jobData['syqxz_min']=$data['syqxz_min']; $jobData['company_id'] = $user->id; $jobData['robot'] = 0; $jobData['valid'] = 1; $jobData['refresh_time'] = time(); $jobData['setmeal_deadline'] = $setmeal->endtime ? strtotime($setmeal->endtime) : 0; $jobData['setmeal_id'] = $setmeal->setmeal_id; $jobData['setmeal_name'] = $setmeal->setmeal_name; if ($basis_contact=='1') { $contactArr = ['contact', 'telephone', 'landline_tel', 'email', 'address', 'contact_show', 'telephone_show', 'email_show', 'landline_tel_show']; foreach ($contactArr as $key => $val) { if ($val == 'telephone') { $conData[$val] = $com_info['mobile']; } elseif ($val == 'landline_tel') { if ($com_info[$val]) { if ($jid) { $conData[$val] = $com_info[$val]; } else { $list = explode('-', $com_info[$val]); foreach ($list as $ke => $vo) { if ($vo) { $conData[$val][$ke] = $vo; } else { $conData[$val][$ke] = ''; } } } } else { $conData[$val] = ''; } } else { $conData[$val] = $com_info[$val]; } } $jobContactData = $conData; } else { $jobContactData = $contactData; } $subsite_id[] = $com_info['subsite_id']; DB::beginTransaction(); try { if ($jid) { if (!$this->jobsRepository->update($jobData, $jid)) { throw new Exception('修改职位失败'); } //修改分站关系 if ($subsite_id) { if ($this->subsiteJobRepository->findSubsite($jid)->isNotEmpty()) { if (!$this->subsiteJobRepository->deleteWhere(['jobs_id'=>$jid])) { throw new Exception('修改分站关系失败'); } } foreach ($subsite_id as $key => $val) { $sub_data[] = [ 'subsite_id'=>$val, 'jobs_id'=>$jid, 'created_at'=>date('Y-m-d H:i:s', time()), 'updated_at'=>date('Y-m-d H:i:s', time()), ]; } if (false == $this->subsiteJobRepository->createData($sub_data)) { throw new Exception('修改分站关系失败'); } } if (false == $this->jobsContactRepository->update($jobContactData, $jid)) { throw new Exception('修改联系方式失败'); } event_search_update(Jobs::class, (string)$jid, 'update'); event_search_update(Company::class, (string)$user->id, 'update'); } else { if (!$job = $this->jobsRepository->store($jobData)) { throw new Exception('添加职位失败'); } $jobContactData['job_id'] = $job->id; if (false == $this->jobsContactRepository->store($jobContactData)) { throw new Exception('添加联系方式失败'); } // if (!$this->companyRepository->modifyJobsNum($user->id, 1, 1)) { // throw new Exception('修改企业职位数失败!'); // } // if (!$this->membersSetmealRepository->modifyJobsMeanwhile($setmeal->id, 1, 2)) { // throw new Exception('修改套餐可发布职位数失败!'); // } //添加分站关系 if ($subsite_id) { foreach ($subsite_id as $key => $val) { $sub_data[] = [ 'subsite_id'=>$val, 'jobs_id'=>$job->id, 'created_at'=>date('Y-m-d H:i:s', time()), 'updated_at'=>date('Y-m-d H:i:s', time()), ]; } if (false == $this->subsiteJobRepository->createData($sub_data)) { throw new Exception('职位同步至其他分站失败!'); } } event_search_update(Jobs::class, (string)$job->id, 'update'); event_search_update(Company::class, (string)$user->id, 'update'); } DB::commit(); if ($jid) { $msg = '修改'; $log_type=1003; } else { $msg = '添加'; $log_type=1002; $jid=$job->id; $total=$setmeal->jobs_meanwhile-$this->jobsRepository->jobsTotal($condition); $this->membersSetmealLogRepository->createLog($user,"发布了职位{$jobData['jobs_name']}",$total); } //写日志 $this->memberLogRepository->createLog($user,$log_type,$jid); return response()->json(['status' => 1, 'msg' => $msg . "职位成功"]); } catch (Exception $e) { DB::rollback(); return response()->json(['status' => 0, 'msg' => $e->getMessage()]); } } /** * 职位保存 * @param $data * @param $user * @return JsonResponse */ public function jobsSaveMobile($data, $user) { $jid = ''; //分站关系 if (isset($data['subsite_id'])) { $subsite_id = explode(',', $data['subsite_id']); } else { $subsite_id = []; } unset($data['subsite_id']); if (isset($data['id']) && $data['id']) { $jid = $data['id']; $job_info = $this->jobsRepository->findWhere(['id'=>$jid,'company_id'=>$user->id])->first(); if (empty($job_info)){ return response()->json(['status'=>0, 'msg'=>"无改职位!"]); } unset($data['id']); } else { //查询企业已发布多少职位数 $condition['display'] = 1; $condition['valid'] = 1; $condition['company_id'] = $user->id; $jobsCount = $this->jobsRepository->jobsTotal($condition); //查询企业套餐内可发布职位数 $mySetmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype); if (isExpire($mySetmeal)){ return response()->json(['status'=>0, 'msg'=>"提醒:您的套餐已到期,请及时到我的套餐处升级套餐"]); } if ($mySetmeal->jobs_meanwhile<=$jobsCount) { return response()->json(['status'=>0, 'msg'=>"当前显示的职位已经达到最大限制,请升级服务套餐!"]); } } $basis_contact = $data['basis_contact']; unset($data['basis_contact']); $jobData = []; $contactData = []; foreach ($data as $key => $val) { if ($key == 'contact') { $contactData['contact'] = $val; } elseif ($key == 'telephone') { $contactData['telephone'] = $val; } elseif ($key == 'landline_tel') { if ($jid) { $contactData['landline_tel'] = $val; } else { $list1 = explode('-', $val); foreach ($list1 as $ke => $vo) { if ($vo) { $contactData['landline_tel'][$ke] = $vo; } else { $contactData['landline_tel'][$ke] = ''; } } } } elseif ($key == 'email') { $contactData['email'] = $val; } elseif ($key == 'address') { $contactData['address'] = $val; } elseif ($key == 'telephone_show') { $contactData['telephone_show'] = $val; } elseif ($key == 'contact_show') { $contactData['contact_show'] = $val; } elseif ($key == 'landline_tel_show') { $contactData['landline_tel_show'] = $val; } elseif ($key == 'email_show') { $contactData['email_show'] = $val; } elseif ($key == 'notify_mobile') { $contactData['notify_mobile'] = $val; } elseif ($key == 'notify') { $contactData['notify'] = $val; } else { if ($key == 'jobcategory') { $category = explode('.', $val); $jobData['topclass'] = $category[0]; $jobData['category'] = $category[1]; $jobData['subclass'] = $category[2]; } elseif ($key == 'deadline') { if ($val) { $jobData[$key] = time() + ($val * 86400); } else { $jobData[$key] = time() + 30 * 86400; } } elseif ($key == 'tag') { $jobData[$key] = explode(',', $val); } elseif ($key == 'age') { $jobData[$key] = $val; } else { $jobData[$key] = $val; } } } // if (isset($jobData['syqxz_min']) && $jobData['syqxz_min'] && $jobData['syqxz_min'] < $jobData['wage_min']*0.8 ) { // // return response()->json(['status'=>0, 'msg'=>"试用期薪资不得低于正式工资的80%"]); // } $com_info = $this->companyRepository->getCompanyColumn($user->id, ['*']); $setmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype); if (!$jid) { $jobData['audit']= 2; } else { if ($com_info['audit']==1) { $jobData['audit'] = config('aix.companyset.audit.audit_type.audit_verifycom_editjob') == 1?$job_info->audit:2; } else { $jobData['audit'] = config('aix.companyset.audit.audit_type.audit_unexaminedcom_editjob')==1?$job_info['audit']:2; } } $jobArr = ['map_zoom', 'scale', 'companyname', 'created_at', 'audit','trade','subsite_id']; foreach ($jobArr as $key => $val) { if ($val == 'companyname') { $jobData['company_name'] = $com_info['companyname']; } elseif ($val == 'created_at') { $jobData['company_addtime'] = strtotime($com_info['created_at']); } elseif ($val == 'audit') { $jobData['company_audit'] = $com_info['audit']; } else { $jobData[$val] = $com_info[$val]; } } if ($data['wage']==-1) { $jobData['wage'] = -1; $jobData['wage_min']=0; $jobData['wage_max']=0; } else { if (intval($data['wage'])==0) { $jobData['wage'] = 0; $jobData['wage_min']=$data['wage_min']; $jobData['wage_max']=$data['wage_max']; } else { $wage = explode('~', format_wage(get_category($jobData['wage']))); if (isset($wage[1])) { $jobData['wage_max'] =intval($wage[1]); } $jobData['wage_min'] =intval($wage[0]); } } if(isset($data['syq'])){ $jobData['syq']=$data['syq']; } if(isset($data['syqxz_min'])){ $jobData['syqxz_min']=$data['syqxz_min']; } $jobData['company_id'] = $user->id; $jobData['robot'] = 0; $jobData['valid'] = 1; $jobData['refresh_time'] = time(); $jobData['setmeal_deadline'] = $setmeal->endtime ? strtotime($setmeal->endtime) : 0; $jobData['setmeal_id'] = $setmeal->setmeal_id; $jobData['setmeal_name'] = $setmeal->setmeal_name; if ($basis_contact==1) { $contactArr = ['contact', 'telephone', 'landline_tel', 'email', 'address', 'contact_show', 'telephone_show', 'email_show', 'landline_tel_show']; foreach ($contactArr as $key => $val) { if ($val == 'telephone') { $conData[$val] = $com_info['mobile']; } elseif ($val == 'landline_tel') { if ($com_info[$val]) { if ($jid) { $conData[$val] = $com_info[$val]; } else { $list = explode('-', $com_info[$val]); foreach ($list as $ke => $vo) { if ($vo) { $conData[$val][$ke] = $vo; } else { $conData[$val][$ke] = ''; } } } } else { $conData[$val] = ''; } } else { $conData[$val] = $com_info[$val]; } } $jobContactData = $conData; } else { $jobContactData = $contactData; } $subsite_id[] = $com_info['subsite_id']; DB::beginTransaction(); try { if ($jid) { if (!$this->jobsRepository->update($jobData, $jid)) { throw new Exception('修改职位失败'); } //修改分站关系 if ($subsite_id) { if ($this->subsiteJobRepository->findSubsite($jid)->isNotEmpty()) { if (!$this->subsiteJobRepository->deleteWhere(['jobs_id'=>$jid])) { throw new Exception('修改分站关系失败'); } } foreach ($subsite_id as $key => $val) { $sub_data[] = [ 'subsite_id'=>$val, 'jobs_id'=>$jid, 'created_at'=>date('Y-m-d H:i:s', time()), 'updated_at'=>date('Y-m-d H:i:s', time()), ]; } if (false ===$this->subsiteJobRepository->createData($sub_data)) { throw new Exception('修改分站关系失败'); } } if (false===$this->jobsContactRepository->update($jobContactData, $jid)) { throw new Exception('修改联系方式失败'); } event_search_update(Jobs::class, (string)$jid, 'update'); event_search_update(Company::class, (string)$com_info['id'], 'update'); } else { if (false == $jobs = $this->jobsRepository->store($jobData)) { throw new Exception('添加职位失败'); } $jobContactData['job_id'] = $jobs->id; if (false === $this->jobsContactRepository->create($jobContactData)) { throw new Exception('添加联系方式失败'); } // if (!$this->companyRepository->modifyJobsNum($user->id, 1, 1)) { // throw new Exception('修改企业职位数失败!'); // } // if (!$this->membersSetmealRepository->modifyJobsMeanwhile($setmeal->id, 1, 2)) { // throw new Exception('修改套餐可发布职位数失败!'); // } //添加分站关系 if ($subsite_id) { foreach ($subsite_id as $key => $val) { $sub_data[] = [ 'subsite_id'=>$val, 'jobs_id'=>$jobContactData['job_id'], 'created_at'=>date('Y-m-d H:i:s', time()), 'updated_at'=>date('Y-m-d H:i:s', time()), ]; } if (!$this->subsiteJobRepository->createData($sub_data)) { throw new Exception('职位同步至其他分站失败!'); } } event_search_update(Jobs::class, (string)$jobs->id, 'update'); event_search_update(Company::class, (string)$user->id, 'update'); } DB::commit(); if ($jid) { $msg = '修改'; } else { $msg = '添加'; } return response()->json(['status' => 1, 'msg' => $msg . "职位成功"]); } catch (Exception $e) { DB::rollback(); return response()->json(['status' => 0, 'msg' => $e->getMessage()]); } } /**职位关闭 * @param $request * @return JsonResponse */ public function jobsClose($id,$user) { if (!is_array($id)) { $ids = explode(',', $id); } else { $ids = $id; } $jobsExist=$this->jobsRepository->jobsHas($user,$ids); if (empty($jobsExist) && !empty($data['id'])){ return response()->json(['status'=>0, 'msg'=>"没有这个职位"]); } if (!$this->jobsRepository->closeJobs($ids)) { return response()->json(['status' => 0, 'msg' => '职位关闭失败', 'data' => '']); } $condition = [['whereIn','id', $ids]]; event_search_update(Jobs::class, $condition, 'update'); $com_ids =$this->jobsRepository->findWhereIn('id', $ids, ['company_id'])->toArray(); $company_condition = [['whereIn','id', $com_ids]]; event_search_update(Company::class, $company_condition, 'update'); //写日志 if (!is_array($id)) { foreach ($ids as $item) { if (!$this->memberLogRepository->createLog($user,1007,$item)) { throw new \Exception('添加刷新记录失败!'); } } }else{ if (!$this->memberLogRepository->createLog($user,1007,$id)) { throw new \Exception('添加刷新记录失败!'); } } return response()->json(['status' => 1, 'msg' => '职位关闭成功', 'data' => '']); } /** * 职位恢复 * @param $request * @return JsonResponse */ public function jobsShow($id, $user) { $ids = explode(',', $id); $data['display'] = 1; $data['valid'] = 1; $data['deadline'] = time()+config('aix.companyset.comset.com_set.job_expire')*86400; $jobsExist=$this->jobsRepository->jobsHas($user,$ids); if (empty($jobsExist)){ return response()->json(['status'=>0, 'msg'=>"没有这个职位"]); } //查询企业已发布多少职位数 $condition['company_id'] = $user->id; $condition[] = ['audit','<>',3]; $condition['display'] = 1; $condition['valid'] = 1; $jobsCount = $this->jobsRepository->jobsTotal($condition); //查询企业套餐内可发布职位数 $mySetmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype); if ($mySetmeal->jobs_meanwhile<=$jobsCount) { return response()->json(['status'=>0, 'msg'=>"当前显示的职位已经达到最大限制,请升级服务套餐或关闭未招聘职位!"]); } if (!$this->jobsRepository->showJobs($ids, $data)) { return response()->json(['status' => 0, 'msg' => '职位恢复失败', 'data' => '']); } $condition = [['whereIn','id', $ids]]; event_search_update(Jobs::class, $condition, 'update'); $com_ids =$this->jobsRepository->findWhereIn('id', $ids, ['company_id'])->toArray(); $company_condition = [['whereIn','id', $com_ids]]; event_search_update(Company::class, $company_condition, 'update'); //写日志 if (!is_array($id)) { foreach ($ids as $item) { if (!$this->memberLogRepository->createLog($user,1008,$item)) { throw new \Exception('添加删除记录失败!'); } } }else{ if (!$this->memberLogRepository->createLog($user,1008,$id)) { throw new \Exception('添加删除记录失败!'); } } return response()->json(['status' => 1, 'msg' => '职位恢复成功', 'data' => '']); } /** * 职位删除 * @param $request * @return JsonResponse */ public function jobsDel($id, $user) { if (!is_array($id)) { $ids = explode(',', $id); } else { $ids = $id; } $count = count($ids); $setmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype); DB::beginTransaction(); try { if (!$this->jobsRepository->delJobs($ids)) { throw new Exception('职位删除失败'); } // if (!$this->companyRepository->modifyJobsNum($user->id, 2, $count)) { // throw new Exception('修改企业职位数失败!'); // } if (!$this->jobsContactRepository->delJobsContact($ids)) { throw new Exception('删除职位联系人失败!'); } // if (!$this->membersSetmealRepository->modifyJobsMeanwhile($setmeal->id, $count, 1)) { // throw new Exception('修改套餐可发布职位数失败!'); // } $condition = [['whereIn', 'id', $ids]]; event_search_update(Jobs::class, $condition, 'delete'); $com_ids =$this->jobsRepository->findWhereIn('id', $ids, ['company_id'])->toArray(); $company_condition = [['whereIn','id', $com_ids]]; event_search_update(Company::class, $company_condition, 'update'); DB::commit(); } catch (Exception $e) { DB::rollback(); return response()->json(['status' => 0, 'msg' =>$e->getMessage(), 'data' => '']); } //写日志 if (!is_array($id)) { foreach ($ids as $item) { if (!$this->memberLogRepository->createLog($user,1009,$item)) { throw new \Exception('添加删除记录失败!'); } } }else{ if (!$this->memberLogRepository->createLog($user,1009,$id)) { throw new \Exception('添加删除记录失败!'); } } return response()->json(['status' => 1, 'msg' => '职位删除成功', 'data' => '']); } /**招聘效果统计==访客统计 * @param $request * @return mixed * @throws \Throwable */ public function statisticsVisitor($request, $user) { return $this->allStatistics($request, 'visitor', $user); } /**招聘效果统计==职位浏览 * @param $request * @return mixed * @throws \Throwable */ public function statisticsViewjobs($request, $user) { return $this->allStatistics($request, 'viewjobs', $user); } /**招聘效果统计==应聘 * @param $request * @return mixed * @throws \Throwable */ public function statisticsApply($request, $user) { return $this->allStatistics($request, 'apply', $user); } /**招聘效果统计 * @param $request * @param $type * @return mixed * @throws \Throwable */ public function allStatistics($request, $type, $user) { $settr = $request->settr?$request->settr:7; $source = $request->source?$request->source:1; $jobid = $request->jobid?$request->jobid:0; $where['company_id'] = $user->id; $where[] = ['apply', '>=', 0]; $apply = 0; if ($type == "apply") { $where[] = ['apply', '>=',1]; $apply = 1; } $model = $this->companyStatisticsRepository; $today = date('Y-m-d'); $settr_tmp = strtotime($today)-($settr+1)*3600*24; if ($settr>0) { $where[] = ['created_at','>=', date('Y-m-d', $settr_tmp)]; $where[] = ['created_at','<', $today]; } if ($source>0) { $where['source'] = $source; } if ($jobid>0) { $where['job_id'] = $jobid; } $param_array = ['settr','source','jobid','page']; $params= []; if ($request->all()) { foreach ($request->all() as $k => $v) { if (in_array($k, $param_array)) { $params[$k] = $v; } } } $category = []; $set_total = $set_login = []; for ($i=$settr_tmp; $i < strtotime($today); $i=$i+3600*24) { $category[] = date('Y-m-d', $i); $set_total[$i] = 0; $set_login[$i] = 0; } $uidArr = []; $count_num = ['total'=>0,'login'=>0]; if ($type) { $remark = $type.'_'; } else { $remark=''; } $statistics_list = $model->orderBy('created_at', 'desc')->findWhere($where)->toArray(); $view_time = []; foreach ($statistics_list as $key => $value) { if ($value['uid']>0) { if ($value['job_id']>0 && $value['apply']==0 && !isset($view_time['time']['viewjobs'][$value['uid']])) { $view_time['time']['viewjobs'][$value['uid']] = strtotime($value['created_at']); $view_time['source']['viewjobs'][$value['uid']] = $value['source']; } if ($value['job_id']>0 && $value['apply']>0 && !isset($view_time['time']['apply'][$value['uid']])) { $view_time['time']['apply'][$value['uid']] = strtotime($value['created_at']); $view_time['source']['apply'][$value['uid']] = $value['source']; $view_time['source']['visitor'][$value['uid']] = $value['source']; $view_time['time']['visitor'][$value['uid']] = strtotime($value['created_at']); } if ($value['apply']==0 && !isset($view_time['time']['visitor'][$value['uid']])) { $view_time['time']['visitor'][$value['uid']] = strtotime($value['created_at']); $view_time['source']['visitor'][$value['uid']] = $value['source']; } $set_login[strtotime(date('Y-m-d', strtotime($value['created_at'])))]++; $uidArr[] = $value['uid']; } $set_total[strtotime(date('Y-m-d', strtotime($value['created_at'])))]++; $count_num['total']++; } $res ['view_time'] = $view_time; $line_xml = ''; $line_xml.= ''; foreach ($category as $key => $value) { $line_xml.= ''; } $line_xml.= ''; if ($apply == 1) { $line_xml.= ''; foreach ($set_login as $key => $value) { $line_xml.= ''; } $line_xml.= ''; } else { $line_xml.= ''; foreach ($set_total as $key => $value) { $line_xml.= ''; } $line_xml.= ''; $line_xml.= ''; foreach ($set_login as $key => $value) { $line_xml.= ''; } $line_xml.= ''; } $line_xml.= ''; $res ['line_xml'] = $line_xml; if (!empty($uidArr)) { //这里如果需要缓存的话,需要做修改 // $resumelist = Cache::get($remark.$where['apply'].'_'.$user->id.'_'.$jobid.'_'.$source.'_'.$settr.'_resumelist'); // if (null === $resumelist) { $resumelist = $this->resumeRepository->findResumeList($uidArr); // Cache::put($remark.$where['apply'].'_'.$user->id.'_'.$jobid.'_'.$source.'_'.$settr.'_resumelist', $resumelist, 10); // } } else { $resumelist = []; } $sex_total = [1=>0,2=>0]; $sex_total['total'] = 0; $education_total = []; $education_total['total'] = 0; $experience_total = []; $experience_total['total'] = 0; $age_total = []; $age_total['total'] = 0; foreach ($resumelist as $key => $value) { if ($value->display_name=="2") { $resumelist[$key]->fullname="N".str_pad($value->id, 7, "0", STR_PAD_LEFT); } elseif ($value->display_name=="3") { if ($value->sex==1) { $resumelist[$key]->fullname=cut_str($value->fullname, 1, 0, "先生"); } elseif ($value->sex == 2) { $resumelist[$key]->fullname=cut_str($value->fullname, 1, 0, "女士"); } else { $resumelist[$key]->fullname=cut_str($value->fullname, 1, 0, "**"); } } else { $resumelist[$key]->fullname=$value->fullname; } $resumelist[$key]->intention_jobs=cut_str($value->intention_jobs, 10, 0, '..'); $resumelist[$key]->age=date('Y')-$value->birthdate; if (!$request->ajax()) { $count_num['login']++; if ($value->sex>0) { if (isset($sex_total[$value->sex])) { $sex_total[$value->sex]++; } else { $sex_total[$value->sex] = 1; } } if ($value->experience>0) { if (isset($experience_total['total'])) { $experience_total['total'] += 1; } else { $experience_total['total'] = 0; $experience_total['total'] +=1 ; } if (isset($experience_total['data'][$value->experience])) { $experience_total['data'][$value->experience]['num']++; } else { $experience_total['data'][$value->experience]['label'] = $value->experience_cn; $experience_total['data'][$value->experience]['num'] = 1; } } if ($value->education>0) { if (isset($education_total['total'])) { $education_total['total'] += 1; } else { $education_total['total'] = 0; $education_total['total'] +=1 ; } if (isset($education_total['data'][$value->education])) { $education_total['data'][$value->education]['num']++; } else { $education_total['data'][$value->education]['label'] = $value->education_cn; $education_total['data'][$value->education]['num'] = 1; } } if ($value->birthdate>0) { if (isset($age_total['total'])) { $age_total['total'] += 1; } else { $age_total['total'] = 0; $age_total['total'] +=1 ; } $minus_age = date('Y') - $value->birthdate; if ($minus_age<26) { $age_total['data'][0]['label'] = '18-25岁'; if (isset($age_total['data'][0]['num'])) { $age_total['data'][0]['num'] += 1; } else { $age_total['data'][0]['num'] = 0; $age_total['data'][0]['num'] +=1 ; } } elseif ($minus_age<31) { $age_total['data'][1]['label'] = '26-30岁'; if (isset($age_total['data'][1]['num'])) { $age_total['data'][1]['num'] += 1; } else { $age_total['data'][1]['num'] = 0; $age_total['data'][1]['num'] +=1 ; } } elseif ($minus_age<41) { $age_total['data'][2]['label'] = '31-40岁'; if (isset($age_total['data'][2]['num'])) { $age_total['data'][2]['num'] += 1; } else { $age_total['data'][2]['num'] = 0; $age_total['data'][2]['num'] +=1 ; } } elseif ($minus_age<51) { $age_total['data'][3]['label'] = '41-50岁'; if (isset($age_total['data'][3]['num'])) { $age_total['data'][3]['num'] += 1; } else { $age_total['data'][3]['num'] = 0; $age_total['data'][3]['num'] +=1 ; } } else { $age_total['data'][4]['label'] = '50岁'; if (isset($age_total['data'][4]['num'])) { $age_total['data'][4]['num'] += 1; } else { $age_total['data'][4]['num'] = 0; $age_total['data'][4]['num'] +=1 ; } } } } } $res['table_data'] = $resumelist; if ($request->ajax()) { $res['mark'] = $type; $html = view('app.company.ajax.ajax_statistics_list', $res)->render(); return response()->json(['data'=>$html]); } $sex_xml = ''; if (!empty($sex_total['total'])) { $sex_xml.= ''; $sex_xml.= ''; } $sex_xml.= ''; $res['sex_xml'] = $sex_xml; $experience_xml = ''; if (!empty($experience_total['data'])) { foreach ($experience_total['data'] as $key => $value) { $experience_xml.= ''; } } $experience_xml.= ''; $res['experience_xml'] = $experience_xml; // dd($experience_xml); $education_xml = ''; if (!empty($education_total['data'])) { foreach ($education_total['data'] as $key => $value) { $education_xml.= ''; } } $education_xml.= ''; $res['education_xml'] = $education_xml; $age_xml = ''; if (!empty($age_total['data'])) { foreach ($age_total['data'] as $key => $value) { $age_xml.= ''; } } $age_xml.= ''; $res['age_xml'] = $age_xml; $res['source'] = $source; $res['settr'] = $settr; $res['jobid'] = $jobid; $mysetmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, 1); $upper_limit = 0; $jids = $this->jobsRepository->jobsTotal([['company_id', '=', $user->id]]); if ($jids>=$mysetmeal->jobs_meanwhile) { $upper_limit = 1; } $res['upper_limit'] = $upper_limit; $res['source_arr'] = ['1'=>'PC端','2'=>'触屏端','3'=>'移动端']; $res['count_num'] = $count_num; $res['params'] = $params; return $res; } public function callCashPay($user, $increment_info, $my_point, $order_pay_type, $payment_name = '', $amount = '0.0', $is_deductible, $deductible = 0, $description = '', $params = '', $points = 0, $stemeal = 0, $discount = '') { //获取支付方式 $paymenttpye = $this->paymentService->returnPayment($payment_name); if (!$paymenttpye) { return array( 'status'=>0, 'msg' => '支付方式错误!'); } if ($my_point->points < $deductible) { return array( 'status'=>0, 'msg' => '积分不足,请使用其他方式支付!'); } if ($is_deductible==0) { $deductible = 0; } if ($deductible>0) { $m_amount = $amount- floatval($deductible/config('aix.companyset.points.points_set.payment_rate')); } else { $m_amount = $amount; } $m_amount=round($m_amount,2); $paysetarr['ordtotal_fee']=$m_amount; if ($description=='') { $description = '购买服务:'.$increment_info['name']; } $description .= ';'.$paymenttpye->name.$paysetarr['ordtotal_fee'].'元'; if ($deductible>0) { $description .= ';积分支付:'.$deductible.'积分'; } $stime = time(); //生成订单 $order = $this->orderService->addOrder($user, $order_pay_type, $amount, $paysetarr['ordtotal_fee'], 0, $increment_info['name'], $payment_name, $paymenttpye->name, $description, 1, $deductible, $stemeal, 0, serialize($params), $discount); $tradeNo = $this->payService->getTradeNo($order->id); if (!$this->serviceService->updateOid($order->id, $tradeNo)) { throw new ResponseException('生成订单号失败!'); } if ($payment_name == 'wechat') { $type = 'scan'; } else { $type = 'web'; } $payOrder = new PayOrder(); $payOrder->trade_no = $tradeNo; $payOrder->subject = '购买' . $increment_info['name']; $payOrder->detail = $description; $payOrder->price = $m_amount; //执行刷新操作或其他 $payOrder->callback = "App\Services\Common\OrderService.incrementSave"; $payOrder->return_url = route('jobs.list'); $result = $this->payService->pay($payment_name, $type, $payOrder); if ($payment_name == 'wechat') { return response()->json([ 'status' => 1, 'tradeCode' => get_qrcode_html($result->code_url), 'tradeNo' => $tradeNo, ]); } else { return $result; } } /**刷新职位 =======积分刷新职位或套餐内免费 * @param $jid * @param $mySetmeal * @return array */ public function jobsRefreshSave($jid, $user, $mySetmeal) { $jobsCount = count($jid); $where = [ 'uid' => $user->id, 'utype' => 1, 'type' => 1006, 'mode' => 2 ]; $todayCount = $this->refreshLogRepository->getTodayRefreshTimes($where); //今天免费刷新次数 $headsel1 = 0; $free_mode = 0; if ($todayCount >= ($mySetmeal->refresh_jobs_free + config('aix.companyset.comsume.comsume_set.refresh_jobs_more'))) { $myPoints = $this->memberPointRepository->getPointsOne($user->id, 1); if ($myPoints['points'] < ($jobsCount * config('aix.companyset.comsume.comsume_set.refresh_jobs_price') * config('aix.companyset.points.points_set.payment_rate'))) { return ['status' => 0, 'msg' => "你的积分不足,不能刷新职位!"]; } $headsel1=1; $handsel['uid'] = $user->id; $handsel['utype'] = 1; $handsel['htype'] = 'refresh_jobs'; $handsel['htype_cn'] = '刷新职位'; $handsel['operate'] = 2; $handsel['points'] = config('aix.companyset.comsume.comsume_set.refresh_jobs_price') * config('aix.companyset.points.points_set.payment_rate') * $jobsCount; $log_paymode = '积分兑换刷新'; } else { $free_mode = 1; $log_paymode = '套餐内免费刷新'; } //查询职位名称 $jobs_name_arr = $this->jobsRepository->findJobsName($jid); $josname = array_column($jobs_name_arr, 'jobs_name', 'id'); DB::beginTransaction(); try { foreach ($jid as $key => $val) { if (!$this->jobsRepository->jobsRefresh($val)) { throw new \Exception('刷新失败'); } if ($free_mode!=1) { if (!$this->memberPointRepository->reportDeal($user->id, 1, 2, ($jobsCount * config('aix.companyset.comsume.comsume_set.refresh_jobs_price')*config('aix.companyset.points.points_set.payment_rate')))) { throw new \Exception('积分设置失败!'); } } if (!$this->companyRepository->companySave(['refresh_time'=>time()], $user->id)) { throw new \Exception('刷新失败!修改企业信息表失败'); } // 写入会员积分操作日志 if ($headsel1) { if (!$this->memberHandselRepository->addNew($handsel)) { throw new \Exception('刷新失败!会员积分增减记录添加失败'); } } //添加刷新操作日志 $logData = [ 'uid' => $user->id, 'utype' => 1, 'mode' => 2, 'type' => 1006, 'obj_id'=> $val, ]; if (!$this->refreshLogRepository->addLog($logData)) { throw new \Exception('添加刷新记录失败!'); } //写日志 if (!$this->memberLogRepository->createLog($user,1006,[$val,$log_paymode])) { throw new \Exception('添加刷新记录失败!'); } $members_log['log_uid']=$user->id; $members_log['log_utype']=1; $members_log['log_username']=$user->username; $log_leave=$mySetmeal->refresh_jobs_free-1; $members_log['log_leave'] = $log_leave<0?0:$log_leave; $members_log['log_value'] = '刷新职位(职位名称:'.$josname[$val].')'; $members_log['log_source']='网页版'; if (!$this->membersSetmealLogRepository->addNew($members_log)) { throw new \Exception('刷新失败!'); } event_search_update(Jobs::class, (string)$val, 'update'); Cache::put('refresh_jobid_'.$val, $jid, config('aix.companyset.comset.other_set.refresh_jobs_space')); } DB::commit(); return ['status' => 1, 'msg' => "刷新成功!"]; } catch (Exception $e) { DB::rollback(); return ['status' => 0, 'msg' => $e->getMessage()]; } } /** * 付费刷新 */ public function jobRefreshPay($jobs_id, $user, $is_deductible,$deductible,$mySetmeal){ if (isExpire($mySetmeal)){ return ['status' => 0, 'msg' => "提醒:您的套餐已到期,请及时到我的套餐处升级套餐!"]; } DB::beginTransaction(); try { if (!$this->jobsRepository->jobsRefresh($jobs_id)) { throw new \Exception('刷新失败'); } if ($is_deductible) { if (!$this->memberPointRepository->reportDeal($user->id, 1, 2,$deductible)) { throw new \Exception('积分设置失败!'); } } if (!$this->companyRepository->companySave(['refresh_time'=>time()], $user->id)) { throw new \Exception('刷新失败!修改企业信息表失败'); } // 写入会员积分操作日志 $headsel1=1; $handsel['uid'] = $user->id; $handsel['utype'] = 1; $handsel['htype'] = 'refresh_jobs'; $handsel['htype_cn'] = '刷新职位'; $handsel['operate'] = 2; $handsel['points'] = $deductible; if ($headsel1) { if (!$this->memberHandselRepository->addNew($handsel)) { throw new \Exception('刷新失败!会员积分增减记录添加失败'); } } //添加刷新操作日志 $logData = [ 'uid' => $user->id, 'utype' => 1, 'mode' => 2, 'type' => 1006, 'obj_id'=> $jobs_id, ]; if (!$this->refreshLogRepository->addLog($logData)) { throw new \Exception('添加刷新记录失败!'); } //写会员操作日志 if (!$this->memberLogRepository->createLog($user,1006,[$jobs_id,"付费刷新"])) { throw new \Exception('添加刷新记录失败!'); } $members_log['log_uid']=$user->id; $members_log['log_utype']=1; $members_log['log_username']=$user->username; $log_leave=$mySetmeal->refresh_jobs_free-1; $members_log['log_leave'] = $log_leave<0?0:$log_leave; $josname = $this->jobsRepository->getName($jobs_id); $members_log['log_value'] = '刷新职位(职位名称:'.$josname.')'; $members_log['log_source']='网页版'; if (!$this->membersSetmealLogRepository->addNew($members_log)) { throw new \Exception('刷新失败!'); } event_search_update(Jobs::class, (string)$jobs_id, 'update'); DB::commit(); Cache::put('refresh_jobid_'.$jobs_id, $jobs_id, config('aix.companyset.comset.other_set.refresh_jobs_space')); return ['status' => 1, 'msg' => "刷新成功!"]; } catch (Exception $e) { DB::rollback(); return ['status' => 0, 'msg' => $e->getMessage()]; } } /** * 微信公众号刷新职位 */ public function jobsRefreshWechat($user) { //企业发布职位数 $map['company_id'] = $user->id; if (config('aix.companyset.comset.show_set.jobs_display')== 1) { $map['audit'] = 1; } $map['display'] = 1; $map['valid'] = 1; $user_jobs = $this->jobsRepository->getComJobs($map); //我的套餐 $mySetmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype); if (isExpire($mySetmeal)){ return ['status' => 0, 'msg' => "提醒:您的套餐已到期,请及时到我的套餐处升级套餐!"]; } //我的积分 $myPoints = $this->memberPointRepository->getPointsOne($user->id, 1); $where = [ 'uid' => $user->id, 'utype' => 1, 'type' => 1006, 'mode' => 2 ]; $todayCount = $this->refreshLogRepository->getTodayRefreshTimes($where); //今天免费刷新次数 //没有可刷新职位 if (count($user_jobs)==0) { return ['status'=>2,'msg'=>'没有可刷新的职位']; } //刷新间隔时间 $where1 = [ 'uid' => $user->id, 'utype' => 1, 'type' => 1006, 'mode' => 2 ]; $refrestime = $this->refreshLogRepository->getLastRefreshDate($where1); $duringtime = time() - strtotime($refrestime?$refrestime->created_at:0); $space = config('aix.companyset.comset.other_set.refresh_jobs_space') * 60; if ($space > 0 && $duringtime <= $space) { return ['status' => 3, 'msg' => $space . "秒内不能重复刷新职位",]; } $headsel1 = 0; $free_mode = 0; if ($todayCount >= ($mySetmeal->refresh_jobs_free + config('aix.companyset.comsume.comsume_set.refresh_jobs_more'))) { if ($myPoints['points'] < (count($user_jobs) * config('aix.companyset.comsume.comsume_set.refresh_jobs_price') * config('aix.companyset.points.points_set.payment_rate'))) { return ['status' => 4, 'msg' => "你的积分不足,不能刷新职位!", 'url'=>route('mobile.firm.service.points.add')]; } $headsel1=1; $handsel['uid'] = $user->id; $handsel['utype'] = 1; $handsel['htype'] = 'refresh_jobs'; $handsel['htype_cn'] = '刷新职位'; $handsel['operate'] = 2; $handsel['points'] = config('aix.companyset.comsume.comsume_set.refresh_jobs_price') * config('aix.companyset.points.points_set.payment_rate') * count($user_jobs); $log_paymode = '积分兑换刷新'; } else { $free_mode = 1; $log_paymode = '套餐内免费刷新'; } //查询职位名称 $jobs_name_arr = $this->jobsRepository->getComJobs($map, ['id','jobs_name']); $josname = array_column($jobs_name_arr, 'jobs_name', 'id'); $jid = array_column($jobs_name_arr, 'id', 'jobs_name'); DB::beginTransaction(); try { foreach ($jid as $key => $val) { if (!$this->jobsRepository->jobsRefresh($val)) { throw new \Exception('刷新失败'); } if ($free_mode!=1) { if (!$this->memberPointRepository->reportDeal($user->id, 1, 2, (count($user_jobs) * config('aix.companyset.comsume.comsume_set.refresh_jobs_price')*config('aix.companyset.points.points_set.payment_rate')))) { throw new \Exception('积分设置失败!'); } } if (!$this->companyRepository->companySave(['refresh_time'=>time()], $user->id)) { throw new \Exception('刷新失败!修改企业信息表失败'); } // 写入会员积分操作日志 if ($headsel1) { if (!$this->memberHandselRepository->addNew($handsel)) { throw new \Exception('刷新失败!会员积分增减记录添加失败'); } } //添加刷新操作日志 $logData = [ 'uid' => $user->id, 'utype' => 1, 'mode' => 2, 'type' => 1006, 'obj_id'=> $val, ]; if (!$this->refreshLogRepository->addLog($logData)) { throw new \Exception('添加刷新记录失败!'); } $members_log['log_uid']=$user->id; $members_log['log_utype']=1; $members_log['log_username']=$user->username; $log_leave=$mySetmeal->refresh_jobs_free-1; $members_log['log_leave'] = $log_leave<0?0:$log_leave; $members_log['log_value'] = '刷新职位(职位名称:'.$josname[$val].')'.$log_paymode; $members_log['log_source']='网页版'; if (!$this->membersSetmealLogRepository->addNew($members_log)) { throw new \Exception('刷新失败!'); } Cache::put('refresh_jobid_'.$val, $jid, config('aix.companyset.comset.other_set.refresh_jobs_space')); } DB::commit(); return ['status' => 1, 'msg' => "刷新成功!"]; } catch (Exception $e) { DB::rollback(); return ['status' => 0, 'msg' => $e->getMessage()]; } } /** * 企业会员中心首页一键刷新职位 */ public function jobsRefreshAll($user) { $map['company_id'] = $user->id; if (config('aix.companyset.comset.show_set.jobs_display')== 1) { //如果是先审核再展示 $map['audit'] = 1; }else{ $map[]= ['audit', '!=',"3"];//如果是先展示再审核,去掉审核未通过的 } $map['valid'] = 1; $user_jobs = $this->jobsRepository->jobsTotal($map); if ($user_jobs==0) { return response()->json(['status'=>0,'msg'=>'没有可刷新的职位']); } $where = [ 'uid' => $user->id, 'utype' => 1, 'type' => 1006, 'mode' => 2 ]; $refresh_time = $this->refreshLogRepository->getTodayRefreshTimes($where); $mySetmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype); if (isExpire($mySetmeal)){ return response()->json(['status' => 0, 'msg' => "提醒:您的套餐已到期,请及时到我的套餐处升级套餐!"]); } if (!$mySetmeal) { return response()->json(['status'=>0,'msg'=>'您还没有开通服务,请开通!']); } if ($mySetmeal->exprie == 1 && $mySetmeal->setmeal_id > 1) { return response()->json(['status'=>0,'msg'=>'您的服务已经到期,请重新开通!']); } $route = route('jobs.list'); if(is_mobile_route()){ $route = route('mobile.firm.jobs.list'); } if(isset(request()->vail)&&!empty(request()->vail)){ $condition['company_id'] = $user->id; if (config('aix.companyset.comset.show_set.jobs_display')== 1) { $condition['audit'] = 1; }else{ $condition[]= ['audit', '!=',"3"];//如果是先展示再审核,去掉审核未通过的 } $condition['valid'] = 1; $jobsid_arr = $this->jobsRepository->findWhere($condition, ['id'])->toArray(); $yid = array_column($jobsid_arr, 'id'); $r = $this->jobsRefreshSave($yid, $user, $mySetmeal); return response()->json(['status'=>$r['status'],'msg'=>$r['msg']]); }else{ if ($refresh_time >= $mySetmeal->refresh_jobs_free) { return response()->json(['status'=>2,'msg'=>'      您当前共有 '.$user_jobs.' 条在招职位,今天免费刷新次数已用完。
请前往 职位列表 单条刷新。','data'=>route('jobs.list', ['type'=>1])]); /* $mobile_surplus = $mySetmeal->refresh_jobs_free + config('aix.companyset.comsume.comsume_set.refresh_jobs_more')-$refresh_time; if ($mobile_surplus >= 0) { return response()->json(['status'=>2,'msg'=>'      您当前共有 '.$user_jobs.' 条在招职位,今天免费刷新次数已用完。
请前往 职位列表 单条刷新。使用触屏版还可免费刷新 '.$mobile_surplus.' 次!','data'=>route('jobs.list', ['type'=>1])]); } else { return response()->json(['status'=>2,'msg'=>'      您当前共有 '.$user_jobs.' 条在招职位,今天免费刷新次数已用完。
请前往 职位列表 单条刷新。','data'=>route('jobs.list', ['type'=>1])]); }*/ } elseif ($user_jobs+$refresh_time>$mySetmeal->refresh_jobs_free) { $surplus = $mySetmeal->refresh_jobs_free - $refresh_time; return response()->json(['status'=>2,'msg'=>'      您当前共有 '.$user_jobs.' 条在招职位,今天免费刷新次数剩余 '.$surplus.' 次。
请前往 职位列表 单条刷新。','data'=>route('jobs.list', ['type'=>1])]); } else { $surplus = $mySetmeal->refresh_jobs_free - $refresh_time; return response()->json(['status'=>3,'msg'=>'      您当前共有 '.$user_jobs.' 条在招职位,今天免费刷新次数剩余 '.$surplus.' 次。
如不需要批量刷新职位,请前往 职位列表 单条刷新。','data'=>route('jobs.list', ['type'=>1])]); } } } //找工作 public function getLists($whereData) { //默认地区 $citycategory = array_get($whereData, 'citycategory'); if (!$citycategory) { $citycategory = config('aix.system.site_other.site_other.district'); } return false; } public function getJobInfo($where, $user = null) { $val = $this->jobsRepository->getInfo($where); if (!$val) { return ['status'=>0,'error'=>'职位不存在']; } if (!($user && $user->utype == 1 && $user->id == $val->company_id)) { if ($val->display != 1) { return ['status'=>0,'error'=>'职位已关闭']; } if ($val->valid != 1) { return ['status'=>0,'error'=>'职位已失效']; } if (config('aix.companyset.comset.show_set.jobs_display')==1) { if ($val->audit !='1') { return ['status'=>0,'error'=>'职位审核中或审核失败']; } } else { if ($val->audit =='3') { return ['status'=>0,'error'=>'职位审核失败']; } } } $companyInfo = $this->companyRepository->find($val->company_id, ['utype']); $tmp = 0; if (($val->audit == 2 && config('aix.companyset.comset.show_set.jobs_display') == 1) || $val->audit == '3') { $tmp = 1; } /*if ($tmp) { throw new ResponseException('职位不存在', '', '404'); }*/ $val->tmp = $tmp; /*$subsite_type = Cache::get('subsite_type'); //TODO 获取职位信息时添加分站判断,判断职位是否可以在当前分站显示 if ($subsite_type) { //获取职位分站id $subsite_id = get_jobs_subsite_id($val); //判断分站是否可以访问 check_url(Cache::get('subsite_id'), $subsite_id); }*/ if ($val->deadline < time()) { $val->jobs_overtime = 1; } elseif ($val->audit <> '1' || $val->display <> '1' || ($val->setmeal_deadline <> '0' && $val->setmeal_deadline < time())) { $val->jobs_overtime = 2; } if ($val->setmeal_deadline < time() && $val->setmeal_deadline <> "0" && $val->add_mode == "2") { $val->deadline = $val->setmeal_deadline; } if ($val->amount == 0) { $val->amount = '若干'; } $subsite_id = get_jobs_subsite_id($val); $val->jobs_url = route(url_rewrite('AIX_jobsshow', null, $subsite_id), array('id'=>$val['id'])); $setmeal = $this->membersSetmealRepository->getSetmealByUid($val->company_id, $companyInfo->utype); $val->show_contact_direct = $setmeal->show_contact_direct; $profile = $this->companyRepository->getCompanyInfo(array('id'=>$val->company_id)); $profile->setmeal_id = $setmeal->setmeal_id; $profile->setmeal_name = $setmeal->setmeal_name; $val->company = $profile; $val->contact =$this->jobsContactRepository->getContactInfo(array('job_id'=>$val->id)); $val->expire = sub_day($val->deadline, time()); $val->contents = htmlspecialchars_decode($val->contents, ENT_QUOTES); $val->refresh_time_cn = daterange(time(), $val->refresh_time, 'Y-m-d', "#FF3300"); $val->company_url = route(url_rewrite('AIX_companyshow'), array('id'=>$val->company_id)); if ($val->company->logo) { $val->company->logo=upload_asset($val->company->logo); } else { $val->company->logo = public_data_path('data/upload/no_logo.png'); } if ($val->company->website) { $val->company->website_ = $val->company->website; if ((strstr($val->company->website, "http://") === false) && (strstr($val->company->website, "https://") === false)) { $val->company->website = "http://".$val->company->website; } else { if (strstr($val->company->website, "http://") === false) { $val->company->website_ = str_replace("https://", "", $val->company->website_); } else { $val->company->website_ = str_replace("http://", "", $val->company->website_); } } } //薪资待遇 if ($val->wage > 0) { $wage_category = $this->categoryRepository->getOriginCategory(array('alias'=>'AIX_wage','id'=>$val->wage)); if ($wage_category && preg_match_all('(\d+)', $wage_category->demand, $reg)) { $reg = $reg[0]; if (config('aix.system.site_other.site_other.site_salary') == 1) { $val->minwage = $reg[0]%1000==0?(($reg[0]/1000).'K'):(round($reg[0]/1000, 1).'K'); $val->maxwage = array_has($reg, 1)?($reg[1]%1000==0?(($reg[1]/1000).'K'):(round($reg[1]/1000, 1).'K')):0; } elseif (config('aix.system.site_other.site_other.site_salary') == 2) { if ($reg[0] >= 10000) { if ($reg[0]%10000 == 0) { $val->minwage = ($reg[0]/10000).'万'; } else { $minwage = round($reg[0]/10000, 1); $val->minwage = strpos($minwage, '.') ? str_replace('.', '万', $minwage) : $minwage.'万'; } } else { if ($reg[0]%1000 == 0) { $val->minwage = ($reg[0]/1000).'千'; } else { $minwage = round($reg[0]/1000, 1); $val->minwage = strpos($minwage, '.') ? str_replace('.', '千', $minwage) : $minwage.'千'; } } if (array_has($reg, 1)) { if ($reg[1] >= 10000) { if ($reg[1]%10000 == 0) { $val->maxwage = ($reg[1]/10000).'万'; } else { $maxwage = round($reg[1]/10000, 1); $val->maxwage = strpos($maxwage, '.') ? str_replace('.', '万', $maxwage) : $maxwage.'万'; } } elseif ($reg[1]) { if ($reg[1]%1000 == 0) { $val->maxwage = ($reg[1]/1000).'千'; } else { $maxwage = round($reg[1]/1000, 1); $val->maxwage = strpos($maxwage, '.') ? str_replace('.', '千', $maxwage) : $maxwage.'千'; } } else { $val->maxwage = 0; } } else { $val->maxwage = 0; } } } else { $val->maxwage = 0; } if ($val->minwage == $val->maxwage) { $val->wage_cn = $val->minwage.'/月'; } else { if ($val->minwage>0 && $val->maxwage==0) { $val->wage_cn = $val->minwage.'以上/月'; } else { $val->wage_cn = $val->minwage.'~'.$val->maxwage.'/月'; } } } elseif ($val->wage == -1) { $val->wage_cn = '面议'; } else { //自定义薪资 $maxwage = $val->wage_max; $minwage = $val->wage_min; if ($val->ygxs == '363') { $val->wage_cn = $val->wage_min . '元/小时'; } else { if (config('aix.system.site_other.site_other.site_salary') == 1) { $val->minwage = $minwage % 1000 == 0 ? (($minwage / 1000) . 'K') : (round($minwage / 1000, 1) . 'K'); if ($minwage == 0) { $val->maxwage = '以上'; } else { $val->maxwage = $maxwage % 1000 == 0 ? (($maxwage / 1000) . 'K') : (round($maxwage / 1000, 1) . 'K'); } } elseif (config('aix.system.site_other.site_other.site_salary') == 2) { if ($minwage >= 10000) { if ($minwage % 10000 == 0) { $val->minwage = ($minwage / 10000) . '万'; } else { $minwage = round($minwage / 10000, 1); $val->minwage = strpos($minwage, '.') ? str_replace('.', '万', $minwage) : $minwage . '万'; } } else { if ($minwage % 1000 == 0) { $val->minwage = ($minwage / 1000) . '千'; } else { $minwage = round($minwage / 1000, 1); $val->minwage = strpos($minwage, '.') ? str_replace('.', '千', $minwage) : $minwage . '千'; } } if ($maxwage > 0) { if ($maxwage >= 10000) { if ($maxwage % 10000 == 0) { $val->maxwage = ($maxwage / 10000) . '万'; } else { $maxwage = round($maxwage / 10000, 1); $val->maxwage = strpos($maxwage, '.') ? str_replace('.', '万', $maxwage) : $maxwage . '万'; } } elseif ($maxwage) { if ($maxwage % 1000 == 0) { $val->maxwage = ($maxwage / 1000) . '千'; } else { $maxwage = round($maxwage / 1000, 1); $val->maxwage = strpos($maxwage, '.') ? str_replace('.', '千', $maxwage) : $maxwage . '千'; } } else { $val->maxwage = '0'; } } else { $val->maxwage = '0'; } } if ($val->minwage == $val->maxwage) { $val->wage_cn = $val->minwage . '/月'; } else { if ($val->minwage > 0 && $val->maxwage == 0) { $val->wage_cn = $val->minwage . '以上/月'; } else { $val->wage_cn = $val->minwage . '~' . $val->maxwage . '/月'; } } } } $age = $val->age; if (count($age)>1) { if (!$age[0] && !$age[1]) { $val->age_cn = '不限'; } else { if ($age[0] && $age[1]) { $val->age_cn = $age[0].'-'.$age[1].'岁'; } else { $age[0] && $val->age_cn = $age[0].'岁以上'; $age[1] && $val->age_cn = $age[1].'岁以下'; } } } else { $val->age_cn = $val->age_cn = (int)$age[0].'岁以上'; } $other_categories = $this->categoryRepository->getCategories(); //企业性质 if ($other_categories) { $company_types = array_get($other_categories, 'AIX_company_type'); if ($company_types) { $type_cn = array_get($company_types, $val->company->nature); if ($type_cn) { $val->company->nature_cn = $type_cn['demand']; } } //企业行业 $company_trades = array_get($other_categories, 'AIX_trade'); if ($company_trades) { $trade_cn = array_get($company_trades, $val->company->trade); if ($trade_cn) { $val->company->trade_cn = $trade_cn['demand']; } } //企业规模 $company_scales = array_get($other_categories, 'AIX_scale'); if ($company_scales) { $scale_cn = array_get($company_scales, $val->company->scale); if ($scale_cn) { $val->company->scale_cn = $scale_cn['demand']; } } } else { $val->company->nature_cn = ''; $val->company->trade_cn = ''; $val->company->scale_cn = ''; } //标签 $job_tags = array(); if ($other_categories) { $job_tags = array_get($other_categories, 'AIX_jobtag'); } if (implode(',', $val->tag)) { $tag_cn = array(); foreach ($val->tag as $k => $v) { $tag = array_get($job_tags, $v); $tag_cn[] = $tag['demand']; } $val->tag_cn = $tag_cn; } else { $val->tag_cn = array(); } if ($other_categories) { //工作性质 $job_nature = array_get($other_categories, 'AIX_jobs_nature'); if ($job_nature) { $nature_cn = array_get($job_nature, $val->nature); if ($nature_cn) { $val->nature_cn = $nature_cn['demand']; } else { $val->nature_cn = '不限'; } } //工作经验 $job_experience = array_get($other_categories, 'AIX_experience'); if ($job_experience) { $experience_cn = array_get($job_experience, $val->experience); } if ($experience_cn) { $val->experience_cn = $experience_cn['demand']; } else { $val->experience_cn = '不限'; } //学历要求 $job_education = array_get($other_categories, 'AIX_education'); if ($job_education) { $education_cn = array_get($job_education, $val->education); } if ($education_cn) { $val->education_cn = $education_cn['demand']; } else { $val->education_cn = '不限'; } //职位类别 $categories = array(); if (Cache::has('jobs_cate_list')) { $categories = Cache::get('jobs_cate_list'); } else { $categories = $this->categoryJobsRepository->jobsCateInfoCache(); Cache::put('jobs_cate_list', $categories, '86400'); } $category = array(); if ($val->subclass) { $category = array_get($categories['id'], $val->subclass); } elseif ($val->category) { $category = array_get($categories['id'], $val->category); } elseif ($val->topclass) { $category = array_get($categories['id'], $val->topclass); } if ($category) { $val->category_cn = $category['name']; } else { $val->category_cn = ''; } //职位类别 if ($this->app_spell) { $spell = $val->category ? $val->category : $val->topclass; if ($spell) { $val->jobcategory = $categories['id'][$spell]['spell']; } else { $val->jobcategory = ''; } $val->jobcategory_id = $spell; } else { $val->jobcategory = intval($val->topclass).".".intval($val->category).".0"; $val->jobcategory_id = $val->category ? $val->category : $val->topclass; } //用工形式 $company_ygxs = array_get($other_categories, 'AIX_ygxs'); if ($company_ygxs) { $ygxs_cn = array_get($company_ygxs, $val->ygxs); if ($ygxs_cn) { $val->ygxs_cn = $ygxs_cn['demand']; } else { $val->ygxs_cn = '不限'; } } //技能等级 $techlevels = array_get($other_categories, 'AIX_techlevel'); if ($techlevels) { $techlevel_cn = array_get($techlevels, $val->techlevel); if ($techlevel_cn) { $val->techlevel_cn = $techlevel_cn['demand']; } else { $val->techlevel_cn = '不限'; } } //试用期 $syqs = array_get($other_categories, 'zs_syq'); if ($syqs) { if (empty($val->syq)) { $val->syq = 367; } $syq_cn = array_get($syqs, $val->syq); if ($syq_cn) { $val->syq_cn = $syq_cn['demand']; } else { $val->syq_cn = '无'; } } //试用期工资: if ($val->wage == -1) { $val->syqxz_min_cn='面议'; } else { $val->syqxz_min_cn=$val->syqxz_min.'元/月'; } } //性别要求 if ($val->sex =='1') { $val->sex_cn = '男'; } elseif ($val->sex =='2') { $val->sex_cn = '女'; } else { $val->sex_cn = '不限'; } //工作地点 $city_cates = Cache::get('city_cate_list'); if (null === $city_cates) { $city_cates = $this->categoryDistrictRepository->cityCateCache(); Cache::put('city_cate_list', $city_cates, '86400'); } if (!strpos($val->district, ".")) { if (array_get($city_cates['id'], $val->district)) { $val->district_cn = $city_cates['id'][$val->district]['name']; if ($city_cates['id'][$val->district]['parent_id'] > 0) { $parent_district = array_get($city_cates['id'], $city_cates['id'][$val->district]['parent_id']); if ($parent_district) { $val->district_cn = $parent_district['name'].$val->district_cn; if ($parent_district['parent_id'] > 0) { $pp_district = array_get($city_cates['id'], $parent_district['parent_id']); if ($pp_district) { $val->district_cn = $pp_district['name'].$val->district_cn; } } } } } } else { $city_district = explode('.', $val->district); $city_district_cn = array(); foreach ($city_district as $k => $v) { if ($v) { $district_info = array_get($city_cates['id'], $v); if ($district_info) { $city_district_cn[] = $district_info['name']; } } } $val->district_cn = implode('/', $city_district_cn); } //企业所在地区 if (!strpos($val->company->district, ".")) { //直接读取地区信息 $district_cn = array_get($city_cates['id'], $val->company->district); if ($district_cn) { $val->company->district_cn = $district_cn['name']; } } else {//处理地区信息 $c_district = explode('.', $val->company->district); $district_cn = []; foreach ($c_district as $k => $v) { if ($v) { $district_info = array_get($city_cates['id'], $v); if ($district_info) { $district_cn[] = $district_info['name']; } } } $district_cn = implode('/', $district_cn); $val->company->district_cn = $district_cn; } //处理联系方式是否显示 $hide = true; if (isMobile()) { $showjobcontact = config('aix.companyset.comset.contact_set.showjobcontact_wap'); } else { $showjobcontact = config('aix.companyset.comset.contact_set.showjobcontact'); } if ($showjobcontact == 0) { $hide = false; } elseif ($showjobcontact == 1) { if ($user) { $hide = false; } } //判断是否是企业用户自己创建的职位 if ($hide) { if ($user && $user->utype ==1 && $val->company_id == $user->id) { $hide = false; } } if ($hide) { if ($val->contact->telephone) { $val->contact->telephone = contact_hide($val->contact->telephone); } else { $val->contact->telephone = contact_hide(trim(implode('-', $val->contact->landline_tel), '-'), 1); } } else { if ($user && $user->utype ==1 && $val->company_id == $user->id) { $val->contact->contact_show = 1; $val->contact->telephone_show = 1; if (!$val->contact->telephone) { $val->contact->telephone = trim(implode('-', $val->contact->landline_tel), '-'); } } else { if ($val->contact->telephone_show==0 && $val->contact->landline_tel_show==0) { $val->contact->telephone_show = 0; } elseif ($val->contact->telephone_show==1 && $val->contact->telephone) { $val->contact->telephone_show = $val->contact->telephone_show; } elseif ($val->contact->telephone && (!$val->contact->landline_tel || ($val->contact->landline_tel && !trim(implode('-', $val->contact->landline_tel), '-'))) && $val->contact->telephone_show==0) { $val->contact->telephone_show = $val->contact->telephone_show; } else { $val->contact->telephone = trim(implode('-', $val->contact->landline_tel), '-'); $val->contact->telephone_show = $val->contact->landline_tel_show; } } } $val->contact->telephone_ = $val->contact->telephone; if (config('aix.companyset.comset.contact_type_set.contact_img_com') == 2) { $pwdhash = config('aix.system.site_other.site_other.pwb_hash'); $val->contact->telephone = "encrypt($val->contact->telephone, $pwdhash),'type'=>'phone'))."' />"; } elseif (config('aix.companyset.comset.contact_type_set.contact_img_com') == 3 && C('LOG_SOURCE')!=2) {// 扫码获取 $val->contact->telephone = ''; } $val->hide = $hide; //简历处理效率 $app_where[] = array('jobs_id','=',$val->id); $app_where[] = array('created_at','>',date('Y-m-d H:i:s', strtotime("-14day"))); $apply = $this->personalJobsApplyRepository->getJobsApply($app_where); $val->deliver = 0; $reply = 0; $reply_time = 0; foreach ($apply as $key => $v) { if ($v->is_reply) { $reply++; if ($v->reply_time) { $reply_time += $v->reply_time - strtotime($v->created_at); } } if ($user && $user->utype==2 && $user->id == $v->personal_uid) { $val->deliver = 1; } } if (count($apply)) { $val->company->reply_ratio = !$apply ? '0%' : intval($reply / count($apply) * 100).'%'; } else { $val->company->reply_ratio = '0%'; } $val->company->reply_time = !$reply_time ? '0天' : sub_day(intval($reply_time / count($apply)), 0); if (!$val->company->last_login_time) { $val->company->last_login_time = '未登录'; } if ($user && $user->utype == 2) { $resume = $this->resumeRepository->getPersonInfo($user->id); $val->resume = $resume; if ($resume) { $val->resume->url = route(url_rewrite('AIX_resumeshow'), ['id'=>$val->resume->id]); } //判断是否在黑名单 $shield_where = [ 'uid' => $user->id, 'company_id' => $val->company_id ]; if(!$this->ResumePrivacyRepository->getShield($shield_where)) { //没有记录访问记录 $log_where = array('uid'=>$user->id,'job_id'=>$val->id); $view_log = $this->viewJobRepository->getLog($log_where, 1); if ($view_log) { $log_data = array('updated_at' => date('Y-m-d H:i:s', time())); $this->viewJobRepository->update($log_data, $log_where); } else { $time = date('Y-m-d H:i:s', time()); $log_data = array( 'uid' => $user->id, 'job_id' => $val->id, 'company_id' => $val->company_id, 'created_at' => $time, 'updated_at' => $time ); $this->viewJobRepository->addLog($log_data); } } //检测是否已收藏 $favor_log = $this->personFavoriteRepository->getInfo(array('job_id'=>$val->id,'uid'=>$user->id)); if ($favor_log) { $val->favor = 1; } else { $val->favor = 0; } } else { $val->favor = 0; } //来源分站名称 $subsites = Cache::get('subsites_list'); if (array_has($subsites, $val->subsite_id)) { $val->subsite_cn = $subsites[$val->subsite_id]['sitename']; } else { $val->subsite_cn = ''; } // if(!$this->memberLogRepository->createLog(auth('web-company')->user(),2034,$where['id'])){ // throw new \Exception("日志记失败!"); // } return ['status'=>1, 'job'=>$val]; } public function incrementData($where, $num, $filed) { return $this->jobsRepository->incrementData($where, $num, $filed); } //获取紧急招聘职位 public function getEmergencyJobs($limit = '') { $emergency_jobs = array(); $emergency_where = array( array('valid','=','1'), array('emergency','=','1') ); if (config('aix.companyset.comset.show_set.jobs_display')==1) { $emergency_where[] = array('audit','=',1); } else { $emergency_where[] = array('audit','<>',3); } $emergency_where[] = array('display','=',1); $emergency_where[] = array('valid','=',1); $emergency_jobs = $this->getOtherJobs($emergency_where, $limit); return $emergency_jobs; } //获取最新职位 public function getNewJobs($limit = '') { $new_jobs = array(); $where = array( array('valid','=','1'), ); if (config('aix.companyset.comset.show_set.jobs_display')==1) { $where[] = array('audit','=',1); } else { $where[] = array('audit','<>',3); } $where[] = array('display','=',1); $where[] = array('valid','=',1); $where[] = array('deadline','>',time()); $jobs = $this->jobsRepository->getCompanyJobs($where, array(), array('refresh_time'=>'desc'), $limit); if ($jobs->isNotEmpty()) { $other_categories = $this->categoryRepository->getCategories(); if ($other_categories) { $wages = array_get($other_categories, 'AIX_wage'); $educations = array_get($other_categories, 'AIX_education'); $experiences = array_get($other_categories, 'AIX_experience'); $natures = array_get($other_categories, 'AIX_job_nature'); } else { $wages = array(); $educations = array(); $experiences = array(); $natures = array(); } $city_cates = Cache::get('city_cate_list'); if (null === $city_cates) { $city_cates = $this->categoryDistrictRepository->cityCateCache(); Cache::put('city_cate_list', $city_cates, '86400'); } foreach ($jobs as $k => $v) { //修改薪资信息 $jobs[$k]->wage_cn = '薪资面议'; if ($wages) { if ($wage= array_get($wages, $v->wage)) { $jobs[$k]->wage_cn = $wage['demand']; if (config('aix.system.site_other.site_other.site_salary') == 1) { $jobs[$k]->wage_cn = array_has($wages, [$v->wage])?$wages[$v->wage]['k_demand']:'面议'; } elseif (config('aix.system.site_other.site_other.site_salary') == 2) { $jobs[$k]->wage_cn = array_has($wages, [$v->wage])?$wages[$v->wage]['c_demand']:'面议'; } } } //修改学历 $jobs[$k]->education_cn = '学历不限'; if ($educations) { if ($education = array_get($educations, $v->education)) { $jobs[$k]->education_cn = $education['demand']; } } //工作经验 $jobs[$k]->experience_cn = '经验不限'; if ($experiences) { if ($experience = array_get($experiences, $v->experience)) { $jobs[$k]->experience_cn = $experience['demand']; } } //职位性质 $jobs[$k]->nature_cn = '不限'; if ($natures) { if ($nature = array_get($natures, $v->nature)) { $jobs[$k]->nature_cn = $nature['demand']; } } //修改工作所在地 $jobs[$k]->district_cn =''; if (!strpos($v->district, ".")) { $district_cn = array_get($city_cates['id'], $v->district); if ($district_cn) { $jobs[$k]->district_cn = $district_cn['name']; } } else { $c_district = explode('.', $v->district); $district_cn = array(); foreach ($c_district as $j => $val) { if ($val) { $district_info = array_get($city_cates['id'], $val); if ($district_info) { $district_cn[] = $district_info['name']; } } } $district_cn = implode('/', $district_cn); $jobs[$k]->district_cn = $district_cn; } //企业logo $company = $v->company; if ($company->logo) { $jobs[$k]->company_logo=upload_asset($company->logo); } else { $jobs[$k]->company_logo = public_data_path('data/upload/no_logo.png'); } } $new_jobs = $jobs; } return $new_jobs; } public function getOtherJobs($where, $limit = '') { $lists = $this->jobsRepository->getOtherJobs($where, $limit); if (!$lists->toArray()) { return $lists; } else { $other_categories = $this->categoryRepository->getCategories(); if ($other_categories) { $wages = array_get($other_categories, 'AIX_wage'); $educations = array_get($other_categories, 'AIX_education'); $experiences = array_get($other_categories, 'AIX_experience'); $natures = array_get($other_categories, 'AIX_job_nature'); } else { $wages = array(); $educations = array(); $experiences = array(); $natures = array(); } $city_cates = Cache::get('city_cate_list'); if (null === $city_cates) { $city_cates = $this->categoryDistrictRepository->cityCateCache(); Cache::put('city_cate_list', $city_cates, '86400'); } foreach ($lists as $k => $v) { //修改薪资信息 $lists[$k]->wage_cn = '面议'; if ($v->wage >0) { if ($wages) { if ($wage= array_get($wages, $v->wage)) { $lists[$k]->wage_cn = $wage['demand']; if (config('aix.system.site_other.site_other.site_salary') == 1) { $lists[$k]->wage_cn = array_has($wages, [$v->wage])?$wages[$v->wage]['k_demand']:'面议'; } elseif (config('aix.system.site_other.site_other.site_salary') == 2) { $lists[$k]->wage_cn = array_has($wages, [$v->wage])?$wages[$v->wage]['c_demand']:'面议'; } } } } elseif ($v->wage == 0) { $lists[$k]->wage_cn = $this->dealWage($v->wage, $v->wage_min, $v->wage_max); } //修改学历 $lists[$k]->education_cn = '学历不限'; if ($educations) { if ($education = array_get($educations, $v->education)) { $lists[$k]->education_cn = $education['demand']; } } //工作经验 $lists[$k]->experience_cn = '经验不限'; if ($experiences) { if ($experience = array_get($experiences, $v->experience)) { $lists[$k]->experience_cn = $experience['demand']; } } //职位性质 $lists[$k]->nature_cn = '不限'; if ($natures) { if ($nature = array_get($natures, $v->nature)) { $lists[$k]->nature_cn = $nature['demand']; } } //修改工作所在地 $lists[$k]->district_cn =''; if (!strpos($v->district, ".")) { $district_cn = array_get($city_cates['id'], $v->district); if ($district_cn) { $lists[$k]->district_cn = $district_cn['name']; } } else { $c_district = explode('.', $v->district); $district_cn = array(); foreach ($c_district as $j => $val) { if ($val) { $district_info = array_get($city_cates['id'], $val); if ($district_info) { $district_cn[] = $district_info['name']; } } } $district_cn = implode('/', $district_cn); $lists[$k]->district_cn = $district_cn; } //年龄限制 if (is_array($v->age)) { if (implode('', $v->age)=='') { $lists[$k]->age_cn = '不限'; } else { $lists[$k]->age_cn = implode('-', $v->age).'岁'; } } else { if ($v->age == '-' || $v->age == '0') { $lists[$k]->age_cn = '不限'; } else { $lists[$k]->age_cn = $v->age.'岁'; } } $lists[$k]->refresh_time_cn = date('Y-m-d', $v->refresh_time); } } return $lists; } //收藏职位 public function jobFavor($job_id) { if (!$job_id) { throw new ResponseException('请选择要收藏的职位!'); } if (!is_array($job_id)) { $jobs_id = explode(',', $job_id); } else { $jobs_id = $job_id; } if (count($jobs_id) == 1) { //单个收藏 $jobInfo = $this->jobsRepository->getJobsById($job_id); if (!$jobInfo) { throw new ResponseException('请选择有效职位!'); } //判断当前职位是否已收藏 $uid = auth('web-member')->user()->id; $favor_log = $this->personFavoriteRepository->getInfo(array('job_id'=>$job_id,'uid'=>$uid)); if ($favor_log) { //throw new ResponseException('您已经收藏该职位,不能重复收藏!'); //取消收藏 $cancel_rst = $this->personFavoriteRepository->cancelFavor(array('job_id'=>$job_id,'uid'=>$uid)); if (!$cancel_rst) { throw new ResponseException('取消收藏失败!'); } //return true; return 1; } $time = date('Y-m-d H:i:s', time()); $favor_data = array( 'uid' => $uid, 'job_id' => $job_id, 'job_name' => $jobInfo->jobs_name, 'created_at' => $time, 'updated_at'=>$time ); $add_res = $this->personFavoriteRepository->addData($favor_data); if ($add_res) { //return true; return 2; } else { throw new ResponseException('收藏失败!'); } } else { //批量收藏 //获取所选有效职位信息 //获取当前用户收藏的所有职位信息 //所选职位是否已收藏,组成添加数据 $jobs = $this->jobsRepository->getJobs($jobs_id); $fav_jobs = $this->getFavoriteJobs(array('uid'=>auth('web-member')->user()->id), 'job_id'); $fav_data = array(); $stime = date('Y-m-d H:i:s', time()); foreach ($jobs as $k => $v) { if (!$fav_jobs || ($fav_jobs && !array_has($fav_jobs, $v->id))) { $fav_data[] = array( 'uid' => auth('web-member')->user()->id, 'job_id' => $v->id, 'job_name' => $v->jobs_name, 'created_at' => $stime, 'updated_at' => $stime ); } } if ($fav_data) { $rst = $this->personFavoriteRepository->insertData($fav_data); if ($rst) { return true; } else { throw new ResponseException('收藏失败!'); } } else { throw new ResponseException('您已经收藏所选职位,不能重复收藏!'); } } } //获取企业会员审核通过的职位(有效、通过审核(后台职位显示设置要求)、在招的职位) public function getAuditJobs($company_id) { $where = array( array('company_id','=',$company_id), array('valid','=','1'), array('display','=','1') ); if (config('aix.companyset.comset.show_set.jobs_display') == 1) { $where[] = array('audit','=', '1'); } else { $where[] = array('audit','<>', '3'); } return $this->jobsRepository->getOtherJobsCount($where); } public function getAuditJobsNum($company_id) { $rst = $this->getAuditJobs($company_id); return count($rst); } public function dealjobList($data, $limit) { $list = array(); if ($data) { $wage_categories = $this->categoryRepository->getCategories(); foreach ($data as $key => $val) { if ($limit && ($key >= $limit)) { break; } $list[$key] = $val; //薪资字段 if ($val->wage > 0) { if ($wage_categories) { if (config('aix.system.site_other.site_other.site_salary') == 1) { $list[$key]->wage_cn = array_has($wage_categories['AIX_wage_k'], [$val->wage])?$wage_categories['AIX_wage_k'][$val->wage]:'面议'; } elseif (config('aix.system.site_other.site_other.site_salary') == 2) { $list[$key]->wage_cn = array_has($wage_categories['AIX_wage_c'], [$val->wage])?$wage_categories['AIX_wage_c'][$val->wage]:'面议'; } } } elseif ($val->wage==0) { $list[$key]->wage_cn = $this->dealWage($val->wage, $val->wage_min, $val->wage_max); } else { $list[$key]->wage_cn = '面议'; } $list[$key]->experience_cn = '经验不限'; $list[$key]->education_cn = '学历不限'; $other_categories = $this->categoryRepository->getCategories(); if ($other_categories) { if ($val->experience) { $job_experience = array_get($other_categories, 'AIX_experience'); if ($job_experience) { $list[$key]->experience_cn = $job_experience[$val->experience]['demand']; } } if ($val->education) { $job_education = array_get($other_categories, 'AIX_education'); if ($job_education) { $list[$key]->education_cn = $job_education[$val->education]['demand']; } } } $city_cates = Cache::get('city_cate_list'); if (null === $city_cates) { $city_cates = $this->categoryDistrictRepository->cityCateCache(); Cache::put('city_cate_list', $city_cates, '86400'); } if (!strpos($val->district, ".")) { if (array_get($city_cates['id'], $val->district)) { $list[$key]->district_cn = $city_cates['id'][$val->district]['name']; if ($city_cates['id'][$val->district]['parent_id'] > 0) { $parent_district = array_get($city_cates['id'], $city_cates['id'][$val->district]['parent_id']); if ($parent_district) { $list[$key]->district_cn = $parent_district['name'].$list[$key]->district_cn; if ($parent_district['parent_id'] > 0) { $pp_district = array_get($city_cates['id'], $parent_district['parent_id']); if ($pp_district) { $list[$key]->district_cn = $pp_district['name'].$list[$key]->district_cn; } } } } } } else { $city_district = explode('.', $val->district); $city_district_cn = array(); foreach ($city_district as $k => $v) { if ($v) { $district_info = array_get($city_cates['id'], $v); if ($district_info) { $city_district_cn[] = $district_info['name']; } } } $list[$key]->district_cn = implode('/', $city_district_cn); } } } return $list; } public function dealWage($wage, $minwage, $maxwage,$ygxs = 0) { // 小时工处理 $date_str = '月'; if($ygxs == 363){ $date_str = '小时'; }else{ if (config('aix.system.site_other.site_other.site_salary') == 1) { $minwage = $minwage%1000==0?(($minwage/1000).'K'):(round($minwage/1000, 1).'K'); if ($minwage == 0) { $maxwage = '以上'; } else { $maxwage = $maxwage%1000==0?(($maxwage/1000).'K'):(round($maxwage/1000, 1).'K'); } } elseif (config('aix.system.site_other.site_other.site_salary') == 2) { if ($minwage >= 10000) { if ($minwage%10000 == 0) { $minwage = ($minwage/10000).'万'; } else { $minwage = round($minwage/10000, 1); $minwage = strpos($minwage, '.') ? str_replace('.', '万', $minwage) : $minwage.'万'; } } else { if ($minwage%1000 == 0) { $minwage = ($minwage/1000).'千'; } else { $minwage = round($minwage/1000, 1); $minwage = strpos($minwage, '.') ? str_replace('.', '千', $minwage) : $minwage.'千'; } } if ($maxwage > 0) { if ($maxwage >= 10000) { if ($maxwage%10000 == 0) { $maxwage = ($maxwage/10000).'万'; } else { $maxwage = round($maxwage/10000, 1); $maxwage = strpos($maxwage, '.') ? str_replace('.', '万', $maxwage) : $maxwage.'万'; } } elseif ($maxwage) { if ($maxwage%1000 == 0) { $maxwage = ($maxwage/1000).'千'; } else { $maxwage = round($maxwage/1000, 1); $maxwage = strpos($maxwage, '.') ? str_replace('.', '千', $maxwage) : $maxwage.'千'; } } else { $maxwage = '0'; } } else { $maxwage = '0'; } } } if ($minwage == $maxwage) { if($ygxs == 363){ $wage_cn = $minwage.'元/'.$date_str; }else{ $wage_cn = $minwage.'/'.$date_str; } } else { if ($minwage>0 && $maxwage==0) { $wage_cn = $minwage.'以上/'.$date_str; } elseif ($wage==0 && $minwage==0 && $maxwage==0) { $wage_cn = $minwage.'以上/'.$date_str; } else { $wage_cn = $minwage.'~'.$maxwage.'/'.$date_str; } } return $wage_cn; } public function dealjobFilelds($list, $map_data = array(), $limit = '') { $favor_jobs = array(); $apply_jobs = array(); if (auth('web-member')->check()) { //个人用户登录时获取个人收藏的简历信息和一段时间间隔内已申请的职位信息 config('aix.personal_set.per_set.per_set.apply_job_space') $favor_where = array('uid'=> auth('web-member')->user()->id); $favor_jobs = $this->getFavoriteJobs($favor_where); $space_time = (integer)config('aix.personal_set.per_set.per_set.apply_job_space'); $stime = date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-".$space_time." day")))); $apply_where = array(array('personal_uid','=',auth('web-member')->user()->id),array('created_at','>=',$stime)); $apply_jobs = $this->getApplyJobs($apply_where); } $other_categories = $this->categoryRepository->getCategories(); $wage_categories = $this->categoryRepository->getCategories(); $city_cates = Cache::get('city_cate_list'); if (null === $city_cates) { $city_cates = $this->categoryDistrictRepository->cityCateCache(); Cache::put('city_cate_list', $city_cates, '86400'); } $categories = array(); if (Cache::has('jobs_cate_list')) { $categories = Cache::get('jobs_cate_list'); } else { $categories = $this->categoryJobsRepository->jobsCateInfoCache(); Cache::put('jobs_cate_list', $categories, '86400'); } $filter_lat = ''; $filter_lng = ''; if ($map_data) { $filter_lng = $map_data['lng']; $filter_lat = $map_data['lat']; } $return_list = array(); foreach ($list as $key => $val) { if ($limit && ($key >= $limit)) { break; } $return_list[$key] = $val; if (!$val->company) { $companyInfo = $this->companyRepository->getCompanyInfo(['id'=>$val->company_id]); $return_list[$key]->company = $companyInfo; $val->company = $companyInfo; $val->company->membersSetmeal = $this->membersSetmealRepository->getSetmealByUid($companyInfo->id, 1); } //套餐图片 if ($val->company->membersSetmeal) { $val->setmeal_img = $val->company->membersSetmeal->setmeal_img; } else { $val->setmeal_img = null; } if ($favor_jobs && array_has($favor_jobs, $val->id)) { $return_list[$key]->has_favor = 1; } else { $return_list[$key]->has_favor = 0; } if ($apply_jobs && array_has($apply_jobs, $val->id)) { $return_list[$key]->has_deliver = 1; } else { $return_list[$key]->has_deliver = 0; } //薪资字段 if ($val->wage == -1) { $return_list[$key]->wage_cn = '面议'; } else { if ($val->wage > 0) { if ($wage_categories) { if (config('aix.system.site_other.site_other.site_salary') == 1) { $return_list[$key]->wage_cn = array_has($wage_categories['AIX_wage_k'], [$val->wage])?$wage_categories['AIX_wage_k'][$val->wage]:'面议'; } elseif (config('aix.system.site_other.site_other.site_salary') == 2) { $return_list[$key]->wage_cn = array_has($wage_categories['AIX_wage_c'], [$val->wage])?$wage_categories['AIX_wage_c'][$val->wage]:'面议'; } } } else { $return_list[$key]->wage_cn = $this->dealWage($val->wage, $val->wage_min, $val->wage_max,$val->ygxs); } } $return_list[$key]->experience_cn = '经验不限'; $return_list[$key]->nature_cn = '职位性质不限'; $return_list[$key]->education_cn = '学历不限'; $return_list[$key]->tag_cn = array(); $return_list[$key]->category_cn = ''; $return_list[$key]->company->nature_cn = ''; $return_list[$key]->company->scale_cn = ''; if ($other_categories) { if ($val->experience) { $job_experience = array_get($other_categories, 'AIX_experience'); if ($job_experience) { $return_list[$key]->experience_cn = $job_experience[$val->experience]['demand']; } } if ($val->nature) { $job_nature = array_get($other_categories, 'AIX_jobs_nature'); if ($job_nature) { $return_list[$key]->nature_cn = $job_nature[$val->nature]['demand']; } } if ($val->education) { $job_education = array_get($other_categories, 'AIX_education'); if ($job_education) { $return_list[$key]->education_cn = $job_education[$val->education]['demand']; } } $return_list[$key]->company_audit = $val->company->audit; $return_list[$key]->setmeal_id = $val->company->setmeal_id; $return_list[$key]->setmeal_name = $val->company->setmeal_name; $job_tags = array_get($other_categories, 'AIX_jobtag'); if (implode(',', $val->tag)) { $tag_cn = array(); foreach ($val->tag as $k => $v) { $tag = array_get($job_tags, $v); $tag_cn[] = $tag['demand']; } $return_list[$key]->tag_cn = $tag_cn; } //企业性质 $company_types = array_get($other_categories, 'AIX_company_type'); if ($company_types) { $type_cn = array_get($company_types, $val->company->nature); if ($type_cn) { $return_list[$key]->company->nature_cn= $type_cn['demand']; } } //企业规模 $company_scales = array_get($other_categories, 'AIX_scale'); if ($company_scales) { $scale_cn = array_get($company_scales, $val->company->scale); if ($scale_cn) { $return_list[$key]->company->scale_cn = $scale_cn['demand']; } } //企业行业 $company_trades = array_get($other_categories, 'AIX_trade'); if ($company_trades) { $trade_cn = array_get($company_trades, $val->company->trade); if ($trade_cn) { $return_list[$key]->company->trade_cn = $trade_cn['demand']; } } //企业logo if ($val->company->logo) { $return_list[$key]->company->logo = upload_asset($val->company->logo); } else { $return_list[$key]->company->logo = public_data_path('data/upload/no_logo.png'); } } //职位类别 $category = array(); if ($val->subclass) { $category = array_get($categories['id'], $val->subclass); } elseif ($val->category) { $category = array_get($categories['id'], $val->category); } elseif ($val->topclass) { $category = array_get($categories['id'], $val->topclass); } if ($category) { $return_list[$key]->category_cn = $category['name']; } //工作地点 if (!strpos($val->district, ".")) { if (array_get($city_cates['id'], $val->district)) { $return_list[$key]->district_cn = $city_cates['id'][$val->district]['name']; if ($city_cates['id'][$val->district]['parent_id'] > 0) { $parent_district = array_get($city_cates['id'], $city_cates['id'][$val->district]['parent_id']); if ($parent_district) { $return_list[$key]->district_cn = $parent_district['name'].$return_list[$key]->district_cn; if ($parent_district['parent_id'] > 0) { $pp_district = array_get($city_cates['id'], $parent_district['parent_id']); if ($pp_district) { $return_list[$key]->district_cn = $pp_district['name'].$return_list[$key]->district_cn; } } } } } } else { $city_district = explode('.', $val->district); $city_district_cn = array(); foreach ($city_district as $k => $v) { if ($v) { $district_info = array_get($city_cates['id'], $v); if ($district_info) { $city_district_cn[] = $district_info['name']; } } } $return_list[$key]->district_cn = implode('/', $city_district_cn); } //刷新时间 if (!$val->refresh_time) { $return_list[$key]->refresh_time = strtotime($val->updated_at); } //距离 if ($map_data) { $filter_lng = $map_data['lng']; $filter_lat = $map_data['lat']; $return_list[$key]->map_range = $this->getDistance($filter_lng, $filter_lat, $val->map_x, $val->map_y); } //招聘人数 if (!$val->amount) { $return_list[$key]->amount = '若干'; } //年龄限制 if (is_array($val->age)) { /* if ((implode('', $val->age)=='') || ((int)implode('', $val->age)==0)) { $return_list[$key]->age_cn = '不限'; } else { $return_list[$key]->age_cn = implode('-', $val->age).'岁'; }*/ if (count($val->age)>1) { $age = $val->age; if (!$age[0] && !$age[1]) { $return_list[$key]->age_cn = '不限'; } else { if ($age[0] && $age[1]) { $return_list[$key]->age_cn = $age[0].'-'.$age[1].'岁'; } else { $age[0] && $return_list[$key]->age_cn = $age[0].'岁以上'; $age[1] && $return_list[$key]->age_cn = $age[1].'岁以下'; } } } else { $age = $val->age; $return_list[$key]->age_cn = $val->age_cn = (int)$age[0].'岁以上'; } } else { if ($val->age == '-' || $val->age == '0') { $return_list[$key]->age_cn = '不限'; } else { $return_list[$key]->age_cn = $val->age.'岁'; } } //性别 if ($val->sex == 1) { $return_list[$key]->sex_cn = '男'; } elseif ($val->sex == 2) { $return_list[$key]->sex_cn = '女'; } else { $return_list[$key]->sex_cn = '不限'; } } return $return_list; } public function getApplyJobs($where, $field = 'jobs_id') { $rst = $this->personalJobsApplyRepository->getJobsApply($where); $list = array(); if ($rst->toArray()) { foreach ($rst as $key => $val) { $list[$val->$field] = $val; } } return $list; } public function getFavoriteJobs($where, $field = 'job_id') { $rst = $this->personFavoriteRepository->getList($where); $list = array(); if ($rst->toArray()) { foreach ($rst as $key => $val) { $list[$val->$field] = $val; } } return $list; } public function getDistance($lng1, $lat1, $lng2, $lat2) { $radLat1 = deg2rad($lat1); $radLat2 = deg2rad($lat2); $radLng1 = deg2rad($lng1); $radLng2 = deg2rad($lng2); $a = $radLat1 - $radLat2; $b = $radLng1 - $radLng2; $s = 2 * asin(sqrt(pow(sin($a / 2), 2) + cos($radLat1) * cos($radLat2) * pow(sin($b / 2), 2))) * 6378.137; return round($s, 2).'km'; } public function dealJobCompanies($jobs) { $job_companys = array(); if ($jobs) { foreach ($jobs as $k => $val) { if (!$job_companys || ($job_companys && !array_has($job_companys, $val->company_id))) { $job_companys[$val->company_id] = $val->company; $jobs_where = array(array('company_id','=',$val->company_id),array('valid','=',1),array('display','=',1)); if (config('aix.companyset.comset.show_set.jobs_display') == 1) { $jobs_where[] = array('audit','=','1'); } else { $jobs_where[] = array('audit','<>','3'); } $jobs = $this->getOtherJobs($jobs_where, 3); $job_companys[$val->company_id]->jobs = $jobs; } } } return array_values($job_companys); } //获取推荐职位 public function getRecommendOrder($user = array()) { $order = array(); /*if (auth('web-member')->check()) { $order = array('refresh_time'=>'desc'); } else { $order = array('click'=>'desc','stime'=>'desc','refresh_time'=> 'desc'); }*/ $order = array('click'=>'desc','stime'=>'desc','refresh_time'=> 'desc'); return $order; } //TODO 修改用户读取方式 public function getRecommendWhere($user = array()) { $where = array(); //个人会员 if ($user && $user->utype==2) { $filter_resume = array( array('uid','=',$user->id) ); if (config('aix.personal_set.per_set.show_set.resume_display')==2) { $filter_resume[] = array('audit','<>',0); } else { $filter_resume[] = array('audit','=',2); } $resumes = $this->resumeRepository->getResumes($filter_resume); if ($resumes->isNotEmpty()) { $or_where = array(); foreach ($resumes as $k => $v) { $or_where[] = $this->setRecommendJobWhere($v); } $and_where = array(); $and_where[] = array('valid','=',1); $and_where[] = array('display','=',1); if (config('aix.companyset.comset.show_set.jobs_display')==1) { $and_where[] = array('audit','=',1); } else { $and_where[] = array('audit','<>',3); } $where['or'] = $or_where; $where['and'] = $and_where; } return $where; } else { //游客、企业会员 - 点击次数、置顶职位、刷新靠前的职位 /*$where[] = array('valid','=',1); $where[] = array('display','=',1); if (config('aix.companyset.comset.show_set.jobs_display')==1) { $where[] = array('audit','=',1); } else { $where[] = array('audit','<>',3); } $where[] = array('subsite_ids','=',get_subsite_id());*/ $where['and'][] = array('valid','=',1); $where['and'][] = array('display','=',1); if (config('aix.companyset.comset.show_set.jobs_display')==1) { $where['and'][] = array('audit','=',1); } else { $where['and'][] = array('audit','<>',3); } $where['and'][] = array('subsite_ids','=',get_subsite_id()); } return $where; } //匹配个人推荐职位的查询条件 public function setRecommendJobWhere($resume) { $where = array(); /*$where[] = array('valid','=',1); $where[] = array('display','=',1); if (config('aix.companyset.comset.show_set.jobs_display')==1) { $where[] = array('audit','=',1); } else { $where[] = array('audit','<>',3); }*/ //匹配性别 if ($resume->sex == 1) { $where[] = array('sex','<>',2); } else { $where[] = array('sex','<>',1); } //匹配年龄age_min、age_max $age = date("Y") - $resume->birthdate; $where[] = array('age_min','<=',$age); $where[] = array('age_max','>=',$age); $where[] = array('education','<=',$resume->education); //匹配学历 $where[] = array('experience','<=',$resume->experience); //匹配工作经验 $where[] = array('nature','=',$resume->nature); //匹配工作性质 - 精准匹配 //匹配期望行业trade - 如果没有值则不添加匹配条件 if ($resume->trade) { $trades = explode(',', $resume->trade); $where[] = array('trade','in',$trades); } //匹配期望职位 - 二级职位 $intention_jobs_cates = explode(',', $resume->intention_jobs_id); $intention_cates = array(); foreach ($intention_jobs_cates as $k => $v) { $i_ids = explode('.', $v); if (array_has($i_ids, 1)) { $intention_cates[] = (int)$i_ids[1]; } } if ($intention_cates) { $where[] = array('intention_jobs_id','in',$intention_cates); } //匹配工作地区(职位的工作地区)(三级地区存在时匹配三级地区,不存在时匹配二级地区) $district = explode(',', $resume->district); $district_ids = array(); if ($district) { foreach ($district as $k => $v) { if (!strpos($v, ".")) { $district_ids[] = $v; } else { $district_arr = explode('.', $v); if (array_has($district_arr, 2) && array_get($district_arr, 2)>0) { $district_ids[] = (int)$district_arr[2]; } else { $district_ids[] = (int)$district_arr[1]; } } } } if ($district_ids) { $where[] = array('district','in',$district_ids); } //匹配期望薪资 - (第二版逻辑:职位薪资最大值和最小值包含期望薪资、面议) $where[] = array('wage_min','<=',$resume->wage_min); $where[] = array('wage_max','>=',$resume->wage_max); $where[] = array('subsite_ids','=',get_subsite_id()); return $where; } public function autoRefreshJobs(array $pid_arr) { if ($this->jobsRepository->autoRefreshJobs($pid_arr)) { return true; } return false; } /**将职位管理内的职位转入招聘会职位库 * @param $request * @return JsonResponse * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function jobsAddToJobfair($request,$user) { $jid = $request->id; if (!$jid || !$jobsInfo = $this->jobsRepository->find($jid)) { return response()->json(['status'=>0,'msg'=>"参数错误或无此职位"]); } $this->isOwn($jid,$user); $type1 = $this->jobfairJobRepository->findWhere(['jobs_name'=>$jobsInfo->jobs_name,'company_id'=>$jobsInfo->company_id,'type'=>1])->isNotEmpty(); $type2 = $this->jobfairJobRepository->findWhere(['jobs_name'=>$jobsInfo->jobs_name,'company_id'=>$jobsInfo->company_id,'type'=>2])->isNotEmpty(); if($type1 && $type2 ){ return response()->json(['status'=>0,'msg'=>"该职位已存在招聘会职位库中,请添加其他职位"]); } $insertArr = []; if ($jobCatact = $this->jobsContactRepository->getContactInfo(['job_id'=>$jid])) { $contactData = $this->jobsContactRepository->find($jobCatact->id); $contactArr = ['contact','qq','mobile','notify','landline_tel','email','address','notify_mobile','contact_show','telephone_show','email_show','landline_tel_show']; foreach ($contactArr as $key => $val) { if ($val == 'mobile') { $insertArr[$val] = $jobCatact->telephone; } elseif ($val=='landline_tel') { if (isset($jobCatact->landline_tel)) { $insertArr[$val] = implode('-', $jobCatact->landline_tel); } else { $insertArr[$val]='--'; } } else { $insertArr[$val] = $jobCatact->$val; } } } $jobfairArr = [ 'jobs_name', 'company_id', 'company_name', 'company_addtime', 'company_audit', 'stick', 'amount', 'negotiable', 'jobs_content', 'audit', 'click', 'display', 'robot', 'map_x', 'map_y', 'map_zoom', 'add_mode', 'department', 'nature', 'sex', 'age', 'topclass', 'category', 'subclass', 'trade', 'scale', 'district', 'education', 'experience', 'wage', 'wage_max', 'wage_min', 'ygxs', 'syq', 'syqxz_min', 'techlevel' ]; foreach ($jobfairArr as $key => $val) { $insertData[$val] = $jobsInfo->$val; } if ($jobsInfo['topclass'] && $jobsInfo['category'] && $jobsInfo['subclass']) { $insertData['category_cn'] = get_job_category_cn($jobsInfo['topclass'].".".$jobsInfo['category'].'.'.$jobsInfo['subclass']); } else { $insertData['category_cn'] = ''; } if(!empty($insertData['age'])){ $insertData['age'] = implode('-',$insertData['age'] ); } $insertData['nature_cn'] = $jobsInfo['nature']?get_category($jobsInfo['nature']):''; $insertData['trade_cn'] = $jobsInfo['trade']?get_category($jobsInfo['trade']):''; $insertData['scale_cn'] = $jobsInfo['scale']?get_category($jobsInfo['scale']):''; $insertData['education_cn'] = $jobsInfo['education']?get_category($jobsInfo['education']):''; $insertData['experience_cn'] = $jobsInfo['experience']?get_category($jobsInfo['experience']):""; if (intval($insertData['wage']) == 0) { if ($insertData['wage_max']) { $insertData['wage_cn'] = $insertData['wage_min'].'~'.$insertData['wage_max'].'/月'; } else { $insertData['wage_cn'] = $insertData['wage_min'].'/月以上'; } }elseif(intval($insertData['wage']) == -1){ $insertData['wage_cn'] = '面议'; }else{ $insertData['wage_cn'] = $jobsInfo['wage']?get_category($jobsInfo['wage']):''; } $insertData['ygxs'] = $jobsInfo['ygxs']?$jobsInfo['ygxs']:''; $insertData['syq'] = $jobsInfo['syq']?$jobsInfo['syq']:''; $insertData['syqxz_min'] = $jobsInfo['syqxz_min']?$jobsInfo['syqxz_min']:''; $insertData['techlevel'] = $jobsInfo['techlevel']?$jobsInfo['techlevel']:''; $insertData['district_cn'] = get_district_cn($jobsInfo['district']); if ($jobsInfo['tag'][0]) { $insertData['tag_cn'] = get_tag_cn(implode(',', $jobsInfo['tag'])); } else { $insertData['tag_cn']=''; } switch ($jobsInfo['sex']) { case 1: $insertData['sex_cn'] = '男'; break; case 2: $insertData['sex_cn'] = '女'; break; case 0: $insertData['sex_cn'] = '不限'; break; } try{ if(!$type1){ $insertData['type'] = 1; if (!$jobfair_jobid = $this->jobfairJobRepository->create($insertData)) { throw new \Exception('转入招聘会职位库失败!'); } if ($insertArr) { $insertArr['pid'] = $jobfair_jobid->id; $this->jobfairJobsContactRepository->create($insertArr); } } if(!$type2){ $insertData['type'] = 2; if (!$jobfairout_jobid = $this->jobfairJobRepository->create($insertData)) { throw new \Exception('转入招聘会职位库失败!'); } if ($insertArr) { $insertArr['pid'] = $jobfairout_jobid->id; $this->jobfairJobsContactRepository->create($insertArr); } } DB::commit(); return response()->json(['status'=>1,'msg'=>"成功转入招聘会职位库!",'data' => '']); }catch (Exception $e) { DB::rollback(); return response()->json(['status'=>1,'msg'=>$e->getMessage(),'data' => '']); } } public function isOwn($ids,$user) { $ids = is_array($ids)?$ids:explode(',',$ids); $putJobs = $this->jobsRepository->getPluck(['company_id'=>$user->id],'id')->toArray(); if(array_diff($ids,$putJobs)) { throw new ResponseException('抱歉,您只能操作自己的招聘会职位!'); } } }