feat(billing): show user display name in ledger records
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -200,7 +200,7 @@ export async function listLedgerPaged(pool, query) {
|
|||||||
params,
|
params,
|
||||||
);
|
);
|
||||||
const [rows] = await pool.query(
|
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
|
l.session_id, l.note, l.created_at
|
||||||
FROM h5_billing_ledger l
|
FROM h5_billing_ledger l
|
||||||
JOIN h5_users u ON u.id = l.user_id
|
JOIN h5_users u ON u.id = l.user_id
|
||||||
@@ -214,6 +214,7 @@ export async function listLedgerPaged(pool, query) {
|
|||||||
id: Number(row.id),
|
id: Number(row.id),
|
||||||
userId: row.user_id,
|
userId: row.user_id,
|
||||||
username: row.username,
|
username: row.username,
|
||||||
|
displayName: row.display_name,
|
||||||
type: row.type,
|
type: row.type,
|
||||||
amountCents: Number(row.amount_cents),
|
amountCents: Number(row.amount_cents),
|
||||||
tokens: Number(row.tokens),
|
tokens: Number(row.tokens),
|
||||||
|
|||||||
@@ -839,7 +839,10 @@ function LedgerTab() {
|
|||||||
{result.items.map((row) => (
|
{result.items.map((row) => (
|
||||||
<tr key={row.id}>
|
<tr key={row.id}>
|
||||||
<td className="billing-time">{formatTime(row.createdAt)}</td>
|
<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><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'}`}>
|
<td className={`billing-num ${row.amountCents < 0 ? 'text-error' : 'text-income'}`}>
|
||||||
{row.amountCents >= 0 ? '+' : ''}¥{formatYuan(Math.abs(row.amountCents))}
|
{row.amountCents >= 0 ? '+' : ''}¥{formatYuan(Math.abs(row.amountCents))}
|
||||||
|
|||||||
@@ -282,6 +282,7 @@ export type LedgerEntry = {
|
|||||||
id: number;
|
id: number;
|
||||||
userId: string;
|
userId: string;
|
||||||
username: string;
|
username: string;
|
||||||
|
displayName: string;
|
||||||
type: 'recharge' | 'deduct' | 'refund' | 'adjust';
|
type: 'recharge' | 'deduct' | 'refund' | 'adjust';
|
||||||
amountCents: number;
|
amountCents: number;
|
||||||
tokens: number;
|
tokens: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user