chore: 清理归档文件和文档模板
删除不再需要的归档文件和过时的文档模板,包括多个README、安全策略、前端集成蓝图等文件,同时移除了未使用的业务文档和项目结构文件。 优化项目结构,移除冗余文件,保持代码库整洁。主要删除archive/handover目录下的多个文件及doc目录下的部分文档模板。
This commit is contained in:
@@ -10,29 +10,214 @@
|
||||
### 1.1 命名规范
|
||||
- **表前缀**: `cf_` (crawlful)
|
||||
- **字段命名**: snake_case
|
||||
- **金額字段**: `decimal(10,2)` 或更高精度。
|
||||
- **金額字段**: `decimal(10,2)` 或更高精度。**禁止**使用 float/double。
|
||||
- **物理单位**: 长度 (cm), 重量 (kg), 体积 (m³)。
|
||||
|
||||
### 1.2 核心表定义
|
||||
### 1.2 数据库安全约束
|
||||
- **⚠️ 严禁**: 代码中执行 `DROP`, `TRUNCATE` 等破坏性操作
|
||||
- **幂等性**: 所有建表语句必须使用 `db.schema.hasTable` 前置校验
|
||||
- **JSON 处理**: images/skus/attributes 入库前序列化,出库解析
|
||||
- **唯一约束**: `cf_product` 表必须保证 (platform, productId) 唯一
|
||||
|
||||
#### 租户与用户
|
||||
- `cf_tenant`: 租户 ID、名称、配额、状态。
|
||||
- `cf_user`: 邮箱、密码哈希、角色 (ADMIN/MANAGER 等)、租户 ID。
|
||||
### 1.3 核心表定义
|
||||
|
||||
#### 店铺与商品
|
||||
- `cf_shop`: 租户 ID、平台 (AMAZON/TIKTOK 等)、授权 Token。
|
||||
- `cf_product`: 租户 ID、源平台 ID、标题、描述、JSON 图片列表。
|
||||
- `cf_product_sku`: SKU 编码、属性 JSON、成本价、零售价、重量/尺寸。
|
||||
#### 1.3.1 租户与用户
|
||||
|
||||
#### 订单与库存
|
||||
- `cf_inventory`: SKU ID、仓库 ID、总数量、可用/预留数量。
|
||||
- `cf_order`: 平台订单号、总金额、货币、利润/利润率、状态。
|
||||
- `cf_order_item`: 订单项、SKU ID、单价、数量。
|
||||
**cf_tenant** (租户表)
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| id | string(PK) | 租户ID |
|
||||
| name | string | 租户名称 |
|
||||
| quota | json | 配额配置 |
|
||||
| status | string | 状态 |
|
||||
| created_at | datetime | 创建时间 |
|
||||
| updated_at | datetime | 更新时间 |
|
||||
|
||||
#### 供应链与财务
|
||||
- `cf_supplier`: 供应商名称、联系方式、评分、状态。
|
||||
- `cf_purchase_order`: 采购单号、供应商 ID、总金额、状态。
|
||||
- `cf_finance_reconciliation`: 对账周期、总销售/利润、差异状态。
|
||||
**cf_user** (用户表)
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| id | string(PK) | 用户ID |
|
||||
| email | string | 邮箱 |
|
||||
| password_hash | string | 密码哈希 |
|
||||
| role | enum | ADMIN/MANAGER/OPERATOR/FINANCE/SOURCING/LOGISTICS/ANALYST |
|
||||
| tenant_id | string(FK) | 租户ID |
|
||||
| created_at | datetime | 创建时间 |
|
||||
| updated_at | datetime | 更新时间 |
|
||||
|
||||
#### 1.3.2 店铺与商品
|
||||
|
||||
**cf_shop** (店铺表)
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| id | string(PK) | 店铺ID |
|
||||
| tenant_id | string(FK) | 租户ID |
|
||||
| platform | enum | AMAZON/EBAY/SHOPEE/TIKTOK/TEMU/1688 |
|
||||
| platform_shop_id | string | 平台店铺ID |
|
||||
| name | string | 店铺名称 |
|
||||
| auth_token | encrypted | 授权Token(加密存储) |
|
||||
| status | string | 状态 |
|
||||
| **trace_id** | string | 链路追踪ID |
|
||||
| created_at | datetime | 创建时间 |
|
||||
| updated_at | datetime | 更新时间 |
|
||||
|
||||
**cf_product** (商品主表)
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| id | string(PK) | 商品ID |
|
||||
| tenant_id | string(FK) | 租户ID |
|
||||
| shop_id | string(FK) | 店铺ID |
|
||||
| platform | enum | 平台类型 |
|
||||
| platform_product_id | string | 平台商品ID |
|
||||
| title | string | 商品标题 |
|
||||
| description | text | 商品描述 |
|
||||
| images | json | 图片列表(JSON数组) |
|
||||
| category | string | 类目 |
|
||||
| status | string | 状态 |
|
||||
| **trace_id** | string | 链路追踪ID |
|
||||
| **business_type** | enum | TOC/TOB |
|
||||
| created_at | datetime | 创建时间 |
|
||||
| updated_at | datetime | 更新时间 |
|
||||
| **唯一约束**: (platform, platform_product_id) |
|
||||
|
||||
**cf_product_sku** (SKU变体表)
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| id | string(PK) | SKU ID |
|
||||
| tenant_id | string(FK) | 租户ID |
|
||||
| shop_id | string(FK) | 店铺ID |
|
||||
| product_id | string(FK) | 商品ID |
|
||||
| sku_code | string | SKU编码 |
|
||||
| attributes | json | 属性JSON(颜色/尺寸等) |
|
||||
| cost_price | decimal(10,2) | 成本价 |
|
||||
| retail_price | decimal(10,2) | 零售价 |
|
||||
| weight_kg | decimal(8,3) | 重量(kg) |
|
||||
| length_cm | decimal(8,2) | 长度(cm) |
|
||||
| width_cm | decimal(8,2) | 宽度(cm) |
|
||||
| height_cm | decimal(8,2) | 高度(cm) |
|
||||
| **trace_id** | string | 链路追踪ID |
|
||||
| **business_type** | enum | TOC/TOB |
|
||||
| created_at | datetime | 创建时间 |
|
||||
| updated_at | datetime | 更新时间 |
|
||||
|
||||
#### 1.3.3 订单与库存
|
||||
|
||||
**cf_inventory** (库存表)
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| id | string(PK) | 库存ID |
|
||||
| tenant_id | string(FK) | 租户ID |
|
||||
| shop_id | string(FK) | 店铺ID |
|
||||
| sku_id | string(FK) | SKU ID |
|
||||
| warehouse_id | string | 仓库ID |
|
||||
| total_qty | int | 总数量 |
|
||||
| available_qty | int | 可用数量 |
|
||||
| reserved_qty | int | 预留数量 |
|
||||
| **trace_id** | string | 链路追踪ID |
|
||||
| **business_type** | enum | TOC/TOB |
|
||||
| created_at | datetime | 创建时间 |
|
||||
| updated_at | datetime | 更新时间 |
|
||||
|
||||
**cf_consumer_orders** (C端订单表)
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| id | string(PK) | 订单ID |
|
||||
| tenant_id | string(FK) | 租户ID |
|
||||
| shop_id | string(FK) | 店铺ID |
|
||||
| platform | enum | 平台类型 |
|
||||
| platform_order_id | string | 平台订单号 |
|
||||
| total_amount | decimal(10,2) | 总金额 |
|
||||
| currency | string | 币种 |
|
||||
| profit | decimal(10,2) | 利润 |
|
||||
| profit_margin | decimal(5,2) | 利润率(%) |
|
||||
| status | string | 订单状态 |
|
||||
| **trace_id** | string | 链路追踪ID |
|
||||
| **task_id** | string | 任务ID |
|
||||
| **business_type** | enum | TOC/TOB |
|
||||
| created_at | datetime | 创建时间 |
|
||||
| updated_at | datetime | 更新时间 |
|
||||
|
||||
**cf_order_item** (订单项表)
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| id | string(PK) | 订单项ID |
|
||||
| order_id | string(FK) | 订单ID |
|
||||
| sku_id | string(FK) | SKU ID |
|
||||
| unit_price | decimal(10,2) | 单价 |
|
||||
| quantity | int | 数量 |
|
||||
| created_at | datetime | 创建时间 |
|
||||
|
||||
#### 1.3.4 供应链与财务
|
||||
|
||||
**cf_supplier** (供应商表)
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| id | string(PK) | 供应商ID |
|
||||
| tenant_id | string(FK) | 租户ID |
|
||||
| name | string | 供应商名称 |
|
||||
| contact | json | 联系方式 |
|
||||
| rating | decimal(3,2) | 评分 |
|
||||
| status | string | 状态 |
|
||||
| **trace_id** | string | 链路追踪ID |
|
||||
| created_at | datetime | 创建时间 |
|
||||
| updated_at | datetime | 更新时间 |
|
||||
|
||||
**cf_purchase_order** (采购订单表)
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| id | string(PK) | 采购单号 |
|
||||
| tenant_id | string(FK) | 租户ID |
|
||||
| supplier_id | string(FK) | 供应商ID |
|
||||
| total_amount | decimal(10,2) | 总金额 |
|
||||
| status | string | 状态 |
|
||||
| **trace_id** | string | 链路追踪ID |
|
||||
| created_at | datetime | 创建时间 |
|
||||
| updated_at | datetime | 更新时间 |
|
||||
|
||||
**cf_finance_reconciliation** (财务对账表)
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| id | string(PK) | 对账ID |
|
||||
| tenant_id | string(FK) | 租户ID |
|
||||
| shop_id | string(FK) | 店铺ID |
|
||||
| period | string | 对账周期 |
|
||||
| total_sales | decimal(12,2) | 总销售额 |
|
||||
| total_profit | decimal(12,2) | 总利润 |
|
||||
| variance_status | string | 差异状态 |
|
||||
| **trace_id** | string | 链路追踪ID |
|
||||
| created_at | datetime | 创建时间 |
|
||||
| updated_at | datetime | 更新时间 |
|
||||
|
||||
#### 1.3.5 审计日志
|
||||
|
||||
**cf_audit_log** (审计日志表)
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| id | string(PK) | 日志ID |
|
||||
| tenant_id | string | 租户ID |
|
||||
| shop_id | string | 店铺ID |
|
||||
| task_id | string | 任务ID |
|
||||
| trace_id | string | 链路追踪ID |
|
||||
| business_type | enum | TOC/TOB |
|
||||
| action | string | 操作类型 |
|
||||
| entity_type | string | 实体类型 |
|
||||
| entity_id | string | 实体ID |
|
||||
| old_values | json | 旧值 |
|
||||
| new_values | json | 新值 |
|
||||
| user_id | string | 操作用户ID |
|
||||
| ip_address | string | IP地址 |
|
||||
| created_at | datetime | 创建时间 |
|
||||
|
||||
### 1.4 五元组追踪字段说明
|
||||
|
||||
所有业务表必须包含以下追踪字段:
|
||||
|
||||
| 字段 | 类型 | 说明 | 必填 |
|
||||
|------|------|------|------|
|
||||
| tenant_id | string | 租户ID - 业务隔离 | ✅ |
|
||||
| shop_id | string | 店铺ID - 平台/店铺隔离 | ✅ (店铺相关表) |
|
||||
| task_id | string | 任务ID - 任务追踪 | ✅ (异步任务) |
|
||||
| trace_id | string | 链路追踪ID - 全链路唯一 | ✅ |
|
||||
| business_type | enum | TOC/TOB | ✅ |
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user