# 库存域服务 > **入口**: [_index.md](_index.md) --- ## 服务列表 | 服务 | 文件 | 职责 | |------|------|------| | InventoryService | services/InventoryService.ts | 库存管理 | | WarehouseService | services/WarehouseService.ts | 仓库管理 | | ReplenishmentService | services/ReplenishmentService.ts | 补货管理 | --- ## 核心流程 ``` 库存查询 → 库存调整 → 库存预警 → 自动补货 ``` --- ## InventoryService ### 方法列表 | 方法 | 说明 | 参数 | 返回 | |------|------|------|------| | list | 库存列表 | ListParams | Inventory[] | | get | 库存详情 | skuId | Inventory | | updateStock | 更新库存 | skuId, quantity, type | Inventory | | reserve | 预留库存 | skuId, quantity | Inventory | | release | 释放预留 | skuId, quantity | Inventory | ### 库存操作类型 | 类型 | 说明 | |------|------| | IN | 入库 | | OUT | 出库 | | ADJUST | 调整 | | RESERVE | 预留 | | RELEASE | 释放 | --- ## WarehouseService ### 方法列表 | 方法 | 说明 | 参数 | 返回 | |------|------|------|------| | list | 仓库列表 | tenantId | Warehouse[] | | get | 仓库详情 | id | Warehouse | | create | 创建仓库 | CreateRequest | Warehouse | | update | 更新仓库 | id, UpdateRequest | Warehouse | --- ## ReplenishmentService ### 方法列表 | 方法 | 说明 | 参数 | 返回 | |------|------|------|------| | checkAlert | 检查预警 | tenantId | Alert[] | | createOrder | 创建补货单 | CreateRequest | ReplenishmentOrder | | getOrder | 获取补货单 | id | ReplenishmentOrder | --- ## 状态机 ``` IN_STOCK → LOW_STOCK → OUT_OF_STOCK ↑ ↓ ↓ └───────────┴────────────┘ (补货后恢复) ``` | 状态 | 说明 | 触发条件 | |------|------|---------| | IN_STOCK | 有库存 | quantity > threshold | | LOW_STOCK | 低库存 | quantity ≤ threshold | | OUT_OF_STOCK | 缺货 | quantity = 0 | | RESERVED | 预留 | 有预留数量 | --- ## API端点 | 端点 | 方法 | 服务方法 | |------|------|----------| | /api/v1/inventory | GET | InventoryService.list | | /api/v1/inventory/:skuId | GET | InventoryService.get | | /api/v1/inventory/:skuId/stock | PUT | InventoryService.updateStock | | /api/v1/warehouses | GET | WarehouseService.list | | /api/v1/warehouses | POST | WarehouseService.create | | /api/v1/replenishment/alerts | GET | ReplenishmentService.checkAlert | --- *最后更新: 2026-03-22*