From 86057eaa3bd176f7aa830dc9ab03f0f352ec9f54 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 31 Jul 2026 14:57:25 +0800 Subject: [PATCH] feat: integrate Redis balance finalize_balance after consume_accounting --- product_management/core.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/product_management/core.py b/product_management/core.py index b86bdef..af9b5d2 100644 --- a/product_management/core.py +++ b/product_management/core.py @@ -1527,6 +1527,15 @@ WHERE resource_ref_id = ${llm_id}$ AND product_type = 'llm_model' LIMIT 1""" await sor.C('biz_orderdetail', orderdetail) await consume_accounting(sor, orderid, accounting_items) + # Finalize Redis balance reservation (non-critical) + try: + luid = getattr(llmusage, 'id', None) + if luid: + from llmage.balance import finalize_balance + await finalize_balance(ServerEnv(), luid, customer_amount) + except Exception as e: + exception(f'finalize_balance failed (non-critical): {e}') + # Mark llmusage as accounted lmage_dbname = ServerEnv().get_module_dbname('llmage') async with db.sqlorContext(lmage_dbname) as sor: