feat(iit-manager): Add WeChat Official Account integration for patient notifications

Features:
- PatientWechatCallbackController for URL verification and message handling
- PatientWechatService for template and customer messages
- Support for secure mode (message encryption/decryption)
- Simplified route /wechat/patient/callback for WeChat config
- Event handlers for subscribe/unsubscribe/text messages
- Template message for visit reminders

Technical details:
- Reuse @wecom/crypto for encryption (compatible with Official Account)
- Relaxed Fastify schema validation to prevent early request blocking
- Access token caching (7000s with 5min pre-refresh)
- Comprehensive logging for debugging

Testing: Local URL verification passed, ready for SAE deployment

Status: Code complete, waiting for WeChat platform configuration
This commit is contained in:
2026-01-04 22:53:42 +08:00
parent dfc472810b
commit b31255031e
167 changed files with 3055 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
# 企业微信环境变量配置说明
# 微信环境变量配置说明(企业微信 + 服务号)
## 📋 必需的环境变量
@@ -6,7 +6,7 @@
```env
# ==========================================
# 企业微信配置
# 企业微信配置(研究者端)
# ==========================================
# 企业微信基础配置(应用信息)
@@ -20,6 +20,21 @@ WECHAT_ENCODING_AES_KEY=V88eT3O9bMW897h4btr7v7qvQlmlMf31edTQCmuhOhO
# 测试用户ID可选仅测试环境使用
WECHAT_TEST_USER_ID=FengZhiBo
# ==========================================
# 微信服务号配置(患者端)
# ==========================================
# 微信服务号基础配置
WECHAT_MP_APP_ID=wx062568ff49e4570c
WECHAT_MP_APP_SECRET=c0d19435d1a1e948939c16d767ec0faf
# 微信服务号回调配置(消息加解密,安全模式)
WECHAT_MP_TOKEN=<需要生成3-32位字符串>
WECHAT_MP_ENCODING_AES_KEY=<需要生成43位字符串>
# 微信小程序配置(可选,后续开发)
WECHAT_MINI_APP_ID=<待申请>
```
## 📝 配置项说明