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:
@@ -282,6 +282,27 @@ CREATE TABLE `platforms` (
|
||||
UNIQUE KEY `slug` (`slug`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
DROP TABLE IF EXISTS `platform_credits`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `platform_credits` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`platform_id` int(11) NOT NULL,
|
||||
`credits_purchased` decimal(12,2) NOT NULL DEFAULT 0.00,
|
||||
`credit_date` date NOT NULL,
|
||||
`payment_method` varchar(100) DEFAULT NULL,
|
||||
`notes` text DEFAULT NULL,
|
||||
`type` enum('credit','debit') NOT NULL DEFAULT 'credit',
|
||||
`purchase_ref_id` int(11) DEFAULT NULL,
|
||||
`created_at` datetime DEFAULT current_timestamp(),
|
||||
`updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `platform_id` (`platform_id`),
|
||||
KEY `credit_date` (`credit_date`),
|
||||
KEY `idx_pc_type` (`type`),
|
||||
KEY `idx_pc_ref` (`purchase_ref_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
DROP TABLE IF EXISTS `referral_social_shares`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
|
||||
Reference in New Issue
Block a user