From 2dffd76d05646039b2b87b167c7c52702d9eef89 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 10 Apr 2026 21:15:38 +0800 Subject: [PATCH] bugfix --- accounting/test_accounting.py | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 accounting/test_accounting.py diff --git a/accounting/test_accounting.py b/accounting/test_accounting.py new file mode 100644 index 0000000..90a9e11 --- /dev/null +++ b/accounting/test_accounting.py @@ -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()) +