mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-20 23:58:33 +02:00
Fix: History payments
This commit is contained in:
+3
-3
@@ -153,12 +153,12 @@
|
||||
<!-- Summary Section -->
|
||||
<div id="history-summary" style="display:grid; grid-template-columns:1fr 1fr; gap:15px; margin-bottom:20px;">
|
||||
<div style="background:#1a1a3d; padding:12px; border-radius:6px; border:1px solid #4c1d95;">
|
||||
<div style="color:#888; font-size:0.85em;">Total Received</div>
|
||||
<div style="color:#888; font-size:0.85em;">Total Rewards</div>
|
||||
<div id="total-received" style="color:#4ade80; font-size:1.3em; font-weight:bold;">0 WOW</div>
|
||||
</div>
|
||||
<div style="background:#1a1a3d; padding:12px; border-radius:6px; border:1px solid #4c1d95;">
|
||||
<div style="color:#888; font-size:0.85em;">Total Payments</div>
|
||||
<div id="total-payments" style="color:#60a5fa; font-size:1.3em; font-weight:bold;">0</div>
|
||||
<div style="color:#888; font-size:0.85em;">Total Paid</div>
|
||||
<div id="total-payments" style="color:#60a5fa; font-size:1.3em; font-weight:bold;">0 WOW</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -107,10 +107,10 @@ const TransactionHistory = {
|
||||
|
||||
const currency = payouts.currency || payments.currency || 'WOW';
|
||||
const totalReceived = payouts.totalReceivedFormatted || '0';
|
||||
const totalPayments = payments.total || 0;
|
||||
const totalPaid = payments.totalPaidFormatted || '0';
|
||||
|
||||
$('#total-received').text(totalReceived + ' ' + currency);
|
||||
$('#total-payments').text(totalPayments);
|
||||
$('#total-payments').text(totalPaid + ' ' + currency);
|
||||
},
|
||||
|
||||
_renderPayouts: function() {
|
||||
|
||||
+7
-1
@@ -308,10 +308,14 @@ app.get('/api/user/:socketId/payments', asyncHandler(async (req, res) => {
|
||||
`, [user.id, limit, offset]);
|
||||
|
||||
const countResult = await db.query(
|
||||
`SELECT COUNT(*) as total FROM payments WHERE user_id = $1`,
|
||||
`SELECT COUNT(*) as total,
|
||||
COALESCE(SUM(CASE WHEN status = 'confirmed' THEN expected_amount ELSE 0 END), 0) as total_paid
|
||||
FROM payments WHERE user_id = $1`,
|
||||
[user.id]
|
||||
);
|
||||
|
||||
const totalPaid = parseInt(countResult.rows[0].total_paid, 10) || 0;
|
||||
|
||||
res.json({
|
||||
payments: result.rows.map(row => ({
|
||||
id: row.id,
|
||||
@@ -325,6 +329,8 @@ app.get('/api/user/:socketId/payments', asyncHandler(async (req, res) => {
|
||||
description: row.description
|
||||
})),
|
||||
total: parseInt(countResult.rows[0].total, 10),
|
||||
totalPaid: totalPaid,
|
||||
totalPaidFormatted: gameModeManager.formatAtomicHuman(totalPaid, 4),
|
||||
limit,
|
||||
offset,
|
||||
currency: gameModeManager.cryptoType
|
||||
|
||||
Reference in New Issue
Block a user