diff --git a/accounting/init.py b/accounting/init.py index c2fc277..2c2c9b5 100644 --- a/accounting/init.py +++ b/accounting/init.py @@ -7,10 +7,12 @@ from accounting.bill import write_bill from accounting.openaccount import openOwnerAccounts, openProviderAccounts, openResellerAccounts, openCustomerAccounts from accounting.getaccount import getAccountBalance, getCustomerBalance, getAccountByName, get_account_total_amount from accounting.bizaccount import BizAccounting +from accounting.recharge import RechargeAccounting, recharge_accounting def load_accounting(): g = ServerEnv() g.Accounting = Accounting + g.RechargeAccounting = RechargeAccounting g.write_bill = write_bill g.openOwnerAccounts = openOwnerAccounts g.openProviderAccounts = openProviderAccounts @@ -21,3 +23,4 @@ def load_accounting(): g.getAccountByName = getAccountByName g.get_account_total_amount = get_account_total_amount g.BizAccounting = BizAccounting + g.recharge_accounting = recharge_accounting diff --git a/accounting/recharge.py b/accounting/recharge.py index 85423f7..bba91ea 100644 --- a/accounting/recharge.py +++ b/accounting/recharge.py @@ -1,6 +1,7 @@ from datetime import datetime from appPublic.uniqueID import getID +from appPublic.log import debug, exception from sqlor.dbpools import DBPools from appPublic.timeUtils import curDateString from appPublic.argsConvert import ArgsConvert @@ -33,7 +34,7 @@ class RechargeAccounting: 'id':self.billid, 'customerid':self.recharge_log['customerid'], 'resellerid':None, - 'orderid':None, + 'orderid':recharge_log['orderid'], 'business_op':self.recharge_log['action'], 'amount':self.recharge_log['recharge_amt'], 'bill_date':self.curdate, @@ -63,15 +64,21 @@ class RechargeAccounting: await sor.C('bill', self.bill.copy()) # await sor.C('recharge_log', self.recharge_log.copy()) -async def recharge_accounting(sor, customerid, action, orderid, transdate, recharge_amt): +async def recharge_accounting(sor, customerid, action, orderid, + transdate, recharge_amt, recharge_fee): """ summary:recharge channe(handly, wechat, alipay) """ + if action not in ['RECHARGE', 'RECHARGE_REVESE']: + e = Exception(f'get a wrong recharge action({action})' + exception(f'{e}') + raise e recharge_log = { "customerid":customerid, "transdate":transdate, "orderid":orderid, "recharge_amt":recharge_amt, + "recharge_fee": recharge_fee, "action":action, } ra = RechargeAccounting(recharge_log)