# 导出每日账户账单

> 导出指定日期的每日账户账单 CSV。

```yaml
openapi: 3.1.0
info:
  title: 导出每日账户账单
  version: 1.0.0
  description: 导出指定日期的每日账户账单 CSV。
paths:
  /api/v2/account/statement/daily/export:
    post:
      summary: 导出每日账户账单
      description: 导出指定日期的每日账户账单 CSV。
      parameters:
        - name: apikey
          in: header
          required: true
          description: Onerway 分配的账户服务 API key 请求 Header；必须使用与请求域名相同环境的值。
          schema:
            type: string
            description: Onerway 分配的账户服务 API key 请求 Header；必须使用与请求域名相同环境的值。
        - name: x-timestamp
          in: header
          required: true
          description: 请求时间戳；网关使用该 Header 防止请求被重放。
          schema:
            type: string
            description: 请求时间戳；网关使用该 Header 防止请求被重放。
            x-onerway-constraints:
              - kind: rule
                text: 时间戳必须在服务端当前时间 10分钟以内；支持 10 位秒级或 13 位毫秒级时间戳。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                requestId:
                  type: string
                  description: 请求 ID，用于幂等控制和链路追踪。
                onBehalfOf:
                  type: string
                  description: 平台商户代子商户导出时使用的子商户号；调用方商户必须是子商户的父商户。
                date:
                  type: string
                  description: 账单日期，使用 `yyyyMMdd` 格式。
                  x-onerway-constraints:
                    - kind: rule
                      text: 使用 `yyyyMMdd` 格式，例如 `20260720`。
                currency:
                  type: string
                  description: 账单币种；使用 [ISO
                    4217](https://en.wikipedia.org/wiki/ISO_4217#List_of_ISO_4217_currency_codes)
                    三位字母货币代码。
                businessType:
                  type: string
                  description: 账单导出的业务类型；缺省值为 `PAYOUT`。
                  enum:
                    - ACQUIRING
                    - PAYOUT
                    - BAAS
                    - ISSUING
                  x-enum-descriptions:
                    ACQUIRING: 收单业务账单。
                    PAYOUT: 付款业务账单。
                    BAAS: BaaS 业务账单。
                    ISSUING: 发卡业务账单。
              required:
                - requestId
                - date
                - currency
            examples:
              export-daily-payout-statement:
                summary: 导出 2026-07-20 USD 付款账单
                value:
                  requestId: REQ-STMT-20260720-0001
                  date: "20260720"
                  currency: USD
                  businessType: PAYOUT
      responses:
        "200":
          description: USD 付款账单 CSV 响应
          content:
            application/json:
              schema:
                type: object
                properties:
                  respCode:
                    type: string
                    description: JSON 错误响应中的标准化响应码。
                    x-onerway-value:
                      empty: true
                      when:
                        en: Returned in JSON error responses when the CSV stream has not been committed
                          yet. Successful CSV stream responses do not include a
                          JSON response envelope.
                        zh: 当 CSV 响应尚未提交且接口返回 JSON 错误结构时返回；成功的 CSV 文件流响应不包含 JSON 响应壳。
                  respMsg:
                    type: string
                    description: 与 `respCode` 对应的可读响应信息。
                    x-onerway-value:
                      empty: true
                      when:
                        en: Returned in JSON error responses when the CSV stream has not been committed
                          yet. Successful CSV stream responses do not include a
                          JSON response envelope.
                        zh: 当 CSV 响应尚未提交且接口返回 JSON 错误结构时返回；成功的 CSV 文件流响应不包含 JSON 响应壳。
                  file:
                    type: object
                    properties:
                      csv:
                        type: object
                        properties:
                          statementHeader:
                            type: object
                            properties:
                              Merchantid:
                                type: string
                                description: 调用方身份解析出的商户号；平台代子商户调用时，为 `onBehalfOf` 指定的有效商户。
                              Date:
                                type: string
                                description: 账单日期，按 `GMT+8 yyyy/M/d` 展示。
                              Currency:
                                type: string
                                description: 账单币种，使用 [ISO
                                  4217](https://en.wikipedia.org/wiki/ISO_4217#List_of_ISO_4217_currency_codes)
                                  三位字母货币代码。
                            description: CSV 第一段。表头行为 `Merchantid,Date,Currency`。
                          summaryRows:
                            type: array
                            description: 余额汇总区。表头行为
                              `Balancetype,Openingbalance,Movementamount,Endingbalance`。固定输出
                              `Total Balance`、`Available`、`Frozen`、`Risk
                              Deposit`、`Pending Settlement`。
                            items:
                              type: object
                              properties:
                                Balancetype:
                                  type: string
                                  description: 余额类型展示名称。
                                  enum:
                                    - Total Balance
                                    - Available
                                    - Frozen
                                    - Risk Deposit
                                    - Pending Settlement
                                  x-enum-descriptions:
                                    Total Balance: 所有账单余额类型汇总后的总余额。
                                    Available: 可用余额。
                                    Frozen: 冻结余额。
                                    Risk Deposit: 风险保证金余额。
                                    Pending Settlement: 待结算余额。
                                Openingbalance:
                                  type: string
                                  description: 账单日期的期初余额。
                                Movementamount:
                                  type: string
                                  description: 账单日期内的净发生额，按转入金额减转出金额计算。
                                Endingbalance:
                                  type: string
                                  description: 账单日期的期末余额。
                          detailRows:
                            type: array
                            description: 流水明细区。表头行为
                              `Time,Balancetype,Serialnumber,Activitytype,Moveamount,RelatedtransationID,Remark`。
                            items:
                              type: object
                              properties:
                                Time:
                                  type: string
                                  description: 余额变动时间，按 `yyyy/M/d H:mm:ss` 展示。
                                Balancetype:
                                  type: string
                                  description: 由账户流水子账户类型映射出的余额类型展示名称；如果子账户类型未配置映射，可能返回原始子账户类型。
                                  enum:
                                    - Available
                                    - Frozen
                                    - Risk Deposit
                                    - Pending Settlement
                                  x-enum-descriptions:
                                    Available: 由账户流水子账户类型 `AVAIL` 映射。
                                    Frozen: 由账户流水子账户类型 `FREEZE` 映射。
                                    Risk Deposit: 由账户流水子账户类型 `DEPOSIT` 映射。
                                    Pending Settlement: 由账户流水子账户类型 `UNSETTLE` 映射。
                                Serialnumber:
                                  type: string
                                  description: 交易单号，取自 `serviceId`。
                                Activitytype:
                                  type: string
                                  description: 活动类型，来源于 `txnType`。该 CSV 字段不是固定枚举：若账户交易类型字典存在英文翻译，则使用英文描述；否则回退为原始
                                    `txnType` 值。
                                Moveamount:
                                  type: string
                                  description: 流水变动金额。增加方向为正数；减少方向带负号。
                                RelatedtransationID:
                                  type: string
                                  description: 关联交易 ID，取自 `externalOrderId`。
                                Remark:
                                  type: string
                                  description: 备注。若备注字典存在匹配值，则使用字典描述；否则使用原始备注。
                        description: UTF-8 编码的 CSV 账单文件；文件包含账单头、余额汇总区和流水明细区，段与段之间使用空行分隔。
                    description: "成功响应返回 CSV 文件流，`Content-Type: text/csv;
                      charset=UTF-8`；`Content-Disposition` Header 形如
                      `attachment; filename=statement_{date}_{currency}.csv`。请将
                      UTF-8 编码内容保存为 `.csv` 文件。"
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        description: 对外业务错误码，与 `respCode` 对齐。
                      declineCode:
                        type: string
                        description: 兼容字段，与 `code` 保持一致。
                      message:
                        type: string
                        description: 可读错误信息。
                      type:
                        type: string
                        description: 标准化错误类型。
                      param:
                        type: string
                        description: 触发错误的请求参数名，可选。
                      requestId:
                        type: string
                        description: 调用方请求 ID，与 body `requestId` 保持一致。
                    description: 标准化错误对象；仅在 CSV 响应尚未提交时返回；一旦响应已写入，则失败仅记录日志，调用方收到已部分写入的 CSV。
              examples:
                export-daily-payout-statement:
                  summary: USD 付款账单 CSV 响应
                  value:
                    file:
                      csv:
                        statementHeader:
                          Merchantid: replace_with_merchant_no
                          Date: GMT+8 2026/7/20
                          Currency: USD
                        summaryRows:
                          - Balancetype: Total Balance
                            Openingbalance: "3000.00"
                            Movementamount: "400.00"
                            Endingbalance: "3400.00"
                          - Balancetype: Available
                            Openingbalance: "2500.00"
                            Movementamount: "500.00"
                            Endingbalance: "3000.00"
                        detailRows:
                          - Time: 2026/7/20 10:30:00
                            Balancetype: Available
                            Serialnumber: "20001"
                            Activitytype: Payout
                            Moveamount: "-100.00"
                            RelatedtransationID: replace_with_external_order_id
                            Remark: Payout to bank account
                export-daily-payout-statement-error:
                  summary: 生成失败时返回的错误结构
                  value:
                    respCode: "10001"
                    respMsg: Invalid request parameter
                    error:
                      code: "10001"
                      declineCode: "10001"
                      message: currency must not be blank
                      type: invalid_request_error
                      param: currency
                      requestId: REQ-STMT-20260720-0001
            text/csv:
              schema:
                type: string
                format: binary
          headers:
            Content-Disposition:
              description: 提供下载文件名，取值形如 `attachment;
                filename=statement_{date}_{currency}.csv`。
              schema:
                type: string
      x-onerway-lifecycle:
        phase: active
        access:
          description:
            en: Access to the Account service APIs is enabled by Onerway approval.
            zh: 账户服务 API 的访问权限需经 Onerway 审批后开通。
```
