bugfix
This commit is contained in:
parent
bcb47f31de
commit
a176289226
@ -1,6 +1,6 @@
|
||||
from ahserver.serverenv import ServerEnv, get_serverenv
|
||||
from platformbiz.recharge import Recharge
|
||||
from platformbiz.pb_acc import PlatformBizAccRecharge, get_owner_orgid
|
||||
from platformbiz.pb_acc import PlatformBizAccRecharge, get_owner_orgid, get_balance
|
||||
from platformbiz.biz_order import change_recharge_status
|
||||
|
||||
def load_platformbiz():
|
||||
@ -9,4 +9,5 @@ def load_platformbiz():
|
||||
g.PlatformBizAccRecharge = PlatformBizAccRecharge
|
||||
g.change_recharge_status = change_recharge_status
|
||||
g.get_owner_orgid = get_owner_orgid
|
||||
g.get_balance = get_balance
|
||||
|
||||
|
@ -1,12 +1,24 @@
|
||||
import time
|
||||
from appPublic.timeUtils import timestampstr
|
||||
from appPublic.registerfunction import rfexe
|
||||
from sqlor.dbpools import DBPools
|
||||
from ahserver.serverenv import get_serverenv
|
||||
from accounting.accounting_config import Accounting
|
||||
|
||||
from accounting.bill import write_bill
|
||||
|
||||
def get_owner_orgid(sor, orgid):
|
||||
async def get_owner_orgid(sor, orgid):
|
||||
return '0'
|
||||
|
||||
async def get_balance(orgid):
|
||||
db = DBPools()
|
||||
dbname = await rfexe('get_module_dbname', 'platformbiz')
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
f = get_serverenv('getCustomerBalance')
|
||||
if f:
|
||||
return await f(sor, orgid)
|
||||
return None
|
||||
|
||||
class PlatformBizAcc:
|
||||
async def get_orgid_by_trans_role(self, sor, orgtype):
|
||||
if orgtype== 'customer':
|
||||
|
70
platformbiz/sale.py
Normal file
70
platformbiz/sale.py
Normal file
@ -0,0 +1,70 @@
|
||||
|
||||
from appPublic.log import debug, exception
|
||||
from traceback import format_exc
|
||||
|
||||
|
||||
async def get_price(sor, sellerid, buyerid, productid, prod_config):
|
||||
"""
|
||||
获得商品价格
|
||||
resellerid:商户id
|
||||
productid:商品id
|
||||
prod_config:商品配置
|
||||
返回
|
||||
[
|
||||
{ownerid, list_price, price}, ...
|
||||
]
|
||||
"""
|
||||
sql1 = """select a.*,
|
||||
b.pricing_mode,
|
||||
b.count_price,
|
||||
b.pricingapiid
|
||||
from product a left join prodpricing b on a.id=b.prodid
|
||||
where a.id = ${productid}$
|
||||
and a.ownerid = ${sellerid}$"""
|
||||
prods = await sor.sqlExe(sql1, {'productid':productid, 'sellerid':sellerid})
|
||||
if len(prods) < 1:
|
||||
e = Exception(f'{resellerid=} {productid=} product not found')
|
||||
exception(f'{e=}')
|
||||
raise e
|
||||
prod = prods[0]
|
||||
if prod.pricing_mode == '0' and prod.count_price:
|
||||
# 按数量计费
|
||||
pricing_info = {
|
||||
'ownerid':resellerid,
|
||||
'buyerid':buyerid,
|
||||
'productid':productid,
|
||||
'list_price': prod_config.get('count',1) * prod.count_price,
|
||||
'price':
|
||||
}
|
||||
elif prod.pricing_mode == '2':
|
||||
# 按资源因子计费
|
||||
pricing_info = await fact_pricing(sor, productid, prod_config)
|
||||
elif prod_pricing_mode == '2':
|
||||
# 外部计费
|
||||
f = get_serverenv('pricing_api')
|
||||
pricing_info = await f(sor, prod.pricingapiid, providerpid, prod_config)
|
||||
else:
|
||||
pricing_info = {
|
||||
}
|
||||
|
||||
sql = """select a.*,
|
||||
b.providerpid,
|
||||
c.pricing_mode,
|
||||
c.agreeid,
|
||||
c.discount
|
||||
from product a, agreeproduct b, agreedetail c
|
||||
where a.id = b.resellerpid
|
||||
and a.orgid = ${resellerid}$
|
||||
and id = ${productid}$
|
||||
and a.providerpid = b.providerpid
|
||||
and b.agreedetailid = c.id
|
||||
"""
|
||||
ns = {
|
||||
"resellerid":resellerid,
|
||||
"productid":productid
|
||||
}
|
||||
recs = await sor.sqlExe(sql, ns.copy())
|
||||
if len(recs) < 1:
|
||||
e = Exception(
|
||||
return None
|
||||
d =
|
Loading…
Reference in New Issue
Block a user