| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 | 
							- <?php
 
- namespace App\Repositories;
 
- use App\Models\Company;
 
- use App\Models\PersonalJobsApply;
 
- use App\Models\Member;
 
- use App\Models\Category;
 
- use App\Models\Jobs;
 
- use Prettus\Repository\Eloquent\BaseRepository;
 
- use Prettus\Repository\Criteria\RequestCriteria;
 
- use Illuminate\Support\Facades\DB;
 
- /**
 
-  * Class MemberRepositoryEloquent.
 
-  *
 
-  * @package namespace App\Repositories;
 
-  */
 
- class PersonalJobsApplyRepository extends BaseRepository
 
- {
 
-     /**
 
-      * Specify Model class name
 
-      *
 
-      * @return string
 
-      */
 
-     public function model()
 
-     {
 
-         return PersonalJobsApply::class;
 
-     }
 
-     /**
 
-      * Boot up the repository, pushing criteria
 
-      */
 
-     public function boot()
 
-     {
 
-         $this->pushCriteria(app(RequestCriteria::class));
 
-     }
 
-     /**
 
-      * 获取已申请职位数。
 
-      * @param $resume_id
 
-      * @param $personal_uid
 
-      * @return mixed
 
-      */
 
-     public function getApplyJobs($personal_uid, $where)
 
-     {
 
-         return $this->model->with(['resumes','jobs'=>function($query) use ($where) {
 
-             $query->whereIn('audit', $where)->where('display', 1)->where('valid', 1);
 
-         }])->where(['personal_uid'=>$personal_uid])->whereHas('resumes')->whereHas('jobs')->count();
 
-     }
 
-     public function getApplyJobsDef($resume_id, $where)
 
-     {
 
-         return $this->model->with(['resumes','jobs'=>function($query) use ($where) {
 
-             $query->whereIn('audit', $where)->where('display', 1)->where('valid', 1);
 
-         }])->where(['resume_id'=>$resume_id])->whereHas('resumes')->whereHas('jobs')->count();
 
-     }
 
-     public function getApplyResume($jobs_id)
 
-     {
 
-         return $this->model->where(['jobs_id'=>$jobs_id,'is_reply'=>0])->count();
 
-     }
 
-     /**
 
-      * @param $map
 
-      * @param $valid 停招职位
 
-      * @param $apply_time 投递时间
 
-      * @param $page
 
-      * @return mixed
 
-      */
 
-     public function getResume($where, $page)
 
-     {
 
-         return $this->model->with('jobs')->with('resumes')->where($where)->orderByRaw("FIELD(is_reply,0,1,3,2,4)")->orderBy('id', 'desc')->orderBy('created_at', 'desc')->paginate($page);
 
-     }
 
-     public function companyLabelResume($id, $data)
 
-     {
 
-         return $this->update($data, $id);
 
-     }
 
-     /**
 
-      * 近两周收到的简历
 
-      * @return mixed
 
-      */
 
-     public function twoWeeksTotal($id)
 
-     {
 
-         return $this->model->where('created_at', '>=', date('Y-m-d', time()-86400*14))->where('company_id', '=', $id)->count();
 
-     }
 
-     /**
 
-      * 近两周处理的简历
 
-      * @return mixed
 
-      */
 
-     public function twoWeeksReplyTotal($id)
 
-     {
 
-         $where = [
 
-             ['created_at','>=',date('Y-m-d', time() - 86400*14)],
 
-             ['is_reply', '>', 0],
 
-             ['personal_look','=',2],
 
-         ];
 
-         return $this->model->where($where)->where('company_id', '=', $id)->count();
 
-     }
 
-     /**
 
-      * 删除简历申请
 
-      * @param $id
 
-      * @return mixed
 
-      * @param $company_id
 
-      */
 
-     public function delJobsApply($id,$company_id)
 
-     {
 
-         return $this->model->whereIn('id', $id)->where("company_id",$company_id)->delete();
 
-     }
 
-     /**
 
-      * 查询单个简历申请
 
-      * @param $where
 
-      * @return mixed
 
-      */
 
-     public function getOne($where)
 
-     {
 
-         return $this->model->where($where)->orderBy('id', 'desc')->first();
 
-     }
 
-     public function getJobsApply($where)
 
-     {
 
-         return $this->model->where($where)->orderBy('id', 'desc')->get();
 
-     }
 
-     /**
 
-      * 获取简历ID
 
-      * @param $id
 
-      * @return mixed
 
-      */
 
-     public function getResumeId($id)
 
-     {
 
-         return $this->model->whereIn('id', $id)->select(['resume_id'])->get()->toArray();
 
-     }
 
-     /**
 
-      * 检测是否申请过职位
 
-      */
 
-     public function checkJobsApply($resume_id, $company_id, $jobs_id = false)
 
-     {
 
-         $where['resume_id'] = $resume_id;
 
-         $where['company_id'] = $company_id;
 
-         $jobs_id && $where['jobs_id'] = $jobs_id;
 
-         if (!$this->model->where($where)->first()) {
 
-             return false;
 
-         }
 
-         return true;
 
-     }
 
-     /**
 
-      * 获取一条职位申请记录
 
-      */
 
-     public function findJobsApply($resume_id, $company_id, $jobs_id = false,$id=0)
 
-     {
 
-         $where['resume_id'] = $resume_id;
 
-         $where['company_id'] = $company_id;
 
-         if (!empty($id)){
 
-             $where['id']=$id;
 
-         }
 
-         $jobs_id && $where['jobs_id'] = $jobs_id;
 
-         return $this->model->where($where)->first();
 
-     }
 
-     /**
 
-      * 修改投递状态和查看状态
 
-      * @param $where
 
-      * @return mixed
 
-      */
 
-     public function updateApply($where)
 
-     {
 
-         return $this->model->where($where)->update(['is_reply'=>3,'personal_look'=>2]);
 
-     }
 
-     /**简历回收站
 
-      * @param $uid
 
-      * @param $page
 
-      * @return mixed
 
-      */
 
-     public function recycle($uid, $page)
 
-     {
 
-         $where = [
 
-             'company_id'=>$uid,
 
-         ];
 
-         return $this->model->onlyTrashed()->where($where)->paginate($page);
 
-     }
 
-     /**删除收到的简历
 
-      * @param $id
 
-      * @return mixed
 
-      */
 
-     public function destroyJobsApply($id)
 
-     {
 
-         return $this->model->whereIn('id', $id)->forceDelete();
 
-     }
 
-     /**清空回收站
 
-      * @param $company_id
 
-      * @return mixed
 
-      */
 
-     public function clearRecycle($company_id)
 
-     {
 
-         return $this->model->where('company_id', $company_id)->forceDelete();
 
-     }
 
-     public function applyJobs($where, $jobs_id = array())
 
-     {
 
-         if ($jobs_id) {
 
-             return $this->model->where($where)->whereIn('jobs_id', $jobs_id)->orderBy('created_at', 'desc')->get();
 
-         } else {
 
-             return $this->model->where($where)->orderBy('created_at', 'desc')->get();
 
-         }
 
-     }
 
-     public function checkApplyJobs($where, $jobs_id = array())
 
-     {
 
-         if ($jobs_id) {
 
-             return $this->model->where($where)->whereIn('jobs_id', $jobs_id)->get();
 
-         } else {
 
-             return $this->model->where($where)->get();
 
-         }
 
-     }
 
-     //获取其它字段包含whereIn条件的字段的申请记录
 
-     public function getApplies($where, $whereIn = array())
 
-     {
 
-         $list = array();
 
-         if ($whereIn) {
 
-             $rst = $this->model->where($where)->whereIn(key($whereIn), $whereIn[key($whereIn)])->get();
 
-         } else {
 
-             $rst = $this->model->where($where)->get();
 
-         }
 
-         if ($rst->toArray()) {
 
-             foreach ($rst as $k => $v) {
 
-                 $list[$v->resume_id] = $v;
 
-             }
 
-         }
 
-         return $list;
 
-     }
 
-     public function addData($data)
 
-     {
 
-         return $this->model->create($data);
 
-     }
 
-     public function setApply($where, $set)
 
-     {
 
-         return $this->model->where($where)->update($set);
 
-     }
 
-     /**投递简历数
 
-      * @param $where
 
-      * @return mixed
 
-      */
 
-     public function resumesCount($where)
 
-     {
 
-         return $this->model->where($where)->count();
 
-     }
 
-     public function getStateArr()
 
-     {
 
-         return $this->model->getStateArr();
 
-     }
 
-     public function getResumeApplyGroup($where, $fileds = 'count(p.id) as num,j.category,c.demand', $group_by = 'j.category', $order_by = 'count(p.jobs_id) DESC', $limit = '')
 
-     {
 
-         $rst = DB::table(PersonalJobsApply::getTableName().' as p')->select(DB::raw($fileds))
 
-             ->leftjoin(Member::getTableName().' as m', 'm.id', '=', 'p.personal_uid')
 
-             //->leftjoin(Jobs::getTableName().' as j', 'j.id', '=', 'p.jobs_id')
 
-             ->leftjoin(Company::getTableName().' as cp', 'cp.id', '=', 'p.company_id')
 
-             ->leftjoin(Category::getTableName().' as c', 'c.id', '=', 'cp.trade')
 
-             ->where($where)
 
-             ->groupBy($group_by)
 
-             ->orderByRaw($order_by);
 
-         if ($limit) {
 
-             $rst->offset(0)->limit($limit);
 
-         }
 
-         return $rst->get();
 
-     }
 
-     public function getApplyNumGroup($where, $group_by, $subsite_id)
 
-     {
 
-         $rst = $this->model->where($where)->select(DB::raw('count(id),DATE(created_at)'))->when($subsite_id!=-1, function($query) use($subsite_id) {
 
-             $query->whereHas('members', function ($query) use ($subsite_id) {
 
-                 $query->where(['subsite_id'=>$subsite_id]);
 
-             });
 
-         });
 
-         if ($group_by) {
 
-             $rst->groupBy($group_by);
 
-         }
 
-         return $rst->get();
 
-     }
 
-     public function getApplyNum($where, $company_where)
 
-     {
 
-         return $this->model
 
-                     ->where($where)
 
-                     ->when($company_where, function ($query) use ($company_where) {
 
-                         $query->whereHas('companys', function ($query) use ($company_where) {
 
-                             $query->where($company_where);
 
-                         });
 
-                     })->count();
 
-     }
 
-     public function getApplyNumByGroup($where, $company_where, $fields, $group_by, $order_by = '')
 
-     {
 
-         $rst = $this->model->select(DB::raw($fields))->where($where)
 
-             ->when($company_where, function ($query) use ($company_where) {
 
-                 $query->whereHas('companys', function ($query) use ($company_where) {
 
-                     $query->where($company_where);
 
-                 });
 
-             });
 
-         if ($group_by) {
 
-             foreach ($group_by as $k => $v) {
 
-                 $rst->groupBy($v);
 
-             }
 
-         }
 
-         if ($order_by) {
 
-             $rst->orderByRaw($order_by);
 
-         }
 
-         return $rst->get();
 
-     }
 
-     public function getApplyNumByCompanyGroup($where, $company_where, $fields, $group_by, $order_by = '', $limit = '')
 
-     {
 
-         $rst = $this->model->with('companys')->select(DB::raw($fields))->where($where)
 
-             ->when($company_where, function ($query) use ($company_where) {
 
-                 $query->whereHas('companys', function ($query) use ($company_where) {
 
-                     $query->where($company_where);
 
-                 });
 
-             });
 
-         if ($group_by) {
 
-             foreach ($group_by as $k => $v) {
 
-                 $rst->groupBy($v);
 
-             }
 
-         }
 
-         if ($order_by) {
 
-             $rst->orderByRaw($order_by);
 
-         }
 
-         if ($limit) {
 
-             $rst->offset(0)->limit($limit);
 
-         }
 
-         return $rst->get();
 
-     }
 
-     public function getResumeNumBySexGroup($resume_where, $member_where)
 
-     {
 
-         $rst = $this->model->with(['memberInfos'])->where($resume_where)->when($member_where, function($query) use($member_where) {
 
-             $query->whereHas('members', function ($query) use ($member_where) {
 
-                 $query->where($member_where);
 
-             });
 
-         })->get();
 
-         return $rst;
 
-     }
 
-     public function getPersonalJobByID($id){
 
-         return $this->model->where("id",$id)->first();
 
-     }
 
-     public function getResumeApplyWithDeleted($where, $member_where)
 
-     {
 
-         $rst = $this->model
 
-             //->withTrashed()
 
-             ->where($where)
 
-             ->when($member_where, function ($query) use ($member_where) {
 
-                 $query->whereHas('members', function ($query) use ($member_where) {
 
-                     //$query->withTrashed()->where($member_where);
 
-                     $query->where($member_where);
 
-                 });
 
-             })->get();
 
-         return $rst;
 
-     }
 
-     public function getPluck($where,$column)
 
-     {
 
-         return $this->model->where($where)->pluck($column);
 
-     }
 
- }
 
 
  |