Files
ycc-proxy-server/deploy/sql/alipay_from_callback_migration.sql
2026-01-12 16:43:08 +08:00

40 lines
2.4 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- ============================================
-- 支付宝from消息回调记录表 - 创建表
-- ============================================
-- 说明用于记录和存储支付宝from消息回调的所有记录
-- 执行时间2025-XX-XX
-- ============================================
CREATE TABLE `alipay_from_callback` (
`id` CHAR(36) NOT NULL COMMENT 'UUID主键',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`delete_time` datetime DEFAULT NULL COMMENT '删除时间',
`del_state` tinyint NOT NULL DEFAULT '0' COMMENT '删除状态0=未删除1=已删除',
`version` bigint NOT NULL DEFAULT '0' COMMENT '版本号(乐观锁)',
/* 业务字段 */
`msg_method` varchar(100) NOT NULL COMMENT '消息类型alipay.merchant.tradecomplain.changed, alipay.security.risk.complaints.merchants.notify',
`app_id` varchar(50) NOT NULL COMMENT '应用ID',
`notify_id` varchar(100) DEFAULT NULL COMMENT '通知ID支付宝返回的',
`biz_content` text NOT NULL COMMENT '业务内容JSON字符串存储完整的biz_content',
`status` varchar(20) NOT NULL DEFAULT 'pending' COMMENT '处理状态pending=待处理processed=已处理failed=处理失败',
`error_message` text DEFAULT NULL COMMENT '错误信息(如果处理失败)',
PRIMARY KEY (`id`),
KEY `idx_msg_method` (`msg_method`) COMMENT '优化按消息类型查询',
KEY `idx_app_id` (`app_id`) COMMENT '优化按应用ID查询',
KEY `idx_notify_id` (`notify_id`) COMMENT '优化按通知ID查询用于去重',
KEY `idx_status` (`status`) COMMENT '优化按处理状态查询',
KEY `idx_create_time` (`create_time`) COMMENT '优化按创建时间查询'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='支付宝from消息回调记录表';
-- ============================================
-- 说明:
-- 1. 此表用于记录所有支付宝from消息回调的原始数据
-- 2. biz_content 存储完整的JSON字符串便于后续查看和调试
-- 3. status 字段用于标记回调的处理状态
-- 4. notify_id 可用于去重,避免重复处理同一条回调
-- 5. 支持软删除del_state
-- 6. 由于回调类型多样不解析biz_content统一存储JSON字符串
-- ============================================