# 视频多维定价表 — 手动验证清单 > 基于 `docs/testing/video-pricing-test-plan.md` | 测试环境:WSL CN (23000) ## 环境准备 ```bash BASE=http://127.0.0.1:23000 ADMIN_COOKIE="session_m=<从浏览器获取>" TOKEN="sk-" ``` 登录方式:打开 `$BASE` → 登录 → DevTools → Application → Cookies → 复制 `session_m` 的值。 --- ## 一、CRUD 操作(P01–P12) ### P01 获取配置列表 ```bash curl -s "$BASE/api/option/model_pricing" \ -H "Cookie: $ADMIN_COOKIE" -H "New-Api-User: 1" | jq ``` ### P02 创建定价配置 ```bash curl -s -X PUT "$BASE/api/option/model_pricing/hailuo-video" \ -H "Cookie: $ADMIN_COOKIE" -H "New-Api-User: 1" \ -H "Content-Type: application/json" -d '{ "schema_version": 1, "scope": "model", "billing_unit": "per_call", "preconsume_strategy": "exact", "dimensions": [ {"key": "resolution", "source": "request.resolution", "type": "string", "default": null}, {"key": "duration", "source": "request.duration", "type": "number", "default": null} ], "table": [ {"resolution": "768P", "duration": 10, "price": 0.04, "source": "manual"}, {"resolution": "1080P", "duration": 10, "price": 0.08, "source": "manual"} ], "fallback": {"strategy": "reject"} }' | jq ``` ### P03 读取单配置 ```bash curl -s "$BASE/api/option/model_pricing/hailuo-video" \ -H "Cookie: $ADMIN_COOKIE" -H "New-Api-User: 1" | jq ``` ### P05 删除配置 ```bash curl -s -X DELETE "$BASE/api/option/model_pricing/hailuo-video" \ -H "Cookie: $ADMIN_COOKIE" -H "New-Api-User: 1" | jq ``` --- ## 二、配置校验(V01–V17) 使用 P02 的 body 修改字段来触发各种校验错误: ### V07 per_call + minimum 冲突 ```bash curl -s -X PUT "$BASE/api/option/model_pricing/test-v" \ -H "Cookie: $ADMIN_COOKIE" -H "New-Api-User: 1" \ -H "Content-Type: application/json" -d '{ "schema_version": 1, "scope": "model", "billing_unit": "per_call", "preconsume_strategy": "minimum", "dimensions": [{"key":"r","source":"request.resolution","type":"string","default":null}], "table": [{"r":"x","price":0.04,"source":"manual"}], "fallback": {"strategy": "reject"} }' | jq # 预期: {"success": false, "message": "billing_unit per_call requires..."} ``` --- ## 三、计费验证(E01–E08) 需要先配置定价,再提交视频任务,观察 quota 变化。 ### E01 精确匹配 — 提交任务 ```bash # 1. 配置定价表 curl -s -X PUT "$BASE/api/option/model_pricing/hailuo-video" \ -H "Cookie: $ADMIN_COOKIE" -H "New-Api-User: 1" \ -H "Content-Type: application/json" -d '{ "schema_version": 1, "scope": "model", "billing_unit": "per_call", "preconsume_strategy": "exact", "dimensions": [ {"key": "res", "source": "request.resolution", "type": "string", "default": null} ], "table": [{"res": "768P", "price": 0.04, "source": "manual"}], "fallback": {"strategy": "reject"} }' # 2. 查询当前配额 Q_BEFORE=$(curl -s "$BASE/api/user/self" \ -H "Authorization: Bearer $TOKEN" | jq '.data.quota') echo "Quota before: $Q_BEFORE" # 3. 提交视频任务 TASK_ID=$(curl -s -X POST "$BASE/v1/videos" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"model":"hailuo-video","prompt":"test","resolution":"768P"}' \ | jq -r '.id') echo "Task: $TASK_ID" # 4. 等待完成(约 45 秒) sleep 50 # 5. 查询任务结果 curl -s "$BASE/v1/videos/$TASK_ID" \ -H "Authorization: Bearer $TOKEN" | jq # 6. 查询配额 Q_AFTER=$(curl -s "$BASE/api/user/self" \ -H "Authorization: Bearer $TOKEN" | jq '.data.quota') echo "Quota after: $Q_AFTER" echo "Delta: $((Q_BEFORE - Q_AFTER))" # 预期 delta = 20000 (= 0.04 × 500000) ``` ### E04 不匹配 → reject ```bash curl -i -X POST "$BASE/v1/videos" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"model":"hailuo-video","prompt":"reject test","resolution":"NOT_IN_TABLE"}' # 预期: HTTP 400, quota 不变 ``` ### E03 Wildcard 匹配 配置 `"res": "*"` + `"dur": 10`,发送任意 resolution → 匹配 wildcard 行 → quota 扣 0.05×500000=25000 ### E05 Fallback=max 配置 `"fallback": {"strategy": "max"}`,发不匹配请求 → 按表中最高价 0.10 计费 ### E06 Fallback=default 配置 `"fallback": {"strategy": "default", "default_price": 0.07}` → 不匹配时按 0.07×500000=35000 计费 --- ## 四、Per 1M Tokens 计费(E09–E14,需 mock 上游) ```bash # 配置 Doubao/Seedance 的 per_1m_tokens 定价 curl -s -X PUT "$BASE/api/option/model_pricing/seedance-2" \ -H "Cookie: $ADMIN_COOKIE" -H "New-Api-User: 1" \ -H "Content-Type: application/json" -d '{ "schema_version": 1, "scope": "model", "billing_unit": "per_1m_tokens", "preconsume_strategy": "minimum", "dimensions": [ {"key": "res", "source": "request.resolution", "type": "string", "default": null} ], "table": [{"res": "1080P", "price": 200, "source": "manual"}], "fallback": {"strategy": "reject"} }' # 提交任务(需 DoubaoVideo 渠道) curl -s -X POST "$BASE/v1/videos" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"model":"seedance-2","prompt":"test","resolution":"1080P","_mock_total_tokens":1000000}' # 预扣: PreConsumedQuota × 200 × ratio / 1M ≈ 1 quota # 结算: 1000000 × 200 / 1M × QuotaPerUnit × ratio ``` --- ## 五、Remix 计费(E15–E18) ```bash # 对已完成的视频任务进行 remix curl -s -X POST "$BASE/v1/videos/$ORIGINAL_VIDEO_ID/remix" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"model":"hailuo-video","prompt":"remix version"}' # 预期: 继承原任务的定价配置, 预扣与原始任务相同 ``` --- ## 快速自检清单 | # | 操作 | 验证点 | ✓ | |---|------|--------|---| | 1 | 创建配置 | API 返回 200,含完整配置 | | | 2 | 非法 schema_version=2 | API 返回 400 | | | 3 | 精确匹配提交任务 | quota 扣除 = price × 500000 | | | 4 | 不匹配+reject | 400 + quota 不变 | | | 5 | Wildcard 匹配 | 正确匹配 * 行 | | | 6 | Fallback max | 扣表中最高价 | | | 7 | Fallback default | 扣 default_price | | | 8 | 删除配置 | 200 | | | 9 | 删除后读取 | 404 | |