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)