Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7120d4b5ea | |||
| b45fcabbf3 |
@@ -156,7 +156,7 @@ export async function listUsagePaged(pool, query) {
|
|||||||
);
|
);
|
||||||
const [rows] = await pool.query(
|
const [rows] = await pool.query(
|
||||||
`SELECT r.id, r.user_id, u.username, u.display_name, r.agent_session_id, r.request_id,
|
`SELECT r.id, r.user_id, u.username, u.display_name, r.agent_session_id, r.request_id,
|
||||||
r.input_tokens, r.output_tokens, r.cost_cents, r.balance_after_cents, r.created_at
|
r.input_tokens, r.output_tokens, r.cost_cents, r.balance_after_cents, r.billing_source, r.created_at
|
||||||
FROM h5_usage_records r
|
FROM h5_usage_records r
|
||||||
JOIN h5_users u ON u.id = r.user_id
|
JOIN h5_users u ON u.id = r.user_id
|
||||||
${where}
|
${where}
|
||||||
@@ -176,6 +176,7 @@ export async function listUsagePaged(pool, query) {
|
|||||||
outputTokens: Number(row.output_tokens),
|
outputTokens: Number(row.output_tokens),
|
||||||
costCents: Number(row.cost_cents),
|
costCents: Number(row.cost_cents),
|
||||||
balanceAfterCents: Number(row.balance_after_cents),
|
balanceAfterCents: Number(row.balance_after_cents),
|
||||||
|
billingSource: row.billing_source ?? 'wallet',
|
||||||
createdAt: Number(row.created_at),
|
createdAt: Number(row.created_at),
|
||||||
})),
|
})),
|
||||||
total: Number(total),
|
total: Number(total),
|
||||||
|
|||||||
@@ -450,6 +450,11 @@ function UsageRecordsTable({
|
|||||||
result: PagedResult<UsageRecord>;
|
result: PagedResult<UsageRecord>;
|
||||||
onPage: (page: number) => void;
|
onPage: (page: number) => void;
|
||||||
}) {
|
}) {
|
||||||
|
const formatBillingSource = (row: UsageRecord) => {
|
||||||
|
if (row.billingSource === 'subscription') return '套餐额度';
|
||||||
|
return `¥${formatYuan(row.costCents)}`;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="admin-table-wrap">
|
<div className="admin-table-wrap">
|
||||||
@@ -474,8 +479,10 @@ function UsageRecordsTable({
|
|||||||
</td>
|
</td>
|
||||||
<td className="billing-num">{row.inputTokens.toLocaleString()}</td>
|
<td className="billing-num">{row.inputTokens.toLocaleString()}</td>
|
||||||
<td className="billing-num">{row.outputTokens.toLocaleString()}</td>
|
<td className="billing-num">{row.outputTokens.toLocaleString()}</td>
|
||||||
<td className="billing-num">¥{formatYuan(row.costCents)}</td>
|
<td className="billing-num">{formatBillingSource(row)}</td>
|
||||||
<td className="billing-num">¥{formatYuan(row.balanceAfterCents)}</td>
|
<td className="billing-num">
|
||||||
|
{row.billingSource === 'subscription' ? '—' : `¥${formatYuan(row.balanceAfterCents)}`}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -238,7 +238,9 @@ export function DashboardPage() {
|
|||||||
<td>
|
<td>
|
||||||
in {row.inputTokens} / out {row.outputTokens}
|
in {row.inputTokens} / out {row.outputTokens}
|
||||||
</td>
|
</td>
|
||||||
<td>¥{formatYuan(row.costCents)}</td>
|
<td>
|
||||||
|
{row.billingSource === 'subscription' ? '套餐额度' : `¥${formatYuan(row.costCents)}`}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -244,6 +244,7 @@ export type UsageRecord = {
|
|||||||
outputTokens: number;
|
outputTokens: number;
|
||||||
costCents: number;
|
costCents: number;
|
||||||
balanceAfterCents: number;
|
balanceAfterCents: number;
|
||||||
|
billingSource: 'wallet' | 'subscription';
|
||||||
createdAt: number;
|
createdAt: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user