bugfix
This commit is contained in:
parent
b2bca68160
commit
93e12c2bad
@ -3,11 +3,14 @@ import json
|
||||
import time
|
||||
import datetime
|
||||
from appPublic.uniqueID import getID
|
||||
import json, time
|
||||
|
||||
from appPublic.dictObject import DictObject
|
||||
from appPublic.log import info, error, exception, debug
|
||||
from appPublic.jsonConfig import getConfig
|
||||
from sqlor.dbpools import DBPools
|
||||
from ahserver.serverenv import ServerEnv
|
||||
from accounting.consume import consume_accounting
|
||||
|
||||
|
||||
MODULE_NAME = "product_management"
|
||||
@ -1346,10 +1349,6 @@ WHERE resource_ref_id = ${llm_id}$ AND product_type = 'llm_model' LIMIT 1"""
|
||||
4. Compute final amounts with discounts for each party
|
||||
5. Build accounting items and call consume_accounting
|
||||
"""
|
||||
from appPublic.uniqueID import getID as _getID
|
||||
from accounting.consume import consume_accounting
|
||||
import json, time
|
||||
|
||||
env = ServerEnv()
|
||||
llmid = llmusage.llmid
|
||||
userorgid = llmusage.userorgid
|
||||
@ -1432,7 +1431,7 @@ WHERE resource_ref_id = ${llm_id}$ AND product_type = 'llm_model' LIMIT 1"""
|
||||
# Each link: PAY* (reseller→provider) except last link: PAY (customer→reseller)
|
||||
biz_date = await env.get_business_date(None) # will use default
|
||||
timestamp = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
orderid = _getID()
|
||||
orderid = getID()
|
||||
|
||||
# Determine supplier discount (for last link to provider)
|
||||
last_link_discount = 1.0
|
||||
@ -1518,7 +1517,7 @@ WHERE resource_ref_id = ${llm_id}$ AND product_type = 'llm_model' LIMIT 1"""
|
||||
}
|
||||
await sor.C('biz_order', order)
|
||||
orderdetail = {
|
||||
"id": _getID(),
|
||||
"id": getID(),
|
||||
"orderid": orderid,
|
||||
"productid": product_id,
|
||||
"product_cnt": 1,
|
||||
@ -1529,7 +1528,6 @@ WHERE resource_ref_id = ${llm_id}$ AND product_type = 'llm_model' LIMIT 1"""
|
||||
await consume_accounting(sor, orderid, accounting_items)
|
||||
|
||||
# Mark llmusage as accounted
|
||||
from ahserver.serverenv import ServerEnv
|
||||
lmage_dbname = ServerEnv().get_module_dbname('llmage')
|
||||
async with db.sqlorContext(lmage_dbname) as sor:
|
||||
await sor.U('llmusage', {
|
||||
@ -1567,7 +1565,6 @@ WHERE resource_ref_id = ${llm_id}$ AND product_type = 'llm_model' LIMIT 1"""
|
||||
await self.product_accounting(lu)
|
||||
# Clean up failed records
|
||||
try:
|
||||
from ahserver.serverenv import ServerEnv
|
||||
lmage_dbname = ServerEnv().get_module_dbname('llmage')
|
||||
async with DBPools().sqlorContext(lmage_dbname) as sor:
|
||||
await sor.execute(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user