/*
 Navicat Premium Data Transfer

 Source Server         : mac-mysql
 Source Server Type    : MySQL
 Source Server Version : 80036 (8.0.36)
 Source Host           : 192.168.86.7:3309
 Source Schema         : cycle_wallet

 Target Server Type    : MySQL
 Target Server Version : 80036 (8.0.36)
 File Encoding         : 65001

 Date: 03/06/2024 05:57:41
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for wallet_address
-- ----------------------------
DROP TABLE IF EXISTS `wallet_address`;
CREATE TABLE `wallet_address`  (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `role` tinyint NOT NULL DEFAULT 1 COMMENT '使用角色：1.用户  2.系统',
  `role_tags` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '1' COMMENT '角色标签(英文逗号分割)：1.钱包  2.提现  3.归集  ',
  `use_status` tinyint NOT NULL DEFAULT 1 COMMENT '使用状态：1.未使用 2.使用中 3.废弃',
  `currency_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '币种代码',
  `balance` decimal(64, 12) NOT NULL DEFAULT 0.000000000000 COMMENT '当前余额',
  `address_hex` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'hex地址',
  `address_base58` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'base58地址',
  `private_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '私钥',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `addr_hex`(`currency_code` ASC, `address_hex` ASC) USING BTREE,
  UNIQUE INDEX `addr_base58`(`currency_code` ASC, `address_base58` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of wallet_address
-- ----------------------------

-- ----------------------------
-- Table structure for wallet_address_transaction
-- ----------------------------
DROP TABLE IF EXISTS `wallet_address_transaction`;
CREATE TABLE `wallet_address_transaction`  (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `currency_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '币种代码',
  `type` tinyint NOT NULL COMMENT '类型：1.转入 2.转出',
  `wallet_address_id` bigint NOT NULL,
  `amount` decimal(64, 12) NOT NULL DEFAULT 0.000000000000 COMMENT '金额（浮点数）',
  `block_transaction_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '链上交易id',
  `block_number` bigint NOT NULL,
  `block_event_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '链上交易事件名',
  `block_from_address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '链上时间转入地址',
  `block_to_address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '链上时间转出地址',
  `block_value` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '链上原始金额',
  `block_timestamp` bigint NOT NULL COMMENT '链上时间',
  `created_at` datetime NOT NULL,
  `is_notify` tinyint NOT NULL DEFAULT 1 COMMENT '是否处理平台余额：1.待处理 2.处理中 3.已处理 4.处理失败',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of wallet_address_transaction
-- ----------------------------

-- ----------------------------
-- Table structure for wallet_currency
-- ----------------------------
DROP TABLE IF EXISTS `wallet_currency`;
CREATE TABLE `wallet_currency`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `type` smallint UNSIGNED NOT NULL COMMENT '币种类型：1.现金 2.加密货币',
  `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '币种代码（唯一）',
  `token` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '币种合约地址',
  `transfer_rate` decimal(10, 6) NOT NULL DEFAULT 0.000000 COMMENT '转账费率',
  `desc` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '说明',
  `created_at` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '钱包币种表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of wallet_currency
-- ----------------------------

-- ----------------------------
-- Table structure for wallet_platform
-- ----------------------------
DROP TABLE IF EXISTS `wallet_platform`;
CREATE TABLE `wallet_platform`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `appid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `secret` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `notify_ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '平台下发地址',
  `created_at` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of wallet_platform
-- ----------------------------
INSERT INTO `wallet_platform` VALUES (1, 'CYCLE', 'CYCLE', NULL, NULL, NULL, '2024-03-06 16:42:15');

-- ----------------------------
-- Table structure for wallet_platform_balance
-- ----------------------------
DROP TABLE IF EXISTS `wallet_platform_balance`;
CREATE TABLE `wallet_platform_balance`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `platform_id` int NOT NULL,
  `currency_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '币种代码',
  `total_amount` decimal(64, 12) NOT NULL DEFAULT 0.000000000000 COMMENT '总余额',
  `frozen_amount` decimal(64, 12) NOT NULL DEFAULT 0.000000000000 COMMENT '已冻结余额',
  `available_amount` decimal(64, 12) NOT NULL DEFAULT 0.000000000000 COMMENT '可用余额',
  `created_at` datetime NULL DEFAULT NULL,
  `updated_at` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of wallet_platform_balance
-- ----------------------------

-- ----------------------------
-- Table structure for wallet_platform_balance_transaction
-- ----------------------------
DROP TABLE IF EXISTS `wallet_platform_balance_transaction`;
CREATE TABLE `wallet_platform_balance_transaction`  (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `sn` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账变唯一订单号',
  `type` tinyint NOT NULL COMMENT '账变类型',
  `status` tinyint NOT NULL COMMENT '状态：1.待处理 2.进行中 3.成功 4.失败',
  `platform_id` int NOT NULL COMMENT '平台id',
  `currency_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '币种代码',
  `balance_id` bigint NOT NULL COMMENT 'wallet_platform_balance id',
  `block_transaction_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '链上交易id',
  `bind_wallet_address_id` bigint NOT NULL COMMENT '当前绑定钱包地址id',
  `bind_wallet_address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '当前绑定钱包地址',
  `from_wallet_address_id` bigint NULL DEFAULT NULL COMMENT '出金钱包id，',
  `from_wallet_address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出金钱包地址',
  `to_wallet_address_id` bigint NULL DEFAULT NULL COMMENT '到账钱包id',
  `to_wallet_address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '提现地址',
  `uid` bigint NULL DEFAULT NULL COMMENT '平台uid',
  `amount` decimal(64, 12) NOT NULL DEFAULT 0.000000000000 COMMENT '金额',
  `fee_amount` decimal(64, 12) NOT NULL DEFAULT 0.000000000000 COMMENT '手续费金额',
  `before_total_amount` decimal(64, 12) NOT NULL DEFAULT 0.000000000000 COMMENT '钱包之前总余额',
  `after_total_amount` decimal(64, 12) NOT NULL DEFAULT 0.000000000000 COMMENT '钱包之后总余额',
  `remark` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `source_wallet_id` bigint NULL DEFAULT NULL COMMENT '来源钱包，提现时填写from钱包id',
  `callback_time` datetime NULL DEFAULT NULL COMMENT '回调时间',
  `callback_wallet_address_transaction_id` bigint NULL DEFAULT NULL COMMENT '回调后钱包账变表id',
  `is_notify` tinyint NOT NULL DEFAULT 1 COMMENT '通知平台状态',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of wallet_platform_balance_transaction
-- ----------------------------

-- ----------------------------
-- Table structure for wallet_platform_bind
-- ----------------------------
DROP TABLE IF EXISTS `wallet_platform_bind`;
CREATE TABLE `wallet_platform_bind`  (
  `id` bigint NOT NULL,
  `platform_id` int NOT NULL COMMENT '平台id',
  `wallet_address_id` bigint NOT NULL COMMENT '绑定钱包地址',
  `currency_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '币种代码',
  `uid` bigint NOT NULL COMMENT '用户uid（平台传入）',
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `unique_bind`(`platform_id` ASC, `wallet_address_id` ASC, `currency_code` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of wallet_platform_bind
-- ----------------------------

-- ----------------------------
-- Table structure for wallet_platform_bind_history
-- ----------------------------
DROP TABLE IF EXISTS `wallet_platform_bind_history`;
CREATE TABLE `wallet_platform_bind_history`  (
  `id` bigint NOT NULL,
  `orgi_id` bigint NOT NULL COMMENT '原id',
  `platform_id` int NOT NULL COMMENT '平台id',
  `wallet_address_id` bigint NOT NULL COMMENT '绑定钱包地址',
  `currency_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '币种代码',
  `uid` bigint NULL DEFAULT NULL COMMENT '用户uid（平台传入）',
  `orgi_created_at` datetime NOT NULL COMMENT '原创建时间',
  `remark` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `unique_bind`(`platform_id` ASC, `wallet_address_id` ASC, `currency_code` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of wallet_platform_bind_history
-- ----------------------------

-- ----------------------------
-- Table structure for wallet_setting
-- ----------------------------
DROP TABLE IF EXISTS `wallet_setting`;
CREATE TABLE `wallet_setting`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `remark` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `created_at` datetime NULL DEFAULT NULL,
  `updated_at` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '钱包系统配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of wallet_setting
-- ----------------------------

-- ----------------------------
-- Table structure for wallet_tron_block
-- ----------------------------
DROP TABLE IF EXISTS `wallet_tron_block`;
CREATE TABLE `wallet_tron_block`  (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `status` tinyint NOT NULL COMMENT '状态：1.待处理 2.处理中 3.已处理 4.处理失败',
  `block_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区块hash id',
  `block_num` bigint NOT NULL COMMENT '区块高度或编号',
  `block_timestamp` bigint NOT NULL COMMENT '区块创建时间',
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `block_number`(`block_num` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of wallet_tron_block
-- ----------------------------

SET FOREIGN_KEY_CHECKS = 1;
