Tích hợp API
Đơn hàng

API Đơn hàng

Tất cả endpoints yêu cầu header Authorization: Bearer <token>.


Lấy danh sách đơn hàng

GET /orders

Query params:

ParamTypeMô tả
statusstringpending, confirmed, preparing, ready, completed, cancelled
branchIduuidLọc theo chi nhánh
dateYYYY-MM-DDLọc theo ngày (mặc định: hôm nay)
pagenumberTrang (mặc định: 1)
limitnumberSố kết quả (mặc định: 20, tối đa: 100)

Response:

{
  "orders": [
    {
      "id": "uuid",
      "tableId": "uuid",
      "tableLabel": "A1",
      "status": "preparing",
      "paymentStatus": "paid",
      "total": 95000,
      "items": [
        {
          "id": "uuid",
          "menuItemName": "Cà phê sữa đá",
          "quantity": 2,
          "unitPrice": 35000,
          "note": "Ít đường"
        }
      ],
      "createdAt": "2025-03-01T08:30:00+07:00"
    }
  ],
  "total": 42,
  "page": 1,
  "limit": 20
}

Lấy chi tiết 1 đơn hàng

GET /orders/:id

Cập nhật trạng thái đơn hàng

PATCH /orders/:id/status
Content-Type: application/json
Authorization: Bearer <token>

Body:

{ "status": "confirmed" }

Các chuyển trạng thái hợp lệ:

stateDiagram-v2 [*] --> pending: Order created pending --> confirmed: Payment confirmed pending --> cancelled: Customer cancels confirmed --> preparing: Chef starts confirmed --> cancelled: Store cancels preparing --> ready: Item ready ready --> completed: Customer picked up cancelled --> [*] completed --> [*] note right of pending Waiting for payment confirmation end note note right of confirmed Payment verified Sent to kitchen end note note right of preparing Item being made Timer running end note note right of ready Item complete Waiting for pickup end note
Order status state machine - valid transitions shown with arrows

Xác nhận thanh toán VietQR

POST /orders/:id/confirm-payment
Authorization: Bearer <token>

Dùng khi nhân viên xác nhận đã nhận tiền chuyển khoản. Cập nhật paymentStatuspaid và chuyển đơn sang bước tiếp theo.


Webhook sự kiện đơn hàng

Xem tài liệu Webhooks → để nhận thông báo realtime khi đơn hàng thay đổi trạng thái.