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?"距到期时间还有".sub_day($val->deadline,time())."":"目前已过期";
return $val;
}
}