bugfix
This commit is contained in:
parent
13e7ae95d6
commit
d392edb8c1
@ -4,55 +4,32 @@ from sqlor.dbpools import DBPools
|
||||
from appPublic.timeUtils import curDateString, timestampstr
|
||||
from appPublic.argsConvert import ArgsConvert
|
||||
from appbase.businessdate import get_business_date
|
||||
from .accounting_config import get_accounting_config, PFBiz
|
||||
from .accounting_config import get_accounting_config, PFBiz, Accounting
|
||||
from .const import *
|
||||
from .accountingnode import get_accounting_nodes
|
||||
from .excep import *
|
||||
from .getaccount import getAccountByName
|
||||
|
||||
class ConsumeBiz(PFBiz):
|
||||
def __init__(self, consume_logs):
|
||||
def __init__(self, od):
|
||||
self.db = DBPools()
|
||||
self.consume_logs = consume_logs
|
||||
|
||||
async def accounting(self, sor):
|
||||
self.sor = sor
|
||||
self.orderid = self.consume_logs[0]['orderid']
|
||||
self.action = od.action
|
||||
self.orderid = od['orderid']
|
||||
self.curdate = await get_business_date(sor)
|
||||
self.timestamp = timestampstr()
|
||||
self.action = self.consume_logs[0]['action']
|
||||
self.action = od['action']
|
||||
self.billid = getID()
|
||||
if self.action not in ['PAY', 'PAY_REVERSE']:
|
||||
e = Exception(f'{self.action} action not defined')
|
||||
exception(f'{__file__}:{__line__}:{e}')
|
||||
raise e
|
||||
self.customerid = od['customerid']
|
||||
self.resellerid = od['resellerid']
|
||||
self.transamount = od['recharge_amt']
|
||||
self.productid = od['productid']
|
||||
# self.providerid = od['providerid']
|
||||
self.summary = f'{self.action}|{self.customerid}|{self.resellerid}|{self.productid}'
|
||||
self.variable = {
|
||||
"交易金额": log['transamt'],
|
||||
"交易手续费": log['transfee']
|
||||
}
|
||||
|
||||
for i, log in enumerate(self.consume_logs):
|
||||
self.customerid = log['customerid']
|
||||
self.resellerid = log['resellerid']
|
||||
self.transamount = log['recharge_amt']
|
||||
self.productid = log['productid']
|
||||
# self.providerid = log['providerid']
|
||||
self.summary = f'{self.action}|{self.customerid}|{self.resellerid}|{self.productid}'
|
||||
self.variable = {
|
||||
"交易金额": log['transamt'],
|
||||
"交易手续费": log['transfee']
|
||||
}
|
||||
if i == 0:
|
||||
self.bill = {
|
||||
'id':self.billid,
|
||||
'customerid':self.customerid,
|
||||
'resellerid':self.resellerid,
|
||||
'orderid':self.orderid,
|
||||
'business_op':self.action,
|
||||
'amount':log['transamt'],
|
||||
'bill_date':self.curdate,
|
||||
'bill_timestamp':self.timestamp
|
||||
}
|
||||
await sor.C('bill', self.bill.copy())
|
||||
ao = Accounting(self)
|
||||
await ao.do_accounting(sor)
|
||||
|
||||
async def get_orgid_by_trans_role(self, sor, leg, role):
|
||||
if role == 'owner':
|
||||
return '0'
|
||||
@ -65,4 +42,24 @@ class ConsumeBiz(PFBiz):
|
||||
e = Exception(f'unknown role({role})')
|
||||
exception(f'Exception:{e}')
|
||||
raise e
|
||||
|
||||
|
||||
async def consume_accounting(sor, orderid, order_details):
|
||||
ods = []
|
||||
billid = getID()
|
||||
for od in order_details:
|
||||
od['billid'] = billid
|
||||
od['orderid'] = orderid
|
||||
ods.append(ConsumeBiz(od))
|
||||
ao = Accounting(ods)
|
||||
bill = {
|
||||
'id':self.billid,
|
||||
'customerid':self.customerid,
|
||||
'resellerid':self.resellerid,
|
||||
'orderid':self.orderid,
|
||||
'business_op':self.action,
|
||||
'amount':log['transamt'],
|
||||
'bill_date':self.curdate,
|
||||
'bill_timestamp':self.timestamp
|
||||
}
|
||||
await sor.C('bill', bill.copy())
|
||||
await ao.do_accounting(sor)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user