Files
soul-yongping/开发文档/4、前端/ui/04-API接口说明.md
2026-02-09 15:09:29 +08:00

4.6 KiB
Raw Blame History

API接口说明

接口列表

1. 配置接口

GET /api/config

获取系统配置信息

响应示例:

{
  "settings": {
    "distributorShare": 90,
    "authorShare": 10,
    "sectionPrice": 1,
    "baseBookPrice": 9.9,
    "paymentMethods": {...}
  }
}

2. 用户接口

POST /api/users/login

用户登录

请求参数:

参数 类型 必填 说明
phone string 手机号
code string 验证码

POST /api/users/register

用户注册

请求参数:

参数 类型 必填 说明
phone string 手机号
nickname string 昵称
referralCode string 推荐码

GET /api/users

获取用户列表(管理端)

PUT /api/users/[id]

更新用户信息


3. 购买接口

POST /api/purchases

创建购买订单

请求参数:

参数 类型 必填 说明
type string 购买类型section/fullbook
sectionId string 章节ID单章购买时必填
paymentMethod string 支付方式wechat
amount number 金额

GET /api/purchases

获取购买记录


4. 提现接口

POST /api/withdrawals

申请提现

请求参数:

参数 类型 必填 说明
amount number 提现金额
method string 提现方式wechat/alipay
account string 收款账号
name string 真实姓名

GET /api/withdrawals

获取提现记录


5. 分销接口

GET /api/distribution

获取分销数据

查询参数:

参数 类型 说明
type string 查询类型my-bindings/stats
userId string 用户ID

6. 存客宝CKB接口

POST /api/ckb/join

加入类型申请(导师顾问/资源对接/团队招募)

请求参数:

参数 类型 必填 说明
type string 类型mentor/investor/team/partner
phone string 手机号(二选一)
wechat string 微信号(二选一)
userId string 用户ID

POST /api/ckb/match

匹配行为上报

请求参数:

参数 类型 必填 说明
matchType string 匹配类型
phone string 手机号
wechat string 微信号
matchedUser object 匹配到的用户信息

7. 支付接口

POST /api/payment/create

创建支付订单

POST /api/payment/query

查询支付状态


8. 内容接口

GET /api/book/[sectionId]

获取章节内容

GET /api/book/sections

获取章节列表


接口流程图

购买流程

┌─────────┐     ┌─────────────┐     ┌─────────────┐
│  用户   │────▶│ 选择购买方式 │────▶│ 创建订单    │
└─────────┘     └─────────────┘     └──────┬──────┘
                                           │
                                           ▼
┌─────────┐     ┌─────────────┐     ┌─────────────┐
│ 完成购买 │◀────│ 轮询支付状态 │◀────│ 生成二维码  │
└─────────┘     └─────────────┘     └─────────────┘

分销绑定流程

┌─────────┐     ┌─────────────┐     ┌─────────────┐
│ 访客访问 │────▶│ 识别推荐码  │────▶│ 创建绑定关系 │
│ ?ref=xxx│     └─────────────┘     └──────┬──────┘
└─────────┘                                │
                                           ▼
┌─────────┐     ┌─────────────┐     ┌─────────────┐
│ 分成计算 │◀────│ 访客购买    │◀────│ 30天绑定期  │
│ 推广者90%│     └─────────────┘     └─────────────┘
└─────────┘

文档版本v2.0 | 更新日期2026-01-18