diff --git a/changelogs/2026-05/09_feat_traveler_type_mismatch_to_notify_center.md b/changelogs/2026-05/09_feat_traveler_type_mismatch_to_notify_center.md new file mode 100644 index 0000000..8cba8e2 --- /dev/null +++ b/changelogs/2026-05/09_feat_traveler_type_mismatch_to_notify_center.md @@ -0,0 +1,66 @@ +# 出行人类型不符通知迁移到通知中心 + TRAVELER_INCOMPLETE 配置修复 + +> **服务**: hl-order-service-v2 + hl-user-service +> **PR**: #1915 (Closes #1914) +> **日期**: 2026-05-09 +> **影响范围**: 后端通知链路;无前端改动 + +--- + +## ⚠️ 关键变化(无 API 字段变化,纯链路 + 配置治理) + +PR #1892 实现"出行人类型不符提醒定制师"时直调 `userFeignClient.sendWechatMessage` 硬编码企微通知,绕过通知中心。本 PR 迁移到通知中心 + 顺路修一个 prod 配置 bug。 + +**前端无需任何改动**。 + +--- + +## 一、改动清单 + +### A. Flyway V20260509_002 + +1. **修复 prod 配置 bug**:`UPDATE notification_event_config SET wework_enabled=0, wework_receiver_type=NULL, wework_content_template=NULL WHERE event_code='TRAVELER_INCOMPLETE'` + - 原 wework_receiver_type='USER' 是无效值(dispatcher switch 不识别),prod 7 天内 12 条全部 SKIP "无企微接收人" + - 该事件接收人是 C 端客户(USER),语义上不该走企微(企微只能发企业内部 admin),关掉企微通道,保留小程序订阅消息 +2. **新增事件 `TRAVELER_TYPE_MISMATCH`**: + - `wework_enabled=1, wework_receiver_type='CUSTOMIZER'` + - `wework_content_template` 含占位符 `${orderNo}/${productName}/${contactName}/${contactPhone}/${departureDate}/${declaredSummary}/${actualSummary}` + - `ON DUPLICATE KEY UPDATE` 幂等重跑 + +### B. 代码 + +- `TravelerTypeMismatchNotifier`:移除 `userFeignClient`/`complaintUserFeignClient`/`@Async("travelerNotifyExecutor")`/customizerId+wechatUserid SKIP 路径 +- 改注入 `NotificationEventHelper`,通过 `sendRaw(NotificationEventMessage)` 投 MQ +- 收件人由 `NotificationDispatcher.resolveWeworkRecipient` 按 CUSTOMIZER 查 `admin.enterprise_wechat_id` 自动 resolve +- 删 `TravelerNotifyConfig` + 对应测试(MQ 全链已异步,业务侧线程池冗余) +- 钩子 A(补全完毕)+ 钩子 B(改 4 count) + afterCommit 注册 全部保留 + +### C. 测试 8 用例全绿 + +- 一致不发 / 不一致发 / customizerId=null 仍发(由 dispatcher 兜底) / 订单不存在 +- 边界:列表空 → actual 全 0 / null type 跳过 / productName 长度>20 截断 / declared 全 null + actual 空 → 一致 + +## 二、行为变化 + +| 场景 | PR #1892 | 本 PR | +|------|---------|-------| +| 触发不一致 | 直调企微 Feign 发文本消息 | 投 MQ → dispatcher → 企微通道发送 | +| customizerId=null | Notifier 内 SKIP 不发 | Notifier 仍发 → dispatcher saveSendLog status=2(无企微接收人) | +| wechatUserid 为空 | Notifier 查 ComplaintUserFeignClient SKIP | dispatcher 查 admin.enterprise_wechat_id 兜底 saveSendLog status=2 | +| 通知日志 | `notification_log` 由 WechatApiClient 自动落 | `notification_send_log` 标准统一日志,event_code='TRAVELER_TYPE_MISMATCH' | +| admin 在通知中心 UI 关闭企微 | 无效(硬编码绕过) | **生效**(wework_enabled=0 → dispatcher 不分发) | + +## 三、@mmg 关注点(无前端改动) + +无 API 改动,小程序/管理端无需调整。 + +## 四、运维关注 + +- 部署后跑 V20260509_002 自动落库,可在通知中心 UI 看到新事件 `出行人类型不符提醒` 出现在 `订单消息` 分组 +- admin 可在通知中心配置页改文案/开关该事件的企微/站内信通道(本期默认只开企微) +- prod 12 条历史 SKIP 条目不会清理(只是新事件的策略变了) + +## 五、规则依据 + +铁规 19b:**任何消息发送必须走通知中心,严禁硬编码** —— 站内信/短信/小程序/公众号/企微 全渠道通过 NotificationDispatcher + notification_event_config,不许直调 sendXxxMessage Feign 写死文案。 +