mirror of
https://github.com/myronblair/tomtomgames
synced 2026-06-30 17:51:08 -05:00
Auto-debit platform credits when purchase is approved
When a pending purchase is resolved as completed: - Inserts a debit row into platform_credits for the matching platform (joins token_purchases.platform_id slug → platforms.id) - Debit notes include purchase #, player name, username, token count, amount, method - Total shown in credit modal now subtracts debits from credits (net balance) Credit history table updates: - CREDIT/DEBIT type badges, debit rows tinted red with − prefix - Debit rows show "Purchase #X ↗" button that closes modal, jumps to the Purchases section (all tab), and highlights that purchase row - Edit/delete buttons hidden on auto-generated debit rows Also fixes: resolve_purchase was echoing $sent (undefined variable bug) Also fixes: purchaseCard div now has id="pr-N" so jump-highlight works Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -120,7 +120,7 @@ switch ($action) {
|
||||
$rows = db()->prepare("SELECT * FROM platform_credits WHERE platform_id=? ORDER BY credit_date DESC, id DESC");
|
||||
$rows->execute([$pid]);
|
||||
$credits = $rows->fetchAll();
|
||||
$total = db()->prepare("SELECT COALESCE(SUM(credits_purchased),0) FROM platform_credits WHERE platform_id=?");
|
||||
$total = db()->prepare("SELECT COALESCE(SUM(CASE WHEN type='debit' THEN -credits_purchased ELSE credits_purchased END),0) FROM platform_credits WHERE platform_id=?");
|
||||
$total->execute([$pid]);
|
||||
echo json_encode(['success'=>true,'credits'=>$credits,'total'=>(float)$total->fetchColumn()]);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user