Skip to content

Allocation Usage

1. Tổng quan

Thuộc tínhGiá trị
IDFEAT-SALE-ALLOC
Trạng tháiStable
Ownersale-team
Phụ thuộcAllocationUnit, AllocationZone, AllocationLayout (schema allocation), SaleOrder, Reservation

Sức chứa allocation sử dụng một dòng đa hình AllocationUsage(usageType, usageId) liên kết một AllocationUnit (bàn/ghế/tủ) với hoặc một SaleOrder hoặc một Reservation. Mỗi đơn vị được phân bổ có một dòng usage; cùng vòng đời cho cả hai parent. Xem ADR-0004.

2. Mô hình thực thể

Chi tiết trường — xem Mô hình miền §3.5.

3. Vòng đời

TừSự kiệnĐến
ACTIVESaleOrder thanh toán thành côngSUCCESS
ACTIVEhủy order/reservationCANCELLED
ACTIVEreservedTo của reservation đã qua mà chưa check-inEXPIRED

4. Vận hành

AllocationUsageService (allocation-usage.service.ts — 841 dòng).

Phương thứcChữ kýMục đích
startForOrder{ saleOrderId, merchantId, allocationUnitId, type, assigneeId? }Tạo usage ACTIVE gắn với SaleOrder
complete{ usageId }ACTIVE → SUCCESS (gọi từ payment-success handler)
moveUsagesToOrder{ fromOrderId, toOrderId }Dùng khi merge order để chuyển hướng usage hiện có
resolvePrincipalIdsByAllocation{ unitId, zoneId, ... }Phân giải order/reservation TỪ unit/zone để định tuyến
Batch cancel / completeendpoint theo specChuyển trạng thái hàng loạt

5. REST Endpoints

VerbPathAuthPermissionHandler
6× CRUD/allocation-usagesJWT/BASICAllocationUsage.<crud>merchant-scoped
GET/allocation-usages?zoneId=...&unitId=...JWT/BASICAllocationUsage.findlọc theo zone/unit
Batch ops/allocation-usages/batch/...JWT/BASIC(theo op)AllocationUsageService.*

OpenAPI live: /v1/api/sale/doc/openapi.json.

6. Sự kiện

Outbound (WebSocket):

TopicKhi nàoAction enumRooms
observation/allocation/allocation-usagestartForOrderUSAGE_CREATEDgetAllocationUsageRooms (merchant + unit + cây phân cấp zone)
samecompleteUSAGE_COMPLETEDsame
samecancelUSAGE_CANCELLEDsame

Outbound (Kafka): không trực tiếp — phát Kafka payment-success thuộc về SaleOrderPaymentWebhookService.

7. Trang liên quan

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.