跳轉到

送出日結

POST /daily-close

日結完成信號與控制總數。須在該營業日所有交易批次都送完後送出。總部收到後會以已收到的交易重新計算,與控制總數比對,結果可用查詢對帳結果取得。

權限

API 金鑰(x-functions-key)

Request

Header 必填 說明
x-functions-key Y {api_key}
Content-Type Y application/json

Body

欄位 型別 必填 說明
batch_id UUID Y 冪等鍵(更正重送時用新的 batch_id)
store_id string Y 門市代碼
business_date date Y 營業日
batch_count integer Y 該營業日 /trade-records 的批次數
trade_record_count integer Y 交易筆數(不重複 trade_record_id)
item_row_count integer Y 品項列總數(含套餐子品項列)
payment_row_count integer Y 付款列總數
net_sales_amount decimal string Y 淨營收,定義見下
tax_amount decimal string Y 稅額合計
tip_amount decimal string Y 小費合計
payment_total_amount decimal string Y 付款金額合計,定義見下
currency string Y ISO 4217,須與門市幣別相同
closed_at timestamp Y 日結時間

計算定義

欄位 計算方式
net_sales_amount 標準交易型態 is_revenue = true 的交易,total_amount − tax_amount − tip_amount 的加總(以最新 version 計)
payment_total_amount Σ(amount × 收付方向),方向見收付款性質代碼表;DEPOSIT_APPLIED 不重複計入(訂金收取時已計)

範例

{
  "batch_id": "5d6e7f80-9a0b-4c1d-8e2f-3a4b5c6d7e8f",
  "store_id": "US001",
  "business_date": "2026-10-14",
  "batch_count": 5,
  "trade_record_count": 312,
  "item_row_count": 958,
  "payment_row_count": 330,
  "net_sales_amount": "9821.40",
  "tax_amount": "795.53",
  "tip_amount": "1402.10",
  "payment_total_amount": "11980.23",
  "currency": "USD",
  "closed_at": "2026-10-15T00:12:00-07:00"
}

Response

202 Accepted(record_count 為 1)

{ "batch_id": "5d6e7f80-9a0b-4c1d-8e2f-3a4b5c6d7e8f", "status": "ACCEPTED", "record_count": 1, "warnings": [] }

同一 batch_id 重送回 200 ALREADY_RECEIVED。

錯誤

HTTP code 情況
400 INVALID_PAYLOAD 格式、必填錯誤,或幣別與門市不符
401 UNAUTHORIZED 未帶 API 金鑰或金鑰錯誤
403 STORE_NOT_ALLOWED store_id 不屬於該合作夥伴

注意事項

Warning

  • 日結必須最後送。日結送出後才到的交易批次,可能造成對帳不一致。
  • 同一門市同一營業日可多次送出(更正時),以最後一次為準;每次更正請使用新的 batch_id。
  • 已日結的營業日若有交易異動,請先重送異動交易(version +1),再重送日結。