feat: add Solana USDT/USDC support and refine admin payouts UI

This commit is contained in:
mstfyldz
2026-03-13 05:17:04 +03:00
parent 5f0df83686
commit 641498957c
16 changed files with 1335 additions and 120 deletions

View File

@@ -0,0 +1,34 @@
import { NextRequest, NextResponse } from 'next/server';
import { db } from '@/lib/db';
export async function GET(
req: NextRequest,
context: { params: Promise<{ id: string }> }
) {
try {
const { id } = await context.params;
const result = await db.query(
'SELECT network, token, balance, withdrawn, total_gross FROM merchant_balances WHERE merchant_id = $1 ORDER BY network, token',
[id]
);
// Also get the merchant fee
const merchantRes = await db.query('SELECT fee_percent FROM merchants WHERE id = $1', [id]);
const feePercent = parseFloat(merchantRes.rows[0]?.fee_percent || '1.0');
return NextResponse.json({
balances: result.rows.map(r => ({
network: r.network,
token: r.token,
balance: parseFloat(r.balance),
withdrawn: parseFloat(r.withdrawn),
totalGross: parseFloat(r.total_gross || r.balance),
available: parseFloat(r.balance) - parseFloat(r.withdrawn)
})),
feePercent
});
} catch (err: any) {
return NextResponse.json({ error: err.message }, { status: 500 });
}
}