from datetime import datetime from appPublic.uniqueID import getID from sqlor.dbpools import DBPools from appPublic.timeUtils import curDateString from appPublic.argsConvert import ArgsConvert from .accounting_config import get_accounting_config, AccountingOrgs from .const import * from .accountingnode import get_accounting_nodes from .excep import * from .getaccount import getAccountByName from .businessdate import get_business_date from .recharge import RechargeAccounting class AlipayAccountingOrgs(AccountingOrgs): def __init__(self, caller, accounting_orgid, customerid, resellerid=None): super(AlipayAccountingOrgs, self). __init__(caller, accounting_orgid, customerid, resellerid=resellerid) self.variable['手续费'] = self.caller.fee_amt async def get_act_specstr(self): return ACTNAME_RECHARGE_ALIPAY class AlipayRechargeAccounting(RechargeAccounting): def __init__(self, recharge_log): super(AlipayRechargeAccounting, self).__init__(recharge_log) self.fee_amt = recharge_log['fee_amt'] async def accounting(self, sor): self.sor = sor bz_date = await get_business_date(sor=sor) if bz_date != self.curdate: raise AccountingDateNotInBusinessDate(self.curdate, bz_date) nodes = await get_accounting_nodes(sor, self.customerid) lst = len(nodes) - 1 self.accountingOrgs = [] for i, n in enumerate(nodes): if i < lst: ao = AlipayAccountingOrgs(self, nodes[i], self.customerid, resellerid=nodes[i+1]) else: ao = AlipayAccountingOrgs(self, nodes[i], self.customerid) self.accountingOrgs.append(ao) await self.write_bill(sor) [await ao.do_accounting(sor) for ao in self.accountingOrgs ] print(f'recharge ok for {self.bill}, {nodes=}') return True