Files
makemd/docs/ARCHIVE/01_Architecture/03_Domain_Model.md

484 lines
9.4 KiB
Markdown
Raw Normal View History

# DOMAIN_MODEL领域模型
## 核心实体
### Merchant商户
- id
- name
- statuspending / active / inactive
- created_at
- updated_at
- contact_person
- contact_email
- contact_phone
- address
- business_typeB2B / B2C
---
### User用户
- id
- merchant_id
- roleadmin / operator / viewer
- status
- username
- email
- password_hash
- created_at
- updated_at
---
### Store店铺
- id
- merchant_id
- name
- platform
- platform_shop_id
- description
- status
- created_at
- updated_at
---
### Feature功能
- code
- name
- price_typefree / paid
- price_value
- description
---
### PlatformIntegration平台集成
- id
- merchant_id
- platform_nameSellbrite / Shoplazza / SaleSmartly
- api_key
- api_secret
- access_token
- refresh_token
- status
- created_at
- updated_at
---
### CrossBorderProduct跨境商品
- id
- product_id
- hs_code
- tariff_rate
- compliance_status
- country_of_origin
- weight
- dimensions
- created_at
- updated_at
---
### CustomsDocument清关文件
- id
- order_id
- document_type
- document_url
- status
- created_at
- updated_at
---
### CrossBorderOrder跨境订单
- id
- order_id
- customs_status
- shipping_status
- tracking_number
- logistics_provider
- estimated_delivery
- created_at
- updated_at
- category
---
### MerchantFeature商户功能
- id
- merchant_id
- feature_code
- statusinactive / pending_payment / active / expired
- expire_at
- created_at
- updated_at
---
### Order订单
- id
- user_id
- merchant_id
- total_amount
- statuspending / paid / split / shipped / completed / refunded
- created_at
- updated_at
- shipping_address
- payment_method
---
### SubOrder子订单
- id
- order_id
- merchant_id
- store_id
- amount
- status
- created_at
- updated_at
---
### Product商品
- id
- merchant_id
- store_id
- name
- sku
- price
- stock
- status
- created_at
- updated_at
---
### Inventory库存
- id
- product_id
- merchant_id
- warehouse_id
- quantity
- status
- last_sync_at
---
### Payment支付
- id
- merchant_id
- amount
- statuscreated / paid / failed
- typefeature / order
- payment_method
- transaction_id
- created_at
- updated_at
---
### Bill账单
- id
- merchant_id
- typeincome / expense
- amount
- statuspending / confirmed / settled
- source_typeorder / feature
- source_id
- created_at
- updated_at
---
### Permission权限
- id
- role
- resource
- action
- created_at
---
### Settlement结算
- id
- merchant_id
- total_amount
- platform_fee
- net_amount
- status
- period_start
- period_end
- created_at
- updated_at
---
### Analytics数据分析
- id
- merchant_id
- report_type
- data
- generated_at
- period_start
- period_end
---
## 商品中心领域模型Product Center Domain Model
> **设计原则**: 采用三层商品模型SPU → SKU → Listing支持多平台统一管理
### 商品层级关系
```
SPU产品层
├── SKU-001库存单元层
│ ├── Listing-A平台商品层
│ ├── Listing-B平台商品层
│ └── Listing-C平台商品层
├── SKU-002库存单元层
│ └── Listing-D平台商品层
└── SKU-003库存单元层
└── Listing-E平台商品层
```
### SPU标准产品单元
| 字段 | 类型 | 说明 |
|------|------|------|
| id | string | 主键 |
| tenant_id | string | 租户ID |
| name | string | 产品名称 |
| brand | string | 品牌 |
| category_id | string | 类目ID |
| description | text | 产品描述 |
| attributes | json | 通用属性 |
| status | enum | DRAFT/ACTIVE/INACTIVE/ARCHIVED |
| created_at | timestamp | 创建时间 |
| updated_at | timestamp | 更新时间 |
```typescript
interface SPU {
id: string;
tenantId: string;
name: string;
brand: string;
categoryId: string;
description: string;
attributes: Record<string, any>;
status: 'DRAFT' | 'ACTIVE' | 'INACTIVE' | 'ARCHIVED';
createdAt: Date;
updatedAt: Date;
}
```
### SKU库存单元
| 字段 | 类型 | 说明 |
|------|------|------|
| id | string | 主键 |
| spu_id | string | 关联SPU |
| tenant_id | string | 租户ID |
| sku_code | string | SKU编码 |
| attributes | json | 变体属性 {"color": "red", "size": "XL"} |
| cost_price | decimal(10,2) | 成本价 |
| base_price | decimal(10,2) | 基准价(参考锚点) |
| weight | decimal(10,3) | 重量(kg) |
| dimensions | json | 尺寸 {length, width, height} |
| status | enum | ACTIVE/INACTIVE |
| created_at | timestamp | 创建时间 |
| updated_at | timestamp | 更新时间 |
```typescript
interface SKU {
id: string;
spuId: string;
tenantId: string;
skuCode: string;
attributes: Record<string, any>;
costPrice: number;
basePrice: number;
weight: number;
dimensions: { length: number; width: number; height: number };
status: 'ACTIVE' | 'INACTIVE';
createdAt: Date;
updatedAt: Date;
}
```
### PlatformListing平台商品
| 字段 | 类型 | 说明 |
|------|------|------|
| id | string | 主键 |
| sku_id | string | 关联SKU |
| shop_id | string | 店铺ID |
| tenant_id | string | 租户ID |
| platform | enum | 平台类型 |
| platform_listing_id | string | 平台商品ID |
| title | string | 商品标题 |
| price | decimal(10,2) | 最终销售价 |
| original_price | decimal(10,2) | 原价 |
| stock | int | 库存 |
| status | enum | DRAFT/PENDING/ACTIVE/INACTIVE |
| strategy_id | string | 价格策略ID |
| override_price | decimal(10,2) | 手动覆盖价格 |
| created_at | timestamp | 创建时间 |
| updated_at | timestamp | 更新时间 |
```typescript
interface PlatformListing {
id: string;
skuId: string;
shopId: string;
tenantId: string;
platform: 'TIKTOK' | 'SHOPEE' | 'LAZADA' | 'SHOPIFY' | 'WOOCOMMERCE' | 'B2B';
platformListingId: string;
title: string;
price: number;
originalPrice: number;
stock: number;
status: 'DRAFT' | 'PENDING' | 'ACTIVE' | 'INACTIVE';
strategyId: string;
overridePrice: number | null;
createdAt: Date;
updatedAt: Date;
}
```
### PriceStrategy价格策略
| 字段 | 类型 | 说明 |
|------|------|------|
| id | string | 主键 |
| tenant_id | string | 租户ID |
| name | string | 策略名称 |
| scope_type | enum | PLATFORM/SHOP/LISTING |
| scope_id | string | 作用域ID |
| strategy_type | enum | MULTIPLIER/FIXED/DYNAMIC |
| value | decimal(10,2) | 策略值(倍率或固定值) |
| min_price | decimal(10,2) | 最低价格限制 |
| max_price | decimal(10,2) | 最高价格限制 |
| status | enum | ACTIVE/INACTIVE |
| created_at | timestamp | 创建时间 |
| updated_at | timestamp | 更新时间 |
```typescript
interface PriceStrategy {
id: string;
tenantId: string;
name: string;
scopeType: 'PLATFORM' | 'SHOP' | 'LISTING';
scopeId: string;
strategyType: 'MULTIPLIER' | 'FIXED' | 'DYNAMIC';
value: number;
minPrice: number;
maxPrice: number;
status: 'ACTIVE' | 'INACTIVE';
createdAt: Date;
updatedAt: Date;
}
```
### SKUMappingSKU映射
| 字段 | 类型 | 说明 |
|------|------|------|
| id | string | 主键 |
| tenant_id | string | 租户ID |
| sku_id | string | 系统SKU ID |
| platform | enum | 平台类型 |
| shop_id | string | 店铺ID |
| platform_sku_id | string | 平台SKU ID |
| mapping_type | enum | AUTO/MANUAL |
| confidence | decimal(5,2) | 匹配置信度 |
| status | enum | ACTIVE/INACTIVE |
| created_at | timestamp | 创建时间 |
| updated_at | timestamp | 更新时间 |
```typescript
interface SKUMapping {
id: string;
tenantId: string;
skuId: string;
platform: string;
shopId: string;
platformSkuId: string;
mappingType: 'AUTO' | 'MANUAL';
confidence: number;
status: 'ACTIVE' | 'INACTIVE';
createdAt: Date;
updatedAt: Date;
}
```
### Organization组织架构
| 字段 | 类型 | 说明 |
|------|------|------|
| id | string | 主键 |
| tenant_id | string | 租户ID |
| parent_id | string | 父级ID |
| name | string | 组织名称 |
| type | enum | COMPANY/DEPARTMENT/TEAM |
| path | string | 层级路径 |
| level | int | 层级深度 |
| status | enum | ACTIVE/INACTIVE |
| created_at | timestamp | 创建时间 |
| updated_at | timestamp | 更新时间 |
```typescript
interface Organization {
id: string;
tenantId: string;
parentId: string | null;
name: string;
type: 'COMPANY' | 'DEPARTMENT' | 'TEAM';
path: string;
level: number;
status: 'ACTIVE' | 'INACTIVE';
createdAt: Date;
updatedAt: Date;
}
```
### ShopAuthorization店铺授权
| 字段 | 类型 | 说明 |
|------|------|------|
| id | string | 主键 |
| shop_id | string | 店铺ID |
| tenant_id | string | 租户ID |
| auth_type | enum | OAUTH/API_KEY/AGENT |
| access_token | text | 访问令牌 |
| refresh_token | text | 刷新令牌 |
| expire_at | timestamp | 过期时间 |
| cookies | text | CookieAgent授权 |
| proxy | json | 代理配置 |
| status | enum | PENDING/ACTIVE/EXPIRED/INVALID |
| last_sync_at | timestamp | 最后同步时间 |
| created_at | timestamp | 创建时间 |
| updated_at | timestamp | 更新时间 |
```typescript
interface ShopAuthorization {
id: string;
shopId: string;
tenantId: string;
authType: 'OAUTH' | 'API_KEY' | 'AGENT';
accessToken: string;
refreshToken: string;
expireAt: Date;
cookies: string;
proxy: { host: string; port: number; username: string };
status: 'PENDING' | 'ACTIVE' | 'EXPIRED' | 'INVALID';
lastSyncAt: Date;
createdAt: Date;
updatedAt: Date;
}
```