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