Files
yunke/yunke-server/tests/test_api_customers.py
T
浅念 fd3cf0003b feat(customers): 微信客户页脚改云客口径(Σ员工好友数声明值8590,用户选B方案)
- GET /api/customers/declared-total: Σ wechat_account.contacts_num
- 页脚优先显示云客口径(回退真实total);列表内容保持去重真实行
- 云客列表声明值含其ES索引重复doc(连行id都相同无法物理区分),仅对齐计数

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-20 13:44:39 +08:00

26 lines
994 B
Python

# ---------------------------------------------------------------------------
# GET /api/customers/declared-total — 云客口径合计(页脚对齐云客显示,2026-08-20)
# ---------------------------------------------------------------------------
async def _seed_accounts_for_declared(session):
from app.db.models import WechatAccount
session.add_all([
WechatAccount(wx_id="w1", contacts_num=100),
WechatAccount(wx_id="w2", contacts_num=23),
WechatAccount(wx_id="w3", contacts_num=None),
])
await session.commit()
async def test_declared_total_sums_contacts_num(make_client):
"""declared_total = Σ wechat_account.contacts_num(云客声明的含重复口径)。"""
client = await make_client(_seed_accounts_for_declared)
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 # 只计有值的员工