bugfix
This commit is contained in:
parent
82c6bcba02
commit
cea916f316
@ -1,6 +0,0 @@
|
||||
|
||||
async def get_accounting_orgid(sor, leg):
|
||||
return '0'
|
||||
|
||||
async def get_accountid(sor, leg):
|
||||
|
@ -3,7 +3,7 @@ from platformbiz.recharge import Recharge
|
||||
from platformbiz.pb_acc import PlatformBizAccRecharge, get_owner_orgid, get_balance
|
||||
from platformbiz.biz_order import change_recharge_status
|
||||
from platformbiz.pricing import calc_prod_price, get_sell_price, get_price_infos
|
||||
from platformbiz.product import agree_product_clone
|
||||
from platformbiz.product import agree_products_clone, open_agree_account
|
||||
|
||||
def load_platformbiz():
|
||||
g = ServerEnv()
|
||||
@ -15,4 +15,6 @@ def load_platformbiz():
|
||||
g.calc_prod_price = calc_prod_price
|
||||
g.get_sell_price = get_sell_price
|
||||
g.get_price_infos = get_price_infos
|
||||
g.agree_product_clone = agree_product_clone
|
||||
g.agree_products_clone = agree_products_clone
|
||||
g.open_agree_account = open_agree_account
|
||||
|
||||
|
@ -85,15 +85,14 @@ c.prodtypeid as agree_prodtypeid,
|
||||
c.discount,
|
||||
c.step_type
|
||||
from product as a, agreement as b, agreedetail as c
|
||||
where a.agreeid = b.id
|
||||
and ( a.prodtypeid = c.prodtypeid or c.prodtypeid is NULL)
|
||||
and a.agreeid = b.id
|
||||
and a.orgid = b.providerid
|
||||
and b.enable_date <= ${biz_date}$
|
||||
and b.expire_date > ${biz_date}$
|
||||
and a.orgid = ${sellerid}$
|
||||
and b.resellerid = ${buyerid}$
|
||||
and a.id = ${productid}$
|
||||
where c.agreeid = b.id
|
||||
and ( a.prodtypeid = c.prodtypeid or c.prodtypeid is NULL)
|
||||
and a.orgid = b.providerid
|
||||
and b.enable_date <= ${biz_date}$
|
||||
and b.expire_date > ${biz_date}$
|
||||
and a.orgid = ${sellerid}$
|
||||
and b.resellerid = ${buyerid}$
|
||||
and a.id = ${productid}$
|
||||
"""
|
||||
recs = await sor.sqlExe(sql, {'sellerid':sellerid,
|
||||
'buyerid':buyerid,
|
||||
@ -101,7 +100,7 @@ where a.agreeid = b.id
|
||||
'productid':productid
|
||||
})
|
||||
if len(recs) == 0:
|
||||
e = f'there is no agreement for {sellerid=} and {buyerid=}, {productid=} at {biz_date=} '
|
||||
e = f'there is no agreement for {sellerid=} and {buyerid=}, {productid=} at {biz_date=} {sql=}'
|
||||
debug(f'{e=}')
|
||||
return None
|
||||
rec = None
|
||||
@ -181,9 +180,11 @@ async def get_sell_price(sor, sellerid, buyerid, productid, list_price):
|
||||
if agree is None:
|
||||
return list_price
|
||||
|
||||
debug(f'{agree=}')
|
||||
if agree.discount:
|
||||
return list_price * agree.discount
|
||||
discount = await get_step_discount(sor, agree.agreedetailid, agree.step_type, selllerid, buyerid)
|
||||
debug(f'step {discount=}')
|
||||
return discount * list_price
|
||||
|
||||
async def get_price_infos(sor, sellerid, buyerid, productid, prod_config):
|
||||
@ -211,7 +212,7 @@ where a.id = ${productid}$
|
||||
raise e
|
||||
prod = prods[0]
|
||||
if prod.agreeid is not None:
|
||||
cost_pricing_infos = get_price_infos(sor, prod.providerid, sellerid, prod.providerpid, prod_config)
|
||||
cost_pricing_infos = await get_price_infos(sor, prod.providerid, sellerid, prod.providerpid, prod_config)
|
||||
|
||||
if prod.pricing_method == '0':
|
||||
# 按资源因子计费
|
||||
@ -224,7 +225,7 @@ where a.id = ${productid}$
|
||||
'list_price': list_price,
|
||||
'sell_price': sell_price
|
||||
}
|
||||
elif prod_pricing_method == '1':
|
||||
elif prod.pricing_method == '1':
|
||||
# 外部计费
|
||||
f = get_serverenv('pricing_api')
|
||||
list_price = await f(sor, prod.apiid, providerpid, prod_config)
|
||||
@ -238,11 +239,11 @@ where a.id = ${productid}$
|
||||
}
|
||||
else:
|
||||
# 供应商计费
|
||||
if len(cost_pricing_info) < 1:
|
||||
if len(cost_pricing_infos) < 1:
|
||||
e = Exception(f'{sellerid=}, {buyerid=}, {productid=} has not resell agreement')
|
||||
exception(e)
|
||||
raise e
|
||||
list_price = cost_pricing_info[-1]['list_price']
|
||||
list_price = cost_pricing_infos[-1]['list_price']
|
||||
sell_price = await get_sell_price(sor, sellerid, buyerid, productid, list_price)
|
||||
pricing_info = {
|
||||
'sellerid': sellerid,
|
||||
@ -251,5 +252,7 @@ where a.id = ${productid}$
|
||||
'list_price': list_price,
|
||||
'sell_price': sell_price
|
||||
}
|
||||
if len(cost_pricing_infos) > 0:
|
||||
pricing_info['cost_price'] = cost_pricing_infos[-1]['sell_price']
|
||||
cost_pricing_infos.append(pricing_info)
|
||||
return cost_pricing_infos
|
||||
|
Loading…
Reference in New Issue
Block a user