# Đối soát

> Base URL: `https://pos.pages.fm/api/v1`. Xác thực bằng tham số truy vấn `api_key`.

## Danh sách phiếu đối soát

`GET /shops/{SHOP_ID}/reconciliations`

Lấy danh sách phiếu đối soát. Mỗi phiếu kèm các đơn thuộc phiếu trong mảng `orders`

### Tham số

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Mã shop |
| `page` | query | integer |  | Số trang |
| `page_size` | query | integer |  | Kích thước trang. Mặc định 10, tối đa 50 (gửi lớn hơn sẽ bị hạ về 50) |
| `sort_by` | query | string |  | Sắp xếp tăng dần theo `updated_at` (rồi `system_id`) để đồng bộ tăng dần. Không gửi thì sắp theo thời điểm tạo giảm dần Values: `updated_at`. |
| `startDateUpdatedAt` | query | integer (int64) |  | Chỉ lấy phiếu có `updated_at` >= thời điểm này (unix timestamp, giây). Có thể gửi một mình, không cần `endDateUpdatedAt` |
| `endDateUpdatedAt` | query | integer (int64) |  | Chỉ lấy phiếu có `updated_at` <= thời điểm này (unix timestamp, giây) |
| `include_removed` | query | boolean |  | Bao gồm phiếu đã gỡ (`is_removed: true`). Gửi `true` để bật |
| `system_id[]` | query | integer[] |  | Lọc theo mã nội bộ của phiếu. Cũng nhận một giá trị dạng `system_id=123` |
| `display_id` | query | integer |  | Lọc theo mã phiếu hiển thị trên shop |
| `search` | query | string |  | Tìm theo `display_id` hoặc `custom_id` của phiếu. Nhiều mã cách nhau bằng khoảng trắng hoặc dấu phẩy; khớp bất kỳ mã nào |
| `partner_id[]` | query | string[] |  | ID đơn vị vận chuyển trên hệ thống Pancake (xem Danh sách đơn vị vận chuyển). Cũng nhận một giá trị dạng `partner_id=1` |
| `creator_id` | query | string (uuid) |  | Lọc theo mã người tạo phiếu |
| `order_id` | query | integer |  | Chỉ lấy phiếu chứa đơn này (mã nội bộ của đơn, `system_id` của đơn hàng) |
| `startDate` | query | integer (int64) |  | Đầu khoảng thời điểm tạo phiếu (unix timestamp, giây). Chỉ áp dụng khi gửi cả `startDate` và `endDate` |
| `endDate` | query | integer (int64) |  | Cuối khoảng thời điểm tạo phiếu (unix timestamp, giây) |
| `startDatePaidAt` | query | integer (int64) |  | Đầu khoảng thời điểm thanh toán (unix timestamp, giây). Chỉ áp dụng khi gửi cả `startDatePaidAt` và `endDatePaidAt`; phiếu chưa có `paid_at` bị loại |
| `endDatePaidAt` | query | integer (int64) |  | Cuối khoảng thời điểm thanh toán (unix timestamp, giây) |

### Phản hồi

- `200` Success (object)
- `403` API key không hợp lệ hoặc đã bị tắt (ErrorResponse)

```json
{
  "success": true,
  "page_number": 1,
  "page_size": 10,
  "total_entries": 1,
  "total_pages": 1,
  "data": [
    {
      "system_id": 123,
      "display_id": 92,
      "custom_id": "7358901234567890123",
      "partner_id": "1",
      "control_type": "control_cod",
      "note": "Đối soát COD tuần 38",
      "excel_cod": 1250000,
      "excel_fee": 65000,
      "pos_cod": 1250000,
      "paid_at": "2026-09-18T08:06:55",
      "payment_status": "paid",
      "creator": {
        "id": "d6e6a545-f102-439e-9943-8ac8369f9735",
        "name": "vudzung12"
      },
      "updater": {
        "id": "d6e6a545-f102-439e-9943-8ac8369f9735",
        "name": "vudzung12"
      },
      "inserted_at": "2026-09-17T03:12:40.512345",
      "updated_at": "2026-09-18T08:06:55.000000",
      "is_removed": false,
      "orders": [
        {
          "order_id": 1418,
          "display_id": 1418,
          "custom_id": null,
          "extend_code": "S58824.MB25.C3.500020713",
          "order_number_vtp": null,
          "order_status": 4,
          "result": "succeed",
          "message": null,
          "cod_amount": 750000,
          "partner_fee": 35000,
          "pos_cod": 750000,
          "currency": "VND",
          "reconciliation_at": "2026-09-17T03:12:40"
        },
        {
          "order_id": 1419,
          "display_id": 1419,
          "custom_id": null,
          "extend_code": "S58824.MB25.C3.500020714",
          "order_number_vtp": null,
          "order_status": 4,
          "result": "mismatch",
          "message": null,
          "cod_amount": 500000,
          "partner_fee": 30000,
          "pos_cod": 520000,
          "currency": "VND",
          "reconciliation_at": "2026-09-17T03:12:40"
        }
      ]
    }
  ]
}
```
