用户生成资源容量管控

This commit is contained in:
2026-06-29 13:50:39 +08:00
parent b21f35582e
commit 25fa41f894
21 changed files with 1314 additions and 80 deletions
@@ -33,6 +33,7 @@ from app.services.generation_billing_service import (
)
from app.services.generation_log_service import log_task_event
from app.services.generation_refund_service import mark_chat_generation_task_failed_and_refund_once
from app.services.resource_capacity_service import assert_user_resource_capacity_available
from app.tasks.celery_app import celery_app
router = APIRouter(
@@ -566,6 +567,8 @@ async def retry_task(
if task.status != "failed":
raise HTTPException(status_code=400, detail="只有失败任务可以重试")
await assert_user_resource_capacity_available(db, current_user.id)
attempt_no = await get_next_credit_attempt_no(
db,
owner_type=OWNER_CHAT_GENERATION_TASK,