From a56b15c92ccb174b27b53956b57633e626be2438 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 11 Jan 2025 19:40:06 +0800 Subject: [PATCH] bugfix --- platformbiz/accounting.py | 6 ++++ platformbiz/init.py | 12 ++++++++ platformbiz/pb_acc.py | 58 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 platformbiz/accounting.py create mode 100644 platformbiz/init.py create mode 100644 platformbiz/pb_acc.py diff --git a/platformbiz/accounting.py b/platformbiz/accounting.py new file mode 100644 index 0000000..25e1ca6 --- /dev/null +++ b/platformbiz/accounting.py @@ -0,0 +1,6 @@ + +async def get_accounting_orgid(sor, leg): + return '0' + +async def get_accountid(sor, leg): + diff --git a/platformbiz/init.py b/platformbiz/init.py new file mode 100644 index 0000000..d5e78d3 --- /dev/null +++ b/platformbiz/init.py @@ -0,0 +1,12 @@ +from ahserver.serverenv import ServerEnv, get_serverenv +from platformbiz.recharge import Recharge +from platformbiz.pb_acc import PlatformBizAccRecharge, get_owner_orgid +from platformbiz.biz_order import change_recharge_status + +def load_platformbiz(): + g = ServerEnv() + g.Recharge = Recharge + g.PlatformBizAccRecharge = PlatformBizAccRecharge + g.change_recharge_status = change_recharge_status + g.get_owner_orgid = get_owner_orgid + diff --git a/platformbiz/pb_acc.py b/platformbiz/pb_acc.py new file mode 100644 index 0000000..948c340 --- /dev/null +++ b/platformbiz/pb_acc.py @@ -0,0 +1,58 @@ +import time +from appPublic.timeUtils import timestampstr +from ahserver.serverenv import get_serverenv +from accounting.accounting_config import Accounting +from accounting.bill import write_bill + +def get_owner_orgid(sor, orgid): + return '0' + +class PlatformBizAcc: + async def get_orgid_by_trans_role(self, sor, orgtype): + if orgtype== 'customer': + return self.customerid + if orgtype== 'reseller': + return self.resellerid + if orgtype== 'provider': + return self.providerid + if orgtype == 'owner': + return '0' + return None + +class PlatformBizAccRecharge(PlatformBizAcc): + def __init__(self, rlid): + self.rlid = rlid + + async def accounting(self, sor): + sql = """select * from recharge_log where id=${rlid}$""" + recs = await sor.sqlExe(sql, {'rlid':self.rlid}) + if len(recs) < 1: + e = Exception(f'get recharge log err by {rlid=}') + exception(f'{e=}') + raise e + self.recharge = recs[0] + self.customerid = self.recharge.customerid + self.orderid = self.recharge.orderid + self.userid = self.recharge.userid + get_business_date = get_serverenv('get_business_date') + self.curdate = await get_business_date(sor) + self.variable = { + "交易金额":self.recharge.recharge_amt, + "充值费率":self.recharge.fee_rate, + "充值费用":self.recharge.feemat + } + bill = await write_bill(sor, self.customerid, self.userid, + self.recharge.orderid, + self.recharge.action, + self.recharge.recharge_amt) + + self.billid = bill.id + self.bill = bill + self.providerid = None + self.resellerid = None + self.action = self.recharge.action + self.productid = None + self.timestamp = timestampstr() + a = Accounting(self) + r = await a.do_accounting(sor) +