From ced0f993defd5415e2b5458ea23e9ce6748df635 Mon Sep 17 00:00:00 2001 From: wong <106998207@qq.com> Date: Fri, 5 Dec 2025 10:44:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=BB=84=E5=8F=8A=E5=A5=BD=E5=8F=8B?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WechatChatroomController.php | 21 +++++++++++++++-- .../controller/WechatFriendController.php | 23 +++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/Server/application/chukebao/controller/WechatChatroomController.php b/Server/application/chukebao/controller/WechatChatroomController.php index bd07bb31..8461904b 100644 --- a/Server/application/chukebao/controller/WechatChatroomController.php +++ b/Server/application/chukebao/controller/WechatChatroomController.php @@ -14,13 +14,30 @@ class WechatChatroomController extends BaseController public function getList(){ $page = $this->request->param('page', 1); $limit = $this->request->param('limit', 10); + $keyword = $this->request->param('keyword', ''); + $groupIds = $this->request->param('groupIds', ''); $accountId = $this->getUserInfo('s2_accountId'); if (empty($accountId)){ return ResponseHelper::error('请先登录'); } $query = Db::table('s2_wechat_chatroom') - ->where(['accountId' => $accountId,'isDeleted' => 0]) - ->order('id desc'); + ->where(['accountId' => $accountId,'isDeleted' => 0]); + + // 关键字搜索:群昵称、微信号(这里使用chatroomId作为群标识) + if ($keyword !== '' && $keyword !== null) { + $query->where(function ($q) use ($keyword) { + $like = '%' . $keyword . '%'; + $q->whereLike('nickname', $like) + ->whereOr('conRemark', 'like', $like); + }); + } + + // 分组筛选:groupIds(单个分组ID) + if ($groupIds !== '' && $groupIds !== null) { + $query->where('groupIds', $groupIds); + } + + $query->order('id desc'); $total = $query->count(); $list = $query->page($page, $limit)->select(); diff --git a/Server/application/chukebao/controller/WechatFriendController.php b/Server/application/chukebao/controller/WechatFriendController.php index 521227b9..da4782c2 100644 --- a/Server/application/chukebao/controller/WechatFriendController.php +++ b/Server/application/chukebao/controller/WechatFriendController.php @@ -13,13 +13,32 @@ class WechatFriendController extends BaseController { $page = $this->request->param('page', 1); $limit = $this->request->param('limit', 10); + $keyword = $this->request->param('keyword', ''); + $groupIds = $this->request->param('groupIds', ''); $accountId = $this->getUserInfo('s2_accountId'); if (empty($accountId)) { return ResponseHelper::error('请先登录'); } $query = Db::table('s2_wechat_friend') - ->where(['accountId' => $accountId, 'isDeleted' => 0]) - ->order('id desc'); + ->where(['accountId' => $accountId, 'isDeleted' => 0]); + + // 关键字搜索:昵称、备注、微信号 + if ($keyword !== '' && $keyword !== null) { + $query->where(function ($q) use ($keyword) { + $like = '%' . $keyword . '%'; + $q->whereLike('nickname', $like) + ->whereOr('conRemark', 'like', $like) + ->whereOr('alias', 'like', $like) + ->whereOr('wechatId', 'like', $like); + }); + } + + // 分组筛选:groupIds(单个分组ID) + if ($groupIds !== '' && $groupIds !== null) { + $query->where('groupIds', $groupIds); + } + + $query->order('id desc'); $total = $query->count(); $list = $query->page($page, $limit)->select();