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.
65 lines
2.9 KiB
SQL
65 lines
2.9 KiB
SQL
-- Yipay payment integration for the PHP panel.
|
|
-- Import this file once before enabling Yipay in the admin panel.
|
|
|
|
CREATE TABLE `yipay_orders` (
|
|
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
`order_no` varchar(32) NOT NULL,
|
|
`gateway_trade_no` varchar(80) DEFAULT NULL,
|
|
`paylist_id` bigint(20) UNSIGNED NOT NULL,
|
|
`user_id` bigint(20) UNSIGNED NOT NULL,
|
|
`payment_type` varchar(16) NOT NULL,
|
|
`amount` decimal(12,2) NOT NULL,
|
|
`payment_kind` varchar(16) NOT NULL DEFAULT '',
|
|
`payment_value` text DEFAULT NULL,
|
|
`status` varchar(16) NOT NULL DEFAULT 'creating',
|
|
`error_message` varchar(500) NOT NULL DEFAULT '',
|
|
`paid_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
|
|
`created_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
|
|
`updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
|
|
CONSTRAINT `chk_yipay_order_status` CHECK (`status` IN (
|
|
'creating','pending','paid','refunded','not_created','creation_unknown'
|
|
)),
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `uniq_yipay_order_no` (`order_no`),
|
|
UNIQUE KEY `uniq_yipay_gateway_trade_no` (`gateway_trade_no`),
|
|
UNIQUE KEY `uniq_yipay_paylist_id` (`paylist_id`),
|
|
KEY `idx_yipay_user_created` (`user_id`,`created_at`),
|
|
KEY `idx_yipay_status_created` (`status`,`created_at`),
|
|
KEY `idx_yipay_type_created` (`payment_type`,`created_at`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
|
|
|
CREATE TABLE `yipay_callback_events` (
|
|
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
`event_key` char(64) NOT NULL,
|
|
`order_no` varchar(32) NOT NULL,
|
|
`gateway_trade_no` varchar(80) NOT NULL,
|
|
`payment_type` varchar(16) NOT NULL,
|
|
`trade_status` varchar(32) NOT NULL,
|
|
`payload` mediumtext NOT NULL,
|
|
`received_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
|
|
`processed_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `uniq_yipay_event_key` (`event_key`),
|
|
KEY `idx_yipay_event_order` (`order_no`,`received_at`),
|
|
KEY `idx_yipay_event_trade` (`gateway_trade_no`,`received_at`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
|
|
|
CREATE TABLE `yipay_refunds` (
|
|
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
`order_no` varchar(32) NOT NULL,
|
|
`gateway_trade_no` varchar(80) NOT NULL,
|
|
`amount` decimal(12,2) NOT NULL,
|
|
`status` varchar(16) NOT NULL DEFAULT 'success',
|
|
`gateway_message` varchar(500) NOT NULL DEFAULT '',
|
|
`admin_user_id` bigint(20) UNSIGNED NOT NULL,
|
|
`referral_reversal_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
|
|
`requested_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
|
|
`completed_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
|
|
`updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `uniq_yipay_refund_order` (`order_no`),
|
|
UNIQUE KEY `uniq_yipay_refund_trade` (`gateway_trade_no`),
|
|
KEY `idx_yipay_refund_status_time` (`status`,`requested_at`),
|
|
KEY `idx_yipay_refund_admin_time` (`admin_user_id`,`requested_at`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|