Inventory Service
Quản lý tồn kho cho Retail và nguyên liệu F&B.
Tổng Quan
Inventory Service quản lý "tồn kho vật lý" cho cả thành phẩm (Retail) và nguyên liệu thô (F&B). Hỗ trợ logic trừ kho khác nhau theo loại sản phẩm.
Tính Năng Chính
- Theo dõi Tồn kho - Mức tồn kho real-time theo shop
- Đặt trước - Đặt trước tồn kho khi validate đơn hàng
- Tích hợp Công thức - Trừ nguyên liệu theo recipe cho F&B
- Giao dịch - Lịch sử đầy đủ (IN, OUT, ADJUSTMENT)
- Cảnh báo - Thông báo tồn kho thấp
Bối Cảnh Kiến Trúc
graph LR
ORDER["📝 Order Service"] --> INVENTORY["🏭 Inventory Service"]
FNB["🍳 F&B Engine"] --> INVENTORY
POS["POS"] --> INVENTORY
style INVENTORY fill:#27ae60,stroke:#1e8449,color:#fff
Logic Trừ Tồn Kho
| Loại Sản Phẩm | Logic | Ví dụ |
|---|---|---|
| Physical (Retail) | 1:1 | Bán 1 áo → Trừ 1 |
| PreparedFood (F&B) | Theo công thức | Bán 1 Latte → Trừ 18g hạt + 200ml sữa |
Bắt Đầu Nhanh
cd services/inventory-service-net
cp .env.example .env
dotnet run --project src/InventoryService.API
API Endpoints
| Method | Endpoint | Mô tả |
|---|---|---|
GET |
/api/v1/inventory |
Danh sách tồn kho theo shop |
GET |
/api/v1/inventory/{productId} |
Mức tồn kho |
POST |
/api/v1/inventory/stock-in |
Nhập kho |
POST |
/api/v1/inventory/stock-out |
Xuất kho |
POST |
/api/v1/inventory/reserve |
Đặt trước cho đơn hàng |
POST |
/api/v1/inventory/release |
Giải phóng đặt trước |
POST |
/api/v1/inventory/adjust |
Điều chỉnh tồn kho |
GET |
/api/v1/inventory/transactions |
Lịch sử giao dịch |
Domain Model
public class InventoryItem : Entity, IAggregateRoot
{
public Guid ProductId { get; private set; }
public Guid ShopId { get; private set; }
public int Quantity { get; private set; }
public int ReservedQuantity { get; private set; }
public int AvailableQuantity => Quantity - ReservedQuantity;
public void StockIn(int amount, string reference);
public void StockOut(int amount, string reference);
public void Reserve(int amount, Guid orderId);
public void ReleaseReservation(Guid orderId);
}
Services Liên Quan
- Order Service - Sử dụng qua RetailStrategy
- Catalog Service - Tham chiếu sản phẩm
- F&B Engine - Trừ kho theo công thức
License
Proprietary - GoodGo Platform