From 7ab8d4b8e8985503eb1330fcd099b5f7aaee3b0d Mon Sep 17 00:00:00 2001 From: CI Bot Date: Wed, 16 Sep 2026 01:04:43 +0000 Subject: [PATCH] style: auto-format with black + isort + ruff + prettier [skip ci-format-check] --- apps/api/app/api/routes/points.py | 2 +- apps/api/app/schemas/points.py | 4 ++- packages/domain/points_rules.py | 42 ++++++++++++++++++++++++++----- tests/unit/test_points_routes.py | 1 + 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/apps/api/app/api/routes/points.py b/apps/api/app/api/routes/points.py index e5c72d914..39889e267 100644 --- a/apps/api/app/api/routes/points.py +++ b/apps/api/app/api/routes/points.py @@ -36,9 +36,9 @@ from fastapi import APIRouter, Depends, HTTPException, Query from sqlalchemy.orm import Session from packages.domain.points_rules import ( - MEMBERSHIP_PRICES, FREE_USER_MULTIPLIER, MEMBER_DISCOUNT, + MEMBERSHIP_PRICES, POINTS_PACKAGES, POINTS_SCENES, calculate_points_cost, diff --git a/apps/api/app/schemas/points.py b/apps/api/app/schemas/points.py index 9a135c3c0..6424b28a1 100644 --- a/apps/api/app/schemas/points.py +++ b/apps/api/app/schemas/points.py @@ -142,7 +142,9 @@ class PointsOrderResponse(BaseModel): amount_cents: int points_amount: int = Field(0, description="本次充值/购买可获得的积分(仅 points 类型订单有意义)") status: str - pay_params: dict[str, Any] = Field(default_factory=dict, description="拉起支付所需参数(payment_url/prepay_id 等),支付通道接入后填充") + pay_params: dict[str, Any] = Field( + default_factory=dict, description="拉起支付所需参数(payment_url/prepay_id 等),支付通道接入后填充" + ) expire_at: Optional[str] = Field(None, description="订单过期时间(ISO 8601),默认创建后 48 小时") created_at: Optional[str] = None diff --git a/packages/domain/points_rules.py b/packages/domain/points_rules.py index 78d8ba20a..5bc6dc12a 100644 --- a/packages/domain/points_rules.py +++ b/packages/domain/points_rules.py @@ -8,7 +8,12 @@ import math # 每个场景: base_points(基础积分), unit(计费单位), name(显示名称) POINTS_SCENES: dict[str, dict] = { - "ai_voice": {"base_points": 1, "unit": "分钟", "name": "AI 配音", "description": "AI 配音每分钟消耗 1 积分(免费用户上浮 15%,会员 8~9 折)"}, + "ai_voice": { + "base_points": 1, + "unit": "分钟", + "name": "AI 配音", + "description": "AI 配音每分钟消耗 1 积分(免费用户上浮 15%,会员 8~9 折)", + }, "ai_video": { "base_points": 3, "unit": "条", @@ -16,12 +21,37 @@ POINTS_SCENES: dict[str, dict] = { "extra_per_30s": 1, "description": "智能混剪每条 3 积分起,视频超过 30 秒后每 30 秒加 1 积分;免费用户每日 2 条免费额度", }, - "ai_digital_human": {"base_points": 15, "unit": "分钟", "name": "AI 数字人", "description": "AI 数字人每分钟消耗 15 积分"}, - "voice_clone_train": {"base_points": 0, "unit": "次", "name": "声音克隆训练", "description": "声音克隆训练免费(每用户限 1 个声音)"}, - "voice_clone_synth": {"base_points": 1, "unit": "分钟", "name": "声音克隆合成", "description": "克隆音色合成每分钟消耗 1 积分"}, - "douyin_extract": {"base_points": 1, "unit": "次", "name": "抖音链接提取", "description": "抖音文案提取每次 1 积分"}, + "ai_digital_human": { + "base_points": 15, + "unit": "分钟", + "name": "AI 数字人", + "description": "AI 数字人每分钟消耗 15 积分", + }, + "voice_clone_train": { + "base_points": 0, + "unit": "次", + "name": "声音克隆训练", + "description": "声音克隆训练免费(每用户限 1 个声音)", + }, + "voice_clone_synth": { + "base_points": 1, + "unit": "分钟", + "name": "声音克隆合成", + "description": "克隆音色合成每分钟消耗 1 积分", + }, + "douyin_extract": { + "base_points": 1, + "unit": "次", + "name": "抖音链接提取", + "description": "抖音文案提取每次 1 积分", + }, "ai_rewrite": {"base_points": 1, "unit": "次", "name": "AI 改写文案", "description": "AI 改写文案每次 1 积分"}, - "ai_title": {"base_points": 1, "unit": "次", "name": "AI 标题生成", "description": "AI 生成标题每次 1 积分(免费用户实际上浮后 2 积分/次)"}, + "ai_title": { + "base_points": 1, + "unit": "次", + "name": "AI 标题生成", + "description": "AI 生成标题每次 1 积分(免费用户实际上浮后 2 积分/次)", + }, "ai_cover": {"base_points": 1, "unit": "张", "name": "AI 封面生成", "description": "AI 封面生成每张 1 积分"}, } diff --git a/tests/unit/test_points_routes.py b/tests/unit/test_points_routes.py index 653a4b037..7bc09eda9 100644 --- a/tests/unit/test_points_routes.py +++ b/tests/unit/test_points_routes.py @@ -181,6 +181,7 @@ class TestMultiplierConsistency: """check 端点 required_points 与 calculate_points_cost 结果一致。""" from app.api.routes.points import check_points from app.schemas.points import PointsCheckRequest + from packages.domain.points_rules import calculate_points_cost svc = MagicMock()