| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 | 
							- <?php
 
- /**
 
-  * Created by PhpStorm.
 
-  * Date: 2018/11/19
 
-  * Time: 15:30
 
-  */
 
- namespace App\Repositories;
 
- use App\Models\JobsSearch;
 
- use App\Models\Jobs;
 
- use App\Models\JobsContact;
 
- use Prettus\Repository\Criteria\RequestCriteria;
 
- use Prettus\Repository\Eloquent\BaseRepository;
 
- class JobsSearchRepository extends BaseRepository
 
- {
 
-     public function model()
 
-     {
 
-         return JobsSearch::class;
 
-     }
 
-     public function jobs()
 
-     {
 
-         return Jobs::class;
 
-     }
 
-     /**
 
-      * Boot up the repository, pushing criteria
 
-      */
 
-     public function boot()
 
-     {
 
-         $this->pushCriteria(app(RequestCriteria::class));
 
-     }
 
-     /*
 
-         完善职位索引信息
 
-         @ $jobs 职位信息
 
-         @ $pid  职位id
 
-     */
 
-     public function checkJobs($jobs, $pid)
 
-     {
 
-         $pid=intval($pid);
 
-         if ($pid && !$jobs) {
 
-             $jobs=$this->getJobsOne(array('id'=>$pid));
 
-         }
 
-         if (!$jobs) {
 
-             return false;
 
-         }
 
-         //省市,职位,标签
 
-         $d = array();
 
-         if ($jobs->district) {
 
-             $a = array_filter(explode('.', $jobs->district));
 
-             for ($i=count($a)-1; $i>=0; $i--) {
 
-                 $d[] = 'city'.implode('_', $a);
 
-                 $a[$i] = 0;
 
-             }
 
-         }
 
-         if ($jobs->topclass) {
 
-             $job = $jobs->topclass.'.'.$jobs->category.'.'.$jobs->subclass;
 
-             $a = array_filter(explode('.', $job));
 
-             for ($i=count($a)-1; $i>=0; $i--) {
 
-                 $d[] = 'jobs'.implode('_', $a);
 
-                 $a[$i] = 0;
 
-             }
 
-         }
 
-         if (implode(',', $jobs->tag)) {
 
-             foreach ($jobs->tag as $key => $val) {
 
-                 $d[] = 'tag'.$val;
 
-             }
 
-         }
 
-         $foreach_arr = array(
 
-             'eme'=>'emergency',
 
-             'stick'=>'stick',
 
-             'nat'=>'nature',
 
-             'sex'=>'sex',
 
-             'trade'=>'trade',
 
-             'edu'=>'education',
 
-             'exp'=>'experience',
 
-             'neg'=>'negotiable',
 
-             'set'=>'setmeal_id',
 
-             'audit'=>'audit',
 
-             'dis'=>'display',
 
-             'use'=>'user_status',
 
-             'robot'=>'robot',
 
-             'scale'=>'scale',
 
-             'sub'=>'subsite_id',
 
-             'lic'=>'company_audit',
 
-             'ent'=>'is_entrust'
 
-         );
 
-         foreach ($foreach_arr as $key => $val) {
 
-             if (isset($jobs->$val)) {
 
-                 $d[] = $key.$jobs->$val;
 
-             }
 
-         }
 
-         if ($jobs->allowance_id) {
 
-             $d[] = 'all1';
 
-         }
 
-         $setsqlarr['key_precise'] = implode(' ', $d);
 
-         $jobs->key_precise = $setsqlarr['key_precise'];
 
-         return $this->jobsIndex($jobs['id'], $jobs);
 
-     }
 
-     //更新职位索引表
 
-     public function jobsIndex($id, $jobs)
 
-     {
 
-         $where = array('id'=>$id);
 
-         if ($id && !$jobs) {
 
-             $jobs = $this->getJobsOne($where);
 
-         }
 
-         if (!$jobs) {
 
-             return false;
 
-         }
 
-         if ($jobs->valid != 1) {
 
-             $this->model->where($where)->delete();
 
-         } else {
 
-             $data['id'] = $jobs->id;
 
-             $data['company_id'] = $jobs->company_id;
 
-             $data['wage'] = $jobs->wage;
 
-             $data['stime'] = $jobs->stime;
 
-             $data['map_x'] = $jobs->map_x;
 
-             $data['map_y'] = $jobs->map_y;
 
-             $data['click'] = $jobs->click?$jobs->click:0;
 
-             $data['jobs_name'] = $jobs->jobs_name;
 
-             $data['companyname'] = $jobs->company_name;
 
-             $data['key'] = $jobs->key_precise;
 
-             $data['created_at'] = $jobs->created_at;
 
-             $data['updated_at'] = $jobs->refresh_time?$jobs->refresh_time:$jobs->created_at;
 
-             if ($this->model->where($where)->first()) {
 
-                 $reg = $this->model->where($where)->update($data);
 
-             } else {
 
-                 $reg = $this->model->insert($data);
 
-             }
 
-             return $reg;
 
-         }
 
-         return true;
 
-     }
 
-     //获取单条职位
 
-     public function getJobsOne($where)
 
-     {
 
-         $val = Jobs::where($where)->first();
 
-         if (!$val) {
 
-             return false;
 
-         }
 
-         $val->contact= JobsContact::where(array('job_id'=>$val['id']))->first();
 
-         $val->deadline_days=($val->deadline -time())>0?"距到期时间还有<strong style=\"color:#FF0000\">".sub_day($val->deadline,time())."</strong>":"<span style=\"color:#FF6600\">目前已过期</span>";
 
-         return $val;
 
-     }
 
- }
 
 
  |