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 /ordersQuery params:
| Param | Type | Mô tả |
|---|---|---|
status | string | pending, confirmed, preparing, ready, completed, cancelled |
branchId | uuid | Lọc theo chi nhánh |
date | YYYY-MM-DD | Lọc theo ngày (mặc định: hôm nay) |
page | number | Trang (mặc định: 1) |
limit | number | Số 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/:idCậ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
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 paymentStatus → paid 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.