From 31c348878aec782353be98116ce69d86e9336a90 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 17 Jul 2026 14:43:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(accounting):=20billing.dspy=20=E2=80=94=20c?= =?UTF-8?q?onvert=20DictObject=20to=20list=20when=20sor.sqlExe=20returns?= =?UTF-8?q?=20non-list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/billing.dspy | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wwwroot/billing.dspy b/wwwroot/billing.dspy index 0f327c9..35f20db 100644 --- a/wwwroot/billing.dspy +++ b/wwwroot/billing.dspy @@ -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)