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