diff --git a/Server/application/cunkebao/controller/friend/GetFriendListV1Controller.php b/Server/application/cunkebao/controller/friend/GetFriendListV1Controller.php index a6d12d6e..89abde8c 100644 --- a/Server/application/cunkebao/controller/friend/GetFriendListV1Controller.php +++ b/Server/application/cunkebao/controller/friend/GetFriendListV1Controller.php @@ -38,23 +38,21 @@ class GetFriendListV1Controller extends BaseController $where[] = ['isDeleted','=',0]; } - if(!empty($keyword)){ $where[] = ['nickname|alias|wechatId','like','%'.$keyword.'%']; } + $wechatIds = Db::name('device')->alias('d') + ->join('device_wechat_login dwl','dwl.deviceId=d.id AND dwl.companyId='.$this->getUserInfo('companyId')) + ->where(['d.companyId' => $this->getUserInfo('companyId'),'d.deleteTime' => 0]); - $devices = Db::name('device_wechat_login') - ->where(['companyId' => $this->getUserInfo('companyId'),'alive' => 1]) - ->order('id desc') - ->group('wechatId'); - - if(!empty($deviceIds) && is_array($deviceIds)){ - $devices = $devices->whereIn('deviceId',$deviceIds); + if (!empty($deviceIds)){ + $wechatIds = $wechatIds->where('d.deviceId','in',$deviceIds); } - $devices = $devices->column('wechatId'); + $wechatIds = $wechatIds->column('dwl.wechatId'); - $where[] = ['ownerWechatId','in',$devices]; + + $where[] = ['ownerWechatId','in',$wechatIds]; $data = Db::table('s2_wechat_friend') ->field(['nickname','avatar','alias','id','wechatId','ownerNickname','ownerAlias','ownerWechatId','createTime'])