积分消耗明细改版V1
This commit is contained in:
@@ -55,7 +55,7 @@ from app.services.llm_billing import (
|
||||
log_provider_success,
|
||||
finalize_llm_business_failure,
|
||||
mark_business_success,
|
||||
pre_deduct,
|
||||
charge_llm_credits,
|
||||
)
|
||||
from app.services.operation_log_service import log_operation_error, log_operation_event
|
||||
from app.services.video_upscale.snapshot_service import build_video_upscale_snapshot
|
||||
@@ -466,7 +466,7 @@ async def optimize_generation_prompt(
|
||||
|
||||
ctx = _billing_context(user_id=user_id, record_id=record_id, request_id=req.idempotency_key)
|
||||
try:
|
||||
await pre_deduct(db, ctx)
|
||||
await charge_llm_credits(db, ctx)
|
||||
await db.commit()
|
||||
except Exception:
|
||||
await db.rollback()
|
||||
@@ -638,7 +638,7 @@ async def optimize_generation_prompt(
|
||||
)
|
||||
# 供应商调用和 Token 已由独立调用审计事务保存。结果连续暂存失败后,
|
||||
# 当前 API 已没有可继续恢复的本地业务结果,必须先结束业务状态,再按
|
||||
# 原积分来源退回固定预扣,不能让账务永久停留在 processing。
|
||||
# 原积分来源退回场景积分消费,不能让账务永久停留在 processing。
|
||||
business_already_succeeded = False
|
||||
try:
|
||||
await db.rollback()
|
||||
@@ -672,7 +672,7 @@ async def optimize_generation_prompt(
|
||||
if business_already_succeeded:
|
||||
return PromptOptimizeServiceResult(record_id=record_id, idempotent=True)
|
||||
await finalize_llm_business_failure(ctx, error=str(failure))
|
||||
raise HTTPException(status_code=503, detail="提词已生成但本地暂存失败,固定预扣积分已按原来源退回")
|
||||
raise HTTPException(status_code=503, detail="提词已生成但本地暂存失败,场景消费积分已按原来源退回")
|
||||
|
||||
_log_event(
|
||||
GenerationRecordEventTypeEnum.PROMPT_OPTIMIZE_PROVIDER_RESULT_STAGED,
|
||||
|
||||
Reference in New Issue
Block a user