版本 2.4.7.20261116085428 · 最新
订单 orders
充值、扣款、在线支付与套餐购买产生的订单;租户只见本租户,管理员可跨租户,订单只许改备注。
点击任一接口,右侧显示对应的调用示例。
支付与账户鉴权: 用户(部分参数仅管理员)4 个接口
鉴权
请求头带 X-API-Key(在「API 密钥」页开通,密钥只在开通时显示一次);也可用登录得到的 Authorization: Bearer 令牌。
X-API-Key
鉴权失败回 401;无权回 403(code 为 insufficient_scope 等)。
约定
分页参数 page(从 1 起)、page_size;排序 sort=字段 或 -字段。
时间一律 RFC 3339(UTC);金额单位为分。
写操作成功回 200/201/204;重复提交按资源唯一键回 409。
GET
/api/v2/orders列出订单
鉴权: 用户(部分参数仅管理员)
查询参数
| 字段 | 类型 | 说明 |
|---|---|---|
page | integer | 页码,从 1 开始。 |
page_size | integer | 每页条数。 |
sort | string | 排序字段,逗号分隔,前缀 `-` 表示降序,如 `-created_at,id`。 |
tenant_id | integer | 仅管理员可用:按租户过滤(格式错 422)。租户凭据调用时忽略,只返回本租户数据。 |
tenant_ids | string | 仅管理员可用:只看这些租户,逗号分隔的正整数,去重后至多 200 个(超了或格式错 422);只选 1 个也可用。只做过滤、不切换请求作用域,与 tenant_id 及其他条件取交集;租户凭据带了非空值回 403。 |
type | string | 按订单类型过滤(recharge/deduct/payment/package 等)。 |
pay_type | string | 按支付方式过滤(admin/balance/alipay/wxpay/usdt 等)。 |
status | string | 按状态过滤。 |
currency | string | 按币种过滤(ISO 4217);不填 = 全部币种,金额按下单时汇率折成基准货币。 |
start | string | 下单时间起(含),RFC 3339。 |
end | string | 下单时间止(不含),RFC 3339。 |
GET
/api/v2/orders/stats订单金额统计
鉴权: 用户(部分参数仅管理员)
查询参数
| 字段 | 类型 | 说明 |
|---|---|---|
tenant_id | integer | 仅管理员可用:按租户过滤(格式错 422)。租户凭据调用时忽略,只返回本租户数据。 |
tenant_ids | string | 仅管理员可用:只看这些租户,逗号分隔的正整数,去重后至多 200 个(超了或格式错 422);只选 1 个也可用。只做过滤、不切换请求作用域,与 tenant_id 及其他条件取交集;租户凭据带了非空值回 403。 |
type | string | 按订单类型过滤(recharge/deduct/payment/package 等)。 |
pay_type | string | 按支付方式过滤(admin/balance/alipay/wxpay/usdt 等)。 |
status | string | 按状态过滤。 |
currency | string | 按币种过滤(ISO 4217);不填 = 全部币种,金额按下单时汇率折成基准货币。 |
start | string | 下单时间起(含),RFC 3339。 |
end | string | 下单时间止(不含),RFC 3339。 |
group_by | string | 汇总粒度,缺省 day。 |
GET
/api/v2/orders/{id}获取订单
鉴权: 用户(部分参数仅管理员)
PUT
/api/v2/orders/{id}改订单备注
鉴权: 仅管理员
请求体 application/json
| 字段 | 类型 | 说明 |
|---|---|---|
des必填 | string | 备注说明 |
订单对象
| 字段 | 类型 | 说明 |
|---|---|---|
amount_cents | integer | 金额(分),扣款单为负。 |
archived | boolean | 已被归档任务搬进档案表(只读)。 |
by_pay_type | OrderStatsPayType[] | 按支付方式 × 方向(direction)的小计(支付方式升序、同方式 credit 在前;受同样的类型/状态/时间/租户过滤;金额口径同 items,合计 = items 合计);未付款单支付方式为空串。 |
created_at | string | 创建时间 |
currency | string | 金额币种(ISO 4217)。 |
data | object | 附加数据(如套餐购买明细);在线付差额的充值单带 intent(办理意图,state 为 pending/running/done/failed,failed 时 code/reason 写明原因,done 时 user_package_id 为办理的用户套餐)。 |
des | string | 备注说明 |
group_by | string | 汇总粒度:day、month 或 year。 |
id | integer | 记录 ID |
items | OrderStatsItem[] | 本页条目 |
ledger_id | integer | 关联的账户流水 ID;没有则为空。 |
mch_order_no | string | 商户订单号(网关侧订单号);非在线支付为空。 |
paid_at | string | 付款时间;未付款为空。 |
pay_type | string | admin/balance/alipay/wxpay 等;空 = 未付款。 |
rate_to_base | string | 下单时汇率:1 单位该币 = ? 基准货币(十进制串,8 位小数);之后改汇率不动历史。 |
status | string | 订单状态:unpaid 待付款、paid 已付款。 |
tenant_id | integer | 所属租户(用户)ID |
transaction_id | string | 网关侧交易号;未付款为空。 |
type | string | recharge(管理员充值)/deduct(管理员扣款)/payment(在线支付)/package(套餐)等。 |
updated_at | string | 更新时间 |
返回与错误
成功直接回资源 JSON(HTTP 2xx);失败回 application/problem+json(code、detail,校验失败带 errors);列表为 items + total。
成功
{
"id": 1,
"name": "example"
}列表
{
"items": [
{
"id": 1
}
],
"page": 1,
"page_size": 20,
"total": 1
}失败
{
"code": "validation_failed",
"detail": "请求参数不合法",
"errors": [
{
"code": "required",
"field": "/name",
"message": "name 必填"
}
],
"request_id": "0123456789abcdef",
"status": 422,
"title": "Unprocessable Entity",
"type": "about:blank"
}