fix: llm上线检查定价数据显示实际内容而非记录数

改用 pricing.pricing.get_pricing_display() 获取格式化定价明细,
替换原来的 select count(*) 只显示记录条数
This commit is contained in:
yumoqing 2026-07-24 23:44:00 +08:00
parent 287e6c5a40
commit a4aa40faf5

View File

@ -1,3 +1,5 @@
from pricing.pricing import get_pricing_display
llmid = params_kw.get('llmid', '') llmid = params_kw.get('llmid', '')
if not llmid: if not llmid:
@ -16,23 +18,18 @@ if not ppids:
else: else:
ppid = ppids[0] ppid = ppids[0]
try: try:
async with get_sor_context(request._run_ns, 'pricing') as psor: result = await get_pricing_display(ppid)
pregs = await psor.sqlExe( if not result:
"select * from pricing_program where id=${ppid}$", {'ppid': ppid}) text = "❌ 定价数据: 无当前生效的定价记录"
if not pregs: elif result.get('display_text'):
text = "❌ 定价数据: 依赖定价项目未通过" lines = [f"✅ 定价项目: {result.get('name', ppid)}"]
else: if result.get('pricing_type'):
# 检查 pricing_program_timing 表 lines.append(f" 类型: {result['pricing_type']}")
try: lines.append("")
timings = await psor.sqlExe( lines.append(result['display_text'])
"select count(*) as cnt from pricing_program_timing where ppid=${ppid}$", {'ppid': ppid}) text = '\n'.join(lines)
cnt = timings[0].cnt if timings else 0 else:
if cnt > 0: text = f"✅ 定价项目: {result.get('name', ppid)} (无定价明细)"
text = f"✅ 定价数据(pricing_program_timing): {cnt}条记录"
else:
text = "❌ 定价数据: pricing_program_timing 无记录"
except Exception as e:
text = f"❌ 定价数据: {e}"
except Exception as e: except Exception as e:
text = f"❌ 定价数据: {e}" text = f"❌ 定价数据: {e}"