API Reference
Đơ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ệ:

pending → confirmed → preparing → ready → completed
pending → cancelled
confirmed → cancelled

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.