Files
shanxia2.0/docs/superpowers/specs/2026-06-09-db-product-id-design.md
T
2026-06-10 22:59:34 +08:00

28 lines
1.1 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.
# 地磅三表 CRM 产品 ID + 规格 — 设计文档
> **日期**: 2026-06-09
> **状态**: 已批准(方案 B + 新建必选 CRM 产品)
> **前置**: `docs/superpowers/specs/2026-06-07-dibang-migration-design.md` 方案 A 升级
## 目标
计划、出入库、地磅单三表均存储 `product_id`(`crm_product.id`)与 `specification`(规格快照,来源 `crm_product.model`),新建/编辑时必须从 CRM 选择产品,禁止手输纯文本。
## 字段
| 表 | 新增/补齐 | 保留快照 |
|---|---|---|
| `db_purchase_plan` | `product_id` | `product`、`specification` |
| `db_inbound_outbound` | `product_id`、`specification` | `product` |
| `db_weighing_slip` | `product_id`、`specification` | `cargo_name` |
不建 DB 外键;服务端按 `tenant_no` 校验 CRM 产品存在且 `status=on`,并用 CRM 数据回填名称与规格。
## 级联
计划 → 出入库 → 地磅:复制 `product_id`、`product`/`cargo_name`、`specification`。自动按月生成计划同步复制。
## 历史数据
已有行 `product_id` 可为 NULL;编辑保存时需重新选择 CRM 产品后方可提交。