feat(staff): 弹框客户微信/员工微信列改富单元格(头像+昵称+ID+真实姓名,对齐云客)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -81,7 +81,7 @@ async def _aggregate(session: AsyncSession, owner: str, start: int, end: int) ->
|
||||
return agg_rows, last_map
|
||||
|
||||
|
||||
async def _customer_names(session: AsyncSession, owner: str, talker_ids: list[str]) -> dict[str, str]:
|
||||
async def _customer_names(session: AsyncSession, owner: str, talker_ids: list[str]) -> dict[str, tuple[str, str, str]]:
|
||||
if not talker_ids:
|
||||
return {}
|
||||
stmt = sa.select(
|
||||
@@ -89,15 +89,16 @@ async def _customer_names(session: AsyncSession, owner: str, talker_ids: list[st
|
||||
Customer.friend_remark,
|
||||
Customer.friend_nickname,
|
||||
Customer.real_name,
|
||||
Customer.head_image_url,
|
||||
).where(
|
||||
Customer.channel == "wechat",
|
||||
Customer.owner_account_id == owner,
|
||||
Customer.friend_id.in_(talker_ids),
|
||||
)
|
||||
names: dict[str, str] = {}
|
||||
for fid, remark, nick, real in (await session.execute(stmt)).all():
|
||||
names[fid] = remark or nick or real or fid
|
||||
return names
|
||||
info: dict[str, tuple[str, str, str]] = {}
|
||||
for fid, remark, nick, real, head in (await session.execute(stmt)).all():
|
||||
info[fid] = (remark or nick or real or fid, real or "", head or "")
|
||||
return info
|
||||
|
||||
|
||||
@router.get("/staff-chat-stats")
|
||||
@@ -124,7 +125,9 @@ async def get_staff_chat_stats(
|
||||
customers.append(
|
||||
StaffChatCustomerOut(
|
||||
talker_id=tid,
|
||||
friend_name=names.get(tid, tid),
|
||||
friend_name=(names.get(tid) or (tid, "", ""))[0],
|
||||
real_name=(names.get(tid) or ("", "", ""))[1] or None,
|
||||
head_image_url=(names.get(tid) or ("", "", ""))[2] or None,
|
||||
send_count=int(r.send_count or 0),
|
||||
receive_count=int(r.receive_count or 0),
|
||||
interaction_days=int(r.interaction_days or 0),
|
||||
|
||||
@@ -366,6 +366,8 @@ class StaffChatCustomerOut(BaseModel):
|
||||
|
||||
talker_id: str
|
||||
friend_name: str # remark > nickname > real_name > talker_id
|
||||
real_name: str | None = None # 真实姓名(弹框客户微信列显示)
|
||||
head_image_url: str | None = None # 头像(弹框客户微信列显示)
|
||||
send_count: int # 员工发出(is_send True)
|
||||
receive_count: int # 客户发出(is_send False)
|
||||
interaction_days: int # 窗口内不同日期数
|
||||
|
||||
Reference in New Issue
Block a user