Skip to content

Đặt chỗ

1. Tổng quan

Thuộc tínhGiá trị
IDFEAT-SALE-RES
Trạng tháiStable
Ownersale-team
Phụ thuộcAllocationUnit, AllocationUsage, SaleOrder (sau check-in), Customer (tùy chọn)

Đặt chỗ ghi nhận một booking tương lai với chi tiết khách, party size, và time window. Tạo một đặt chỗ cũng tạo một hoặc nhiều row AllocationUsage (status ACTIVE) giữ unit cho đến check-in hoặc hủy. Khi check-in, sale spawn một SaleOrder và chuyển hướng các row usage.

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

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

3. Vòng đời

TừSự kiệnĐếnSide effect
PENDINGconfirmCONFIRMEDthông báo tùy chọn
CONFIRMEDcheck-inCHECKED_INtạo SaleOrder, retarget AllocationUsage thành usageType=SALE_ORDER
* (non-terminal)cancelCANCELLEDcascade hủy AllocationUsage
CONFIRMEDreservedTo đã qua(thủ công)sweep job đánh dấu AllocationUsage.EXPIRED

4. Vận hành

ReservationService (reservation.service.ts — 686 dòng).

Phương thứcChữ kýMục đích
create{ context, data: TCreateReservationRequest } (dòng 112)Reservation + row AllocationUsage trong một TX
checkIn{ id, ... } (dòng 423)CONFIRMED → CHECKED_IN; spawn SaleOrder
cancel{ id, cancellationReason? } (dòng 340)non-terminal → CANCELLED + cascade

Không có method service confirm chuyên biệt hoặc REST endpoint hôm nay. Transition PENDING → CONFIRMED được thực hiện qua CRUD updateById với status: CONFIRMED (xử lý qua kế thừa MerchantScopedService).

5. REST Endpoints

VerbPathAuthPermissionHandler
6× CRUD/reservationsJWT/BASICReservation.<crud>merchant-scoped (bao gồm create + cập nhật trạng thái)
POST/reservationsJWT/BASICReservation.createReservationService.create (với allocation cùng TX)
POST/reservations/:id/check-inJWT/BASICReservation.checkIncheckIn
POST/reservations/:id/cancelJWT/BASICReservation.cancelcancel

Không có endpoint /confirm — xác nhận qua CRUD PATCH /reservations/:id với { status: 'CONFIRMED' }.

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

6. Sự kiện

Outbound (WebSocket):

TopicKhi nàoAction enum
observation/sale/reservationcreateRESERVATION_CREATED
sameconfirmRESERVATION_CONFIRMED
samecancelRESERVATION_CANCELLED
samecheck-inRESERVATION_CHECKED_IN
observation/allocation/allocation-usagecreate/cancel/check-inUSAGE_CREATED / USAGE_CANCELLED

Rooms qua getReservationRooms (merchant + reservation + cây phân cấp allocation unit/zone).

7. Trang liên quan

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