锁定缴费校验失败时整单回滚,避免样本半成功落库;前端禁止删除锁定缴费样本,改码走更正编码。同步落地样本更正、采集微信通知、OA提及未读、细胞产品套餐与相关迁移文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
82 lines
2.9 KiB
Markdown
82 lines
2.9 KiB
Markdown
# 基础实验交付日前一天服务号提醒 Implementation Plan
|
||
|
||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||
> Spec: `docs/superpowers/specs/2026-10-22-basic-experiment-delivery-remind-design.md`
|
||
|
||
**Goal:** 每天 10:00 扫描次日交付的基础实验计划,向申请单创建人发送服务号模板消息。
|
||
|
||
**Architecture:** 纯函数拼接产品名 + 服务层扫描/幂等/发送;复用 `wechat_mp_message._send_template`;APScheduler Cron 注册;`biz_wx_notify_log` 防重。
|
||
|
||
**Tech Stack:** FastAPI、SQLAlchemy、APScheduler、pytest、微信服务号 template/send
|
||
|
||
---
|
||
|
||
### File map
|
||
|
||
| 文件 | 职责 |
|
||
|------|------|
|
||
| `docs/sql/migrations/2026-10-22-biz-wx-notify-log.sql` | 幂等日志表 |
|
||
| `backend/app/models/models.py` | `BizWxNotifyLog` |
|
||
| `backend/app/core/config.py` | 模板 ID 与字段名配置 |
|
||
| `backend/app/services/wechat_mp_message.py` | `send_basic_experiment_delivery_remind` |
|
||
| `backend/app/services/basic_experiment_delivery_remind.py` | 拼接、扫描、发送、幂等 |
|
||
| `backend/app/tasks/__init__.py` | Cron 10:00 |
|
||
| `backend/tests/test_basic_experiment_delivery_remind.py` | 单测 |
|
||
|
||
---
|
||
|
||
### Task 1: 产品名称拼接(纯函数 TDD)
|
||
|
||
**Files:**
|
||
- Create: `backend/app/services/basic_experiment_delivery_remind.py`
|
||
- Test: `backend/tests/test_basic_experiment_delivery_remind.py`
|
||
|
||
- [x] **Step 1: Write failing tests for `format_delivery_product_name`**
|
||
|
||
- [x] **Step 2: Implement `format_delivery_product_name`**
|
||
|
||
- [x] **Step 3: pytest pass**
|
||
|
||
---
|
||
|
||
### Task 2: 配置 + 模板发送封装
|
||
|
||
**Files:**
|
||
- Modify: `backend/app/core/config.py`
|
||
- Modify: `backend/app/services/wechat_mp_message.py`
|
||
- Test: extend `test_basic_experiment_delivery_remind.py`(mock `_send_template`)
|
||
|
||
- [x] 增加 `WX_MP_TEMPLATE_BASIC_EXPERIMENT_DELIVERY` 与字段配置
|
||
- [x] 增加 `send_basic_experiment_delivery_remind`
|
||
- [x] 单测校验 data 字段键与截断
|
||
|
||
---
|
||
|
||
### Task 3: SQL + Model + 扫描发送 + 幂等
|
||
|
||
**Files:**
|
||
- Create: `docs/sql/migrations/2026-10-22-biz-wx-notify-log.sql`
|
||
- Modify: `backend/app/models/models.py`
|
||
- Modify: `backend/app/services/basic_experiment_delivery_remind.py`
|
||
- Test: `backend/tests/test_basic_experiment_delivery_remind.py`
|
||
|
||
- [x] DDL + `BizWxNotifyLog`
|
||
- [x] `run_delivery_remind_for_date(db, *, today)`:查明天交付、basic_experiment、非 yqx;幂等;发送
|
||
- [x] 单测:命中/跳过取消/跳过无 openid/幂等二次不发
|
||
|
||
---
|
||
|
||
### Task 4: 注册定时任务
|
||
|
||
**Files:**
|
||
- Modify: `backend/app/tasks/__init__.py`
|
||
|
||
- [x] Cron `hour=10, minute=0` 调用 `run_delivery_remind_job(get_db_session)`
|
||
|
||
---
|
||
|
||
### Task 5: 验证 + 图谱
|
||
|
||
- [x] `pytest backend/tests/test_basic_experiment_delivery_remind.py -v`
|
||
- [x] `./scripts/update-graph.sh backend`
|