fix(groups): 微信群排序复刻云客+群详情去掉重复的「成员列表」字段
用户报:①群详情有成员墙后「成员列表」原始串字段重复;②排序与云客不一致。 - 排序:云客「微信群统计」真机判别=员工分组(云客员工列表序)+ 组内 chatRoomId 字符串升序——/api/groups 微信路径改 JOIN wechat_account 按 list_order(NULL 垫底按 owner asc)+room_id asc; WA 保持最近活跃优先 - 群详情:memberIds 从「其他字段」兜底区排除(成员墙已替代,不再 以原始 wxid 串重复出现) 726 测试绿(默认排序断言更新为员工分组序)。 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -101,14 +101,33 @@ async def list_groups(
|
||||
list_stmt = sa.select(ChatGroup)
|
||||
if conditions:
|
||||
list_stmt = list_stmt.where(*conditions)
|
||||
list_stmt = (
|
||||
list_stmt.order_by(
|
||||
sa.nullslast(ChatGroup.last_chat_time.desc()),
|
||||
ChatGroup.room_id.asc(),
|
||||
if (channel or "wechat") == "wechat":
|
||||
# 云客「微信群统计」同款排序(2026-09-10 真机判别):员工分组——
|
||||
# 按云客员工列表序(wechat_account.list_order,NULL 垫底按 wx_id)、
|
||||
# 组内按 room_id(chatRoomId)字符串升序。WA 保持最近活跃优先。
|
||||
list_stmt = (
|
||||
list_stmt.outerjoin(
|
||||
WechatAccount,
|
||||
WechatAccount.wx_id == ChatGroup.owner_account_id,
|
||||
)
|
||||
.order_by(
|
||||
WechatAccount.list_order.is_(None),
|
||||
WechatAccount.list_order.asc(),
|
||||
ChatGroup.owner_account_id.asc(),
|
||||
ChatGroup.room_id.asc(),
|
||||
)
|
||||
.limit(page_size)
|
||||
.offset((page - 1) * page_size)
|
||||
)
|
||||
else:
|
||||
list_stmt = (
|
||||
list_stmt.order_by(
|
||||
sa.nullslast(ChatGroup.last_chat_time.desc()),
|
||||
ChatGroup.room_id.asc(),
|
||||
)
|
||||
.limit(page_size)
|
||||
.offset((page - 1) * page_size)
|
||||
)
|
||||
.limit(page_size)
|
||||
.offset((page - 1) * page_size)
|
||||
)
|
||||
rows = (await session.execute(list_stmt)).scalars().all()
|
||||
|
||||
# ---- 员工微信/员工信息列(wechat_account/staff 关联,本页行集) ----
|
||||
|
||||
Reference in New Issue
Block a user