This commit is contained in:
2026-08-05 10:24:56 +08:00
parent ceb930bd5a
commit 517bcc3531
3 changed files with 39 additions and 6 deletions
+3
View File
@@ -162,6 +162,9 @@ class AdminCreditRecordSummaryOut(BaseModel):
total_recharge: float = 0.0
total_consume: float = 0.0
total_refund: float = 0.0
# 净消耗 = 真实消费(预扣释放不算)- 退款,这才是真正的"消耗了多少积分"口径
# 前端展示"总消耗积分"时应使用此字段,而不是 total_consume(含未退回的)
net_consume: float = 0.0
transaction_count: int = 0
generation_count: int = 0
generation_attempt_count: int = 0
@@ -320,10 +320,16 @@ async def list_admin_credit_records(
if where_clause is not None:
summary_query = summary_query.where(where_clause)
s = (await db.execute(summary_query)).one()
_total_recharge = _round2(s[0])
_total_consume = _round2(s[1])
_total_refund = _round2(s[2])
# 净消耗 = 真实消费 - 退款;如果退款超过消费(连续退了跨周期的),下限为 0 避免负数
_net_consume = _round2(max(_total_consume - _total_refund, 0.0))
summary = {
"total_recharge": _round2(s[0]),
"total_consume": _round2(s[1]),
"total_refund": _round2(s[2]),
"total_recharge": _total_recharge,
"total_consume": _total_consume,
"total_refund": _total_refund,
"net_consume": _net_consume,
"transaction_count": int(s[3] or 0),
"generation_count": int(s[4] or 0),
"generation_attempt_count": int(s[5] or 0),
+27 -3
View File
@@ -540,9 +540,33 @@ const TeamManagementPage: React.FC = () => {
<Button type="primary" icon={<DownloadOutlined />} onClick={handleExportCredits}> Excel</Button>
</div>
{/* 汇总统计 */}
<div style={{ marginBottom: 12, padding: '8px 16px', background: '#f8f9fc', borderRadius: 8, display: 'flex', gap: 24, flexWrap: 'wrap', fontSize: 13 }}>
<span><strong style={{ color: '#ef4444', fontSize: 15 }}>{creditSummary?.totalConsume ?? 0}</strong></span>
{/* 汇总统计:净消耗 = 消费 - 退款,同时展示消费 / 退款 / 充值辅助详情 */}
<div style={{ marginBottom: 12, padding: '12px 18px', background: '#f8f9fc', borderRadius: 10, display: 'flex', gap: 28, flexWrap: 'wrap', fontSize: 13, alignItems: 'center' }}>
<span>
<strong style={{ color: '#ef4444', fontSize: 16, marginLeft: 4 }}>
{creditSummary?.netConsume ?? 0}
</strong>
</span>
<span style={{ color: '#94a3b8' }}>|</span>
<span>
<strong style={{ color: '#f97316', marginLeft: 4 }}>
{creditSummary?.totalConsume ?? 0}
</strong>
</span>
<span>
退
<strong style={{ color: '#10b981', marginLeft: 4 }}>
{creditSummary?.totalRefund ?? 0}
</strong>
</span>
<span>
<strong style={{ color: '#6366f1', marginLeft: 4 }}>
+ {creditSummary?.totalRecharge ?? 0}
</strong>
</span>
</div>
<div style={tableWrapper}>