public function index()
{
$param = I('');
//搜索条件
$param['job'] ? $where['job'] = ['like', '%' . trim($param['job'] . '%')] : '';
//月薪范围
$monthly_pay = explode('至', $param['monthly_pay']);
switch ($param['monthly_pay']) {
case '2':
$where['monthly_pay2'] = ['lt', 3];
break;
case '2-5':
$where['monthly_pay2'] = ['gt', 2];
break;
case '5-10':
$where['monthly_pay2'] = ['gt', 5];
break;
case '10-15':
$where['monthly_pay2'] = ['gt', 10];
break;
case '15-25':
$where['monthly_pay2'] = ['gt', 15];
break;
case '25-50':
$where['monthly_pay2'] = ['gt', 25];
break;
case '50':
$where['monthly_pay1'] = ['gt', 49];
break;
}
//工作经验
$experience = explode('至', $param['experience']);
switch ($param['experience']) {
case '1':
$where['experience2'] = ['lt', 2];
break;
case '1-3':
$where[0] = 'experience1>=1 AND experience2<=3';
break;
case '3-5':
$where[0] = 'experience1>=3 AND experience2<=5';
break;
case '5-10':
$where[0] = 'experience1>=5 AND experience2<=10';
break;
case '10':
$where['experience2'] = ['gt', 9];
break;
}
//学历
$param['education'] ? $where['education'] = $param['education'] : '';
$param['status'] ? $where['p.status'] = $param['status'] : '';
$ctime = explode('至', $param['ctime']);
$param['ctime'] ? $where['p.ctime'] = [['gt', strtotime($ctime[0])], ['lt', strtotime($ctime[1])]] : '';
//清空
if ($param['clear']) {
unset($param);
}
$count = M('recruit_position')->alias('p')->join('ys_recruit_company AS c ON p.cid=c.id', 'left')->where($where)->count();
$Page = new \Think\Page($count, 10);
// $res = M('shop_order')->where($where)->limit($Page->firstRow . ',' . $Page->listRows)
// ->select();
// $data = array_map(function ($v) {
// $v['items'] = json_decode($v['items'], true);
// return $v;
// }, $res);
$res = M('recruit_position')->alias('p')
->field('p.*,c.name,c.logo,c.address')
->join('ys_recruit_company AS c ON p.cid=c.id', 'left')
->where($where)
->limit($Page->firstRow . ',' . $Page->listRows)
->order('ctime desc')
->select();
$this->assign([
'data' => $res,
'job' => $param['job'],
'monthly_pay' => $param['monthly_pay'],
'experience' => $param['experience'],
'education' => $param['education'],
'ctime' => $param['ctime'],
'status' => $param['status'],
'page' => $Page->show()
]);
$this->display();
}
07-10
325
