From 7d8573b52a9628629f78dcddda98bb438e9d7128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E8=80=81=E7=99=BD=E5=85=94?= Date: Fri, 24 Oct 2025 17:20:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=81=94=E7=B3=BB=E4=BA=BA?= =?UTF-8?q?=E5=88=86=E7=BB=84=E7=BB=9F=E8=AE=A1=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=88=86=E5=88=AB=E6=8F=90=E5=8F=96=E5=A5=BD=E5=8F=8B=E5=92=8C?= =?UTF-8?q?=E7=BE=A4=E7=BB=84=E6=A0=87=E7=AD=BEID=E4=BB=A5=E6=8F=90?= =?UTF-8?q?=E9=AB=98=E5=87=86=E7=A1=AE=E6=80=A7=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=B3=A8=E9=87=8A=E4=BB=A5=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=8F=AF=E8=AF=BB=E6=80=A7=EF=BC=8C=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E8=B0=83=E6=95=B4=E6=95=B0=E6=8D=AE=E5=BA=93=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=9D=A1=E4=BB=B6=E4=BB=A5=E6=94=AF=E6=8C=81=E6=9B=B4?= =?UTF-8?q?=E7=81=B5=E6=B4=BB=E7=9A=84=E5=88=86=E7=BB=84=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SidebarMenu/WechatFriends/extend.ts | 17 +++++++++++------ .../SidebarMenu/WechatFriends/index.tsx | 14 ++++++++++++-- Touchkebao/src/utils/dbAction/contact.ts | 19 +++++++++++++++++-- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/extend.ts b/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/extend.ts index f9a3b3c8..220c4d56 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/extend.ts +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/extend.ts @@ -206,8 +206,13 @@ export const getGroupStatistics = async ( labels: ContactGroupByLabel[], customerId?: number, ): Promise => { - const realGroupIds = labels - .filter(item => item.id !== 0) + // 分别提取好友标签和群标签的ID + const friendGroupIds = labels + .filter(item => item.id !== 0 && Number(item.groupType) === 1) + .map(item => item.id); + + const chatGroupIds = labels + .filter(item => item.id !== 0 && Number(item.groupType) === 2) .map(item => item.id); const groupedData: ContactGroupByLabel[] = []; @@ -218,12 +223,12 @@ export const getGroupStatistics = async ( if (Number(label.groupType) === 1) { // 好友分组 if (label.id === 0) { - // 未分组:不属于任何标签的好友 + // 未分组:不属于任何好友标签的好友 count = await ContactManager.getContactCount( userId, "friend", customerId, - realGroupIds, + friendGroupIds, // 只排除好友标签 true, // 排除已分组的 ); } else { @@ -239,12 +244,12 @@ export const getGroupStatistics = async ( } else if (Number(label.groupType) === 2) { // 群组分组 if (label.id === 0) { - // 默认群分组:不属于任何标签的群 + // 默认群分组:不属于任何群标签的群 count = await ContactManager.getContactCount( userId, "group", customerId, - realGroupIds, + chatGroupIds, // 只排除群标签 true, // 排除已分组的 ); } else { diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/index.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/index.tsx index 22b4c34b..deed4a02 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/index.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/WechatFriends/index.tsx @@ -174,8 +174,13 @@ const ContactListSimple: React.FC = ({ })); try { + // 根据当前标签的 groupType 计算正确的 realGroupIds const realGroupIds = labels - .filter(item => item.id !== 0) + .filter( + item => + item.id !== 0 && + Number(item.groupType) === Number(label.groupType), + ) .map(item => item.id); const contacts = await getContactsByGroup( @@ -231,8 +236,13 @@ const ContactListSimple: React.FC = ({ const currentPage = groupData.pages[groupKey] || 1; const nextPage = currentPage + 1; + // 根据当前标签的 groupType 计算正确的 realGroupIds const realGroupIds = labels - .filter(item => item.id !== 0) + .filter( + item => + item.id !== 0 && + Number(item.groupType) === Number(label.groupType), + ) .map(item => item.id); const newContacts = await getContactsByGroup( diff --git a/Touchkebao/src/utils/dbAction/contact.ts b/Touchkebao/src/utils/dbAction/contact.ts index 501c6289..1f0ced1a 100644 --- a/Touchkebao/src/utils/dbAction/contact.ts +++ b/Touchkebao/src/utils/dbAction/contact.ts @@ -326,6 +326,14 @@ export class ContactManager { exclude: boolean = false, ): Promise { try { + console.log("getContactCount 调用参数:", { + userId, + type, + customerId, + groupIds, + exclude, + }); + const conditions: any[] = [ { field: "userId", operator: "equals", value: userId }, { field: "type", operator: "equals", value: type }, @@ -353,14 +361,21 @@ export class ContactManager { // 包含指定分组 conditions.push({ field: "groupId", - operator: "in", + operator: "anyOf", value: groupIds, }); } } + console.log("查询条件:", conditions); + const contacts = await contactUnifiedService.findWhereMultiple(conditions); + + console.log( + `查询结果数量: ${contacts.length}, type: ${type}, groupIds: ${groupIds}`, + ); + return contacts.length; } catch (error) { console.error("获取联系人数量失败:", error); @@ -408,7 +423,7 @@ export class ContactManager { // 包含指定分组 conditions.push({ field: "groupId", - operator: "in", + operator: "anyOf", value: groupIds, }); }