fix: 去掉 aibot 不支持的 font 标签,改加粗+emoji;补拉量合计格式化中文

This commit is contained in:
yeuimu
2026-08-28 02:02:18 +00:00
parent 14321faa91
commit 60e5ff404e
4 changed files with 27 additions and 15 deletions
+21 -8
View File
@@ -25,6 +25,22 @@ def _fmt_diff(diff: dict) -> str:
return " ".join(f"{k}{v:+d}" for k, v in (diff or {}).items()) or "—"
_TOTALS_LABELS = {
"ordersAdded": "订单新增", "ordersUpdated": "订单更新", "ordersRemoved": "订单移除",
"goodsAdded": "商品新增", "goodsUpdated": "商品更新", "goodsRemoved": "商品移除",
}
def _fmt_totals(summary: dict) -> str:
parts = [f"{_TOTALS_LABELS.get(k, k)} {v:,}" for k, v in summary.items()
if k not in ("totalDays", "daysWithDiff") and v]
return " · ".join(parts)
def _short_date(date_str: str) -> str:
return date_str[5:] if len(date_str) == 10 and date_str[:4].isdigit() else date_str
def build_daily_message(
days: int, window: str, riin: dict, sds: dict,
goods: dict, ocr: dict, failures: list[dict],
@@ -41,14 +57,12 @@ def build_daily_message(
diff_days = [d for d in days_r if not d.get("ok")]
total, n_diff = summary.get("totalDays", len(days_r)), summary.get("daysWithDiff", len(diff_days))
if diff_days:
lines.append(f"**{name}** {total - n_diff}/{total} 天一致,"
f'<font color="warning">**{n_diff} 天有差异(已补拉)**</font>')
lines.append(f"**{name}** {total - n_diff}/{total} 天一致,**{n_diff} 天有差异(已补拉)**⚠️")
for d in diff_days[:8]:
lines.append(f"> {d['date']} {_fmt_diff(d.get('diff'))}(补拉 {d.get('orders', 0)} 单)")
lines.append(f"> {_short_date(d['date'])} {_fmt_diff(d.get('diff'))}(补拉 {d.get('orders', 0):,} 单)")
if len(diff_days) > 8:
lines.append(f"> …共 {len(diff_days)} 天")
totals = {k: v for k, v in summary.items()
if k not in ("totalDays", "daysWithDiff") and v}
totals = _fmt_totals(summary)
if totals:
lines.append(f"> 补拉量合计 {totals}")
lines.append("> 注:同一差异长期存在多为统计口径/状态映射问题(如发货后退款未同步)")
@@ -63,7 +77,7 @@ def build_daily_message(
lines.append("**商品完整性**")
for sys in ("RIIN", "SDS"):
g = goods[sys]
zero = f'<font color="warning">**{g["zeroGoodsOrders"]}**</font>' if g["zeroGoodsOrders"] else "0"
zero = f"**{g['zeroGoodsOrders']}**⚠️" if g["zeroGoodsOrders"] else "0"
lines.append(f"> {sys} 订单 {g['orders']:,} · 商品 {g['goods']:,} · 零商品订单 {zero} · 无名称 {g['goodsNoName']:,}")
attention = attention or g["zeroGoodsOrders"] > 0
lines.append(f"> 全库孤儿商品 {goods['RIIN']['orphanGoods']:,}")
@@ -77,8 +91,7 @@ def build_daily_message(
if failures:
attention = True
lines += ["", ('<font color="warning">⚠️ **存在需关注项,见上**</font>' if attention
else '<font color="info">✅ **数据全部一致,无异常**</font>')]
lines += ["", ("⚠️ **存在需关注项,见上**" if attention else "✅ **数据全部一致,无异常**")]
return "\n".join(lines), attention