fix(accounting): billing.dspy — convert DictObject to list when sor.sqlExe returns non-list

This commit is contained in:
yumoqing 2026-07-17 14:43:27 +08:00
parent 0e750b6d31
commit 31c348878a

View File

@ -27,7 +27,9 @@ where a.orgid = ${orgid}$
and d.acc_date >= ${start_date}$
and d.acc_date <= ${end_date}$"""
rows = await sor.sqlExe(sql, ns)
debug(f'billing rows type={type(rows).__name__}, is_list={isinstance(rows, list)}, len={len(rows) if isinstance(rows, list) else "N/A"}')
if not isinstance(rows, list):
rows = list(rows) if rows else []
debug(f'billing rows type={type(rows).__name__}, len={len(rows)}')
# 统计数据 — 独立 ns 避免被 sqlor 修改
stats_ns = {
@ -52,8 +54,8 @@ where a.orgid = ${orgid}$
'credit_sum': float(stats_recs[0].credit_sum) if stats_recs else 0
}
result = {
'total': len(rows) if isinstance(rows, list) else 0,
'rows': rows if isinstance(rows, list) else [],
'total': len(rows),
'rows': rows,
'stats': stats
}
return json.dumps(result, ensure_ascii=False, default=str)