Browse Source

查询客服人员筛选用户数据

master
wanghongjun 5 months ago
parent
commit
401a213709
  1. 41
      app/enterprise/controller/Im.php

41
app/enterprise/controller/Im.php

@ -176,6 +176,47 @@ class Im extends BaseController
return success('', $list);
}
// 查询客服人员筛选用户数据
public function searchUserList()
{
$keywords=$this->request->param('keywords','');
$listRows=$this->request->param('limit',20);
$page=$this->request->param('page',1);
$searchType=$this->request->param('search_type',0);
$prefix = config('database.connections.mysql.prefix');
$where = 'status = 1';
$order = '';
if ($keywords) {
$where .= " and account <> '{$this->userInfo['account']}'";
$where .= " and (";
$where .= "account like '%{$keywords}%' ";
$where .= "or realname like '%{$keywords}%' ";
$where .= "or name_py like '%{$keywords}%' ";
$where .= ")";
}
$field = "user_id,realname,avatar";
$sql = "select {$field} from {$prefix}user where {$where}";
if ($searchType == 1) {
$status=$this->chatSetting['autoAddUser']['status'] ?? 0;
$user_ids=$this->chatSetting['autoAddUser']['user_ids'] ?? [];
if ($status == 1 && $user_ids) {
$user_ids_str = implode(',',$user_ids);
$order = " order by user_id in ({$user_ids_str}) DESC,FIELD(user_id, {$user_ids_str})";
}
}
$sql .= $order;
$offset = ($page - 1) * $listRows;
$sql .= " limit {$offset},{$listRows}";
$list = Db::query($sql);
if($list){
foreach($list as $k=>$v){
$list[$k]['avatar']=avatarUrl($v['avatar'],$v['realname'],$v['user_id'],120);
$list[$k]['id']=$v['user_id'];
}
}
return success('', $list);
}
// 获取聊天记录
public function getMessageList()
{

Loading…
Cancel
Save