diff --git a/yunke-server/app/api/routers/staff_chat_stats.py b/yunke-server/app/api/routers/staff_chat_stats.py index 5223258..cdbbf50 100644 --- a/yunke-server/app/api/routers/staff_chat_stats.py +++ b/yunke-server/app/api/routers/staff_chat_stats.py @@ -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), diff --git a/yunke-server/app/api/schemas.py b/yunke-server/app/api/schemas.py index f307351..5a3c110 100644 --- a/yunke-server/app/api/schemas.py +++ b/yunke-server/app/api/schemas.py @@ -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 # 窗口内不同日期数 diff --git a/yunkes/src/api/types.ts b/yunkes/src/api/types.ts index aca7fd8..7ab4cfb 100644 --- a/yunkes/src/api/types.ts +++ b/yunkes/src/api/types.ts @@ -316,6 +316,8 @@ export interface Message { export interface StaffChatCustomer { talker_id: string friend_name: string + real_name?: string | null + head_image_url?: string | null send_count: number receive_count: number interaction_days: number diff --git a/yunkes/src/components/YkStaffDetailModal.vue b/yunkes/src/components/YkStaffDetailModal.vue index a5b3ec8..cd02869 100644 --- a/yunkes/src/components/YkStaffDetailModal.vue +++ b/yunkes/src/components/YkStaffDetailModal.vue @@ -79,7 +79,30 @@ watch( :formatter="c.formatter" show-overflow-tooltip > -