...
|
...
|
@@ -66,7 +66,7 @@ class CardController extends RestBaseController |
|
|
if($data['keyword']) {
|
|
|
$condition['c.is_recommend'] = 1;//后台推荐
|
|
|
$condition['c.name|company|tel'] = ['like','%'.$data['keyword'].'%'];
|
|
|
$condition2['c.name|company|tel'] = ['like','%'.$data['keyword'].'%','and'];
|
|
|
$condition2['c.name|company|tel'] = ['like','%'.$data['keyword'].'%'];
|
|
|
//搜索日志
|
|
|
$info = Db::name('search')->where(['keyword' => $data['keyword']])->find();
|
|
|
if ($info) {
|
...
|
...
|
@@ -85,14 +85,29 @@ class CardController extends RestBaseController |
|
|
}
|
|
|
$condition = $condition == '' ? '' : $condition;
|
|
|
$condition2['c.id'] = ['in',$ids];
|
|
|
$result = Db::name('card')
|
|
|
if($data['keyword']) {
|
|
|
$where = "SELECT `c`.`id`,`c`.`name`,`c`.`position`,`c`.`tel`,`c`.`home_tel`,`c`.`email`,`c`.`company`,`u`.`avatar`,IF(c.user_id='.$this->userId.',`c`.`user_id`,0) top FROM `bro_card` `c` LEFT JOIN `bro_user` `u` ON `c`.`user_id`=`u`.`id`
|
|
|
WHERE `c`.`is_recommend` = 1 AND ( `c`.`name` LIKE '%".$data['keyword']."%' OR `company` LIKE '%".$data['keyword']."%' OR `tel` LIKE '%".$data['keyword']."%' )
|
|
|
OR ( (`c`.`name` LIKE '%".$data['keyword']."%' OR `company` LIKE '%".$data['keyword']."%' OR `tel` LIKE '%".$data['keyword']."%') and `c`.`id` IN $ids)
|
|
|
ORDER BY top desc,c.create_time desc";
|
|
|
$result = Db::name('card')
|
|
|
->alias('c')
|
|
|
->join('user u','c.user_id=u.id','left')
|
|
|
->where()
|
|
|
->field('c.id,c.name,c.position,c.tel,c.home_tel,c.email,c.company,u.avatar,IF(c.user_id='.$this->userId.',c.user_id,0) top')
|
|
|
->order('top desc,c.create_time desc')
|
|
|
->paginate($per_page);
|
|
|
} else {
|
|
|
$result = Db::name('card')
|
|
|
->alias('c')
|
|
|
->join('user u','c.user_id=u.id','left')
|
|
|
->where($condition)
|
|
|
->whereOr($condition2)
|
|
|
->field('c.id,c.name,c.position,c.tel,c.home_tel,c.email,c.company,u.avatar,IF(c.user_id='.$this->userId.',c.user_id,0) top')
|
|
|
->order('top desc,c.create_time desc')
|
|
|
->select(false);
|
|
|
->paginate($per_page);
|
|
|
}
|
|
|
|
|
|
$this->success('获取成功',$result);
|
|
|
if ($result === false) {
|
|
|
$this->error(['code'=>'40000','msg'=>'获取失败']);
|
...
|
...
|
|