You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
4.2 KiB
SQL
89 lines
4.2 KiB
SQL
-- Native TRC20 USDT payment tables.
|
|
-- Import once, configure the address pool in /admin/usdt, then run:
|
|
-- * * * * * cd /home/www/html && /usr/bin/php xcat usdtScanJob >> /var/log/usdt-scan.log 2>&1
|
|
|
|
CREATE TABLE IF NOT EXISTS `usdt_wallets` (
|
|
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
`address` varchar(64) NOT NULL,
|
|
`label` varchar(100) NOT NULL DEFAULT '',
|
|
`enabled` tinyint(1) UNSIGNED NOT NULL DEFAULT 1,
|
|
`sort` int(10) UNSIGNED NOT NULL DEFAULT 0,
|
|
`allocation_cursor` int(10) UNSIGNED NOT NULL DEFAULT 0,
|
|
`last_assigned_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
`last_scanned_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
`last_error` varchar(500) NOT NULL DEFAULT '',
|
|
`created_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
`updated_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `uniq_usdt_wallet_address` (`address`),
|
|
KEY `idx_usdt_wallet_enabled_sort` (`enabled`,`sort`),
|
|
KEY `idx_usdt_wallet_assignment` (`enabled`,`last_assigned_at`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS `usdt_payment_orders` (
|
|
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
`order_no` varchar(32) NOT NULL,
|
|
`business_type` varchar(32) NOT NULL,
|
|
`business_order_no` varchar(64) NOT NULL,
|
|
`paylist_id` bigint(20) UNSIGNED DEFAULT NULL,
|
|
`user_id` bigint(20) UNSIGNED DEFAULT NULL,
|
|
`wallet_id` int(10) UNSIGNED NOT NULL,
|
|
`amount` decimal(12,2) NOT NULL,
|
|
`exchange_rate` decimal(12,4) NOT NULL,
|
|
`actual_amount` decimal(24,6) NOT NULL,
|
|
`amount_atomic` bigint(20) UNSIGNED NOT NULL,
|
|
`currency` varchar(16) NOT NULL DEFAULT 'CNY',
|
|
`token` varchar(24) NOT NULL DEFAULT 'USDT',
|
|
`network` varchar(24) NOT NULL DEFAULT 'tron',
|
|
`contract_address` varchar(64) NOT NULL,
|
|
`receive_address` varchar(64) NOT NULL,
|
|
`status` varchar(20) NOT NULL DEFAULT 'pending',
|
|
`txid` varchar(64) DEFAULT NULL,
|
|
`block_number` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
`block_timestamp` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
`expires_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
`paid_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
`created_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
`updated_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
`error_message` varchar(500) NOT NULL DEFAULT '',
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `uniq_usdt_order_no` (`order_no`),
|
|
UNIQUE KEY `uniq_usdt_business_order` (`business_type`,`business_order_no`),
|
|
UNIQUE KEY `uniq_usdt_paylist_id` (`paylist_id`),
|
|
UNIQUE KEY `uniq_usdt_wallet_amount` (`wallet_id`,`amount_atomic`),
|
|
UNIQUE KEY `uniq_usdt_txid` (`txid`),
|
|
KEY `idx_usdt_user_created` (`user_id`,`created_at`),
|
|
KEY `idx_usdt_status_expiry` (`status`,`expires_at`),
|
|
KEY `idx_usdt_wallet_status` (`wallet_id`,`status`,`created_at`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS `usdt_chain_transactions` (
|
|
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
`event_key` char(64) NOT NULL,
|
|
`txid` char(64) NOT NULL,
|
|
`contract_address` varchar(64) NOT NULL,
|
|
`from_address` varchar(64) NOT NULL,
|
|
`to_address` varchar(64) NOT NULL,
|
|
`amount_atomic` bigint(20) UNSIGNED NOT NULL,
|
|
`block_number` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
`block_timestamp` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
`payload` mediumtext NOT NULL,
|
|
`status` varchar(20) NOT NULL DEFAULT 'detected',
|
|
`order_no` varchar(32) DEFAULT NULL,
|
|
`detected_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
`processed_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
`error_message` varchar(500) NOT NULL DEFAULT '',
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `uniq_usdt_chain_event` (`event_key`),
|
|
KEY `idx_usdt_chain_txid` (`txid`),
|
|
KEY `idx_usdt_chain_match` (`to_address`,`amount_atomic`,`block_timestamp`),
|
|
KEY `idx_usdt_chain_status` (`status`,`detected_at`),
|
|
KEY `idx_usdt_chain_order` (`order_no`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
|
|
|
-- Permanently remove the retired external USDT gateway data and settings.
|
|
-- Core recharge records in `paylist` and user balances are intentionally kept.
|
|
DROP TABLE IF EXISTS `epusdt_callback_events`;
|
|
DROP TABLE IF EXISTS `epusdt_orders`;
|
|
DELETE FROM `configurations` WHERE LEFT(`name`, 7) = 'epusdt_';
|