Files
xxk-proxy/java/sql/mysql/xxk_proxy_platform_v1.sql
2026-06-11 10:31:24 +08:00

542 lines
30 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.
# XXK (MySQL 5.7 ~ MySQL 8.x)
#
# 1. SQL youlai_admin
# 2. 使 xxk_
# 3. IP IP
USE youlai_admin;
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for xxk_upstream_provider
-- ----------------------------
DROP TABLE IF EXISTS `xxk_upstream_provider`;
CREATE TABLE `xxk_upstream_provider` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`provider_code` varchar(64) NOT NULL COMMENT '供应商编码',
`provider_name` varchar(100) NOT NULL COMMENT '供应商名称',
`provider_type` varchar(32) NOT NULL COMMENT '供应商类型',
`base_url` varchar(255) NOT NULL COMMENT '接口基础地址',
`auth_user_id` varchar(100) DEFAULT NULL COMMENT '上游UserId',
`auth_token` varchar(255) DEFAULT NULL COMMENT '上游Token',
`success_codes` varchar(100) DEFAULT '1000,2001' COMMENT '成功业务码集合',
`http_timeout_ms` int DEFAULT 10000 COMMENT '超时时间(毫秒)',
`status` tinyint DEFAULT 1 COMMENT '状态(1-启用 0-禁用)',
`is_default` tinyint DEFAULT 0 COMMENT '默认供应商(1-是 0-否)',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`create_by` bigint DEFAULT NULL COMMENT '创建人ID',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` bigint DEFAULT NULL COMMENT '更新人ID',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`is_deleted` tinyint DEFAULT 0 COMMENT '逻辑删除(1-已删除 0-未删除)',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_provider_code` (`provider_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='上游供应商配置表';
-- ----------------------------
-- Table structure for xxk_product
-- ----------------------------
DROP TABLE IF EXISTS `xxk_product`;
CREATE TABLE `xxk_product` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`product_code` varchar(64) NOT NULL COMMENT '商品编码',
`product_name` varchar(100) NOT NULL COMMENT '商品名称',
`product_type` varchar(32) NOT NULL COMMENT '商品类型(STATIC_RESIDENTIAL/DYNAMIC_RESIDENTIAL)',
`upstream_provider_id` bigint NOT NULL COMMENT '上游供应商ID',
`upstream_product_code` varchar(64) DEFAULT NULL COMMENT '上游商品编码',
`proxies_type` varchar(64) DEFAULT NULL COMMENT '上游代理类型',
`proxies_format` varchar(64) DEFAULT NULL COMMENT '上游代理格式',
`purpose_web` varchar(64) DEFAULT NULL COMMENT '上游用途参数',
`upstream_params` text DEFAULT NULL COMMENT '上游扩展参数JSON',
`upstream_capabilities` text DEFAULT NULL COMMENT '上游能力JSON',
`protocols_type` tinyint DEFAULT NULL COMMENT '协议类型(1-HTTP 2-SOCKS5 3-HTTP+SOCKS5)',
`udp_status` tinyint DEFAULT 0 COMMENT '是否启用UDP(1-是 0-否)',
`currency` varchar(10) DEFAULT 'RMB' COMMENT '币种',
`enable_distribution` tinyint DEFAULT 1 COMMENT '是否参与分销(1-是 0-否)',
`status` tinyint DEFAULT 1 COMMENT '状态(1-上架 0-下架)',
`sort` int DEFAULT 0 COMMENT '排序',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`create_by` bigint DEFAULT NULL COMMENT '创建人ID',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` bigint DEFAULT NULL COMMENT '更新人ID',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`is_deleted` tinyint DEFAULT 0 COMMENT '逻辑删除(1-已删除 0-未删除)',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_product_code` (`product_code`) USING BTREE,
KEY `idx_product_type_status` (`product_type`, `status`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品主表';
-- ----------------------------
-- Table structure for xxk_product_static_country_price
-- ----------------------------
DROP TABLE IF EXISTS `xxk_product_static_country_price`;
CREATE TABLE `xxk_product_static_country_price` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`product_id` bigint NOT NULL COMMENT '商品ID',
`price_type` varchar(20) DEFAULT NULL COMMENT '价格类型(DEFAULT默认/NODE特殊节点)',
`qiyun_product_type` varchar(32) DEFAULT NULL COMMENT '齐云产品类型',
`qiyun_pid` varchar(64) DEFAULT NULL COMMENT '齐云项目ID',
`qiyun_project_name` varchar(255) DEFAULT NULL COMMENT '齐云项目名称',
`qiyun_area_id` varchar(64) DEFAULT NULL COMMENT '齐云省份ID',
`qiyun_area_name` varchar(255) DEFAULT NULL COMMENT '齐云省份名称',
`qiyun_node_id` varchar(100) DEFAULT NULL COMMENT '齐云节点ID',
`qiyun_node_name` varchar(255) DEFAULT NULL COMMENT '齐云节点名称',
`region_id` bigint DEFAULT NULL COMMENT '地区ID',
`region_code` varchar(64) DEFAULT NULL COMMENT '地区编号',
`region_name` varchar(100) DEFAULT NULL COMMENT '地区名称',
`region_name_zh` varchar(100) DEFAULT NULL COMMENT '地区中文名',
`country_code` varchar(10) NOT NULL COMMENT '国家编码',
`country_name` varchar(100) NOT NULL COMMENT '国家名称',
`base_price` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '地区基础单价',
`currency` varchar(10) DEFAULT 'RMB' COMMENT '币种',
`status` tinyint DEFAULT 1 COMMENT '状态(1-启用 0-禁用)',
`sort` int DEFAULT 0 COMMENT '排序',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`create_by` bigint DEFAULT NULL COMMENT '创建人ID',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` bigint DEFAULT NULL COMMENT '更新人ID',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`is_deleted` tinyint DEFAULT 0 COMMENT '逻辑删除(1-已删除 0-未删除)',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_product_country` (`product_id`, `country_code`) USING BTREE,
KEY `idx_static_price_qiyun_node` (`product_id`, `price_type`, `qiyun_node_id`) USING BTREE,
KEY `idx_country_code` (`country_code`) USING BTREE,
KEY `idx_static_price_region_id` (`region_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='静态商品地区定价表';
-- ----------------------------
-- Table structure for xxk_product_duration_multiplier
-- ----------------------------
DROP TABLE IF EXISTS `xxk_product_duration_multiplier`;
CREATE TABLE `xxk_product_duration_multiplier` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`product_id` bigint NOT NULL COMMENT '商品ID',
`duration_days` int NOT NULL COMMENT '兼容时长天数',
`duration_unit` varchar(16) NOT NULL DEFAULT 'DAY' COMMENT '时长单位(DAY天/HOUR小时)',
`duration_value` int NOT NULL DEFAULT 1 COMMENT '时长数值',
`multiplier` decimal(10,4) NOT NULL DEFAULT 1.0000 COMMENT '价格倍率',
`status` tinyint DEFAULT 1 COMMENT '状态(1-启用 0-禁用)',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`create_by` bigint DEFAULT NULL COMMENT '创建人ID',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` bigint DEFAULT NULL COMMENT '更新人ID',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`is_deleted` tinyint DEFAULT 0 COMMENT '逻辑删除(1-已删除 0-未删除)',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_product_duration_unit_value` (`product_id`, `duration_unit`, `duration_value`) USING BTREE,
KEY `idx_product_duration_days` (`product_id`, `duration_days`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品时长倍率表';
-- ----------------------------
-- Table structure for xxk_product_dynamic_plan
-- ----------------------------
DROP TABLE IF EXISTS `xxk_product_dynamic_plan`;
CREATE TABLE `xxk_product_dynamic_plan` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`product_id` bigint NOT NULL COMMENT '商品ID',
`plan_code` varchar(64) NOT NULL COMMENT '流量套餐编码',
`flow_gb` decimal(12,3) NOT NULL DEFAULT 0.000 COMMENT '流量套餐GB',
`base_price` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '流量套餐基础价',
`allow_sticky_session` tinyint DEFAULT 1 COMMENT '允许粘性会话(1-是 0-否)',
`allow_location_select` tinyint DEFAULT 1 COMMENT '允许地区选择(1-是 0-否)',
`allow_custom_limit` tinyint DEFAULT 0 COMMENT '允许自定义通道流量上限(1-是 0-否)',
`status` tinyint DEFAULT 1 COMMENT '状态(1-启用 0-禁用)',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`create_by` bigint DEFAULT NULL COMMENT '创建人ID',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` bigint DEFAULT NULL COMMENT '更新人ID',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`is_deleted` tinyint DEFAULT 0 COMMENT '逻辑删除(1-已删除 0-未删除)',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_plan_code` (`plan_code`) USING BTREE,
UNIQUE KEY `uk_product_flow` (`product_id`, `flow_gb`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='动态商品流量套餐表';
-- ----------------------------
-- Table structure for xxk_user_profile
-- ----------------------------
DROP TABLE IF EXISTS `xxk_user_profile`;
CREATE TABLE `xxk_user_profile` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`user_id` bigint NOT NULL COMMENT '关联sys_user.id',
`user_type` varchar(32) DEFAULT 'CUSTOMER' COMMENT '用户类型',
`invite_code` varchar(32) DEFAULT NULL COMMENT '邀请码',
`register_source` varchar(32) DEFAULT 'ADMIN' COMMENT '注册来源',
`register_ip` varchar(64) DEFAULT NULL COMMENT '注册IP',
`last_login_ip` varchar(64) DEFAULT NULL COMMENT '最后登录IP',
`last_login_time` datetime DEFAULT NULL COMMENT '最后登录时间',
`status` tinyint DEFAULT 1 COMMENT '状态(1-正常 0-禁用)',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`is_deleted` tinyint DEFAULT 0 COMMENT '逻辑删除(1-已删除 0-未删除)',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_user_id` (`user_id`) USING BTREE,
UNIQUE KEY `uk_invite_code` (`invite_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户业务扩展表';
-- ----------------------------
-- Table structure for xxk_wallet_account
-- ----------------------------
DROP TABLE IF EXISTS `xxk_wallet_account`;
CREATE TABLE `xxk_wallet_account` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`user_id` bigint NOT NULL COMMENT '用户ID',
`balance` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '可用余额',
`frozen_balance` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '冻结余额',
`total_recharge_amount` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '累计充值金额',
`total_consume_amount` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '累计消费金额',
`total_refund_amount` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '累计退款金额',
`status` tinyint DEFAULT 1 COMMENT '状态(1-正常 0-禁用)',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_wallet_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='钱包账户表';
-- ----------------------------
-- Table structure for xxk_wallet_flow
-- ----------------------------
DROP TABLE IF EXISTS `xxk_wallet_flow`;
CREATE TABLE `xxk_wallet_flow` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`flow_no` varchar(64) NOT NULL COMMENT '流水号',
`user_id` bigint NOT NULL COMMENT '用户ID',
`biz_type` varchar(32) NOT NULL COMMENT '业务类型',
`change_type` varchar(16) NOT NULL COMMENT '变动类型(IN/OUT)',
`change_amount` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '变动金额',
`before_balance` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '变动前余额',
`after_balance` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '变动后余额',
`related_order_no` varchar(64) DEFAULT NULL COMMENT '关联订单号',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`operate_by` bigint DEFAULT NULL COMMENT '操作人ID',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_flow_no` (`flow_no`) USING BTREE,
KEY `idx_wallet_user_time` (`user_id`, `create_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='钱包流水表';
-- ----------------------------
-- Table structure for xxk_proxy_order
-- ----------------------------
DROP TABLE IF EXISTS `xxk_proxy_order`;
CREATE TABLE `xxk_proxy_order` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`order_no` varchar(64) NOT NULL COMMENT '订单号',
`user_id` bigint NOT NULL COMMENT '用户ID',
`product_id` bigint NOT NULL COMMENT '商品ID',
`product_type` varchar(32) NOT NULL COMMENT '商品类型',
`order_type` varchar(16) NOT NULL DEFAULT 'NEW' COMMENT '订单类型(NEW/RENEW)',
`order_status` varchar(32) NOT NULL DEFAULT 'WAIT_PAY' COMMENT '订单状态',
`pay_status` varchar(32) NOT NULL DEFAULT 'UNPAID' COMMENT '支付状态',
`open_status` varchar(32) NOT NULL DEFAULT 'WAIT_OPEN' COMMENT '开通状态',
`payment_type` varchar(16) DEFAULT 'BALANCE' COMMENT '支付方式',
`currency` varchar(10) DEFAULT 'RMB' COMMENT '币种',
`buy_quantity` int NOT NULL DEFAULT 1 COMMENT '购买数量',
`duration_days` int NOT NULL COMMENT '购买天数',
`sale_amount` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '销售金额',
`paid_amount` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '实付金额',
`cost_amount` decimal(18,2) DEFAULT 0.00 COMMENT '采购成本',
`open_success_amount` decimal(18,2) DEFAULT 0.00 COMMENT '开通成功金额',
`region_snapshot` text COMMENT '地区快照',
`product_snapshot` mediumtext COMMENT '商品快照',
`inviter_user_id` bigint DEFAULT NULL COMMENT '一级邀请人',
`parent_inviter_user_id` bigint DEFAULT NULL COMMENT '二级邀请人',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`pay_time` datetime DEFAULT NULL COMMENT '支付时间',
`open_time` datetime DEFAULT NULL COMMENT '开通时间',
`finish_time` datetime DEFAULT NULL COMMENT '完成时间',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`is_deleted` tinyint DEFAULT 0 COMMENT '逻辑删除(1-已删除 0-未删除)',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_order_no` (`order_no`) USING BTREE,
KEY `idx_order_user_time` (`user_id`, `create_time`) USING BTREE,
KEY `idx_order_status` (`order_status`, `pay_status`, `open_status`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='代理订单主表';
-- ----------------------------
-- Table structure for xxk_proxy_order_item
-- ----------------------------
DROP TABLE IF EXISTS `xxk_proxy_order_item`;
CREATE TABLE `xxk_proxy_order_item` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`order_id` bigint NOT NULL COMMENT '订单ID',
`order_no` varchar(64) NOT NULL COMMENT '订单号',
`user_id` bigint NOT NULL COMMENT '用户ID',
`product_id` bigint NOT NULL COMMENT '商品ID',
`product_type` varchar(32) NOT NULL COMMENT '商品类型',
`country_code` varchar(10) DEFAULT NULL COMMENT '国家编码',
`country_name` varchar(100) DEFAULT NULL COMMENT '国家名称',
`quantity` int NOT NULL DEFAULT 1 COMMENT '数量',
`duration_days` int NOT NULL COMMENT '时长天数',
`duration_multiplier` decimal(10,4) NOT NULL DEFAULT 1.0000 COMMENT '时长倍率',
`unit_price` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '单价',
`line_amount` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '小计金额',
`flow_gb` decimal(12,3) DEFAULT NULL COMMENT '动态流量GB',
`upstream_payload` mediumtext COMMENT '上游请求快照',
`item_status` varchar(32) DEFAULT 'INIT' COMMENT '订单项状态',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`is_deleted` tinyint DEFAULT 0 COMMENT '逻辑删除(1-已删除 0-未删除)',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_order_item_order_id` (`order_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='代理订单项表';
-- ----------------------------
-- Table structure for xxk_static_proxy_asset
-- ----------------------------
DROP TABLE IF EXISTS `xxk_static_proxy_asset`;
CREATE TABLE `xxk_static_proxy_asset` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`user_id` bigint NOT NULL COMMENT '用户ID',
`order_id` bigint NOT NULL COMMENT '订单ID',
`order_item_id` bigint DEFAULT NULL COMMENT '订单项ID',
`product_id` bigint NOT NULL COMMENT '商品ID',
`upstream_provider_id` bigint NOT NULL COMMENT '上游供应商ID',
`upstream_order_no` varchar(64) DEFAULT NULL COMMENT '上游订单号',
`upstream_proxy_id` varchar(64) NOT NULL COMMENT '上游代理ID',
`proxy_address` varchar(100) NOT NULL COMMENT '代理IP',
`port` int NOT NULL COMMENT '端口',
`username` varchar(100) DEFAULT NULL COMMENT '账号',
`password` varchar(100) DEFAULT NULL COMMENT '密码',
`protocols` varchar(32) DEFAULT NULL COMMENT '协议',
`country_code` varchar(10) DEFAULT NULL COMMENT '国家编码',
`country_name` varchar(100) DEFAULT NULL COMMENT '国家名称',
`city_name` varchar(100) DEFAULT NULL COMMENT '城市名称',
`proxy_status` tinyint DEFAULT 1 COMMENT '代理状态(1-正常 2-禁用 3-维护)',
`is_auto_renew` tinyint DEFAULT 0 COMMENT '自动续费(1-开 0-关)',
`expired_at` datetime DEFAULT NULL COMMENT '到期时间',
`last_sync_time` datetime DEFAULT NULL COMMENT '最后同步时间',
`raw_data` mediumtext COMMENT '原始数据快照',
`status` tinyint DEFAULT 1 COMMENT '业务状态(1-有效 0-无效)',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`is_deleted` tinyint DEFAULT 0 COMMENT '逻辑删除(1-已删除 0-未删除)',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_static_upstream_proxy_id` (`upstream_proxy_id`) USING BTREE,
KEY `idx_static_user_status` (`user_id`, `status`) USING BTREE,
KEY `idx_static_expired_at` (`expired_at`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='静态代理资产表';
-- ----------------------------
-- Table structure for xxk_static_proxy_whitelist
-- ----------------------------
DROP TABLE IF EXISTS `xxk_static_proxy_whitelist`;
CREATE TABLE `xxk_static_proxy_whitelist` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`user_id` bigint NOT NULL COMMENT '用户ID',
`product_id` bigint DEFAULT NULL COMMENT '商品ID',
`proxy_type` varchar(64) DEFAULT NULL COMMENT '静态代理类型',
`whitelist_ip` varchar(64) NOT NULL COMMENT '白名单IP',
`upstream_address_id` varchar(64) DEFAULT NULL COMMENT '上游白名单记录ID',
`status` tinyint DEFAULT 1 COMMENT '状态(1-有效 0-删除)',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_user_whitelist_ip` (`user_id`, `whitelist_ip`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='静态代理白名单表';
-- ----------------------------
-- Table structure for xxk_static_proxy_change_log
-- ----------------------------
DROP TABLE IF EXISTS `xxk_static_proxy_change_log`;
CREATE TABLE `xxk_static_proxy_change_log` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`asset_id` bigint NOT NULL COMMENT '静态资产ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`change_type` varchar(32) NOT NULL COMMENT '变更类型',
`before_value` text COMMENT '变更前',
`after_value` text COMMENT '变更后',
`operator_id` bigint DEFAULT NULL COMMENT '操作人ID',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_static_change_asset_id` (`asset_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='静态代理变更日志表';
-- ----------------------------
-- Table structure for xxk_dynamic_channel
-- ----------------------------
DROP TABLE IF EXISTS `xxk_dynamic_channel`;
CREATE TABLE `xxk_dynamic_channel` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`user_id` bigint NOT NULL COMMENT '用户ID',
`order_id` bigint NOT NULL COMMENT '订单ID',
`order_item_id` bigint DEFAULT NULL COMMENT '订单项ID',
`product_id` bigint NOT NULL COMMENT '商品ID',
`upstream_provider_id` bigint NOT NULL COMMENT '上游供应商ID',
`upstream_channel_id` varchar(64) NOT NULL COMMENT '上游通道ID',
`channel_name` varchar(100) NOT NULL COMMENT '通道名称',
`channel_password` varchar(100) DEFAULT NULL COMMENT '通道密码',
`channel_status` varchar(16) NOT NULL DEFAULT 'ENABLED' COMMENT '通道状态',
`flow_package_gb` decimal(12,3) NOT NULL DEFAULT 0.000 COMMENT '购买流量包GB',
`traffic_limit_gb` decimal(12,3) NOT NULL DEFAULT 0.000 COMMENT '通道流量上限GB',
`used_traffic_gb` decimal(12,3) NOT NULL DEFAULT 0.000 COMMENT '已用流量GB',
`remaining_traffic_gb` decimal(12,3) NOT NULL DEFAULT 0.000 COMMENT '剩余流量GB',
`expired_at` datetime DEFAULT NULL COMMENT '到期时间',
`allow_generate_proxy` tinyint DEFAULT 1 COMMENT '允许生成代理(1-是 0-否)',
`last_sync_time` datetime DEFAULT NULL COMMENT '最后同步时间',
`raw_data` mediumtext COMMENT '原始数据快照',
`status` tinyint DEFAULT 1 COMMENT '业务状态(1-有效 0-无效)',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`is_deleted` tinyint DEFAULT 0 COMMENT '逻辑删除(1-已删除 0-未删除)',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_dynamic_upstream_channel_id` (`upstream_channel_id`) USING BTREE,
KEY `idx_dynamic_user_status` (`user_id`, `status`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='动态通道表';
-- ----------------------------
-- Table structure for xxk_dynamic_channel_traffic_log
-- ----------------------------
DROP TABLE IF EXISTS `xxk_dynamic_channel_traffic_log`;
CREATE TABLE `xxk_dynamic_channel_traffic_log` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`channel_id` bigint NOT NULL COMMENT '动态通道ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`date_type` tinyint DEFAULT NULL COMMENT '查询日期类型',
`start_date` date DEFAULT NULL COMMENT '开始日期',
`end_date` date DEFAULT NULL COMMENT '结束日期',
`used_traffic_gb` decimal(12,3) NOT NULL DEFAULT 0.000 COMMENT '已用流量GB',
`total_traffic_gb` decimal(12,3) DEFAULT 0.000 COMMENT '累计流量GB',
`raw_data` mediumtext COMMENT '原始返回',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_channel_traffic_channel_id` (`channel_id`, `create_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='动态通道流量日志表';
-- ----------------------------
-- Table structure for xxk_dynamic_proxy_generate_log
-- ----------------------------
DROP TABLE IF EXISTS `xxk_dynamic_proxy_generate_log`;
CREATE TABLE `xxk_dynamic_proxy_generate_log` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`channel_id` bigint NOT NULL COMMENT '动态通道ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`location` varchar(32) NOT NULL COMMENT '地区参数',
`domain` varchar(32) DEFAULT 'Global' COMMENT '域名参数',
`sticky_session_time` int NOT NULL DEFAULT 0 COMMENT '粘性会话分钟',
`proxy_count` int NOT NULL DEFAULT 1 COMMENT '生成数量',
`state` varchar(100) DEFAULT NULL COMMENT '',
`city` varchar(100) DEFAULT NULL COMMENT '城市',
`generated_result` mediumtext COMMENT '生成结果',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_generate_channel_id` (`channel_id`, `create_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='动态代理生成日志表';
-- ----------------------------
-- Table structure for xxk_distribution_relation
-- ----------------------------
DROP TABLE IF EXISTS `xxk_distribution_relation`;
CREATE TABLE `xxk_distribution_relation` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`user_id` bigint DEFAULT NULL COMMENT '当前用户ID',
`parent_user_id` bigint DEFAULT NULL COMMENT '一级上级用户ID',
`grand_parent_user_id` bigint DEFAULT NULL COMMENT '二级上级用户ID',
`bind_source` varchar(32) DEFAULT NULL COMMENT '绑定来源',
`bind_time` datetime DEFAULT NULL COMMENT '绑定时间',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`is_deleted` tinyint DEFAULT 0 COMMENT '逻辑删除(1-已删除 0-未删除)',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_distribution_user_id` (`user_id`) USING BTREE,
KEY `idx_distribution_parent_user_id` (`parent_user_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分销关系表';
-- ----------------------------
-- Table structure for xxk_distribution_config
-- ----------------------------
DROP TABLE IF EXISTS `xxk_distribution_config`;
CREATE TABLE `xxk_distribution_config` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`distribution_enabled` tinyint DEFAULT 0 COMMENT '是否启用分销(1-是 0-否)',
`first_level_rate` decimal(10,4) NOT NULL DEFAULT 0.0000 COMMENT '一级佣金比例',
`second_level_rate` decimal(10,4) NOT NULL DEFAULT 0.0000 COMMENT '二级佣金比例',
`withdraw_threshold` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '提现门槛金额',
`withdraw_fee_rate` decimal(10,4) NOT NULL DEFAULT 0.0000 COMMENT '提现手续费比例',
`settle_rule` varchar(32) DEFAULT 'OPEN_SUCCESS_AMOUNT' COMMENT '结算规则',
`status` tinyint DEFAULT 1 COMMENT '状态(1-启用 0-禁用)',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`create_by` bigint DEFAULT NULL COMMENT '创建人ID',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` bigint DEFAULT NULL COMMENT '更新人ID',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分销配置表';
-- ----------------------------
-- Table structure for xxk_distribution_commission
-- ----------------------------
DROP TABLE IF EXISTS `xxk_distribution_commission`;
CREATE TABLE `xxk_distribution_commission` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`user_id` bigint NOT NULL COMMENT '佣金归属用户ID',
`from_user_id` bigint NOT NULL COMMENT '消费用户ID',
`order_id` bigint NOT NULL COMMENT '订单ID',
`order_no` varchar(64) NOT NULL COMMENT '订单号',
`level_no` tinyint NOT NULL COMMENT '层级(1/2)',
`rate` decimal(10,4) NOT NULL DEFAULT 0.0000 COMMENT '佣金比例',
`base_amount` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '佣金基数',
`commission_amount` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '佣金金额',
`commission_status` varchar(32) NOT NULL DEFAULT 'PENDING' COMMENT '佣金状态',
`confirm_time` datetime DEFAULT NULL COMMENT '确认时间',
`settle_time` datetime DEFAULT NULL COMMENT '结算时间',
`invalid_time` datetime DEFAULT NULL COMMENT '失效时间',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_commission_user_status` (`user_id`, `commission_status`) USING BTREE,
KEY `idx_commission_order_id` (`order_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分销佣金流水表';
-- ----------------------------
-- Table structure for xxk_upstream_request_log
-- ----------------------------
DROP TABLE IF EXISTS `xxk_upstream_request_log`;
CREATE TABLE `xxk_upstream_request_log` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`provider_id` bigint NOT NULL COMMENT '供应商ID',
`biz_type` varchar(32) NOT NULL COMMENT '业务类型',
`api_name` varchar(100) NOT NULL COMMENT '接口名称',
`request_url` varchar(255) NOT NULL COMMENT '请求地址',
`request_headers` mediumtext COMMENT '请求头',
`request_body` longtext COMMENT '请求体',
`response_body` longtext COMMENT '响应体',
`http_status` int DEFAULT NULL COMMENT 'HTTP状态码',
`biz_code` varchar(32) DEFAULT NULL COMMENT '业务码',
`success_flag` tinyint DEFAULT 0 COMMENT '是否成功(1-是 0-否)',
`duration_ms` int DEFAULT NULL COMMENT '耗时毫秒',
`error_message` varchar(500) DEFAULT NULL COMMENT '异常信息',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_request_provider_time` (`provider_id`, `create_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='上游请求日志表';
-- ----------------------------
-- Table structure for xxk_order_operate_log
-- ----------------------------
DROP TABLE IF EXISTS `xxk_order_operate_log`;
CREATE TABLE `xxk_order_operate_log` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`order_id` bigint NOT NULL COMMENT '订单ID',
`order_no` varchar(64) NOT NULL COMMENT '订单号',
`operate_type` varchar(32) NOT NULL COMMENT '操作类型',
`before_status` varchar(64) DEFAULT NULL COMMENT '操作前状态',
`after_status` varchar(64) DEFAULT NULL COMMENT '操作后状态',
`content` text COMMENT '操作内容',
`operator_id` bigint DEFAULT NULL COMMENT '操作人ID',
`operator_name` varchar(100) DEFAULT NULL COMMENT '操作人名称',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_order_operate_order_id` (`order_id`, `create_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单操作日志表';
SET FOREIGN_KEY_CHECKS = 1;