bugfix
This commit is contained in:
parent
13e7ae95d6
commit
d392edb8c1
@ -4,54 +4,31 @@ from sqlor.dbpools import DBPools
|
|||||||
from appPublic.timeUtils import curDateString, timestampstr
|
from appPublic.timeUtils import curDateString, timestampstr
|
||||||
from appPublic.argsConvert import ArgsConvert
|
from appPublic.argsConvert import ArgsConvert
|
||||||
from appbase.businessdate import get_business_date
|
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 .const import *
|
||||||
from .accountingnode import get_accounting_nodes
|
from .accountingnode import get_accounting_nodes
|
||||||
from .excep import *
|
from .excep import *
|
||||||
from .getaccount import getAccountByName
|
from .getaccount import getAccountByName
|
||||||
|
|
||||||
class ConsumeBiz(PFBiz):
|
class ConsumeBiz(PFBiz):
|
||||||
def __init__(self, consume_logs):
|
def __init__(self, od):
|
||||||
self.db = DBPools()
|
self.db = DBPools()
|
||||||
self.consume_logs = consume_logs
|
self.action = od.action
|
||||||
|
self.orderid = od['orderid']
|
||||||
async def accounting(self, sor):
|
|
||||||
self.sor = sor
|
|
||||||
self.orderid = self.consume_logs[0]['orderid']
|
|
||||||
self.curdate = await get_business_date(sor)
|
self.curdate = await get_business_date(sor)
|
||||||
self.timestamp = timestampstr()
|
self.timestamp = timestampstr()
|
||||||
self.action = self.consume_logs[0]['action']
|
self.action = od['action']
|
||||||
self.billid = getID()
|
self.billid = getID()
|
||||||
if self.action not in ['PAY', 'PAY_REVERSE']:
|
self.customerid = od['customerid']
|
||||||
e = Exception(f'{self.action} action not defined')
|
self.resellerid = od['resellerid']
|
||||||
exception(f'{__file__}:{__line__}:{e}')
|
self.transamount = od['recharge_amt']
|
||||||
raise e
|
self.productid = od['productid']
|
||||||
|
# self.providerid = od['providerid']
|
||||||
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.summary = f'{self.action}|{self.customerid}|{self.resellerid}|{self.productid}'
|
||||||
self.variable = {
|
self.variable = {
|
||||||
"交易金额": log['transamt'],
|
"交易金额": log['transamt'],
|
||||||
"交易手续费": log['transfee']
|
"交易手续费": 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):
|
async def get_orgid_by_trans_role(self, sor, leg, role):
|
||||||
if role == 'owner':
|
if role == 'owner':
|
||||||
@ -66,3 +43,23 @@ class ConsumeBiz(PFBiz):
|
|||||||
exception(f'Exception:{e}')
|
exception(f'Exception:{e}')
|
||||||
raise 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