fix(customers): WA客户破1万上限(逐员工uid过滤,8585→11931全量)+双渠道页脚云客口径+消息同步刷新最近沟通时间

- wa-friends 逐员工抓取:全局查询~1万行硬上限(云客11931只翻到10000),
  uid=员工WA号过滤(真机验证 declared 1145→1149),total-aware翻页
- declared-total 分渠道:Σ wechat/whatsapp_account.contacts_num(8590/11915)
- 消息增量同步顺带刷新 customer.last_chat_time(云客列表按最近沟通实时
  排序,快照每日一次导致顺序滞后;微信1:1+WA都加)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
浅念
2026-08-20 14:04:06 +08:00
parent fd3cf0003b
commit edca9b4c77
5 changed files with 187 additions and 62 deletions
+16 -4
View File
@@ -16,10 +16,22 @@ async def _seed_accounts_for_declared(session):
async def test_declared_total_sums_contacts_num(make_client):
"""declared_total = Σ wechat_account.contacts_num(云客声明的含重复口径)。"""
client = await make_client(_seed_accounts_for_declared)
"""分渠道 declared_total = Σ 员工账号表 contacts_num(云客含重复口径)。"""
from app.db.models import WhatsappAccount
async def seed_both(session):
await _seed_accounts_for_declared(session)
session.add_all([
WhatsappAccount(uid="a1@s.whatsapp.net", contacts_num=10),
WhatsappAccount(uid="a2@s.whatsapp.net", contacts_num=5),
])
await session.commit()
client = await make_client(seed_both)
r = await client.get("/api/customers/declared-total")
assert r.status_code == 200
body = r.json()
assert body["declared_total"] == 123
assert body["account_count"] == 2 # 只计有值的员工
assert body["wechat"]["declared_total"] == 123
assert body["wechat"]["account_count"] == 2 # 只计有值的员工
assert body["whatsapp"]["declared_total"] == 15
assert body["whatsapp"]["account_count"] == 2