Files
makemd/docs/SERVICES/finance.md

111 lines
2.3 KiB
Markdown
Raw Normal View History

# 财务域服务
> **入口**: [_index.md](_index.md)
---
## 服务列表
| 服务 | 文件 | 职责 |
|------|------|------|
| FinanceService | services/FinanceService.ts | 财务管理 |
| ReconciliationService | services/ReconciliationService.ts | 对账管理 |
| SettlementService | services/SettlementService.ts | 结算管理 |
---
## 核心流程
```
订单完成 → 对账 → 结算 → 利润核算
```
---
## FinanceService
### 方法列表
| 方法 | 说明 | 参数 | 返回 |
|------|------|------|------|
| getOverview | 财务概览 | tenantId | FinanceOverview |
| getProfit | 利润计算 | orderId | Profit |
| getReport | 财务报表 | params | Report |
---
## ReconciliationService
### 方法列表
| 方法 | 说明 | 参数 | 返回 |
|------|------|------|------|
| reconcile | 执行对账 | params | ReconciliationResult |
| getDiscrepancies | 获取差异 | reconciliationId | Discrepancy[] |
| resolve | 解决差异 | discrepancyId, resolution | void |
---
## SettlementService
### 方法列表
| 方法 | 说明 | 参数 | 返回 |
|------|------|------|------|
| list | 结算列表 | params | Settlement[] |
| get | 结算详情 | id | Settlement |
| create | 创建结算 | CreateRequest | Settlement |
| confirm | 确认结算 | id | Settlement |
---
## 利润计算
### 计算公式
```
净利润 = 售价 - 采购成本 - 平台费用 - 物流费用 - 税费 - 汇率对冲 - 售后损耗 - 广告摊销
利润率 = 净利润 / 售价 × 100%
```
### 利润红线
| 业务类型 | 阈值 | 处理 |
|---------|------|------|
| TOC | < 20% | 风控预警 |
| TOB | < 15% | 禁止报价 |
---
## 状态机
```
PENDING → PROCESSING → COMPLETED
FAILED
```
| 状态 | 说明 |
|------|------|
| PENDING | 待处理 |
| PROCESSING | 处理中 |
| COMPLETED | 已完成 |
| FAILED | 失败 |
---
## API端点
| 端点 | 方法 | 服务方法 |
|------|------|----------|
| /api/v1/finance/overview | GET | FinanceService.getOverview |
| /api/v1/finance/profit/:orderId | GET | FinanceService.getProfit |
| /api/v1/reconciliation | POST | ReconciliationService.reconcile |
| /api/v1/settlements | GET | SettlementService.list |
| /api/v1/settlements | POST | SettlementService.create |
---
*最后更新: 2026-03-22*