1
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -28,7 +28,7 @@
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<script type="module" crossorigin src="/assets/index-W0SXIbZy.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-eTB6NUIy.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-D7ShJUt4.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -79,10 +79,10 @@ const AdminDashboard: React.FC = () => {
|
||||
{/* 日期筛选 */}
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: 12, marginBottom: 20 }}>
|
||||
<Space>
|
||||
<Button type={activeRange === 'today' ? 'primary' : 'default'} size="small" onClick={() => setActiveRange('today')}>今日</Button>
|
||||
<Button type={activeRange === 'yesterday' ? 'primary' : 'default'} size="small" onClick={() => setActiveRange('yesterday')}>昨日</Button>
|
||||
<Button type={activeRange === 'week' ? 'primary' : 'default'} size="small" onClick={() => setActiveRange('week')}>本周</Button>
|
||||
<Button type={activeRange === 'month' ? 'primary' : 'default'} size="small" onClick={() => setActiveRange('month')}>本月</Button>
|
||||
<Button type={activeRange === 'today' ? 'primary' : 'default'} size="small" onClick={handleToday}>今日</Button>
|
||||
<Button type={activeRange === 'yesterday' ? 'primary' : 'default'} size="small" onClick={handleYesterday}>昨日</Button>
|
||||
<Button type={activeRange === 'week' ? 'primary' : 'default'} size="small" onClick={handleWeek}>本周</Button>
|
||||
<Button type={activeRange === 'month' ? 'primary' : 'default'} size="small" onClick={handleMonth}>本月</Button>
|
||||
</Space>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, background: '#fff', border: '1px solid #e2e8f0', padding: '4px 12px', borderRadius: 8 }}>
|
||||
<CalendarOutlined style={{ color: '#64748b' }} />
|
||||
@@ -121,7 +121,7 @@ const AdminDashboard: React.FC = () => {
|
||||
</Col>
|
||||
<Col xs={24} lg={12}>
|
||||
<ChartCard title="各模块积分占比" loading={loading}>
|
||||
<ModulePie data={stats?.dailyCreditsByModule || []} />
|
||||
<ModulePie data={stats?.periodCreditsByModule || []} />
|
||||
</ChartCard>
|
||||
</Col>
|
||||
<Col xs={24} lg={12}>
|
||||
|
||||
@@ -233,6 +233,7 @@ export interface AdminStats {
|
||||
lastPeriodRevenue: number;
|
||||
lastPeriodCreditsConsumed: number;
|
||||
dailyCreditsByModule: DailyCredit[];
|
||||
periodCreditsByModule: DailyCredit[];
|
||||
creditsByTeam: TeamCredit[];
|
||||
modelUsage: ModelUsageOut[];
|
||||
}
|
||||
|
||||
@@ -1888,6 +1888,31 @@ async def get_stats(
|
||||
for row in daily_credits_rows
|
||||
]
|
||||
|
||||
# ── 选中周期内各模块积分占比(按 source_module 分组,不拆日期)
|
||||
_period_inner = (
|
||||
select(
|
||||
CreditRecord.source_module.label('module'),
|
||||
func.coalesce(func.sum(func.abs(CreditRecord.amount)), 0).label('credits'),
|
||||
)
|
||||
.where(
|
||||
CreditRecord.type == "consume",
|
||||
CreditRecord.created_at >= date_start,
|
||||
CreditRecord.created_at <= date_end,
|
||||
)
|
||||
.group_by(CreditRecord.source_module)
|
||||
.subquery()
|
||||
)
|
||||
period_credits_rows = (await db.execute(
|
||||
select(
|
||||
func.coalesce(_period_inner.c.module, 'other').label('module'),
|
||||
_period_inner.c.credits,
|
||||
).order_by(_period_inner.c.credits.desc())
|
||||
)).all()
|
||||
period_credits_by_module = [
|
||||
DailyCreditOut(date='', module=row.module, credits=float(row.credits or 0))
|
||||
for row in period_credits_rows
|
||||
]
|
||||
|
||||
# ── 各团队积分消耗(有团队 vs 无团队,使用流水中的团队快照)
|
||||
team_credit_rows = (await db.execute(
|
||||
select(
|
||||
@@ -1944,6 +1969,7 @@ async def get_stats(
|
||||
last_period_revenue=float(last_period_revenue),
|
||||
last_period_credits_consumed=float(last_period_credits_consumed),
|
||||
daily_credits_by_module=daily_credits_by_module,
|
||||
period_credits_by_module=period_credits_by_module,
|
||||
credits_by_team=credits_by_team,
|
||||
model_usage=model_usage,
|
||||
)
|
||||
|
||||
@@ -144,6 +144,7 @@ class AdminStatsOut(BaseModel):
|
||||
last_period_credits_consumed: float = 0.0
|
||||
# 图表数据
|
||||
daily_credits_by_module: list[DailyCreditOut] = []
|
||||
period_credits_by_module: list[DailyCreditOut] = []
|
||||
credits_by_team: list[TeamCreditOut] = []
|
||||
model_usage: list[ModelUsageOut] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user