# 按交易单号查询账户流水

> 按一个或多个交易单号查询关联的账户余额变动记录。

```yaml
openapi: 3.1.0
info:
  title: 按交易单号查询账户流水
  version: 1.0.0
  description: 按一个或多个交易单号查询关联的账户余额变动记录。
paths:
  /api/v2/account/transactions/service/query:
    post:
      summary: 按交易单号查询账户流水
      description: 按一个或多个交易单号查询关联的账户余额变动记录。
      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: 平台商户代子商户查询时使用的子商户号；调用方商户必须是子商户的父商户。
                serviceIds:
                  type: array
                  description: 用于定位关联余额变动记录的交易单号列表。
                  items:
                    type: integer
                  x-onerway-constraints:
                    - kind: range
                      min: 1
                      max: 100
                      unit: 个元素
                      text: 列表不能为空，且最多包含 100 个交易单号。
              required:
                - requestId
                - serviceIds
            examples:
              query-transactions-by-service-ids:
                summary: 按交易单号查询账户流水
                value:
                  requestId: REQ-TRX-20260423-0002
                  serviceIds:
                    - 20001
                    - 20002
                    - 20003
      responses:
        "200":
          description: 交易单号对应的账户流水
          content:
            application/json:
              schema:
                type: object
                properties:
                  respCode:
                    type: string
                    description: 标准化响应码；`20000` 表示成功。
                  respMsg:
                    type: string
                    description: 与 `respCode` 对应的可读响应信息。
                  data:
                    type: object
                    properties:
                      list:
                        type: array
                        description: 与请求 `serviceIds[]` 匹配的账户流水列表。
                        items:
                          type: object
                          properties:
                            acntTxnId:
                              type: integer
                              description: 账户流水 ID，用于标识单条余额变动记录。
                            serviceId:
                              type: integer
                              description: 与该笔余额变动关联的交易单号。
                            currency:
                              type: string
                              description: 交易币种。
                            balanceType:
                              type: string
                              description: 受影响的余额类型。
                            amount:
                              type: string
                              description: 带符号的余额变动金额；正数表示余额增加，负数表示余额减少。
                            balanceUpdDate:
                              type: string
                              description: 余额更新时间，使用 UTC ISO-8601 格式。
                            businessType:
                              type: string
                              description: 触发该余额变动的业务类型。
                            externalOrderId:
                              type: string
                              description: 上游业务系统传入的外部订单号，可选。
                            remark:
                              type: string
                              description: 交易备注。
                    description: 按 `serviceIds[]` 匹配的账户流水数据。
                  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: 标准化错误对象；成功响应中该字段为 null，序列化时省略。
              examples:
                query-transactions-by-service-ids:
                  summary: 交易单号对应的账户流水
                  value:
                    respCode: "20000"
                    respMsg: Success
                    data:
                      list:
                        - acntTxnId: 10001
                          serviceId: 20001
                          currency: USD
                          balanceType: PAYMENT
                          amount: "-100.00"
                          balanceUpdDate: 2026-04-20T10:30:00Z
                          businessType: PAYOUT
                          externalOrderId: replace_with_external_order_id
                          remark: Payout to bank account
                        - acntTxnId: 10002
                          serviceId: 20002
                          currency: USD
                          balanceType: PAYMENT
                          amount: "500.00"
                          balanceUpdDate: 2026-04-19T08:15:00Z
                          businessType: ACQUIRING
                          externalOrderId: replace_with_external_order_id
                          remark: Payment received
      x-onerway-lifecycle:
        phase: active
        access:
          description:
            en: Access to the Account service APIs is enabled by Onerway approval.
            zh: 账户服务 API 的访问权限需经 Onerway 审批后开通。
```
