From 82ce930416994c2119416caed713e976f8d7aede Mon Sep 17 00:00:00 2001 From: ping <1017253325@qq.com> Date: Fri, 5 Jun 2026 17:58:11 +0800 Subject: [PATCH 1/4] update --- b/cntoai/process_user_billing.dspy | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/b/cntoai/process_user_billing.dspy b/b/cntoai/process_user_billing.dspy index 2dc2e17..dc8c87a 100644 --- a/b/cntoai/process_user_billing.dspy +++ b/b/cntoai/process_user_billing.dspy @@ -260,6 +260,13 @@ async def process_user_billing(ns={}): 'status': 'error', 'msg': 'llmid必传' } + model_name = ns.get('model') + if not model_name: + debug(f"{userid} process_user_billing model必传") + return { + 'status': 'error', + 'msg': 'model必传' + } try: amount = round(float(amount), 12) @@ -275,6 +282,9 @@ async def process_user_billing(ns={}): async with db.sqlorContext('kboss') as sor: try: product_li = await sor.R('product', {'providerpid': llmid, 'del_flg': '0'}) + if not product_li: + product_li = await sor.R('product', {'product_code': model_name, 'del_flg': '0'}) + if not product_li: debug(f"{userid} process_user_billing 未找到对应产品,请确认") return { -- 2.34.1 From 8e6cd7051ad04b5dde9a5e3eec73da0addf0cbf7 Mon Sep 17 00:00:00 2001 From: ping <1017253325@qq.com> Date: Mon, 8 Jun 2026 11:20:00 +0800 Subject: [PATCH 2/4] update --- b/cntoai/model_usage_admin_report.dspy | 4 ++-- b/cntoai/model_usage_user_report.dspy | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/b/cntoai/model_usage_admin_report.dspy b/b/cntoai/model_usage_admin_report.dspy index 6b235db..cdd1f91 100644 --- a/b/cntoai/model_usage_admin_report.dspy +++ b/b/cntoai/model_usage_admin_report.dspy @@ -178,7 +178,7 @@ async def _query_model_usage_rows(sor, conditions, limit=None, offset=None): sql = """ SELECT id, userid, llmid, original_price, orderid, bill_status, usage_content, created_at FROM model_usage - WHERE %s + WHERE %s AND bill_status = '0' ORDER BY created_at DESC """ % where_clause if limit is not None: @@ -188,7 +188,7 @@ async def _query_model_usage_rows(sor, conditions, limit=None, offset=None): async def _count_model_usage(sor, conditions): where_clause = ' AND '.join(conditions) if conditions else '1 = 1' - sql = 'SELECT COUNT(*) AS total_count FROM model_usage WHERE %s' % where_clause + sql = 'SELECT COUNT(*) AS total_count FROM model_usage WHERE %s AND bill_status = "0"' % where_clause return (await sor.sqlExe(sql, {}))[0]['total_count'] diff --git a/b/cntoai/model_usage_user_report.dspy b/b/cntoai/model_usage_user_report.dspy index 256d66d..ce827ba 100644 --- a/b/cntoai/model_usage_user_report.dspy +++ b/b/cntoai/model_usage_user_report.dspy @@ -95,7 +95,7 @@ def _normalize_usage_row(row, bill_amount_map=None): 'prompt_tokens': int(usage.get('prompt_tokens') or 0), 'completion_tokens': int(usage.get('completion_tokens') or 0), 'total_tokens': int(usage.get('total_tokens') or 0), - 'amount': round(amount, 4), + 'amount': round(amount, 2), 'bill_status': row.get('bill_status'), 'orderid': orderid, 'usage_time': row.get('created_at'), @@ -155,7 +155,7 @@ async def _query_model_usage_rows(sor, conditions, limit=None, offset=None): sql = """ SELECT id, userid, llmid, original_price, orderid, bill_status, usage_content, created_at FROM model_usage - WHERE %s + WHERE %s AND bill_status = '0' ORDER BY created_at DESC """ % where_clause if limit is not None: -- 2.34.1 From f63fac8390c97c9ab5e69a148f7c81eb42593fc0 Mon Sep 17 00:00:00 2001 From: hrx <18603305412@163.com> Date: Mon, 8 Jun 2026 17:12:06 +0800 Subject: [PATCH 3/4] =?UTF-8?q?token=E7=94=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- f/web-kboss/src/views/tokenUsage/index.vue | 46 ++++++++++++++-------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/f/web-kboss/src/views/tokenUsage/index.vue b/f/web-kboss/src/views/tokenUsage/index.vue index 8c863c7..cf8efa7 100644 --- a/f/web-kboss/src/views/tokenUsage/index.vue +++ b/f/web-kboss/src/views/tokenUsage/index.vue @@ -7,7 +7,7 @@ -

Token用量

+

Token用量

查看模型调用 Token 消耗、调用次数和费用趋势。

@@ -17,7 +17,7 @@ --> - +
@@ -71,7 +71,7 @@ > item.total_tokens), itemStyle: { color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [ @@ -392,6 +405,7 @@ export default { show: true, position: 'right', color: '#344054', + fontSize: 11, formatter: params => this.formatNumber(params.value) } } @@ -657,11 +671,11 @@ export default { .chart-box { width: 100%; - height: 240px; + height: 260px; } .model-rank-chart { - height: 300px; + height: 320px; } .ratio-list, -- 2.34.1 From 88cda528f4ff8abba50d3cc707afc13020daeb7e Mon Sep 17 00:00:00 2001 From: ping <1017253325@qq.com> Date: Mon, 8 Jun 2026 17:32:45 +0800 Subject: [PATCH 4/4] update token report --- b/cntoai/model_usage_admin_report.dspy | 4 ++-- b/cntoai/model_usage_user_report.dspy | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/b/cntoai/model_usage_admin_report.dspy b/b/cntoai/model_usage_admin_report.dspy index cdd1f91..04e6861 100644 --- a/b/cntoai/model_usage_admin_report.dspy +++ b/b/cntoai/model_usage_admin_report.dspy @@ -178,7 +178,7 @@ async def _query_model_usage_rows(sor, conditions, limit=None, offset=None): sql = """ SELECT id, userid, llmid, original_price, orderid, bill_status, usage_content, created_at FROM model_usage - WHERE %s AND bill_status = '0' + WHERE %s AND bill_status != '0' ORDER BY created_at DESC """ % where_clause if limit is not None: @@ -188,7 +188,7 @@ async def _query_model_usage_rows(sor, conditions, limit=None, offset=None): async def _count_model_usage(sor, conditions): where_clause = ' AND '.join(conditions) if conditions else '1 = 1' - sql = 'SELECT COUNT(*) AS total_count FROM model_usage WHERE %s AND bill_status = "0"' % where_clause + sql = 'SELECT COUNT(*) AS total_count FROM model_usage WHERE %s AND bill_status != "0"' % where_clause return (await sor.sqlExe(sql, {}))[0]['total_count'] diff --git a/b/cntoai/model_usage_user_report.dspy b/b/cntoai/model_usage_user_report.dspy index ce827ba..aba1c67 100644 --- a/b/cntoai/model_usage_user_report.dspy +++ b/b/cntoai/model_usage_user_report.dspy @@ -155,7 +155,7 @@ async def _query_model_usage_rows(sor, conditions, limit=None, offset=None): sql = """ SELECT id, userid, llmid, original_price, orderid, bill_status, usage_content, created_at FROM model_usage - WHERE %s AND bill_status = '0' + WHERE %s AND bill_status != '0' ORDER BY created_at DESC """ % where_clause if limit is not None: @@ -165,7 +165,7 @@ async def _query_model_usage_rows(sor, conditions, limit=None, offset=None): async def _count_model_usage(sor, conditions): where_clause = ' AND '.join(conditions) if conditions else '1 = 1' - sql = 'SELECT COUNT(*) AS total_count FROM model_usage WHERE %s' % where_clause + sql = 'SELECT COUNT(*) AS total_count FROM model_usage WHERE %s AND bill_status != "0"' % where_clause return (await sor.sqlExe(sql, {}))[0]['total_count'] -- 2.34.1