| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 | 
							- <?php
 
- namespace App\Services\Statistics;
 
- use App\Exceptions\ResponseException;
 
- use App\Repositories\ResumeRepository;
 
- use App\Repositories\PersonalJobsApplyRepository;
 
- use App\Repositories\CategoryJobsRepository;
 
- use App\Repositories\MemberInfoRepository;
 
- use Illuminate\Support\Facades\Cache;
 
- class ResumeService
 
- {
 
-     protected $resumeRepository;
 
-     protected $personalJobsApplyRepository;
 
-     protected $categoryJobsRepository;
 
-     public function __construct(ResumeRepository $resumeRepository, PersonalJobsApplyRepository $personalJobsApplyRepository, CategoryJobsRepository $categoryJobsRepository)
 
-     {
 
-         $this->resumeRepository = $resumeRepository;
 
-         $this->personalJobsApplyRepository = $personalJobsApplyRepository;
 
-         $this->categoryJobsRepository = $categoryJobsRepository;
 
-     }
 
-     public function getValidResumeNum($where)
 
-     {
 
-         return $this->resumeRepository->getResumesCount($where);
 
-     }
 
-     public function getResumeNum($where, $member_where = [])
 
-     {
 
-         $rst = $this->resumeRepository->getResumeNum($where, $member_where);
 
-         return $rst;
 
-     }
 
-     public function getApplyNumGroup($where, $group_by, $subsite_id)
 
-     {
 
-         $rst = $this->personalJobsApplyRepository->getApplyNumGroup($where, $group_by, $subsite_id);
 
-         return $rst->pluck('count(id)', 'DATE(created_at)')->toArray();
 
-     }
 
-     public function getApplyNum($where, $company_where)
 
-     {
 
-         return $this->personalJobsApplyRepository->getApplyNum($where, $company_where);
 
-     }
 
-     public function getApplyNumByGroup($where, $company_where, $fields, $group_by, $order_by = '')
 
-     {
 
-         return $this->personalJobsApplyRepository->getApplyNumByGroup($where, $company_where, $fields, $group_by, $order_by);
 
-     }
 
-     public function getApplyNumByCompanyGroup($where, $company_where, $fields, $group_by, $order_by = '', $limit = '')
 
-     {
 
-         $rst = $this->personalJobsApplyRepository->getApplyNumByCompanyGroup($where, $company_where, $fields, $group_by, $order_by, $limit);
 
-         $list = [];
 
-         if ($rst->isNotEmpty()) {
 
-             foreach ($rst as $k => $v) {
 
-                 $list[$k]['count'] = $v->count;
 
-                 $list[$k]['company_id'] = $v->company_id;
 
-                 $company = $v->companys;
 
-                 $list[$k]['company_name'] = $company->companyname;
 
-             }
 
-         }
 
-         return $list;
 
-     }
 
-     public function getResumeNumGroup($where, $group_by)
 
-     {
 
-         $rst = $this->resumeRepository->getResumeNumGroup($where, $group_by);
 
-         return $rst->pluck('count(id)', 'DATE(created_at)')->toArray();
 
-     }
 
-     //获取职位分类信息
 
-     public function getJobsCategoryInfo()
 
-     {
 
-         $result = Cache::get('jobs_cate_list');
 
-         if (null === $result) {
 
-             $result = $this->categoryJobsRepository->jobsCateInfoCache();
 
-             Cache::put('jobs_cate_list', $result, '86400');
 
-         }
 
-         return $result;
 
-     }
 
-     public function dealJobCategory($data)
 
-     {
 
-         $cates = $this->getJobsCategoryInfo();
 
-         if ($data) {
 
-             foreach ($data as $k => $v) {
 
-                 $cate_ids = explode('.', $v['cate']);
 
-                 if (array_has($cates['id'], $cate_ids[1])) {
 
-                     $data[$k]['cate_name'] = $cates['id'][$cate_ids[1]]['name'];
 
-                 } else {
 
-                     $data[$k]['cate_name'] = '';
 
-                 }
 
-             }
 
-         }
 
-         return $data;
 
-     }
 
-     public function getAvgWageByEducation($where, $member_where, $fields, $group_by, $order_by = '', $limit = '')
 
-     {
 
-         $rst = $this->resumeRepository->getAvgWageByGroup($where, $member_where, $fields, $group_by, $order_by, $limit);
 
-         return $rst->toArray();
 
-     }
 
-     public function getResumeNumByClass($where, $member_where, $fields, $group_by, $limit = '', $order_by = '')
 
-     {
 
-         $rst = $this->resumeRepository->getNumByClassGroup($where, $member_where, $fields, $group_by, $limit = '', $order_by = '');
 
-         return $rst->pluck('num', 'class')->toArray();
 
-     }
 
-     public function getResumeNumByClassGroup($where, $member_where, $fields, $group_by, $order_by = '', $limit = '')
 
-     {
 
-         $top_arr = [];
 
-         $second_arr = [];
 
-         $top_name_arr = [];
 
-         $second_name_arr = [];
 
-         $cates = $this->getJobsCategoryInfo();
 
-         $cates = $cates['id'];
 
-         $rst = $this->resumeRepository->getResumeNumByClassGroup($where, $member_where, $fields, $group_by, $order_by, $limit);
 
-         if ($rst) {
 
-             $top_arr = $rst['topClass'];
 
-             $second_arr = $rst['secondClass'];
 
-         }
 
-         if ($top_arr && $cates) {
 
-             foreach ($top_arr as $k => $v) {
 
-                 if ($limit && count($top_name_arr) < $limit) {
 
-                     if (array_has($cates, $k)) {
 
-                         $top_name_arr[$k] = $cates[$k]['name'];
 
-                     } else {
 
-                         $top_name_arr[$k] = '';
 
-                     }
 
-                 } else {
 
-                     break;
 
-                 }
 
-             }
 
-         }
 
-         if ($second_arr && $cates) {
 
-             foreach ($second_arr as $k => $v) {
 
-                 if ($limit && count($second_name_arr) < $limit) {
 
-                     if (array_has($cates, $k)) {
 
-                         $second_name_arr[$k] = $cates[$k]['name'];
 
-                     } else {
 
-                         $second_name_arr[$k] = '';
 
-                     }
 
-                 } else {
 
-                     break;
 
-                 }
 
-             }
 
-         }
 
-         return ['top_arr'=>$top_arr,'second_arr'=>$second_arr,'top_name_arr'=>$top_name_arr,'second_name_arr'=>$second_name_arr];
 
-     }
 
-     public function getResumeNumsByGroup($where, $member_where, $fields, $group_by, $order_by)
 
-     {
 
-         $rst = $this->resumeRepository->getAvgWageByGroup($where, $member_where, $fields, $group_by, $order_by);
 
-         return $rst->pluck('num', 'create_month')->toArray();
 
-     }
 
-     public function getResumeNumsGroup($where, $member_where, $fields, $group_by, $order_by = '')
 
-     {
 
-         $rst = $this->resumeRepository->getAvgWageByGroup($where, $member_where, $fields, $group_by, $order_by);
 
-         return $rst;
 
-     }
 
-     public function getResumeNumsByEducationGroup($start_time, $end_time, $subsite_id)
 
-     {
 
-         $resume_where = [
 
-             ['r.created_at', '<=', $end_time],
 
-             ['r.created_at', '>=', $start_time],
 
-         ];
 
-         if (config('aix.personal_set.per_set.show_set.resume_display')=='1') {
 
-             $resume_where[] = array('r.audit','=','2');
 
-         } else {
 
-             $resume_where[] = array('r.audit','<>','0');
 
-         }
 
-         $member_where = array(
 
-             ['m.utype','=',2],
 
-             ['m.status','=',1]
 
-         );
 
-         if ($subsite_id != -1) {
 
-             $member_where[] = ['m.subsite_id','=',$subsite_id];
 
-         }
 
-         $resume_fields = 'count(r.id) as num, mu.education';
 
-         $where = "r.deleted_at is null and m.deleted_at is null";
 
-         $rst = $this->resumeRepository->getResumeNumByEducationGroup($where, $resume_where, $member_where, $resume_fields, 'mu.education', 'mu.education asc');
 
-         return $rst->pluck('num', 'education')->toArray();
 
-     }
 
-     public function getResumeNumsByAgeGroup($subsite_id, $start_time, $end_time, $ages, $age_text)
 
-     {
 
-         //简历查询条件
 
-         $resume_where = [
 
-             ['r.created_at', '<=', $end_time],
 
-             ['r.created_at', '>=', $start_time],
 
-         ];
 
-         if (config('aix.personal_set.per_set.show_set.resume_display')=='1') {
 
-             $resume_where[] = array('r.audit','=','2');
 
-         } else {
 
-             $resume_where[] = array('r.audit','<>','0');
 
-         }
 
-         $member_where = array(
 
-             ['m.utype','=',2],
 
-             ['m.status','=',1]
 
-         );
 
-         if ($subsite_id != -1) {
 
-             $member_where[] = ['m.subsite_id','=',$subsite_id];
 
-         }
 
-         $where = "r.deleted_at is null and m.deleted_at is null AND mu.deleted_at is null";
 
-         $resume_fields = 'count(r.id) as num, mu.birthday';
 
-         $group = '';
 
-         $age_data = [];
 
-         foreach ($ages as $k => $v) {
 
-             $map = [];
 
-             $max_birth = date('Y') - $v['min_age'];
 
-             $min_birth = 0;
 
-             if ($v['max_age']) {
 
-                 $min_birth =  date('Y') - $v['max_age'];
 
-             }
 
-             $map[] = ['mu.birthday', '<=', $max_birth];
 
-             if ($min_birth && $max_birth) {
 
-                 $map[] = ['mu.birthday', '>=', $min_birth];
 
-             }
 
-             $resume_count = $this->resumeRepository->getResumeNumsByAgeGroup($where, $resume_where, $member_where, $map, $resume_fields, $group);
 
-             $age_data[$age_text[$k]] = $resume_count;
 
-         }
 
-         return $age_data;
 
-     }
 
-     public function getResumeApplyGroup($where, $order_fileds, $apply_group, $apply_order, $limit = '')
 
-     {
 
-         return $this->personalJobsApplyRepository->getResumeApplyGroup($where, $order_fileds, $apply_group, $apply_order, $limit);
 
-     }
 
-     public function getResumeBySexGroup($subsite_id, $start_time, $end_time)
 
-     {
 
-         //简历查询条件
 
-         $resume_where = array();
 
-         if (config('aix.personal_set.per_set.show_set.resume_display')=='1') {
 
-             $resume_where[] = array('r.audit','=','2');
 
-         } else {
 
-             $resume_where[] = array('r.audit','<>','0');
 
-         }
 
-         $resume_where[] = ['r.created_at','>=',$start_time];
 
-         $resume_where[] = ['r.created_at','<=',$end_time];
 
-         $member_where = array(array('m.utype','2',1),);
 
-         if ($subsite_id != -1) {
 
-             $member_where[] = array('m.subsite_id','=',$subsite_id);
 
-         }
 
-         $info_where = [];
 
-         $field = 'count(r.id) as num, mu.sex,if (mu.sex=1,"男","女") as sex_cn';
 
-         $group = 'mu.sex';
 
-         $rst = $this->resumeRepository->getResumeNumByGroup($resume_where, $member_where, $info_where, $field, $group);
 
-         return $rst;
 
-     }
 
- }
 
 
  |