fix: test_pricing 直接从DB获取原始YAML避免DictObject序列化失败
This commit is contained in:
parent
810cd4549b
commit
b84f8e406b
@ -983,9 +983,16 @@ async def get_pricing_program_timeing(pptid):
|
|||||||
return ppt
|
return ppt
|
||||||
|
|
||||||
async def test_pricing(pptid, data):
|
async def test_pricing(pptid, data):
|
||||||
ppt = await get_pricing_program_timeing(pptid)
|
# 直接从 DB 获取原始 pricing_data(不调用 ppt_db2app),避免 DictObject 序列化问题
|
||||||
# ppt.pricing_data 已被 ppt_db2app 解析为 dict,需要转回 YAML 字符串
|
env = ServerEnv()
|
||||||
yamlstr = yaml.dump(ppt.pricing_data, allow_unicode=True) if isinstance(ppt.pricing_data, dict) else ppt.pricing_data
|
async with get_sor_context(env, 'pricing') as sor:
|
||||||
|
recs = await sor.R('pricing_program_timing', {'id': pptid})
|
||||||
|
if len(recs) == 0:
|
||||||
|
return None
|
||||||
|
ppt = recs[0]
|
||||||
|
if ppt.pricing_data is None:
|
||||||
|
return None
|
||||||
|
yamlstr = ppt.pricing_data # 原始 YAML 字符串
|
||||||
prices = PricingProgram.get_pricing_from_ymalstr(data, yamlstr)
|
prices = PricingProgram.get_pricing_from_ymalstr(data, yamlstr)
|
||||||
if prices is None:
|
if prices is None:
|
||||||
return None
|
return None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user