Affiliates & Gewinner¶
Affiliates¶
Seite:
app/affiliates/page.tsx(125 Zeilen) API:app/api/affiliates/route.ts(43 Zeilen) Pfad:/affiliates
Tabellen-Spalten¶
| Spalte | Beschreibung |
|---|---|
| Affiliate | Wallet + Name des Werbers (Link zum User) |
| Referred Player | Wallet + Name des Geworbenen (Link zum User) |
| Rate | Provisionssatz in BP + Prozent (z.B. 500 = 5%) |
| Active | Aktiv-Badge |
| Bonus Awarded | Bonus vergeben? |
| Referred Tips | Tipps des Geworbenen |
| Referred Spent | Ausgaben des Geworbenen in USDT |
| Created | Datum der Referral-Erstellung |
API-Query¶
SELECT ar.id, ar.affiliate, ar.referred_player, ar.rate_bp,
ar.active, ar.bonus_awarded, ar.created_at,
u1.first_name as affiliate_name,
u2.first_name as referred_name,
COALESCE(t.total_tips, 0) as referred_tips,
COALESCE(t.total_spent, 0) as referred_spent
FROM affiliate_rates ar
LEFT JOIN users u1 ON LOWER(u1.wallet_address) = LOWER(ar.affiliate)
LEFT JOIN users u2 ON LOWER(u2.wallet_address) = LOWER(ar.referred_player)
LEFT JOIN LATERAL (
SELECT SUM(tip_count) as total_tips,
SUM(total_stake::bigint) as total_spent
FROM tickets WHERE LOWER(player) = LOWER(ar.referred_player)
) t ON true
ORDER BY ar.created_at DESC
Gewinner (Winners)¶
Seite:
app/winners/page.tsx(483 Zeilen) API:app/api/winners/route.ts(118 Zeilen) Pfad:/winners
Aufbau¶
┌──────────────────────────────────────────────────┐
│ Zusammenfassung │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Total │ │ Unique │ │ Total │ │
│ │ Winners │ │ Players │ │ Payouts │ │
│ │ 234 │ │ 180 │ │12.345USDT│ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ ┌──────────┐ ┌──────────────────────┐ │
│ │ Claimed │ │ Unclaimed │ │
│ │ 210 │ │ 24 (1.234 USDT) │ │
│ └──────────┘ └──────────────────────┘ │
├──────────────────────────────────────────────────┤
│ Filter │
│ [Player Wallet] [Day ID] [Claimed ▾] [Min USDT] │
├──────────────────────────────────────────────────┤
│ Gewinner-Liste (paginiert) │
│ Player | Amount | Day | Date | Status | Claim TX │
└──────────────────────────────────────────────────┘
Filter¶
| Filter | Beschreibung |
|---|---|
| Player | Wallet-Adresse (Teilsuche) |
| Day ID | Spezifischer Tag |
| Claimed | Alle / Claimed / Unclaimed |
| Min Amount | Mindestbetrag in USDT |
Status-Anzeige¶
| Status | Badge | Beschreibung |
|---|---|---|
| CLAIMED | Grün | Gewinn ausgezahlt |
| PENDING | Gelb | Claim-TX in Bearbeitung |
| UNCLAIMED | Rot | Noch nicht geclaimed |
Unclaimed-Zeilen werden mit Warnfarbe hinterlegt.
API-Query¶
SELECT w.player, w.amount, w.claimed, w.claimed_at,
w.claim_tx_hash, w.claimed_pending, w.pending_tx_hash,
sr.day_id, sr.created_at as settlement_date,
sr.commit_tx_hash as settlement_tx
FROM settlement_winner_payouts w
JOIN settlement_runs sr ON sr.id = w.settlement_run_id
WHERE sr.status = 'committed'
AND ($player IS NULL OR LOWER(w.player) LIKE LOWER($player))
AND ($dayId IS NULL OR sr.day_id = $dayId)
AND ($claimed IS NULL OR w.claimed = $claimed)
AND ($minAmount IS NULL OR w.amount >= $minAmount)
ORDER BY w.amount DESC
LIMIT $limit OFFSET $offset
Zusammenfassungs-Query¶
SELECT COUNT(*) as total_winners,
COUNT(DISTINCT player) as unique_players,
COALESCE(SUM(amount), 0) as total_payouts,
COUNT(*) FILTER (WHERE claimed = true) as claimed_count,
COUNT(*) FILTER (WHERE claimed = false) as unclaimed_count,
COALESCE(SUM(amount) FILTER (WHERE claimed = false), 0) as unclaimed_amount
FROM settlement_winner_payouts w
JOIN settlement_runs sr ON sr.id = w.settlement_run_id
WHERE sr.status = 'committed'
[AND filter conditions]