ดึงรายงานยอดขายสรุปของสาขาหนึ่ง ในช่วงเวลาที่กำหนด
Endpoint นี้คืนข้อมูลสรุป (Aggregate) เพียง response เดียว ไม่ใช้ Pagination — เหมาะสำหรับ Dashboard และ Reporting โดยตรง ไม่ต้องนำข้อมูลดิบมาคำนวณเอง
Endpoint นี้เหมาะสำหรับ:
read:reports
Access Token ต้องได้รับ Scope read:reports มิฉะนั้นระบบจะปฏิเสธคำขอ
GET /api/partner/v1/reports/sales-summary
Authorization: Bearer <access_token>
| Parameter | Type | Required | Description |
|---|---|---|---|
| branch_id | string (UUID) | Yes | สาขาที่ต้องการดึงรายงาน ต้องอยู่ใน Token's allowed_branch_ids |
| from | string (YYYY-MM-DD) | No | วันเริ่มต้นของช่วงรายงาน (inclusive) |
| to | string (YYYY-MM-DD) | No | วันสิ้นสุดของช่วงรายงาน (inclusive) |
หากไม่ส่ง from และ to ระบบจะคืน All-time Summary ของสาขานั้น (from และ to ใน response จะเป็น null)
curl -X GET \
"https://<host>/api/partner/v1/reports/sales-summary?branch_id=b1f85720-71cf-420e-a584-e36b75d3fd20&from=2026-06-01&to=2026-06-15" \
-H "Authorization: Bearer <access_token>"
{
"data": {
"branch_id": "b1f85720-71cf-420e-a584-e36b75d3fd20",
"from": "2026-06-01",
"to": "2026-06-15",
"total_orders": 53,
"total_revenue": "12510.4",
"total_subtotal": "12510.4",
"total_discount": "113.6",
"total_tax": "818.4",
"total_service_charge": "0",
"total_refunded": "0",
"average_order_value": "236.0452830188679245"
}
}
| Field | Type | Description |
|---|---|---|
| branch_id | string (UUID) | สาขาที่รายงาน |
| from | string | null | วันเริ่มต้นที่ใช้ในการคำนวณ (null หากไม่ส่ง parameter) |
| to | string | null | วันสิ้นสุดที่ใช้ในการคำนวณ (null หากไม่ส่ง parameter) |
| total_orders | number | จำนวน Order ทั้งหมด — นับเฉพาะสถานะ COMPLETED และ PARTIAL_REFUNDED |
| total_revenue | string (decimal) | ยอดขายรวม (sum of total_amount) |
| total_subtotal | string (decimal) | ยอดรวมก่อนภาษีและค่าบริการ |
| total_discount | string (decimal) | ส่วนลดรวมทั้งหมด |
| total_tax | string (decimal) | ภาษีรวมทั้งหมด |
| total_service_charge | string (decimal) | ค่าบริการรวมทั้งหมด |
| total_refunded | string (decimal) | ยอดคืนเงินรวม |
| average_order_value | string (decimal) | ยอดเฉลี่ยต่อ Order = total_revenue / total_orders |
400 Bad Request
{
"error": "invalid_request",
"message": "branch_id is required"
}
404 Not Found
{
"error": "not_found",
"message": "Branch not found"
}
สาเหตุ:
branch_id ไม่ถูกต้องallowed_branch_ids)