46 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 招商银行邮件账单
每天从 163 邮箱读取招商银行 `95555@message.cmbchina.com` 发来的
“招商银行企业交易明细”邮件,提取正文中的限时下载链接,解压 ZIP,
导入“银行账单”,并同步账户当前余额。
## 运行规则
- 默认处理前一天的交易明细。
- 邮箱必须开启 IMAP,配置复用
`runtime/private/wangshang-mail-accounts.json` 中的邮箱连接信息。
- 招商银行下载链接有效期 12 小时,生产任务每天 07:00 执行,失败后
10 分钟自动重试一次;相同 ZIP 指纹只导入一次。
- 07:00、07:10 两次均失败时,由生产服务器直接向指定钉钉企业成员发送一次
失败提醒,不依赖开发机或 Codex 是否在线。提醒只包含账单日期、失败类型和
脱敏后的简短原因。
- ZIP 只接收 XLSX、XLS、CSV,每次解压前校验文件数量、总大小和路径安全。
- 导入按银行流水指纹幂等更新,重复下载不会产生重复流水。
钉钉应用需要开通 `qyapi_robot_sendmsg` 权限。安装时可通过
`-AlertRecipient` 指定接收人的企业昵称,默认是 `山时`。
## 手动测试
```powershell
python scripts\cmb-mail\fetch_daily.py fetch `
--config runtime\private\wangshang-mail-accounts.json `
--date 2026-11-24
```
生产导入:
```sh
/bin/sh /opt/caiwuxitong/runtime/private/cmb-mail/run-server.sh 2026-11-24
```
## 部署
```powershell
pwsh -File scripts\cmb-mail\install-from-workstation.ps1 -RunNow
```
安装脚本复用生产环境已有的 163 邮箱配置,并安装
`/etc/cron.d/caiwu-cmb-mail` 定时任务。服务器提醒通过应用镜像中的
`cmb-mail:notify-failure` 命令发送。