feat(billing): show user display name in ledger records

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-04 14:18:17 +08:00
parent a4d46f2b1e
commit f8317e8312
3 changed files with 7 additions and 2 deletions
+2 -1
View File
@@ -200,7 +200,7 @@ export async function listLedgerPaged(pool, query) {
params,
);
const [rows] = await pool.query(
`SELECT l.id, l.user_id, u.username, l.type, l.amount_cents, l.tokens,
`SELECT l.id, l.user_id, u.username, u.display_name, l.type, l.amount_cents, l.tokens,
l.session_id, l.note, l.created_at
FROM h5_billing_ledger l
JOIN h5_users u ON u.id = l.user_id
@@ -214,6 +214,7 @@ export async function listLedgerPaged(pool, query) {
id: Number(row.id),
userId: row.user_id,
username: row.username,
displayName: row.display_name,
type: row.type,
amountCents: Number(row.amount_cents),
tokens: Number(row.tokens),
+4 -1
View File
@@ -839,7 +839,10 @@ function LedgerTab() {
{result.items.map((row) => (
<tr key={row.id}>
<td className="billing-time">{formatTime(row.createdAt)}</td>
<td>@{row.username}</td>
<td>
<span>{row.displayName || row.username}</span>
<span className="muted"> @{row.username}</span>
</td>
<td><span className={`ledger-type-tag ledger-type-${row.type}`}>{TYPE_LABEL[row.type] ?? row.type}</span></td>
<td className={`billing-num ${row.amountCents < 0 ? 'text-error' : 'text-income'}`}>
{row.amountCents >= 0 ? '+' : ''}¥{formatYuan(Math.abs(row.amountCents))}
+1
View File
@@ -282,6 +282,7 @@ export type LedgerEntry = {
id: number;
userId: string;
username: string;
displayName: string;
type: 'recharge' | 'deduct' | 'refund' | 'adjust';
amountCents: number;
tokens: number;