This commit is contained in:
yumoqing 2026-04-10 21:15:38 +08:00
parent 8613abf6c0
commit 2dffd76d05

View File

@ -0,0 +1,47 @@
import asyncio
import sys
from sqlor.dbpools import DBPools, get_sor_context
from appPublic.dictObject import DictObject
from timeUtils import curDateString, timestampstr
from accounting.consume import consume_accounting
async def get_orgid_by_username(sor, username):
recs = await sor.R('users', {'username': username})
if len(recs):
return recs[0].orgid
return None
async def accounting(username):
env = ServerEnv()
async with get_sor_context(env, 'accounting') as sor:
customerid = await get_orgid_by_username(sor, username)
resellerid = '0'
ais = []
for i in range(10):
d = DictObject()
d.customerid = customerid
d.resellerid = '0'
d.action = 'PAY_REVERSE' if i % 2 ==0 else 'PAY'
d.biz_date = curDateString()
d.timestamp = timstampstr()
d.productid = 'test_product'
d.transamt = 123.432
d.variable = {
"交易金额": 123.432,
"交易手续费": 0
}
ais.append(d)
orderid = 'test_orderid'
await consume_accounting(sor, orderid, ais)
async def main():
if len(sys.argv) < 2:
print(f'{sys.argv[0]} username')
sys.exit(1)
username = sys.argv[1]
await accounting(username)
if __name__ == '__main__':
asyncio.run(main())