-- ============================================================
-- addon/wxchat/install.sql  —— wxchat 插件数据表
-- 由 docs/split_install_sql.py 从根 install.sql 抽取。
-- 框架约定：插件安装时由 ywxapp\service\AddonService 执行本文件
--           （仅允许 CREATE TABLE / INSERT，见 importsql 白名单）。
-- 表名须为 __PREFIX__<插件名>_*，与 __PREFIX__addon 等核心表命名一致。
-- ============================================================
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_app_versions` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `platform` varchar(20) NOT NULL COMMENT '平台: ios/android/harmony',
  `version_code` int unsigned NOT NULL COMMENT '版本号(数字): 101, 102, 103',
  `version_name` varchar(20) NOT NULL COMMENT '版本名称: 1.0.1, 1.0.2',
  `min_support_version` int unsigned NOT NULL DEFAULT '0' COMMENT '最低支持版本号',
  `is_force_update` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否强制更新: 0-否, 1-是',
  `is_compatible` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否兼容旧版本: 1-兼容, 0-不兼容',
  `update_type` varchar(20) NOT NULL DEFAULT 'optional' COMMENT '更新类型: optional-可选, recommended-推荐, required-必须',
  `download_url` varchar(500) NOT NULL COMMENT '下载地址',
  `update_content` text COMMENT '更新内容',
  `size` varchar(20) DEFAULT NULL COMMENT '安装包大小: 25.5MB',
  `md5` varchar(64) DEFAULT NULL COMMENT '文件MD5校验值',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态: 0-禁用, 1-启用',
  `release_time` int unsigned NOT NULL COMMENT '发布时间戳',
  `create_at` int unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  `update_at` int unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `idx_platform` (`platform`),
  KEY `idx_version_code` (`version_code`),
  KEY `idx_status` (`status`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='APP版本管理表';

INSERT INTO `__PREFIX__wxchat_app_versions` (`id`, `platform`, `version_code`, `version_name`, `min_support_version`, `is_force_update`, `is_compatible`, `update_type`, `download_url`, `update_content`, `size`, `md5`, `status`, `release_time`, `create_at`, `update_at`) VALUES
	(1, 'android', 101, '1.0.1', 0, 0, 1, 'optional', 'https://example.com/app-1.0.1.apk', '修复已知问题', '25.5MB', 'md5hash1', 1, 1704067200, 1775573543, 1775573543),
	(2, 'android', 102, '1.0.2', 100, 0, 1, 'recommended', 'https://example.com/app-1.0.2.apk', '优化性能，新增功能', '28.3MB', 'md5hash2', 1, 1706745600, 1775573543, 1775573543),
	(3, 'android', 103, '1.0.3', 101, 1, 0, 'required', 'https://example.com/app-1.0.3.apk', '重要安全更新，必须升级', '30.1MB', 'md5hash3', 1, 1709251200, 1775573543, 1775573543),
	(4, 'ios', 101, '1.0.1', 0, 0, 1, 'optional', 'https://apps.apple.com/app/id123456', '修复已知问题', '25.5MB', 'md5hash1', 1, 1704067200, 1775573543, 1775573543),
	(5, 'ios', 102, '1.0.2', 100, 0, 1, 'recommended', 'https://apps.apple.com/app/id123456', '优化性能，新增功能', '28.3MB', 'md5hash2', 1, 1706745600, 1775573543, 1775573543),
	(6, 'ios', 103, '1.0.3', 101, 1, 0, 'required', 'https://apps.apple.com/app/id123456', '重要安全更新，必须升级', '30.1MB', 'md5hash3', 1, 1709251200, 1775573543, 1775573543);

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_feedback` (
  `id` int NOT NULL AUTO_INCREMENT,
  `uid` int NOT NULL COMMENT '用户ID',
  `type` tinyint(1) DEFAULT '1' COMMENT '类型：1-建议 2-投诉 3-其他',
  `content` text COMMENT '反馈内容',
  `contact` varchar(100) DEFAULT '' COMMENT '联系方式',
  `status` tinyint(1) DEFAULT '0' COMMENT '状态：0-待处理 1-已处理',
  `create_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `idx_uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户反馈表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_coin_logs` (
  `id` int NOT NULL AUTO_INCREMENT,
  `uid` int NOT NULL COMMENT '用户ID',
  `type` varchar(20) DEFAULT '' COMMENT '类型：recharge-充值 consume-消费 reward-奖励',
  `change_num` int DEFAULT '0' COMMENT '变动数量（正为增加，负为减少）',
  `balance_after` int DEFAULT '0' COMMENT '变动后金币',
  `remark` varchar(255) DEFAULT '' COMMENT '备注',
  `create_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `idx_uid` (`uid`),
  KEY `idx_create_at` (`create_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='金币变动明细表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_follow` (
  `id` int NOT NULL AUTO_INCREMENT,
  `uid` int NOT NULL COMMENT '关注者ID',
  `fid` int NOT NULL COMMENT '被关注者ID',
  `status` tinyint(1) DEFAULT '1' COMMENT '状态：1-已关注，0-已取消',
  `create_at` int DEFAULT '0',
  `update_at` int DEFAULT '0',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `uniq_follower_following` (`uid`,`fid`) USING BTREE,
  KEY `idx_uid` (`uid`) USING BTREE,
  KEY `idx_fid` (`fid`) USING BTREE,
  KEY `idx_status` (`status`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户关注表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_friend` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `uid` bigint NOT NULL COMMENT '用户ID',
  `fid` bigint NOT NULL COMMENT '好友ID',
  `remark` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '' COMMENT '好友备注',
  `status` tinyint DEFAULT '1' COMMENT '0-请求中，1-已通过，2-已拒绝',
  `create_at` int unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uid` (`uid`,`fid`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

INSERT INTO `__PREFIX__wxchat_friend` (`id`, `uid`, `fid`, `remark`, `status`, `create_at`) VALUES
	(1, 88888888, 88888891, '', 1, 1773532617),
	(3, 88888888, 88888892, '', 1, 1773532617);

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_group_members` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `gid` bigint NOT NULL,
  `uid` bigint NOT NULL,
  `role` tinyint DEFAULT '0' COMMENT '0-普通成员，1-管理员，2-群主',
  `join_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `gid` (`gid`,`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_groups` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '',
  `uid` bigint NOT NULL COMMENT '创建者ID',
  `member_count` int DEFAULT '1',
  `create_at` int unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_intimacy` (
  `id` int NOT NULL AUTO_INCREMENT,
  `uid` int NOT NULL COMMENT '用户ID',
  `target_uid` int NOT NULL COMMENT '目标用户ID',
  `intimacy` int DEFAULT '0' COMMENT '亲密度值',
  `level` tinyint(1) DEFAULT '1' COMMENT '亲密度等级',
  `last_interaction` int DEFAULT '0' COMMENT '最后互动时间',
  `create_at` int DEFAULT '0',
  `update_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_user_target` (`uid`,`target_uid`),
  KEY `idx_uid` (`uid`),
  KEY `idx_target_uid` (`target_uid`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='亲密度记录表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_message_recalls` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `message_id` bigint NOT NULL COMMENT '被撤回的消息ID',
  `recaller_id` bigint NOT NULL COMMENT '撤回者ID',
  `create_at` int unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `message_id` (`message_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_messages` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `sender_id` bigint NOT NULL COMMENT '发送者ID',
  `receiver_type` tinyint NOT NULL COMMENT '0-单聊，1-群聊',
  `receiver_id` bigint NOT NULL COMMENT '接收者ID（用户ID或群组ID）',
  `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '文本内容',
  `content_type` tinyint DEFAULT '0' COMMENT '0-文本，1-图片，2-视频，3-文件',
  `is_recalled` tinyint DEFAULT '0' COMMENT '是否已撤回',
  `recalled_at` timestamp NULL DEFAULT NULL COMMENT '撤回时间',
  `create_at` int unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `idx_receiver` (`receiver_type`,`receiver_id`),
  KEY `idx_sender` (`sender_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_moment_collects` (
  `id` int NOT NULL AUTO_INCREMENT,
  `mid` int NOT NULL COMMENT '动态ID',
  `uid` int NOT NULL COMMENT '收藏用户ID',
  `fid` int DEFAULT '0' COMMENT '收藏夹ID',
  `create_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_moment_user` (`mid`,`uid`),
  KEY `idx_mid` (`mid`),
  KEY `idx_uid` (`uid`),
  KEY `idx_fid` (`fid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='动态收藏表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_moment_comment_likes` (
  `id` int NOT NULL AUTO_INCREMENT,
  `cid` int NOT NULL COMMENT '评论ID',
  `uid` int NOT NULL COMMENT '点赞用户ID',
  `create_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_comment_user` (`cid`,`uid`),
  KEY `idx_cid` (`cid`),
  KEY `idx_uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='评论点赞表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_moment_comments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `mid` int NOT NULL COMMENT '动态ID',
  `uid` int NOT NULL COMMENT '评论用户ID',
  `pid` int DEFAULT '0' COMMENT '父评论ID（0表示顶级评论）',
  `rid` int DEFAULT NULL COMMENT '回复的用户ID',
  `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '评论内容',
  `like_count` int DEFAULT '0' COMMENT '点赞数',
  `reply_count` int DEFAULT '0' COMMENT '回复数',
  `status` tinyint(1) DEFAULT '1' COMMENT '状态：1-正常，0-删除',
  `is_top` tinyint(1) DEFAULT '0' COMMENT '是否置顶：1-是，0-否',
  `create_at` int DEFAULT '0',
  `update_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `idx_mid` (`mid`),
  KEY `idx_uid` (`uid`),
  KEY `idx_pid` (`pid`),
  KEY `idx_status` (`status`),
  KEY `idx_created_at` (`create_at`),
  KEY `idx_is_top` (`is_top`),
  FULLTEXT KEY `ft_content` (`content`) /*!50100 WITH PARSER `ngram` */ 
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='评论表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_moment_follows` (
  `id` int NOT NULL AUTO_INCREMENT,
  `uid` int NOT NULL COMMENT '关注者ID',
  `fid` int NOT NULL COMMENT '被关注者ID',
  `status` tinyint(1) DEFAULT '1' COMMENT '状态：1-已关注，0-已取消',
  `create_at` int DEFAULT '0',
  `update_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_follower_following` (`uid`,`fid`),
  KEY `idx_uid` (`uid`),
  KEY `idx_fid` (`fid`),
  KEY `idx_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户关注表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_moment_hashtag_ab` (
  `id` int NOT NULL AUTO_INCREMENT,
  `mid` int NOT NULL COMMENT '动态ID',
  `hid` int NOT NULL COMMENT '话题标签ID',
  `create_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_moment_hashtag` (`mid`,`hid`),
  KEY `idx_mid` (`mid`),
  KEY `idx_hid` (`hid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='动态话题关联表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_moment_hashtags` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '标签名称',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '标签描述',
  `moment_count` int DEFAULT '0' COMMENT '动态数',
  `view_count` int DEFAULT '0' COMMENT '浏览数',
  `status` tinyint(1) DEFAULT '1' COMMENT '状态：1-正常，0-禁用',
  `create_at` int DEFAULT '0',
  `update_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_name` (`name`),
  KEY `idx_status` (`status`),
  KEY `idx_moment_count` (`moment_count`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='话题标签表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_moment_likes` (
  `id` int NOT NULL AUTO_INCREMENT,
  `mid` int NOT NULL COMMENT '动态ID',
  `uid` int NOT NULL COMMENT '点赞用户ID',
  `create_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_moment_user` (`mid`,`uid`),
  KEY `idx_mid` (`mid`),
  KEY `idx_uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='动态点赞表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_moment_medias` (
  `id` int NOT NULL AUTO_INCREMENT,
  `mid` int NOT NULL COMMENT '动态ID',
  `type` tinyint(1) NOT NULL COMMENT '媒体类型：1-图片，2-视频',
  `url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '媒体URL',
  `thumbnail_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '缩略图URL（视频用）',
  `width` int DEFAULT NULL COMMENT '宽度',
  `height` int DEFAULT NULL COMMENT '高度',
  `duration` int DEFAULT NULL COMMENT '时长（秒，视频用）',
  `sort_order` int DEFAULT '0' COMMENT '排序顺序',
  `create_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `idx_mid` (`mid`),
  KEY `idx_sort_order` (`sort_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='动态媒体表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_moment_shares` (
  `id` int NOT NULL AUTO_INCREMENT,
  `mid` int NOT NULL COMMENT '动态ID',
  `uid` int DEFAULT NULL COMMENT '分享用户ID（可为空，表示匿名分享）',
  `type` tinyint(1) DEFAULT '1' COMMENT '分享类型：1-微信，2-QQ，3-微博，4-复制链接',
  `platform` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '分享平台',
  `create_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `idx_mid` (`mid`),
  KEY `idx_uid` (`uid`),
  KEY `idx_created_at` (`create_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='动态分享记录表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_moments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `uid` int NOT NULL COMMENT '发布用户ID',
  `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '动态内容',
  `type` tinyint(1) DEFAULT '1' COMMENT '动态类型：1-普通，2-视频，3-图片',
  `location` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '位置',
  `latitude` decimal(10,8) DEFAULT NULL COMMENT '纬度',
  `longitude` decimal(10,8) DEFAULT NULL COMMENT '经度',
  `is_public` tinyint(1) DEFAULT '1' COMMENT '是否公开：1-公开，0-私密',
  `like_count` int DEFAULT '0' COMMENT '点赞数',
  `comment_count` int DEFAULT '0' COMMENT '评论数',
  `share_count` int DEFAULT '0' COMMENT '分享数',
  `collect_count` int DEFAULT '0' COMMENT '收藏数',
  `view_count` int DEFAULT '0' COMMENT '浏览数',
  `status` tinyint(1) DEFAULT '1' COMMENT '状态：1-正常，0-删除',
  `create_at` int DEFAULT '0',
  `update_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `idx_uid` (`uid`),
  KEY `idx_status` (`status`),
  KEY `idx_created_at` (`create_at`),
  FULLTEXT KEY `ft_content` (`content`) /*!50100 WITH PARSER `ngram` */ 
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='动态表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_unread_counts` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `user_id` bigint NOT NULL,
  `contact_type` tinyint NOT NULL COMMENT '0-单聊，1-群聊',
  `contact_id` bigint NOT NULL COMMENT '对方ID或群组ID',
  `unread_count` int DEFAULT '0',
  `update_at` int unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_id` (`user_id`,`contact_type`,`contact_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_view_history` (
  `id` int NOT NULL AUTO_INCREMENT,
  `mid` int NOT NULL COMMENT '动态ID',
  `uid` int DEFAULT NULL COMMENT '浏览用户ID（可为空，表示匿名浏览）',
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'IP地址',
  `user_agent` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '用户代理',
  `create_at` int DEFAULT '0',
  `update_at` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `idx_mid` (`mid`),
  KEY `idx_uid` (`uid`),
  KEY `idx_created_at` (`create_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='浏览记录表';

CREATE TABLE IF NOT EXISTS `__PREFIX__wxchat_realname_auth` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `uid` int NOT NULL COMMENT '用户ID',
  `real_name` varchar(50) NOT NULL DEFAULT '' COMMENT '真实姓名',
  `id_card` varchar(30) NOT NULL DEFAULT '' COMMENT '证件号(脱敏存储)',
  `front_img` varchar(255) NOT NULL DEFAULT '' COMMENT '证件正面',
  `back_img` varchar(255) NOT NULL DEFAULT '' COMMENT '证件反面',
  `hold_img` varchar(255) NOT NULL DEFAULT '' COMMENT '手持证件',
  `face_img` varchar(255) NOT NULL DEFAULT '' COMMENT '人脸照',
  `ai_score` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT 'AI审核分数',
  `ai_result` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'AI初筛:0未审,1通过,2不通过',
  `ai_detail` varchar(512) NOT NULL DEFAULT '' COMMENT 'AI审核详情',
  `status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '人工审核:0待审,1通过,2驳回,-1未提交',
  `reject_reason` varchar(255) NOT NULL DEFAULT '' COMMENT '驳回原因',
  `reviewer_id` int NOT NULL DEFAULT '0' COMMENT '审核人ID',
  `review_at` int unsigned NOT NULL DEFAULT '0' COMMENT '审核时间',
  `create_at` int unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  `update_at` int unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='真人认证表';
SET FOREIGN_KEY_CHECKS = 1;
