Files
SupplierSystem/docs/design/20260720-supplier-prep-amend-full-loop.md
T
Ubuntu deb3e72750
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s
chore: 以 AI 生鲜配送系统 当前版本作为 SupplierSystem 起点
来源仓库:jxc/ai-fresh-delivery
来源提交:f0b1a180e2deb7e4673b9d1c8542619f7bc0f73d
快照树:  09f679334ff38f0ff25e907961c94a8223bcaedd(与来源 HEAD 工作树逐字节一致,3801 个文件)

按约定本仓库不带任何历史提交:来源仓库的历史中含真实凭据
(生产 SSH 私钥 deploy/id_rsa_tencent、server/.env、.env.tencent/.env.production/.env.gitea、
deploy/小程序AppSecret.txt,其中 MP_APPSECRET / S3 AccessKey 经哈希比对与线上同值),
整包推送会把这些凭据永久带入本仓库,故只取「当前版本」的单提交快照。
供应商系统后续开发自本提交开始。
2026-10-08 17:35:43 +08:00

58 lines
2.4 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.
# 供应商追加改量/价:完整下游闭环
日期:2026-07-20
关联:`20260720-supplier-prep-amend-qty-ui.md`、`20260720-prep-price-completed-loop.md`
## 目标 / 非目标
**目标**
追加修改(单价 / 单位 / 数量)保存后,下游必须一致:
| 环 | 动作 |
|----|------|
| 备货 | `supplier_preparations` 价/单位/数量 |
| 订单结算 | 量或单位变 → `syncOrderItemsFromSupplyCompletion`(金额重算) |
| 验收 | 价/单位始终同步;**待验**改 `prepare_qty`;**已入库**同步改 `actual_qty`(纠错口径) |
| 采购成本 | 已入库 → reconcile;未入库 → 按量×价 **upsert** `cost_details(purchase)` |
| 分拣 | 关联 `picking_items`:`required_qty`/单位跟订单明细;若原先已拣满则 `picked_qty` 同跟 |
**非目标**
- 不回退订单主状态;不重开验收任务。
- 不改客户报价主数据(仅明细行价可能因换单位重匹配)。
- 不改配送装车历史日志。
## 方案要点
在 `updatePreparationPurchasePrice`(status≥30)路径统一调用 `closePrepAmendDownstream`:
1. 既有:订单结算(量/单位变)、`syncPreparationPriceToDownstream`
2. 新增:验收数量
- 未入库:`prepare_qty`
- 已入库:`prepare_qty` + `actual_qty` = 新备货量,`unit` 一并更新
3. 成本:`closePurchaseCostLoopAfterPrepPriceChange` 扩展——无账本且未入库时 **INSERT** `order_goods`(量×价>0)
4. 分拣:按履约/订单明细 id 更新 `picking_items.required_qty`(及满拣时 `picked_qty`)与 `unit`
## 改动面
- `docs/design/20260720-supplier-prep-amend-full-loop.md`(本文)
- `supplierPreparationStatusService.ts`
- `docs/design/20260720-supplier-prep-amend-qty-ui.md` 偏差说明
## 验收标准
- [x] 改数量后:待验 prepare_qty / 已入库 actual_qty 均为新量
- [x] 改价或改量后:cost_details 采购金额正确(有入库 reconcile / 无入库 upsert)
- [x] 已有分拣行时 required_qty(满拣则 picked)跟随
- [x] 订单明细 quantity/amount 在量或单位变时更新
## 风险与回滚
- 已入库改 actual_qty 属纠错,会影响成本;仅开关开放的追加改价可用。回滚:去掉入库量同步与账本 INSERT。
验证:
- [x] syncPrepAmendInspectionQty / syncPrepAmendPickingItems / cost upsert
- [x] 生产部署后追加改量改价点验
- 偏差:相对 `amend-qty-ui` 原「不改 actual_qty」已按本文放开