会员模块


8.1 套餐管理

会员套餐列表

GET /api/v1/membership/plans

查询参数 说明
type personal / enterprise
status active / disabled
{
  "code": 0,
  "data": {
    "items": [
      {
        "plan_id": "plan_basic",
        "name": "基础版",
        "type": "personal",
        "price_monthly": "49.00",
        "price_yearly": "490.00",
        "currency": "CNY",
        "status": "active",
        "benefits": [
          { "key": "tpm",            "value": 100000,                      "desc": "每分钟 10万 Token" },
          { "key": "tpd",            "value": 2000000,                     "desc": "每日 200万 Token" },
          { "key": "models",         "value": ["gpt-4o", "qwen-turbo"],    "desc": "可用模型" },
          { "key": "token_discount", "value": "20%",                       "desc": "Token 费率 8折" },
          { "key": "priority",       "value": "P1",                        "desc": "队列优先级 P1" },
          { "key": "support",        "value": "email",                     "desc": "邮件工单支持" }
        ]
      },
      {
        "plan_id": "plan_premium",
        "name": "高级版",
        "type": "personal",
        "price_monthly": "199.00",
        "price_yearly": "1990.00",
        "currency": "CNY",
        "benefits": [
          { "key": "tpm",            "value": 500000,    "desc": "每分钟 50万 Token" },
          { "key": "tpd",            "value": 10000000,  "desc": "每日 1000万 Token" },
          { "key": "token_discount", "value": "40%",     "desc": "Token 费率 6折" },
          { "key": "priority",       "value": "P1",      "desc": "队列优先级 P1" },
          { "key": "support",        "value": "priority","desc": "优先技术支持" }
        ]
      }
    ]
  }
}

套餐详情

GET /api/v1/membership/plans/{plan_id}

创建套餐(管理员)

POST /admin/v1/membership/plans

{
  "name": "企业标准版",
  "type": "enterprise",
  "price_monthly": "999.00",
  "price_yearly": "9990.00",
  "currency": "CNY",
  "benefits": [
    { "key": "tpm", "value": 2000000, "desc": "每分钟 200万 Token" },
    { "key": "member_seats", "value": 50, "desc": "50个成员席位" },
    { "key": "priority", "value": "P0", "desc": "队列最高优先级" }
  ]
}

更新套餐(管理员)

PUT /admin/v1/membership/plans/{plan_id}


8.2 我的会员状态

GET /api/v1/membership/me

{
  "code": 0,
  "data": {
    "plan_id": "plan_basic",
    "plan_name": "基础版",
    "plan_type": "personal",
    "status": "active",
    "period": "yearly",
    "started_at": "2024-01-01T00:00:00Z",
    "expired_at": "2024-12-31T23:59:59Z",
    "auto_renew": true,
    "usage_this_month": {
      "tokens_used": 1200000,
      "tokens_limit": 2000000,
      "usage_percent": 60
    },
    "effective_benefits": {
      "tpm": 100000,
      "token_discount": "20%",
      "priority": "P1"
    }
  }
}

status 枚举:active / expired / cancelled / none(未订阅)


8.3 订阅会员

POST /api/v1/membership/subscribe

{
  "plan_id": "plan_basic",
  "period": "yearly",
  "auto_renew": true,
  "voucher_id": "v_01HX..."
}

响应: 创建订单,返回支付参数(同订单模块)

{
  "code": 0,
  "data": {
    "order_id": "ord_20240101010",
    "plan_name": "基础版(年付)",
    "original_amount": "490.00",
    "discount_amount": "20.00",
    "final_amount": "470.00",
    "currency": "CNY"
  }
}

8.4 续费

POST /api/v1/membership/renew

{
  "period": "yearly",
  "voucher_id": null
}

8.5 取消自动续费

POST /api/v1/membership/cancel

取消后当前会员期结束后不再自动扣款,当前权益保留至到期日。

{ "reason": "暂时不需要了" }

响应:

{
  "code": 0,
  "data": {
    "status": "cancelled",
    "auto_renew": false,
    "valid_until": "2024-12-31T23:59:59Z",
    "message": "您的会员权益将保留至 2024-12-31"
  }
}

8.6 会员变更历史

GET /api/v1/membership/history

{
  "code": 0,
  "data": {
    "items": [
      {
        "history_id": "mh_001",
        "action": "subscribe",
        "plan_name": "基础版",
        "period": "yearly",
        "amount": "490.00",
        "started_at": "2024-01-01T00:00:00Z",
        "expired_at": "2024-12-31T23:59:59Z",
        "order_id": "ord_20240101010",
        "created_at": "2024-01-01T00:00:00Z"
      }
    ]
  }
}

action 枚举:subscribe / renew / upgrade / downgrade / cancel / expired