CREATE TABLE IF NOT EXISTS `activity_idempotency` (
  `id` bigint NOT NULL COMMENT '主键ID',
  `activity` varchar(64) NOT NULL COMMENT '活动标识',
  `sys_origin` varchar(32) NOT NULL COMMENT '系统来源',
  `user_id` bigint NOT NULL COMMENT '用户ID',
  `idempotency_key` varchar(128) NOT NULL COMMENT '客户端幂等键',
  `request_hash` varchar(64) NOT NULL COMMENT '请求参数hash',
  `business_no` varchar(64) NOT NULL DEFAULT '' COMMENT '业务单号',
  `status` varchar(32) NOT NULL DEFAULT 'PROCESSING' COMMENT 'PROCESSING/SUCCEEDED/FAILED',
  `response_json` longtext COMMENT '成功响应快照',
  `error_message` varchar(1024) NOT NULL DEFAULT '' COMMENT '失败原因',
  `create_time` datetime(3) NOT NULL COMMENT '创建时间',
  `update_time` datetime(3) NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_activity_idempotency_key` (`activity`, `sys_origin`, `user_id`, `idempotency_key`),
  KEY `idx_activity_idempotency_business` (`business_no`),
  KEY `idx_activity_idempotency_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='活动付费请求幂等表';
