fix(management): drilldown行补channel字段——前端聊天路由判渠道用(契约冻结前补齐)
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -396,7 +396,7 @@ async def lifecycle_customers(
|
||||
) -> list[dict]:
|
||||
"""drilldown cooling/dormant:该员工账号归属客户(delete_flag 过滤)+
|
||||
msg_daily_stats friend 行全历史 → lifecycle.classify(as_of=窗口末日),
|
||||
返回状态匹配行 {friend_id, nickname, last_day, state},按 last_day asc
|
||||
返回状态匹配行 {friend_id, channel, nickname, last_day, state},按 last_day asc
|
||||
(最陈旧在前)、friend_id asc 排序。
|
||||
|
||||
历史按 (channel, peer) 键控、跨 owner 合并——与批次A _lifecycle_daily
|
||||
@@ -445,6 +445,7 @@ async def lifecycle_customers(
|
||||
if state == want_state:
|
||||
matches.append({
|
||||
"friend_id": c.friend_id,
|
||||
"channel": c.channel,
|
||||
"nickname": c.friend_nickname or c.friend_remark or c.friend_id,
|
||||
"last_day": last,
|
||||
"state": state,
|
||||
@@ -483,6 +484,7 @@ async def fr_fact_rows(
|
||||
)).scalars().all()
|
||||
items = [{
|
||||
"day": f.day,
|
||||
"channel": f.channel,
|
||||
"owner_account_id": f.owner_account_id,
|
||||
"peer_id": f.peer_id,
|
||||
"thread_end_ts": f.thread_end_ts,
|
||||
|
||||
@@ -571,6 +571,7 @@ async def test_drilldown_fr_p90(make_client):
|
||||
# fr_ms desc + 同值按日 desc 决胜:0902 的 pD 在前
|
||||
assert item["fr_ms"] == 600_000
|
||||
assert item["peer_id"] == "pD"
|
||||
assert item["channel"] == "wechat"
|
||||
assert item["owner_account_id"] == "wx2"
|
||||
assert item["chat_hint"] == {"owner_account_id": "wx2", "talker_id": "pD"}
|
||||
r = await client.get(url, params={
|
||||
@@ -618,7 +619,8 @@ async def test_drilldown_lifecycle_customers(make_client):
|
||||
assert r.status_code == 200
|
||||
body = r.json()
|
||||
assert body["total"] == 1 # f2 降温;f1 沉睡、f9 已删
|
||||
assert body["items"][0] == {"friend_id": "f2", "nickname": "客户二",
|
||||
assert body["items"][0] == {"friend_id": "f2", "channel": "wechat",
|
||||
"nickname": "客户二",
|
||||
"last_day": 20260825, "state": "cooling"}
|
||||
|
||||
r = await client.get("/api/management/employees/u1/drilldown",
|
||||
@@ -657,7 +659,8 @@ async def test_drilldown_shared_customer_history(make_client):
|
||||
body = r.json()
|
||||
assert body["total"] == 2 # f1 + f3(历史全在 wx2 名下也不丢)
|
||||
f3 = next(i for i in body["items"] if i["friend_id"] == "f3")
|
||||
assert f3 == {"friend_id": "f3", "nickname": "共享客户",
|
||||
assert f3 == {"friend_id": "f3", "channel": "wechat",
|
||||
"nickname": "共享客户",
|
||||
"last_day": 20260801, "state": "dormant"}
|
||||
# 归属口径仍是 Customer.owner(wx1):u2(wx2)名下看不到
|
||||
r = await client.get("/api/management/employees/u2/drilldown",
|
||||
|
||||
Reference in New Issue
Block a user