feat(approval): 审批单内容快照与二次分配方案版本化

补齐 code-review 遗留 2 项:审批单此前只固化 ref_id/refer_no 指针,复核者看到
的是业务当前内容;二次分配方案在编辑替换与驳回清空时一律物理删除,方案事实
无处回溯。

- 审批单加 version_no 与 snapshot_json(信封 schema_version/order_type/
  captured_at/data);二次分配、月结、调整单三类提交均固化送审内容,开关关闭
  的自动通过路径同样写快照;详情按 snapshot/live/missing 三态回显,历史单
  只读回退当前内容并显式告警,不回填历史快照
- 二次分配方案行改 append-only 版本化(version_no/is_active,唯一键扩为
  business+version+personnel):编辑替换与驳回清空只置历史,核算与详情默认
  只取生效行,业务详情新增 allocation_history
- 送审内容未变不重提、方案未变不新增版本:判据统一为送审内容,两个
  version_no 语义解耦(方案版本=内容第几版,审批单版本=第几次送审)
- 审批单列表、工作台待办、审批超时预警三处 defer 快照列,避免整列拉取
- 月结提交取行加 for_update,防并发提交算出重复的审批单版本号
- 修复审批类型筛选上界 le=2(调整单无法筛选)、快照金额把空值写成 0.00
- V11 迁移三件套同步(Alembic / db/migration / init-dev.sql)

测试:单元 +16(方案内容比较 10、审批入参 6)、集成 +12;全量 891 passed。

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
liuwenxinandClaude Code committed 2026-10-20 18:30:51 +08:00
1 parent 2e0c64849b
commit 4c32a556de
28 files changed
+1458 -76

No files matched your search

+12 -1
View File
@@ -58,12 +58,23 @@ export interface SecondaryAllocationRow {
ratio: string
}
/** 业务详情:附产品明细行与二次分配方案(编辑弹窗一次回显) */
/** 方案版本行(append-only;编辑替换/驳回清空后旧行仍保留为历史) */
export interface AllocationVersionRow extends SecondaryAllocationRow {
/** 方案版本号(同一业务从 1 递增) */
version_no: number
/** 1 当前生效 0 历史版本 */
is_active: number
create_time: string
}
/** 业务详情:附产品明细行、当前方案与方案版本历史(编辑弹窗一次回显) */
export interface BusinessDetail extends BusinessItem {
items: BusinessItemRow[]
secondary_allocations: SecondaryAllocationRow[]
/** 方案合计/余额提示(余额归属待澄清 #2,仅展示) */
allocation_hint: string | null
/** 方案全部版本(含历史;被驳回方案亦保留) */
allocation_history: AllocationVersionRow[]
}
export interface BusinessQueryParams {