484 lines
9.4 KiB
Markdown
484 lines
9.4 KiB
Markdown
|
|
# DOMAIN_MODEL(领域模型)
|
|||
|
|
|
|||
|
|
## 核心实体
|
|||
|
|
|
|||
|
|
### Merchant(商户)
|
|||
|
|
- id
|
|||
|
|
- name
|
|||
|
|
- status(pending / active / inactive)
|
|||
|
|
- created_at
|
|||
|
|
- updated_at
|
|||
|
|
- contact_person
|
|||
|
|
- contact_email
|
|||
|
|
- contact_phone
|
|||
|
|
- address
|
|||
|
|
- business_type(B2B / B2C)
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### User(用户)
|
|||
|
|
- id
|
|||
|
|
- merchant_id
|
|||
|
|
- role(admin / 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_type(free / paid)
|
|||
|
|
- price_value
|
|||
|
|
- description
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### PlatformIntegration(平台集成)
|
|||
|
|
- id
|
|||
|
|
- merchant_id
|
|||
|
|
- platform_name(Sellbrite / 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
|
|||
|
|
- status(inactive / pending_payment / active / expired)
|
|||
|
|
- expire_at
|
|||
|
|
- created_at
|
|||
|
|
- updated_at
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### Order(订单)
|
|||
|
|
- id
|
|||
|
|
- user_id
|
|||
|
|
- merchant_id
|
|||
|
|
- total_amount
|
|||
|
|
- status(pending / 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
|
|||
|
|
- status(created / paid / failed)
|
|||
|
|
- type(feature / order)
|
|||
|
|
- payment_method
|
|||
|
|
- transaction_id
|
|||
|
|
- created_at
|
|||
|
|
- updated_at
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### Bill(账单)
|
|||
|
|
- id
|
|||
|
|
- merchant_id
|
|||
|
|
- type(income / expense)
|
|||
|
|
- amount
|
|||
|
|
- status(pending / confirmed / settled)
|
|||
|
|
- source_type(order / 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;
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### SKUMapping(SKU映射)
|
|||
|
|
|
|||
|
|
| 字段 | 类型 | 说明 |
|
|||
|
|
|------|------|------|
|
|||
|
|
| 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 | Cookie(Agent授权) |
|
|||
|
|
| 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;
|
|||
|
|
}
|
|||
|
|
```
|