From ca3953128bdf105f18d41e78d45c04f0f175e763 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 21 Mar 2025 18:20:10 +0800 Subject: [PATCH] bugfix --- platformbiz/pb_acc.py | 66 ++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 42 deletions(-) diff --git a/platformbiz/pb_acc.py b/platformbiz/pb_acc.py index cadb5da..fc0d8bb 100644 --- a/platformbiz/pb_acc.py +++ b/platformbiz/pb_acc.py @@ -27,57 +27,39 @@ class PlatformBizAcc: def build_accountset(self, sor, biz_order, biz_orderdetails): acconuntset = DictObject() accountset['action'] = biz_order.business_op - accountset['平台'] = get_owner_orgid(sor, '0') - accountset['分销商'] = biz_order.resellerid - accountset['客户'] = biz_order.customerid + accountset['owner'] = get_owner_orgid(sor, '0') + accountset['reseller'] = biz_order.resellerid + accountset['customer'] = biz_order.customerid accountset['交易金额'] = biz_order.amount transfee = await get_transfee(sor, self.resellerid, biz_order.amount, self.curdate) accountset['交易费用'] = transfee accountset.subsets = [] for od in biz_orderdetails: - actions = biz_order.business_op.split('_') - actions[0] = actions[0] + '*' - aset = DictObject() - aset['action'] = '_'.join(actions) - aset['分销商'] = - - async def accounting(self, sor, biz_orderid): - biz_order = await sor.R('biz_order', {'id':biz_orderid}) - details = await sor.R('biz_orderdetail',{'orderid':biz_orderid}) - self.customerid = biz_order.customerid - self.resellerid = biz_order.resellerid - self.orderid = biz_order.id - self.userid = biz_order.userid - self.business_op = biz_order.business_op - get_business_date = get_serverenv('get_business_date') - self.curdate = await get_business_date(sor) - self.transamt = biz_order.amount - transfee = await get_transfee(sor, self.resellerid, biz_order.amount, self.curdate) - self.variable = { - "交易金额":biz_order.amount, - "交易费用":transfee - } - bill = await write_bill(sor, self.customerid, self.userid, - self.orderid, - self.business_op, - biz_order.amount) - - 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) - for detail in details: - detail.prod_config = json.loads(detail.prod_config) price_infos = await get_price_infos(sor, self.resellerid, self.customerid, detail.productid, detail.prod_config) - + if len(price_infos) > 1: + for pi in price_infos[:-1]: + actions = biz_order.business_op.split('_') + actions[0] = actions[0] + '*' + aset = DictObject() + aset['action'] = '_'.join(actions) + aset['owner'] = get_owner_orgid(sor, '0') + aset['reseller'] = pi['buyerid'] + aset['provider'] = pi['resellerid'] + aset['采购成本'] = pi['sell_price'] + accountset.subsets.append(aset) + return accountset + + async def accounting(self, sor, biz_orderid): + biz_order = await sor.R('biz_order', {'id':biz_orderid}) + details = await sor.R('biz_orderdetail',{'orderid':biz_orderid}) + accountset = await self.build_accountset(biz_order, details) + self.curdate = await get_business_date(sor) + transfee = await get_transfee(sor, self.resellerid, biz_order.amount, self.curdate) + a = BizAccounting(self.curdate, biz_order, accountset) + r = await a.do_accounting(sor) async def get_orgid_by_trans_role(self, sor, orgtype): if orgtype== 'customer':