Files
shanxia2.0/docs/data-migration/phase-1-crm/step-03-product-no-renumber.md
T
2026-07-13 20:26:43 +08:00

67 lines
1.6 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.
# P1-1c:CRM 产品编号统一
> **前置**:P1-1b 产品主表已迁入
> **设计**:[superpowers 设计](../../superpowers/specs/2026-07-12-crm-product-no-renumber-design.md)
> **下游**:报价/合同明细 `product_no` 快照经 `crm_product_no_mapping.csv` 转换
---
## 1. 目标
将 `crm_product.product_no` 统一为 **`SXWL` + 6 位流水**(`SXWL000001` …),并生成:
`docs/data-migration/mappings/crm_product_no_mapping.csv`
**`product_id` 不变**。
---
## 2. 执行步骤
| 步骤 | 操作 | 状态 |
|------|------|------|
| 1 | `renumber_crm_product_no.py --dry-run` | ✅ 2026-07-12 |
| 2 | `--apply` + `--mapping-out` | ✅ 更新 239 行 |
| 3 | SQL 验收 | ✅ 非标准编号 0 |
| 4 | 追加 `logs/` | ✅ `logs/2026-07-12-2106-product-no-renumber.md` |
### 命令
```bash
cd backend
venv/bin/python scripts/renumber_crm_product_no.py --dry-run --env-file .env.production
venv/bin/python scripts/renumber_crm_product_no.py --apply --env-file .env.production \
--mapping-out ../docs/data-migration/mappings/crm_product_no_mapping.csv
```
---
## 3. 映射 CSV 列
| 列 | 说明 |
|----|------|
| `product_id` | 不变 |
| `old_product_no` | 重编号前 |
| `new_product_no` | 重编号后 |
| `product_name` / `category_id` | 审计 |
| `seq` / `renumbered_at` | 流水与时间 |
后续脚本用法:
```python
new_no = by_product_id[product_id]["new_product_no"]
# 或
new_no = by_old_no.get(old_product_no)
```
---
## 4. 验收标准
- [x] 239 条均为 `SXWL` + 6 位数字
- [x] 映射 CSV 239 行
- [x] `product_id` 未变
- [ ] 产品列表页展示新编号(待人工)