# 钱包信息（高级接口API）

使用 **账户权限密钥** 只读查询当前个人账户的钱包资金明细、历史消耗汇总、推广返佣统计、模型专属折扣以及充值与账变历史记录。

> [!IMPORTANT]
> - **Base URL**：`https://ai.artsmcp.com/api/open/v1`
> - **鉴权请求头（三选一）**：`Authorization: Bearer <your_account_key>`、`X-Account-Api-Key: <your_account_key>` 或 `X-Api-Key: <your_account_key>`
> - **可用资金说明**：`available_funds` 综合计算现金余额（`balance`）、平台赠送金（`gift_balance`）与授信额度（`credit_limit`）；当 `balance + credit_limit < 0` 时，`cash_in_arrears` 返回 `true`

---

### 1. 获取个人钱包余额与佣金统计

查询个人钱包实时余额、累计消耗统计、推广佣金余额与邀请人数，以及当前账号生效中的单模型专属折扣列表与结算币种。

* **路径**：`GET /api/open/v1/wallet`
* **查询参数 (Query)**：无
* **调用示例 (Curl)**：

```bash
curl -s "https://ai.artsmcp.com/api/open/v1/wallet" \
  -H "Authorization: Bearer <your_account_key>"
```

* **响应示例**：

```json
{
  "balance": 500.0,
  "gift_balance": 20.0,
  "credit_limit": 0.0,
  "available_funds": 520.0,
  "cash_in_arrears": false,
  "total_consumption": 133.5,
  "used_quota": 128.5,
  "gift_used_quota": 5.0,
  "commission_balance": 35.2,
  "total_referred": 6,
  "marketing_enabled": true,
  "commission_ratio": 0.1,
  "commission_basis": "consumption",
  "discounted_models": [],
  "currency": "CNY",
  "currency_symbol": "¥",
  "currency_unit": "元"
}
```

* **返回字段说明**：

| 字段名 | 类型 | 说明 |
| :--- | :--- | :--- |
| `balance` | `number` | 现金钱包余额 |
| `gift_balance` | `number` | 平台赠送金钱包余额 |
| `credit_limit` | `number` | 账户授信透支额度 |
| `available_funds` | `number` | 综合可用总额（`balance + gift_balance + credit_limit`；现金欠费时如实返回负值） |
| `cash_in_arrears` | `boolean` | 是否处于现金透支欠费状态（`balance + credit_limit < 0` 时为 `true`） |
| `total_consumption` | `number` | 历史累计总消耗金额（`used_quota + gift_used_quota`） |
| `used_quota` | `number` | 现金钱包累计实扣消耗金额 |
| `gift_used_quota` | `number` | 赠送钱包累计实扣消耗金额 |
| `commission_balance` | `number` | 推广返佣钱包当前余额 |
| `total_referred` | `integer` | 累计成功邀请注册人数 |
| `marketing_enabled` | `boolean` | 当前用户等级是否开启推广返佣权益 |
| `commission_ratio` | `number` | 推广返佣比例（如 `0.1` 表示 10%） |
| `commission_basis` | `string` | 返佣核算基准（`consumption` 按消费 / `recharge` 按充值） |
| `discounted_models` | `array` | 当前账号单独配置且生效中的模型专属折扣列表 |
| `currency` / `currency_symbol` / `currency_unit` | `string` | 站点结算币种代码、符号与单位名称 |

---

### 2. 查询钱包充值与账变记录

分页查询个人钱包的在线充值订单、兑换码入账与账变明细（时间统一按站点运营时区输出）。

* **路径**：`GET /api/open/v1/wallet/recharges`
* **查询参数 (Query)**：

| 参数名 | 类型 | 默认值 | 说明 |
| :--- | :--- | :--- | :--- |
| `page` | `integer` | `1` | 页码（从 `1` 开始） |
| `per_page` | `integer` | `20` | 每页条数（范围 `1..100`） |
| `wallet_type` | `string` | 全部 | 按钱包类型筛选：`system`（现金钱包）或 `gift`（赠送钱包） |
| `recharge_type` | `string` | 全部 | 按入账类型筛选（如 `alipay`、`wechat`、`stripe`、`redemption`、`transfer`） |

* **调用示例 (Curl)**：

```bash
curl -s "https://ai.artsmcp.com/api/open/v1/wallet/recharges?page=1&per_page=20" \
  -H "Authorization: Bearer <your_account_key>"
```

* **响应示例**：

```json
{
  "data": [
    {
      "amount": 100.0,
      "recharge_type": "wechat",
      "wallet_type": "system",
      "order_no": "ORD202611292015001234",
      "fee_amount": 0.0,
      "remark": "在线充值",
      "created_at": "2026-11-29 20:15:08 (UTC+8)"
    }
  ],
  "total": 1,
  "page": 1,
  "per_page": 20
}
```

* **返回字段说明**：

| 字段名 | 类型 | 说明 |
| :--- | :--- | :--- |
| `data` | `array` | 当前页的充值与账变记录列表 |
| `data[].amount` | `number` | 变动金额（正数表示入账，负数表示扣减） |
| `data[].recharge_type` | `string` | 入账类型（如 `alipay`、`wechat`、`stripe`、`redemption`、`transfer`） |
| `data[].wallet_type` | `string` | 所属钱包类型：`system`（现金钱包）或 `gift`（赠送钱包） |
| `data[].order_no` | `string` | 关联支付订单号（仅在线充值记录返回，无订单号时省略） |
| `data[].fee_amount` | `number` | 在线充值对应的支付手续费（非在线充值时为 `0`） |
| `data[].remark` | `string` | 账变备注说明（无备注时省略） |
| `data[].created_at` | `string` | 记录创建时间（按站点运营时区格式化） |
| `total` | `integer` | 符合筛选条件的总记录数 |
| `page` / `per_page` | `integer` | 当前页码与每页条数 |
