/*
 Navicat Premium Data Transfer

 Source Server         : online
 Source Server Type    : MySQL
 Source Server Version : 50742 (5.7.42-log)
 Source Host           : rm-bp19g41bnqlws5463no.mysql.rds.aliyuncs.com:3306
 Source Schema         : syb_jq

 Target Server Type    : MySQL
 Target Server Version : 50742 (5.7.42-log)
 File Encoding         : 65001

 Date: 10/01/2024 14:47:19
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for t_account_change_info
-- ----------------------------
DROP TABLE IF EXISTS `t_account_change_info`;
CREATE TABLE `t_account_change_info`  (
  `flow_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流水号',
  `account_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账户编号',
  `mch_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户号',
  `change_type` tinyint(2) NULL DEFAULT NULL COMMENT '变动类型 0：充值 1：提现 2：转账 3：退款 ',
  `account_type` tinyint(2) NULL DEFAULT NULL COMMENT '账户类型 0：退款账户 1：营销账户账户类型',
  `before_amt` bigint(15) NULL DEFAULT 0 COMMENT '变动前余额',
  `change_amt` bigint(15) NULL DEFAULT 0 COMMENT '变动金额',
  `after_amt` bigint(15) NULL DEFAULT NULL COMMENT '变动后的金额',
  `state` tinyint(2) NULL DEFAULT 1 COMMENT '状态 1：处理中 2：处理成功 -1：处理失败',
  `ext_flow_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联流水号',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `ext_type` tinyint(2) NULL DEFAULT NULL COMMENT '扩展类型 0：扫码充值，1:汇款转账',
  `extra` json NULL COMMENT '扩展参数',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`flow_no`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '账户变动明细' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_account_info
-- ----------------------------
DROP TABLE IF EXISTS `t_account_info`;
CREATE TABLE `t_account_info`  (
  `account_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账户编号',
  `mch_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户号(原商户号)',
  `type` tinyint(2) NOT NULL COMMENT '类型 0：退款账户 1：营销账户',
  `balacne` bigint(20) NULL DEFAULT 0 COMMENT '余额',
  `freeze` bigint(20) NULL DEFAULT 0 COMMENT '不可用余额',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `remind_state` tinyint(2) NOT NULL DEFAULT 0 COMMENT '提醒状态 0：未开通 1：已开通',
  `remind_rule_ext` json NULL COMMENT '提醒规则',
  `last_notice_time` timestamp NULL DEFAULT NULL COMMENT '最后通知时间',
  PRIMARY KEY (`account_no`) USING BTREE,
  UNIQUE INDEX `idx_unique`(`mch_no`, `type`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '账户表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_agent_config
-- ----------------------------
DROP TABLE IF EXISTS `t_agent_config`;
CREATE TABLE `t_agent_config`  (
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '代理商号',
  `config_key` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置KEY',
  `config_val` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置内容项',
  `group_key` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置分组',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`config_key`, `agent_no`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '代理商配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_agent_info
-- ----------------------------
DROP TABLE IF EXISTS `t_agent_info`;
CREATE TABLE `t_agent_info`  (
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '代理商账号',
  `agent_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '代理商名称',
  `agent_short_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '代理商简称',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '服务商号',
  `pid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '上级代理商号， 空串表示顶级代理商',
  `pid_arr` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '上级代理商号的拼接',
  `pname` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '上级代理商简称',
  `contact_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人姓名',
  `contact_tel` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人手机号',
  `contact_email` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人邮箱',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '代理商状态: 0-停用, 1-正常, 2-待审核, 3-审核驳回, 4-未认证',
  `level` int(11) NOT NULL DEFAULT 1 COMMENT '代理商等级',
  `add_agent_flag` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否允许发展子代理: 0-不允许, 1-允许',
  `add_mch_flag` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否允许发展子商户: 0-不允许, 1-允许',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商备注',
  `audit_remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核备注',
  `cashout_fee_rule_type` tinyint(6) NOT NULL DEFAULT 1 COMMENT '手续费计算公式类型： 1-使用系统默认配置, 2-自定义',
  `cashout_fee_rule` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '{}' COMMENT '手续费计算公式',
  `sett_account_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结算账户类型： WX_CASH-微信零钱; ALIPAY_CASH-支付宝转账; BANK_CARD-银行卡; BANK_PUBLIC-对公; BANK_PRIVATE-对私',
  `sett_account_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结算账户账号',
  `sett_account_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结算账户姓名',
  `sett_account_bank` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结算账户开户行名称',
  `sett_account_sub_bank` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '开户行支行名称',
  `sett_account_telphone` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结算账户联系人手机号（一般为代理商手机号）',
  `license_img` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '营业执照照片',
  `idcard1_img` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '身份证人像面照片',
  `idcard2_img` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '身份证国徽面照片',
  `idcard_in_hand_img` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手持身份证照片',
  `bank_card_img` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行卡照片',
  `permit_img` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '许可证照片',
  `agent_type` tinyint(6) NOT NULL DEFAULT 1 COMMENT '代理商类型: 1-个人, 2-企业',
  `init_user_id` bigint(20) NULL DEFAULT NULL COMMENT '初始用户ID（创建代理商时，允许代理商登录的用户）',
  `login_username` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '登录用户名',
  `sipw` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付密码(敏感信息密码Sensitive information password)',
  `freeze_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '钱包冻结金额, 单位分',
  `freeze_desc` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '冻结原因',
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`agent_no`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '代理商信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_bank_branch
-- ----------------------------
DROP TABLE IF EXISTS `t_bank_branch`;
CREATE TABLE `t_bank_branch`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `branch_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支行联行号',
  `branch_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支行名称',
  `bank_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '银行编码',
  `bank_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '银行名称',
  `province_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '省编码',
  `province_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '省名称',
  `city_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '市编码',
  `city_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '市名称',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx1`(`bank_name`) USING BTREE,
  INDEX `idx2`(`city_code`) USING BTREE,
  INDEX `idx3`(`branch_name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 299433 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '支行信息。该数据取自随行付' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_bank_branch_lkl
-- ----------------------------
DROP TABLE IF EXISTS `t_bank_branch_lkl`;
CREATE TABLE `t_bank_branch_lkl`  (
  `contact_line` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `branch_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `bank_type` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `bank_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `city_code` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `clear_no` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  UNIQUE INDEX `unque`(`contact_line`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_cashout_record
-- ----------------------------
DROP TABLE IF EXISTS `t_cashout_record`;
CREATE TABLE `t_cashout_record`  (
  `rid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '提现记录ID',
  `info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '代理商号等',
  `info_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '系统类型： 参考：SYS_ROLE_TYPE ',
  `info_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '名称快照',
  `apply_amount` bigint(20) NOT NULL COMMENT '申请金额,单位分',
  `sett_fee_amount` bigint(20) NOT NULL COMMENT '手续费金额,单位分',
  `sett_fee_rule` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '手续费计算公式（快照）',
  `sett_amount` bigint(20) NOT NULL COMMENT '最终结算金额 （申请-手续费）, 单位分',
  `sett_account_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '结算账户类型： WX_CASH-微信零钱; ALIPAY_CASH-支付宝转账; BANK_CARD-银行卡',
  `sett_account_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '结算账户账号',
  `sett_account_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结算账户姓名',
  `sett_account_bank` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结算账户开户行名称',
  `sett_account_sub_bank` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '开户行支行名称',
  `sett_account_telphone` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结算账户联系人手机号（一般为代理商手机号）',
  `apply_remark` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户提现备注',
  `sett_info` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '结算备注[系统生成]',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '结算状态: 1-审核中, 2-审核失败, 3-结算中, 4-结算成功, 5-结算失败',
  `sett_cert_img` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '申请资料',
  `transfer_cert_img` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '打款凭证（运营平台）',
  `sett_type` tinyint(6) NOT NULL COMMENT '提现类型： 1-佣金提现',
  `audit_time` datetime NULL DEFAULT NULL COMMENT '审核时间',
  `audit_remark` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核备注',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`rid`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 80000001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '提现结算记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_channel_account_cashout_record
-- ----------------------------
DROP TABLE IF EXISTS `t_channel_account_cashout_record`;
CREATE TABLE `t_channel_account_cashout_record`  (
  `rid` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '提现记录ID',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `mch_ext_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号，也就是现在的申请单编号',
  `mch_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户名称',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `channel_sub_mch_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道子商户号',
  `pay_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付订单号',
  `current_balance` bigint(20) NULL DEFAULT NULL COMMENT '当前查询余额,单位分 （不准确，可能此时账户余额有变动）',
  `cashout_amount` bigint(20) NOT NULL COMMENT '申请提现金额,单位分',
  `state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '提现状态: 0-提现单创建, 1-提现中, 2-提现成功, 3-提现失败',
  `channel_rid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道提现单ID',
  `fail_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '失败原因',
  `success_time` datetime NULL DEFAULT NULL COMMENT '提现成功时间',
  `bank_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '提现银行名称',
  `bank_account` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '提现账户',
  `bank_account_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '提现账户名称',
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人名称',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`rid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '提现结算记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_check_batch
-- ----------------------------
DROP TABLE IF EXISTS `t_check_batch`;
CREATE TABLE `t_check_batch`  (
  `batch_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '对账批次号，支付接口代码ifCode_渠道商户号_对账日期',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `channel_mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '渠道商户号',
  `bill_date` date NOT NULL COMMENT '对账日期',
  `state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '对账批次处理状态：0-未处理,1-已处理',
  `diff_count` int(11) NULL DEFAULT 0 COMMENT '所有差错总单数',
  `un_handle_diff_count` int(11) NULL DEFAULT 0 COMMENT '待处理的差错总单数',
  `total_count` int(11) NULL DEFAULT 0 COMMENT '平台交易总单数',
  `channel_total_count` int(11) NULL DEFAULT 0 COMMENT '渠道交易总单数',
  `total_amount` bigint(20) NULL DEFAULT 0 COMMENT '平台交易总金额',
  `channel_total_amount` bigint(20) NULL DEFAULT 0 COMMENT '渠道交易总金额',
  `total_refund_count` int(11) NULL DEFAULT 0 COMMENT '平台退款总单数',
  `channel_total_refund_count` int(11) NULL DEFAULT 0 COMMENT '渠道退款总单数',
  `total_refund_amount` bigint(20) NULL DEFAULT 0 COMMENT '平台退款总金额',
  `channel_total_refund_amount` bigint(20) NULL DEFAULT 0 COMMENT '渠道退款总金额',
  `total_fee` bigint(20) NULL DEFAULT 0 COMMENT '平台总手续费',
  `channel_total_fee` bigint(20) NULL DEFAULT 0 COMMENT '渠道总手续费',
  `org_bill_file_path` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '原始对账文件存放地址',
  `release_state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '下载/解析状态:0-失败,1-成功',
  `release_err_msg` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '下载/解析失败的描述信息',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`batch_no`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '对账批次表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_check_channel_bill
-- ----------------------------
DROP TABLE IF EXISTS `t_check_channel_bill`;
CREATE TABLE `t_check_channel_bill`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `batch_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '对账批次号，支付接口代码ifCode_渠道商户号_对账日期',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `channel_mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '渠道商户号',
  `bill_date` date NOT NULL COMMENT '对账日期',
  `bill_type` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '账单类型，pay：支付, refund：退款',
  `currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'cny' COMMENT '三位货币代码,人民币:cny',
  `order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '平台订单号',
  `channel_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道订单号',
  `channel_amount` bigint(20) NULL DEFAULT 0 COMMENT '交易金额 单位：分',
  `channel_fee_rate` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道手续费费率',
  `channel_fee_amount` bigint(20) NULL DEFAULT 0 COMMENT '渠道手续费 单位：分',
  `channel_success_at` datetime NULL DEFAULT NULL COMMENT '渠道交易成功时间',
  `channel_user` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道用户标识,如微信openId,支付宝账号',
  `channel_state` tinyint(6) NOT NULL COMMENT '渠道订单状态：0-订单生成, 1-支付中, 2-支付成功, 3-支付失败, 4-已撤销, 5-已退款, 6-订单关闭',
  `org_pay_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '退款原支付订单号',
  `channel_refund_amount` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '退款金额',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '渠道对账单表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_check_diff
-- ----------------------------
DROP TABLE IF EXISTS `t_check_diff`;
CREATE TABLE `t_check_diff`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `batch_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '对账批次号，支付接口代码ifCode_渠道商户号_对账日期',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `channel_mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '渠道商户号',
  `bill_date` date NOT NULL COMMENT '对账日期',
  `bill_type` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '账单类型，pay：支付, refund：退款',
  `order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '平台订单ID',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户号',
  `mch_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户名称',
  `mch_app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户应用ID',
  `mch_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户订单号',
  `amount` bigint(20) NULL DEFAULT 0 COMMENT '平台交易金额,单位分',
  `fee_amount` bigint(20) NULL DEFAULT 0 COMMENT '平台手续费,单位分',
  `refund_amount` bigint(20) NULL DEFAULT 0 COMMENT '平台退款金额',
  `order_state` tinyint(6) NULL DEFAULT 0 COMMENT '平台订单状态：0-订单 生成, 1-支付中, 2-支付成功, 3-支付失败, 4-已撤销, 5-已退款, 6-订单关闭',
  `order_success_at` datetime NULL DEFAULT NULL COMMENT '平台交易成功时间',
  `order_create_at` datetime NULL DEFAULT NULL COMMENT '平台下单时间',
  `channel_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道订单号',
  `channel_state` tinyint(6) NULL DEFAULT 0 COMMENT '渠道订单状态：0-订单生成, 1-支付中, 2-支付成功, 3-支付失败, 4-已撤销, 5-已退款, 6-订单关闭',
  `channel_amount` bigint(20) NULL DEFAULT 0 COMMENT '渠道交易金额,单位分',
  `channel_refund_amount` bigint(20) NULL DEFAULT 0 COMMENT '渠道退款金额',
  `channel_fee_amount` bigint(20) NULL DEFAULT 0 COMMENT '渠道手续费',
  `channel_success_at` datetime NULL DEFAULT NULL COMMENT '渠道交易成功时间',
  `diff_type` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '差异类型：local-长款  channel-短款  order-订单差异(金额差异等)',
  `handle_state` tinyint(6) NULL DEFAULT 0 COMMENT '差异处理状态：0-未处理，1-挂账，2-已处理，3-已忽略',
  `handle_remark` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '处理备注',
  `handle_uid` bigint(20) NULL DEFAULT NULL COMMENT '差异处理者ID',
  `handle_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '差异处理者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '对账差异表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_device_provide_config
-- ----------------------------
DROP TABLE IF EXISTS `t_device_provide_config`;
CREATE TABLE `t_device_provide_config`  (
  `config_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '厂商配置ID',
  `config_desc` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '厂商配置备注信息， 会在商户侧进行回显',
  `device_type` tinyint(6) NOT NULL COMMENT '设备类型：1-云喇叭, 2-云打印, 3-扫码pos, 4-智能pos, 5-收银插件, 6-刷脸设备, 7-如意Lite',
  `provider` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备厂商：zgwl-智谷物联, bsj-博实结, fe-飞鹅, ps-品生, clj-财来聚, wsy-微收银, xjl-小精灵',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '厂商配置参数appId（扫码POS定义唯一appId）',
  `provider_params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '厂商配置参数，json字符串',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '状态： 0-停用，1-启用',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`config_id`) USING BTREE,
  UNIQUE INDEX `app_id`(`app_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1006 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '设备厂商配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_info_account
-- ----------------------------
DROP TABLE IF EXISTS `t_info_account`;
CREATE TABLE `t_info_account`  (
  `info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '运营平台标识/代理商号',
  `info_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '系统类型： 参考：SYS_ROLE_TYPE ',
  `balance_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '钱包余额 单位:分，（已入账金额， 提现中不动账）',
  `un_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '钱包账户不可用金额 单位:分（比如提现中的金额）',
  `audit_profit_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '在途结算(审核中)余额 单位:分，（待结算的金额， 未到结算周期）',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  UNIQUE INDEX `Uni_Info_id`(`info_id`, `info_type`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '钱包表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_info_account_history
-- ----------------------------
DROP TABLE IF EXISTS `t_info_account_history`;
CREATE TABLE `t_info_account_history`  (
  `hid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  `info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '运营平台标识/代理商号',
  `info_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '系统类型： 参考：SYS_ROLE_TYPE ',
  `info_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '名称快照',
  `op_account_type` tinyint(6) NOT NULL COMMENT '变更账户类型： 1-钱包账户, 2-在途账户',
  `op_before_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '变动前账户余额, 单位：分',
  `op_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '变动金额, 单位：分',
  `op_after_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '变动后账户余额, 单位：分',
  `biz_type` tinyint(6) NULL DEFAULT NULL COMMENT '业务类型： 1-订单佣金计算, 2-退款轧差, 3-佣金提现, 4-人工调账',
  `rela_biz_order_type` tinyint(6) NULL DEFAULT NULL COMMENT '关联订单类型： 1-支付订单号, 2-退款订单号, 3-提现单号',
  `rela_biz_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联订单号',
  `sett_id` bigint(20) NULL DEFAULT NULL COMMENT '关联结算记录ID',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`hid`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1037 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '钱包流水表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_isv_info
-- ----------------------------
DROP TABLE IF EXISTS `t_isv_info`;
CREATE TABLE `t_isv_info`  (
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '服务商号',
  `isv_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '服务商名称',
  `isv_level` int(1) NULL DEFAULT NULL COMMENT '1：一级渠道；2：二级渠道',
  `owner_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道持有者类型',
  `owner_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道持有者编号。\r\n如果是代理，则是代理号；\r\n如果是用户，则是用户号；',
  `isv_short_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '服务商简称',
  `contact_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人姓名',
  `contact_tel` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人手机号',
  `contact_email` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人邮箱',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '状态: 0-停用, 1-正常',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`isv_no`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '服务商信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_isv_user_conn
-- ----------------------------
DROP TABLE IF EXISTS `t_isv_user_conn`;
CREATE TABLE `t_isv_user_conn`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道号',
  `info_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户类型',
  `info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户号，代理号或用户号',
  `status` int(2) NOT NULL DEFAULT 0 COMMENT '状态，1：启用；0：未启用',
  `config_status` int(2) NOT NULL DEFAULT 0 COMMENT '是否可配置。1：可配置；0：不可',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `isv_no`(`isv_no`, `info_type`, `info_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 51 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '渠道用户关联表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_location_cache
-- ----------------------------
DROP TABLE IF EXISTS `t_location_cache`;
CREATE TABLE `t_location_cache`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `address` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地址',
  `longitude` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '经度',
  `latitude` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '纬度',
  `createTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updateTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 238 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_app
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_app`;
CREATE TABLE `t_mch_app`  (
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `app_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '应用名称',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `top_agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '顶级代理商号',
  `default_flag` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否默认: 0-否、 1-是（api接口未显式指定应用则使用默认应用）',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '应用状态: 0-停用, 1-正常 2:审核中 -1：审核驳回',
  `state_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核意见',
  `polling_bind_state` tinyint(6) NULL DEFAULT 0 COMMENT '轮询绑定状态。0 - 未开通；1 - 已开通自动绑定；2 - 不开通自动绑定',
  `app_sign_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '[\"MD5\"]' COMMENT '支持的加签方式: MD5、 RSA2（若使用系统测试或者app必须支持MD5）',
  `app_rsa2_public_key` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '应用公钥（RSA2）',
  `app_secret` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用私钥(MD5)',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `capabilities` json NULL COMMENT '配置的功能',
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `range` tinyint(1) NULL DEFAULT 0 COMMENT '0, 线下；1，线上',
  `api_flag` tinyint(1) NULL DEFAULT NULL COMMENT '0: 不支持; 1: 支持',
  `category` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '类目',
  `information` json NULL COMMENT '应用相关资料',
  `mcc_code` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '经营类目',
  `qualification_list` json NULL COMMENT '资质json',
  `pre_capabilities` json NULL COMMENT '开通需求功能',
  PRIMARY KEY (`app_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户应用表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_app_applyment
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_app_applyment`;
CREATE TABLE `t_mch_app_applyment`  (
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `mch_app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用号',
  `mch_apply_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户入网申请单号',
  `wx_weight` int(6) UNSIGNED NOT NULL DEFAULT 1 COMMENT '微信支付交易权重',
  `ali_weight` int(6) UNSIGNED NOT NULL DEFAULT 1 COMMENT '支付宝支付交易权重',
  `ysf_weight` int(6) UNSIGNED NOT NULL DEFAULT 1 COMMENT '银联支付交易权重',
  `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '状态。0：未生效；1：已生效；',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注信息',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`mch_no`, `mch_app_id`, `mch_apply_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '应用与商户进件数据关联表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_app_copy1
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_app_copy1`;
CREATE TABLE `t_mch_app_copy1`  (
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `app_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '应用名称',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `top_agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '顶级代理商号',
  `default_flag` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否默认: 0-否、 1-是（api接口未显式指定应用则使用默认应用）',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '应用状态: 0-停用, 1-正常',
  `polling_bind_state` tinyint(6) NULL DEFAULT 0 COMMENT '轮询绑定状态。0 - 未开通；1 - 已开通自动绑定；2 - 不开通自动绑定',
  `app_sign_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '[\"MD5\"]' COMMENT '支持的加签方式: MD5、 RSA2（若使用系统测试或者app必须支持MD5）',
  `app_rsa2_public_key` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '应用公钥（RSA2）',
  `app_secret` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用私钥(MD5)',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `capabilities` json NULL COMMENT '配置的功能',
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `range` tinyint(1) NULL DEFAULT 0 COMMENT '0, 线下；1，线上',
  `api_flag` tinyint(1) NULL DEFAULT NULL COMMENT '0: 不支持; 1: 支持',
  `category` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '类目',
  `information` json NULL COMMENT '应用相关资料',
  `mcc_code` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '经营类目',
  `qualification_list` json NULL COMMENT '资质json',
  `pre_capabilities` json NULL COMMENT '开通需求功能',
  PRIMARY KEY (`app_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户应用表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_app_push_info
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_app_push_info`;
CREATE TABLE `t_mch_app_push_info`  (
  `cid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备号CID',
  `cid_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'app_plus' COMMENT '设备cid类型：app端：app_plus，小程序端：mp_weixin',
  `uni_push_version` tinyint(6) NOT NULL DEFAULT 1 COMMENT 'uniPush版本，1-1.0版本，2-2.0版本',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `sys_user_id` bigint(20) NOT NULL COMMENT '系统用户ID',
  `device_info` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备信息',
  PRIMARY KEY (`cid`, `uni_push_version`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户app推送设备表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_applyment
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_applyment`;
CREATE TABLE `t_mch_applyment`  (
  `apply_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '系统申请单号/商户号',
  `channel_apply_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道申请单号',
  `channel_sign_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道签约ID',
  `channel_diy_mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道要求的自定义商户号（建议采用mchNo_时间戳（10位）的形式）',
  `channel_mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '通道商户号，收单机构编号',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '服务商号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `top_agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '顶级代理商号',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `if_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '接口名称',
  `mch_full_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户全称',
  `mch_short_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户简称',
  `merchant_type` tinyint(6) NULL DEFAULT NULL COMMENT '商户类型： 1-个人, 2-个体工商户, 3-企业, 4-党政、机关及事业单位, 5-其他组织',
  `contact_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人（不一定的法人）姓名',
  `contact_phone` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人电话',
  `area_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '省市县编码 (非必填， 放在外层用作搜索方便)',
  `area_info` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '省市县名称描述',
  `address` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '详细地址',
  `apply_detail_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户进件详细消息（JSON类型）',
  `state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '状态: 0-未发起（草稿）、 1-审核中、 2-进件成功、 3-驳回待修改、 4-待验证、 5-待签约、6-签约完成/审核成功，等待其他操作、 7-等待系统预审核、 8-预审核拒绝、20-标记风控',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注信息',
  `remain_step` tinyint(1) NULL DEFAULT NULL COMMENT '入网操作剩余步骤，总共有几步主要看通道',
  `succ_res_parameter` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '进件成功接口返回参数, 用于配置到商户侧的参数信息',
  `channel_var1` json NULL COMMENT '渠道拓展参数1',
  `channel_var2` json NULL COMMENT '渠道拓展参数2',
  `cert_states` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '子商户认证状态',
  `store_succ_res_parameter` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '门店入驻成功接口返回参数',
  `apply_error_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '响应提示信息（一般进件异常或提示信息）',
  `ep_user_id` bigint(20) NULL DEFAULT NULL COMMENT '商户所属拓展员ID',
  `apply_page_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '进件来源',
  `settlement_type` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'D1、D0、T1',
  `auto_config_mch_app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '自动配置的应用ID，不为空自动进行关联等一系列配置',
  `auto_config_result_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '自动配置结果信息',
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者姓名',
  `last_apply_at` datetime NULL DEFAULT NULL COMMENT '最后一次请求上游时间',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `pay_interface_id` int(11) NULL DEFAULT NULL COMMENT '支付配置参数ID，关联t_mch_pay_interface_config的ID',
  PRIMARY KEY (`apply_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '特约商户进件信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_config
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_config`;
CREATE TABLE `t_mch_config`  (
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `config_key` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置KEY',
  `config_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置名称',
  `config_val` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置内容项',
  `group_key` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置分组',
  `type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'text' COMMENT '类型: text-输入框, textarea-多行文本, uploadImg-上传图片, switch-开关, radio-单选',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`config_key`, `mch_no`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_division_receiver
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_division_receiver`;
CREATE TABLE `t_mch_division_receiver`  (
  `receiver_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '分账接收者ID',
  `receiver_alias` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '接收者账号别名',
  `receiver_group_id` bigint(20) NULL DEFAULT NULL COMMENT '组ID（便于商户接口使用）',
  `receiver_group_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组名称',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `acc_type` tinyint(6) NOT NULL COMMENT '分账接收账号类型: 0-个人(对私) 1-商户(对公)',
  `acc_no` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分账接收账号',
  `acc_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '分账接收账号名称',
  `channel_acc_no` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道分账接收账号（账号创建完成后渠道侧账号）',
  `relation_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分账关系类型（参考微信）， 如： SERVICE_PROVIDER 服务商等',
  `relation_type_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '当选择自定义时，需要录入该字段。 否则为对应的名称',
  `division_profit` decimal(20, 6) NULL DEFAULT NULL COMMENT '分账比例',
  `state` tinyint(6) NOT NULL COMMENT '分账状态（本系统状态，并不调用上游关联关系）: 1-正常分账, 0-暂停分账',
  `channel_bind_result` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '上游绑定返回信息，一般用作查询账号异常时的记录',
  `channel_ext_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '渠道特殊信息（发起创建分账用户时渠道特殊参数，参考盛付通）',
  `bind_success_time` datetime NULL DEFAULT NULL COMMENT '绑定成功时间',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`receiver_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 800001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户分账接收者账号绑定关系表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_division_receiver_group
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_division_receiver_group`;
CREATE TABLE `t_mch_division_receiver_group`  (
  `receiver_group_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '组ID',
  `receiver_group_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '组名称',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `auto_division_flag` tinyint(6) NOT NULL DEFAULT 0 COMMENT '自动分账组（当订单分账模式为自动分账，改组将完成分账逻辑） 0-否 1-是',
  `created_uid` bigint(20) NOT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`receiver_group_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 100002 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '分账账号组' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_info
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_info`;
CREATE TABLE `t_mch_info`  (
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `mch_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户名称',
  `mch_short_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户简称',
  `type` tinyint(6) NOT NULL DEFAULT 1 COMMENT '类型: 1-普通商户, 2-特约商户(服务商模式)',
  `refund_mode` json NOT NULL COMMENT '支持的退款方式 [\"plat\", \"api\"]',
  `mch_level` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'M0' COMMENT '商户级别： M0(页面简洁，仅基础收款功能), M1(支持api调用， 支持配置应用及分账、转账功能)',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `agent_no_arr` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号数组',
  `top_agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '顶级代理商号',
  `contact_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人姓名',
  `contact_tel` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人手机号',
  `contact_email` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人邮箱',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '商户状态: 0-停用, 1-正常，2-由运营平台停用',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户备注',
  `init_user_id` bigint(20) NULL DEFAULT NULL COMMENT '初始用户ID（创建商户时，允许商户登录的用户）',
  `login_username` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '登录用户名',
  `sipw` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付密码(敏感信息密码Sensitive information password)',
  `advert_flag` tinyint(6) NULL DEFAULT 0 COMMENT '广告开关 0-关闭 1-开启',
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`mch_no`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_modify_applyment
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_modify_applyment`;
CREATE TABLE `t_mch_modify_applyment`  (
  `modify_apply_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户变更系统申请单号',
  `apply_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '系统申请单号/进件商户号',
  `channel_apply_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道申请单号',
  `channel_mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '通道商户号，收单机构编号',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码, 字段冗余',
  `if_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '接口名称, 字段冗余方便检索',
  `origin_detail_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '商户本次变更前的数据（JSON类型）',
  `apply_detail_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户变更详细信息（JSON类型）',
  `modify_apply_type` tinyint(1) NULL DEFAULT NULL COMMENT '1、基本资料变更; 2、结算信息变更; 3、费率信息变更; 4、身份信息补充; 5、通用变更(待定)',
  `state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '状态: 0-未发起（草稿）、 1-审核中、 2-进件成功、 3-驳回、5-待签约',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注信息',
  `remain_step` tinyint(1) NULL DEFAULT NULL COMMENT '商户变更剩余步骤，总共有几步主要看通道',
  `channel_var1` json NULL COMMENT '上游接口返回参数',
  `apply_error_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '响应提示信息（一般进件异常或提示信息）',
  `apply_page_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '变更来源',
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`modify_apply_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户进件变更信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_notify_record
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_notify_record`;
CREATE TABLE `t_mch_notify_record`  (
  `notify_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '商户通知记录ID',
  `order_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '订单ID',
  `order_type` tinyint(6) NOT NULL COMMENT '订单类型:1-支付,2-退款',
  `mch_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户订单号',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `notify_url` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '通知地址',
  `notify_post_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'POST_BODY' COMMENT '发送商户通知的方式：POST_QUERYSTRING, POST_BODY, POST_JSON',
  `res_result` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '通知响应结果',
  `notify_count` int(11) NOT NULL DEFAULT 0 COMMENT '通知次数',
  `notify_count_limit` int(11) NOT NULL DEFAULT 6 COMMENT '最大通知次数, 默认6次',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '通知状态,1-通知中,2-通知成功,3-通知失败',
  `last_notify_time` datetime NULL DEFAULT NULL COMMENT '最后一次通知时间',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`notify_id`) USING BTREE,
  UNIQUE INDEX `Uni_OrderId_Type`(`order_id`, `order_type`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户通知记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_pay_interface_config
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_pay_interface_config`;
CREATE TABLE `t_mch_pay_interface_config`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `sort` int(11) NOT NULL DEFAULT 1 COMMENT '排序字段',
  `alias` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '配置实例别名',
  `info_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账号类型: 参考： SYS_ROLE_TYPE ',
  `info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '服务商号/商户号/应用ID',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `if_params` json NOT NULL COMMENT '接口配置参数,json字符串',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '状态: 0-停用, 1-启用',
  `is_open_applyment` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否开启进件: 0-关闭, 1-开启',
  `is_check_bill` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否开启对账: 0-关闭, 1-开启',
  `ignore_check_bill_mch_nos` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '对账过滤子商户号',
  `cashout_params` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '提现配置，JSON字符串',
  `applyment_ext_params` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '进件特殊参数，JSON字符串',
  `oauth2_info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'oauth2的选择， 空表示使用默认配置条目',
  `sett_hold_day` int(11) NOT NULL DEFAULT 0 COMMENT '佣金结算周期（仅服务商配置， 用于代理商的佣金提现周期）',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_uid` bigint(20) NULL DEFAULT NULL COMMENT '更新者用户ID',
  `updated_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者姓名',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `Uni_InfoType_InfoId_IfCode`(`info_type`, `info_id`, `if_code`) USING BTREE,
  INDEX `alias`(`alias`, `if_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 19 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '支付接口配置参数可选值' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_pay_passage
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_pay_passage`;
CREATE TABLE `t_mch_pay_passage`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口',
  `way_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付方式',
  `risk_config` json NULL COMMENT '风控数据',
  `state` tinyint(6) NOT NULL COMMENT '状态: 0-停用, 1-启用',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `Uni_AppId_WayCode`(`app_id`, `if_code`, `way_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 34 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户支付通道表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_qrc_device_rela
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_qrc_device_rela`;
CREATE TABLE `t_mch_qrc_device_rela`  (
  `qrc_id` bigint(20) NOT NULL COMMENT '码牌ID',
  `device_id` bigint(20) NOT NULL COMMENT '设备ID',
  PRIMARY KEY (`qrc_id`, `device_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户码牌、设备关联表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_qrc_shell
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_qrc_shell`;
CREATE TABLE `t_mch_qrc_shell`  (
  `sid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '模板ID',
  `shell_alias` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '模板别名',
  `sys_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属系统： 参考：SYS_ROLE_TYPE',
  `belong_info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '所属商户ID / 0(平台)',
  `style_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'shellA' COMMENT '模板样式编码： shellA, shellB, shellC ...',
  `config_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '配置信息',
  `shell_img_view_url` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '模板图片地址(示例)',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`sid`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1002 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '码牌模板表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_qrcode_card
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_qrcode_card`;
CREATE TABLE `t_mch_qrcode_card`  (
  `qrc_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '码牌ID',
  `batch_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '批次号',
  `qrc_alias` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '码牌别名',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '划拨的代理商号， 默认为空串',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '绑定的商户号， 默认为空串',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '绑定的应用ID， 默认为空串',
  `store_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '绑定的商户门店ID， 0-表示空',
  `qrc_type` tinyint(6) NULL DEFAULT NULL COMMENT '码牌类型:0-电子码牌，1-实体码牌，2-实体立牌',
  `bind_state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '码牌绑定状态: 0-未绑定, 1-已绑定（一定存在mchNo、appId 和 storeId）',
  `entry_page` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'default' COMMENT '入口页面呈现方式: default-默认(未指定，取决于二维码是否绑定到微信侧), h5-仅H5网页, lite-仅小程序',
  `url_placeholder` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'URL自定义占位符，一般仅绑定多个小程序时需要',
  `fixed_flag` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否固定支付金额: 1-是, 0-否',
  `fixed_pay_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '固定支付金额,单位分',
  `alipay_way_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '指定支付宝的支付方式, 比如wap支付则为： ALI_WAP',
  `qrc_state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '码牌状态: 0-停用, 1-正常',
  `qrc_belong_type` tinyint(6) NOT NULL DEFAULT 1 COMMENT '码牌所属类型: 1-商户自制码牌, 2-运营平台下发码牌',
  `qrc_shell_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '码牌模板ID, 0-表示仅二维码',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`qrc_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 170443521593403 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户码牌表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_store
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_store`;
CREATE TABLE `t_mch_store`  (
  `store_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '门店ID',
  `store_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '门店名称',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `top_agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '顶级代理商号',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `bind_app_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '绑定应用ID',
  `mch_apply_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户号（原进件单号）',
  `default_flag` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否默认: 0-否、 1-是（api接口未显式指定门店则使用默认门店下单）',
  `lng` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '经度',
  `lat` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '纬度',
  `store_outer_img` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '门头照',
  `store_inner_img` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '内景照',
  `store_logo` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '门店Logo',
  `area_code` json NOT NULL COMMENT '省市县编码 (必填，放在外层用作搜索方便)',
  `contact_phone` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人手机号',
  `address` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所在地址',
  `alipay_shop_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '蚂蚁店铺ID',
  `alipay_shop_create_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '蚂蚁店铺申请单ID',
  `alipay_shop_status` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '蚂蚁店铺创建状态(与支付宝一致): 0-未创建; 99-已完结; -1-失败; 031-已提交审核',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`store_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1032 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户门店表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_store_device
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_store_device`;
CREATE TABLE `t_mch_store_device`  (
  `device_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '设备ID',
  `device_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备名称',
  `batch_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '批次号',
  `config_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '关联厂商配置ID',
  `device_type` tinyint(6) NOT NULL COMMENT '设备类型： 参考配置表',
  `provider` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备厂商：参考配置表',
  `device_no` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备号',
  `device_params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备参数，json字符串',
  `biz_config_params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '业务配置参数，json字符串',
  `bind_qrc_id` bigint(20) NULL DEFAULT NULL COMMENT '绑定码牌ID（批量添加云喇叭设备时绑定的码牌ID，与云喇叭设备一对一关系）',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '绑定的商户号， 默认为空串',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '绑定的应用ID， 默认为空串',
  `store_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '绑定的门店ID，0-表示空',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '划拨的代理商号， 默认为空串',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '状态： 0-停用，1-启用',
  `bind_state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '商户绑定状态： 0-未绑定，1-已绑定',
  `bind_type` tinyint(6) NOT NULL DEFAULT 0 COMMENT '绑定类型： 0-门店，1-码牌',
  `bind_time` datetime NULL DEFAULT NULL COMMENT '绑定时间',
  `unbind_time` datetime NULL DEFAULT NULL COMMENT '解绑时间',
  `alipay_bind_state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '蚂蚁店铺Iot设备绑定状态： 0-未绑定，1-已绑定',
  `alipay_shop_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '蚂蚁店铺ID',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`device_id`) USING BTREE,
  UNIQUE INDEX `IDX_Provider_Type_DeviceNo`(`provider`, `device_type`, `device_no`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1017 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户门店设备配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_store_terminal
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_store_terminal`;
CREATE TABLE `t_mch_store_terminal`  (
  `trm_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '表ID',
  `trm_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '终端编号',
  `trm_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '终端名称',
  `trm_type` bigint(20) NOT NULL COMMENT '设备类型 1-终端 2-扫码pos',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `mch_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户名称',
  `store_id` bigint(20) NOT NULL COMMENT '门店ID',
  `store_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '门店名称',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `areacode` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '区域编码',
  `areacode_names` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '区域编码名称',
  `detail_address` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '布放位置',
  `lng` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '经度',
  `lat` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '纬度',
  `state` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态： 0-停用 1-启用',
  `channel_bind_info` json NULL COMMENT '渠道绑定管理 { ifCode:{ ifCode:\"\", ifCodeName: \"\", state: 1, errInfo: \"\"} }',
  `default_flag` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否默认 1-是, 0-否',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`trm_id`) USING BTREE,
  UNIQUE INDEX `Uni_Trm_No`(`trm_no`, `mch_no`, `store_id`, `app_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户辅助终端信息报备表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_sub_info
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_sub_info`;
CREATE TABLE `t_mch_sub_info`  (
  `mch_apply_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 't_mch_applyment的apply_id',
  `channel_mch_no` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 't_mch_applyment的同名字段',
  `channel_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '接入渠道方号',
  `sub_mch_id` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '渠道子商户号',
  `sub_mch_type` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '渠道子商户类型',
  `sub_mch_way` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '渠道子商户号来源, 银联网联等',
  `remark` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注，接入报错信息等',
  `status` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '渠道报备状态',
  `main_use` int(1) NULL DEFAULT 0 COMMENT '是否主要使用，若主要使用，则将该记录的认证状态作为商户的实名认证状态',
  `auth_status` int(2) NULL DEFAULT 0 COMMENT '认证状态, 0：待认证；1： 认证完成',
  `created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`mch_apply_id`, `sub_mch_type`, `sub_mch_way`, `sub_mch_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '渠道子商户信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_third_config
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_third_config`;
CREATE TABLE `t_mch_third_config`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `channel_merchant_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '通道商户编号',
  `third_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'WX' COMMENT '类型 取值范围：wx zfb',
  `type` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置类型，取值范围：00 支付Appid 01 jsapi授权目录',
  `sub_mch_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '子商户号 对应微信或支付宝的子商户号 后期可能涉及银联子商户号',
  `appid_type` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付Appid类型，枚举值. 取值范围：00 公众号; 01 小程序; type=\"01\"时不为空',
  `sub_appid` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'appid',
  `jsapi_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'jsapi授权目录，长度256位 type 为01的时候不能为空',
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_merchant_id`(`channel_merchant_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mch_wxmp_user
-- ----------------------------
DROP TABLE IF EXISTS `t_mch_wxmp_user`;
CREATE TABLE `t_mch_wxmp_user`  (
  `user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '用户编号',
  `sys_user_id` bigint(20) NOT NULL COMMENT '系统用户ID',
  `nickname` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '微信昵称',
  `wx_open_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '微信openId',
  `wx_app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '微信 appId',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `send_status` tinyint(6) NOT NULL DEFAULT 0 COMMENT '消息推送状态：0-未开启，1-开启 2：推送失败，已自动关闭',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`user_id`) USING BTREE,
  UNIQUE INDEX `IDX_SysUserId_WxOpenId_WxAppId`(`sys_user_id`, `wx_open_id`, `wx_app_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户公众号消息接收用户列表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_member_account_history
-- ----------------------------
DROP TABLE IF EXISTS `t_member_account_history`;
CREATE TABLE `t_member_account_history`  (
  `hid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  `mbr_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '会员ID',
  `mbr_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '会员名称 快照',
  `mbr_tel` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '会员手机号 快照',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属商户',
  `store_id` bigint(20) NULL DEFAULT NULL COMMENT '商户门店ID (快照)',
  `qrc_id` bigint(20) NULL DEFAULT NULL COMMENT '码牌ID (快照)',
  `before_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '变动前账户余额, 单位：分',
  `change_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '变动金额, 单位：分',
  `after_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '变动后账户余额, 单位：分',
  `biz_type` tinyint(6) NOT NULL COMMENT '业务类型：1-支付充值, 2-现金充值, 3-消费, 4-消费退款, 5-人工调账',
  `rela_biz_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联订单号',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`hid`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员账户流水表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_member_info
-- ----------------------------
DROP TABLE IF EXISTS `t_member_info`;
CREATE TABLE `t_member_info`  (
  `mbr_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '会员ID',
  `mbr_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '会员名称',
  `mbr_tel` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '会员手机号',
  `wx_mp_open_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '微信公众号用户标识open_id',
  `wx_lite_open_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '微信小程序用户标识open_id',
  `ali_user_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付宝用户标识user_id',
  `ysf_user_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '云闪付用户标识user_id',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属商户',
  `balance` bigint(20) NOT NULL DEFAULT 0 COMMENT '账户余额 单位:分',
  `safe_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '数据安全保护秘钥',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '状态: 0-停用, 1-正常',
  `avatar_url` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '头像地址',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '会员备注',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`mbr_id`) USING BTREE,
  UNIQUE INDEX `UQ_MBR_TEL`(`mch_no`, `mbr_tel`) USING BTREE,
  UNIQUE INDEX `UQ_WX_MP_OPEN_ID`(`mch_no`, `wx_mp_open_id`) USING BTREE,
  UNIQUE INDEX `UQ_WX_LITE_OPEN_ID`(`mch_no`, `wx_lite_open_id`) USING BTREE,
  UNIQUE INDEX `UQ_ALI_USER_ID`(`mch_no`, `ali_user_id`) USING BTREE,
  UNIQUE INDEX `UQ_YSF_USER_ID`(`mch_no`, `ysf_user_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_member_recharge_record
-- ----------------------------
DROP TABLE IF EXISTS `t_member_recharge_record`;
CREATE TABLE `t_member_recharge_record`  (
  `recharge_record_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '充值记录ID',
  `mbr_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '会员ID',
  `mbr_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '会员名称 快照',
  `mbr_tel` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '会员手机号 快照',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属商户',
  `pay_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '支付金额, 单位：分',
  `give_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '赠送金额, 单位：分',
  `entry_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '会员入账金额, 单位：分',
  `after_balance` bigint(20) NULL DEFAULT NULL COMMENT '会员余额, 单位：分',
  `way_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付方式代码',
  `way_code_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付方式代码分类',
  `state` tinyint(6) NOT NULL COMMENT '充值状态：0-初始化, 1-充值中, 2-充值成功, 3-充值失败',
  `pay_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付订单号',
  `success_time` datetime NULL DEFAULT NULL COMMENT '订单支付成功时间',
  `return_url` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '同步跳转地址',
  `notify_url` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '异步通知地址',
  `err_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付错误码',
  `err_msg` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付错误描述',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '充值备注',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`recharge_record_id`) USING BTREE,
  UNIQUE INDEX `Uni_Pay_Order_Id`(`pay_order_id`) USING BTREE,
  INDEX `created_at`(`created_at`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员充值记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_member_recharge_rule
-- ----------------------------
DROP TABLE IF EXISTS `t_member_recharge_rule`;
CREATE TABLE `t_member_recharge_rule`  (
  `rule_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '规则ID',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属商户',
  `recharge_amount` bigint(20) NOT NULL COMMENT '充值金额',
  `give_amount` bigint(20) NULL DEFAULT 0 COMMENT '赠送金额',
  `state` tinyint(6) NOT NULL COMMENT '状态：0-停用 1-启用 ',
  `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序字段, 规则：正序',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`rule_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员充值规则表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_order_profit_sett_record
-- ----------------------------
DROP TABLE IF EXISTS `t_order_profit_sett_record`;
CREATE TABLE `t_order_profit_sett_record`  (
  `rid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '结算记录ID',
  `info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '运营平台标识/代理商号',
  `info_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '系统类型： 参考：SYS_ROLE_TYPE ',
  `info_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '名称快照',
  `info_payway_fee_detail` json NULL COMMENT '费率配置快照 (参考： ApplymentBasicInfo.paywayFeeList)',
  `pay_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付订单号（与t_pay_order对应）',
  `refund_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '退款订单号 (默认空串: 作用为使得唯一索引生效)',
  `cal_type` tinyint(6) NOT NULL COMMENT '计算类型： 1-支付订单入账, 2-退款退佣金',
  `cal_base_amount` bigint(20) NOT NULL COMMENT '计算基数金额, 单位分 （ 订单支付金额、 退款金额 ）',
  `cal_profit_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '利润结算金额, 单位：分',
  `cal_fee_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '费用金额, 单位：分',
  `entry_state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '入账状态： 0-未入账, 1-已入账',
  `entry_time` datetime NOT NULL COMMENT '预计入账日期(比如在途转钱包)',
  `task_time` datetime NULL DEFAULT NULL COMMENT '结算任务执行时间',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`rid`) USING BTREE,
  UNIQUE INDEX `Uni_Pay_Order_Id`(`info_id`, `info_type`, `pay_order_id`, `refund_order_id`, `cal_type`) USING BTREE,
  INDEX `Index_Create_At`(`created_at`) USING BTREE,
  INDEX `Index_Pay_Order_Id`(`pay_order_id`) USING BTREE,
  INDEX `Index_Refund_Order_Id`(`refund_order_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1081 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单分润结算记录' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_order_snapshot
-- ----------------------------
DROP TABLE IF EXISTS `t_order_snapshot`;
CREATE TABLE `t_order_snapshot`  (
  `order_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '订单ID',
  `order_type` tinyint(6) NOT NULL COMMENT '订单类型: 1-支付, 2-退款',
  `mch_req_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '下游请求数据',
  `mch_req_time` datetime NULL DEFAULT NULL COMMENT '下游请求时间',
  `mch_resp_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '向下游响应数据',
  `mch_resp_time` datetime NULL DEFAULT NULL COMMENT '向下游响应时间',
  `channel_req_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '向上游请求数据',
  `channel_req_time` datetime NULL DEFAULT NULL COMMENT '向上游请求时间',
  `channel_resp_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '上游响应数据',
  `channel_resp_time` datetime NULL DEFAULT NULL COMMENT '上游响应时间',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`order_id`, `order_type`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单接口数据快照' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_package_info
-- ----------------------------
DROP TABLE IF EXISTS `t_package_info`;
CREATE TABLE `t_package_info`  (
  `package_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '方案ID',
  `name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '名称',
  `desc` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '描述',
  `price` bigint(10) NULL DEFAULT NULL COMMENT '方案价格',
  `package_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '方案付费信息',
  `package_sort` tinyint(4) NULL DEFAULT NULL COMMENT '排序',
  `package_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '方案内容',
  `package_url` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '开发文档地址',
  `package_specs` tinyint(6) NULL DEFAULT NULL COMMENT '方案类型 0-服务型 1-接口型',
  `package_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '方案分类 ',
  `package_state` tinyint(4) NOT NULL DEFAULT 0 COMMENT '方案状态 0-待上架 1-已上架',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `created_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `package_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联方案的id，多个，逗号隔开',
  `product_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联产品的ids，多个，逗号隔开',
  `pay_interface_codes` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联通道的code，多个，逗号隔开',
  `func_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '固定功能代码',
  `extv` json NULL COMMENT '固定功能配置',
  PRIMARY KEY (`package_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '方案表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_package_order
-- ----------------------------
DROP TABLE IF EXISTS `t_package_order`;
CREATE TABLE `t_package_order`  (
  `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '订单号',
  `package_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方案ID',
  `product_id` bigint(20) NULL DEFAULT NULL COMMENT '产品ID',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '应用ID，\r\n应用ID为-1时，当前记录作为产品开通审核记录；\r\n应用ID有实际的应用ID时候，记录作为产品与应用关联记录',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户号',
  `state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '状态 0-未开通 1-审核中 2-审核失败 3-已开通 4-已取消',
  `state_desc` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核原因',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `created_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `price` bigint(11) NULL DEFAULT NULL COMMENT '开通价格，分',
  `actual_price` bigint(20) NULL DEFAULT 0 COMMENT '实付金额，默认是0，分',
  `pay_img` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付凭证图片',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `UQ_PRODUCT_APP`(`id`, `product_id`, `app_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户产品审核表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_package_order_detail
-- ----------------------------
DROP TABLE IF EXISTS `t_package_order_detail`;
CREATE TABLE `t_package_order_detail`  (
  `order_id` bigint(20) NOT NULL COMMENT '订单号，t_product_app的id',
  `package_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '方案ID',
  `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `created_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  PRIMARY KEY (`order_id`) USING BTREE,
  INDEX `package_id`(`package_id`, `product_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '方案订单关联产品缓存表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_package_product
-- ----------------------------
DROP TABLE IF EXISTS `t_package_product`;
CREATE TABLE `t_package_product`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '1、产品关联产品，2、产品关联方案，3、方案关联方案',
  `attach_from_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'type=1、2时为产品ID，',
  `attach_to_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'type=1时为产品ID，',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `created_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '方案-产品关联表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_package_type
-- ----------------------------
DROP TABLE IF EXISTS `t_package_type`;
CREATE TABLE `t_package_type`  (
  `type_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '分类ID',
  `type_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分类名称',
  `pid` tinyint(4) NOT NULL DEFAULT 0 COMMENT '父节点',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `created_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建人',
  PRIMARY KEY (`type_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '方案分类表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_pay_alizft_sett_record
-- ----------------------------
DROP TABLE IF EXISTS `t_pay_alizft_sett_record`;
CREATE TABLE `t_pay_alizft_sett_record`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '结算ID',
  `pay_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付订单号',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `mch_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户名称',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `pay_order_amount` bigint(20) NOT NULL COMMENT '支付金额,单位分',
  `pay_order_subject` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商品标题',
  `channel_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道订单号 如果为空有可能是补单任务',
  `sub_mch_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '二级商户ID',
  `state` tinyint(6) NOT NULL COMMENT '结算状态,1-待结算,2-结算中,3-结算成功,4-结算失败,5-限流待重试（一般为上游接口限流，等待定时任务重试）',
  `sett_time` datetime NULL DEFAULT NULL COMMENT '结算时间',
  `retry_count` int(11) NOT NULL DEFAULT 0 COMMENT '重试次数',
  `apply_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '调起接口信息',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `IDX_ChannelOrderNo`(`pay_order_id`, `channel_order_no`) USING BTREE,
  INDEX `Index_State`(`state`) USING BTREE,
  INDEX `Index_Created_at`(`created_at`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '直付通二级商户结算记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_pay_interface_config
-- ----------------------------
DROP TABLE IF EXISTS `t_pay_interface_config`;
CREATE TABLE `t_pay_interface_config`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `alt_id` int(11) NULL DEFAULT NULL COMMENT '关联支付配置表中的id, 即t_pay_interface_config_alternative表的id',
  `info_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账号类型: 参考： SYS_ROLE_TYPE ',
  `info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '服务商号/商户号/应用ID',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `if_params` json NOT NULL COMMENT '接口配置参数,json字符串',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '状态: 0-停用, 1-启用',
  `is_open_applyment` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否开启进件: 0-关闭, 1-开启',
  `is_check_bill` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否开启对账: 0-关闭, 1-开启',
  `ignore_check_bill_mch_nos` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '对账过滤子商户号',
  `cashout_params` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '提现配置，JSON字符串',
  `applyment_ext_params` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '进件特殊参数，JSON字符串',
  `oauth2_info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'oauth2的选择， 空表示使用默认配置条目',
  `sett_hold_day` int(11) NOT NULL DEFAULT 0 COMMENT '佣金结算周期（仅服务商配置， 用于代理商的佣金提现周期）',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_uid` bigint(20) NULL DEFAULT NULL COMMENT '更新者用户ID',
  `updated_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者姓名',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `channel_types` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支持通道的类型',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `Uni_InfoType_InfoId_IfCode`(`info_type`, `info_id`, `if_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 41 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '支付接口配置参数表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_pay_interface_define
-- ----------------------------
DROP TABLE IF EXISTS `t_pay_interface_define`;
CREATE TABLE `t_pay_interface_define`  (
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '接口代码 全小写  wxpay alipay ',
  `if_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '接口名称',
  `is_mch_mode` tinyint(6) NOT NULL DEFAULT 1 COMMENT '是否支持普通商户模式: 0-不支持, 1-支持',
  `is_isv_mode` tinyint(6) NOT NULL DEFAULT 1 COMMENT '是否支持服务商子商户模式: 0-不支持, 1-支持',
  `is_support_applyment` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否支持服务商的进件接口: 0-不支持, 1-支持',
  `is_open_applyment` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否开启进件功能: 0-关闭, 1-开启',
  `is_support_check_bill` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否支持对账: 0-不支持, 1-支持',
  `is_open_check_bill` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否开启对账: 0-关闭, 1-开启',
  `is_support_cashout` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否支持提现: 0-不支持, 1-支持',
  `is_open_cashout` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否开启提现: 0-关闭, 1-开启',
  `config_page_type` tinyint(6) NOT NULL DEFAULT 1 COMMENT '支付参数配置页面类型:1-JSON渲染,2-自定义',
  `isv_params` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'ISV接口配置定义描述,json字符串',
  `isvsub_mch_params` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '特约商户接口配置定义描述,json字符串',
  `normal_mch_params` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '普通商户接口配置定义描述,json字符串',
  `channel_types` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '通道类型：0专属通道；1线上通道；2线下通道；多个用英文逗号隔开',
  `way_codes` json NOT NULL COMMENT '支持的支付方式 [\"wxpay_jsapi\", \"wxpay_bar\"]',
  `channel_fee_cal_model` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道手续费计算方式， 包括： 手续费模式等',
  `icon` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '页面展示：卡片-图标',
  `bg_color` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '页面展示：卡片-背景色',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '状态: 0-停用, 1-启用',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`if_code`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '支付接口定义表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_pay_order
-- ----------------------------
DROP TABLE IF EXISTS `t_pay_order`;
CREATE TABLE `t_pay_order`  (
  `pay_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付订单号',
  `mch_ext_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '扩展商户号 现在的申请单编号 也是商户号',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号(更改成了用户号)',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `top_agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '顶级代理商号',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `mch_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户名称',
  `mch_type` tinyint(6) NOT NULL COMMENT '类型: 1-普通商户, 2-特约商户(服务商模式)',
  `store_id` bigint(20) NOT NULL COMMENT '商户门店ID',
  `store_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '门店名称',
  `lng` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '经度',
  `lat` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '纬度',
  `address` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所在地址',
  `device_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备类型：qr_code-码牌，scan_pos-扫码POS，auto_pos-智能POS，other-其他',
  `device_no` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备号',
  `device_provider` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备厂商，参考商户门店设备表',
  `qrc_id` bigint(20) NULL DEFAULT NULL COMMENT '码牌ID',
  `mch_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户订单号',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付接口代码',
  `way_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付方式代码',
  `way_code_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付方式代码分类',
  `amount` bigint(20) NOT NULL COMMENT '支付金额,单位分',
  `mch_fee_rate` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '商户手续费费率快照',
  `mch_fee_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '商户实际手续费,单位分 ( 订单手续费 - 手续费退还金额 )',
  `mch_order_fee_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '商户收单手续费,单位分 (订单快照)',
  `currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'cny' COMMENT '三位货币代码,人民币:cny',
  `state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '支付状态: 0-订单生成, 1-支付中, 2-支付成功, 3-支付失败, 4-已撤销, 5-已退款, 6-订单关闭',
  `notify_state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '向下游回调状态, 0-未发送,  1-已发送',
  `client_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '客户端IP',
  `subject` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商品标题',
  `body` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商品描述信息',
  `channel_isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道服务商机构号',
  `channel_mch_no` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道子商户号',
  `channel_extra` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '特定渠道发起额外参数',
  `channel_user` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道用户标识,如微信openId,支付宝账号',
  `channel_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道订单号',
  `platform_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付凭证上交易单号(微信、支付宝等交易单号)',
  `platform_mch_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付凭证上商户单号(微信、支付宝等商户单号)',
  `channel_biz_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '渠道特殊业务数据，各渠道业务自处理数据',
  `refund_state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '退款状态: 0-未发生实际退款, 1-部分退款, 2-全额退款',
  `refund_times` int(11) NOT NULL DEFAULT 0 COMMENT '退款次数',
  `refund_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '退款总金额,单位分',
  `division_mode` tinyint(6) NULL DEFAULT 0 COMMENT '订单分账模式：0-该笔订单不允许分账, 1-支付成功按配置自动完成分账, 2-商户手动分账(解冻商户金额)',
  `division_state` tinyint(6) NULL DEFAULT 0 COMMENT '订单分账状态：0-未发生分账, 1-等待分账任务处理, 2-分账处理中, 3-分账任务已结束(不体现状态)',
  `division_last_time` datetime NULL DEFAULT NULL COMMENT '最新分账时间',
  `err_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道支付错误码',
  `err_msg` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道支付错误描述',
  `ext_param` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户扩展参数',
  `notify_url` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '异步通知地址',
  `return_url` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '页面跳转地址',
  `buyer_remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '买家备注',
  `seller_remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '卖家备注',
  `ep_user_id` bigint(20) NULL DEFAULT NULL COMMENT '商户拓展员ID',
  `store_user_id` bigint(20) NULL DEFAULT NULL COMMENT '门店收银员ID',
  `mbr_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '会员ID',
  `mbr_tel` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '会员手机号',
  `expired_time` datetime NULL DEFAULT NULL COMMENT '订单失效时间',
  `success_time` datetime NULL DEFAULT NULL COMMENT '订单支付成功时间',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `dr_type` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '交易卡类型 00：借记卡 01：贷记卡 02：微信零钱 03：支付宝花呗 04：支付宝其他 05：数字货币 99：其他',
  `settle_type` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结算类型 D1 D0 T1 DS',
  PRIMARY KEY (`pay_order_id`) USING BTREE,
  UNIQUE INDEX `Uni_MchNo_MchOrderNo`(`mch_no`, `mch_order_no`) USING BTREE,
  UNIQUE INDEX `Uni_IfCode_ChannelOrderNo`(`if_code`, `channel_order_no`) USING BTREE,
  INDEX `Index_Platform_Order_No`(`platform_order_no`) USING BTREE,
  INDEX `Index_Platform_Mch_Order_No`(`platform_mch_order_no`) USING BTREE,
  INDEX `Index_Expired_Time`(`expired_time`) USING BTREE,
  INDEX `Index_State`(`state`) USING BTREE,
  INDEX `created_at`(`created_at`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '支付订单表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_pay_order_division_record
-- ----------------------------
DROP TABLE IF EXISTS `t_pay_order_division_record`;
CREATE TABLE `t_pay_order_division_record`  (
  `record_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '分账记录ID',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `mch_ext_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号，也就是现在的申请单编号',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `mch_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户名称',
  `mch_type` tinyint(6) NOT NULL COMMENT '类型: 1-普通商户, 2-特约商户(服务商模式)',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `pay_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '系统支付订单号',
  `pay_order_channel_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付订单渠道支付订单号',
  `pay_order_amount` bigint(20) NOT NULL COMMENT '订单金额,单位分',
  `pay_order_division_amount` bigint(20) NOT NULL COMMENT '订单实际分账金额, 单位：分（订单金额 - 商户手续费 - 已退款金额）',
  `cal_base_amount_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'INCOME_AMOUNT' COMMENT '计算分账金额的分账基数规则(退分使用)： ORDER_AMOUNT-订单金额， INCOME_AMOUNT-入账金额（订单金额-手续费）',
  `batch_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '系统分账批次号',
  `channel_batch_order_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '上游分账批次号',
  `state` tinyint(6) NOT NULL COMMENT '状态: 0-待分账 1-分账成功（明确成功）, 2-分账失败（明确失败）, 3-分账处理中（一般为渠道侧或定时任务）, 4-分账已受理（上游受理）',
  `channel_resp_result` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '上游返回数据包',
  `receiver_id` bigint(20) NOT NULL COMMENT '账号快照》 分账接收者ID',
  `receiver_group_id` bigint(20) NULL DEFAULT NULL COMMENT '账号快照》 组ID（便于商户接口使用）',
  `receiver_alias` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '接收者账号别名',
  `acc_type` tinyint(6) NOT NULL COMMENT '账号快照》 分账接收账号类型: 0-个人 1-商户',
  `acc_no` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账号快照》 分账接收账号',
  `acc_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '账号快照》 分账接收账号名称',
  `channel_acc_no` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '账号快照》 渠道分账接收账号（账号创建完成后渠道侧账号）',
  `relation_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账号快照》 分账关系类型（参考微信）， 如： SERVICE_PROVIDER 服务商等',
  `relation_type_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账号快照》 当选择自定义时，需要录入该字段。 否则为对应的名称',
  `division_profit` decimal(20, 6) NOT NULL COMMENT '账号快照》 配置的实际分账比例',
  `cal_division_amount` bigint(20) NOT NULL COMMENT '计算该接收方的分账金额,单位分',
  `refund_times` int(11) NOT NULL DEFAULT 0 COMMENT '退款次数',
  `refund_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '退款总金额,单位分',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`record_id`) USING BTREE,
  INDEX `Index_Created_at`(`created_at`) USING BTREE,
  INDEX `Index_State`(`state`) USING BTREE,
  INDEX `Index_Pay_Order_Id`(`pay_order_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '支付订单分账记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_pay_order_division_refund_record
-- ----------------------------
DROP TABLE IF EXISTS `t_pay_order_division_refund_record`;
CREATE TABLE `t_pay_order_division_refund_record`  (
  `division_refund_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分账退款订单号（支付系统生成订单号）',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `mch_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户名称',
  `mch_type` tinyint(6) NOT NULL COMMENT '类型: 1-普通商户, 2-特约商户(服务商模式)',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `state` tinyint(6) NOT NULL COMMENT '状态: 0-退款中 1-退款成功 2-退款失败',
  `pay_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '系统支付订单号',
  `pay_order_channel_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付订单渠道订单号',
  `pay_order_amount` bigint(20) NOT NULL COMMENT '订单支付金额, 单位：分',
  `pay_order_refund_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付订单退款订单号',
  `pay_order_refund_amount` bigint(20) NOT NULL COMMENT '支付订单退款发生金额, 单位：分',
  `division_record_id` bigint(20) NOT NULL COMMENT '分账记录ID',
  `division_batch_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '系统分账批次号',
  `receiver_id` bigint(20) NOT NULL COMMENT '账号快照》 分账接收者ID',
  `receiver_group_id` bigint(20) NULL DEFAULT NULL COMMENT '账号快照》 组ID（便于商户接口使用）',
  `receiver_alias` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '接收者账号别名',
  `acc_type` tinyint(6) NOT NULL COMMENT '账号快照》 分账接收账号类型: 0-个人 1-商户',
  `acc_no` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账号快照》 分账接收账号',
  `acc_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '账号快照》 分账接收账号名称',
  `channel_acc_no` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '账号快照》 渠道分账接收账号（账号创建完成后渠道侧账号）',
  `relation_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账号快照》 分账关系类型（参考微信）， 如： SERVICE_PROVIDER 服务商等',
  `relation_type_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账号快照》 当选择自定义时，需要录入该字段。 否则为对应的名称',
  `division_amount` bigint(20) NOT NULL COMMENT '分账金额,单位分',
  `division_profit` decimal(20, 6) NOT NULL COMMENT '账号快照》 配置的实际分账比例',
  `division_refund_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '分账退款金额,单位分',
  `channel_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道订单号',
  `err_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道错误码',
  `err_msg` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道错误描述',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`division_refund_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '支付订单分账退款记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_pay_way
-- ----------------------------
DROP TABLE IF EXISTS `t_pay_way`;
CREATE TABLE `t_pay_way`  (
  `way_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付方式代码  例如： wxpay_jsapi',
  `way_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付方式名称',
  `way_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'OTHER' COMMENT '支付方式分类：WECHAT-微信, ALIPAY-支付宝, YSFPAY-云闪付, UNIONPAY-银联, OTHER-其他',
  `product_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'PAY' COMMENT '产品类型：PAY-支付产品, TRANSFER-转账产品',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`way_code`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '支付方式表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_product_app_conn
-- ----------------------------
DROP TABLE IF EXISTS `t_product_app_conn`;
CREATE TABLE `t_product_app_conn`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'appID',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户号',
  `state` tinyint(4) NOT NULL DEFAULT 0 COMMENT '状态 0: 未绑定；1：已绑定',
  `state_desc` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核原因',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `created_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `UQ_PRODUCT_APP`(`product_id`, `app_id`, `mch_no`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户应用产品关联表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_product_info
-- ----------------------------
DROP TABLE IF EXISTS `t_product_info`;
CREATE TABLE `t_product_info`  (
  `product_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '产品ID',
  `product_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '产品名称',
  `product_desc` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '产品简介',
  `product_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '产品内容',
  `product_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '产品付费信息',
  `product_sort` int(10) UNSIGNED NULL DEFAULT 100 COMMENT '排序',
  `price` bigint(11) NULL DEFAULT NULL COMMENT '开通价格，元',
  `product_url` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '开发文档地址',
  `product_specs` tinyint(6) NULL DEFAULT NULL COMMENT '产品类型 0-服务型 1-接口型',
  `product_type` tinyint(6) NOT NULL DEFAULT 0 COMMENT '产品分类 0-支付产品',
  `product_state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '产品状态 0-待上架 1-已上架',
  `func_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '固定功能Code',
  `created_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `product_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '价格',
  `package_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联方案的id，多个，逗号隔开',
  `product_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联产品的ids，多个，逗号隔开',
  `pay_interface_codes` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联通道的code，多个，逗号隔开',
  PRIMARY KEY (`product_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '产品信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_product_type
-- ----------------------------
DROP TABLE IF EXISTS `t_product_type`;
CREATE TABLE `t_product_type`  (
  `type_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '分类ID',
  `type_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分类名称',
  `pid` tinyint(6) NOT NULL DEFAULT 0 COMMENT '父节点',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `created_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建人',
  PRIMARY KEY (`type_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 42 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '产品分类表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_qualification_define
-- ----------------------------
DROP TABLE IF EXISTS `t_qualification_define`;
CREATE TABLE `t_qualification_define`  (
  `code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称',
  `params` json NULL,
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`code`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '资质配置定义表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_rate_config
-- ----------------------------
DROP TABLE IF EXISTS `t_rate_config`;
CREATE TABLE `t_rate_config`  (
  `info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '渠道商/服务商/用户ID',
  `info_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '系统类型： 参考：SYS_ROLE_TYPE ',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道商编号，info_type不是渠道商时必填',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `way_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付方式代码',
  `range` int(11) NULL DEFAULT NULL COMMENT '配置范围',
  `mcc_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '资质类型',
  `applyment_support` tinyint(6) NOT NULL DEFAULT 0 COMMENT '进件是否显示（仅服务商配置） 1-是, 0-否',
  `fee_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '冗余字段： 费率方式： SINGLE  LEVEL',
  `fee_rate` decimal(20, 6) NULL DEFAULT NULL COMMENT '冗余字段：单笔费率',
  `payway_fee_detail` json NULL COMMENT '费率配置 (参考： ApplymentBasicInfo.paywayFeeList)',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  UNIQUE INDEX `Uni_Info_id`(`info_id`, `info_type`, `if_code`, `way_code`, `range`, `mcc_code`, `isv_no`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '费率配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_refund_order
-- ----------------------------
DROP TABLE IF EXISTS `t_refund_order`;
CREATE TABLE `t_refund_order`  (
  `refund_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '退款订单号（支付系统生成订单号）',
  `pay_order_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付订单号（与t_pay_order对应）',
  `channel_pay_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道支付单号（与t_pay_order channel_order_no对应）',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号（现在更改为用户号）',
  `mch_ext_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号，也就是现在的申请单编号',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `top_agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '顶级代理商号',
  `store_id` bigint(20) NOT NULL COMMENT '商户门店ID',
  `store_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '门店名称',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `mch_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户名称',
  `mch_type` tinyint(6) NOT NULL COMMENT '类型: 1-普通商户, 2-特约商户(服务商模式)',
  `device_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备类型：qr_code-码牌，scan_pos-扫码POS，auto_pos-智能POS，other-其他',
  `device_no` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备号',
  `device_provider` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备厂商，参考商户门店设备表',
  `mch_refund_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户退款单号（商户系统的订单号）',
  `way_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付方式代码',
  `way_code_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付方式代码分类',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `pay_amount` bigint(20) NOT NULL COMMENT '支付金额,单位分',
  `refund_amount` bigint(20) NOT NULL COMMENT '退款金额,单位分',
  `refund_fee_amount` bigint(20) NOT NULL COMMENT '手续费退还金额, 单位：分',
  `currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'cny' COMMENT '三位货币代码,人民币:cny',
  `state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '退款状态:0-订单生成,1-退款中,2-退款成功,3-退款失败,4-退款任务关闭',
  `client_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '客户端IP',
  `refund_reason` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '退款原因',
  `channel_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道订单号',
  `channel_biz_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '渠道特殊业务数据，各渠道业务自处理数据',
  `err_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道错误码',
  `err_msg` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道错误描述',
  `channel_extra` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '特定渠道发起时额外参数',
  `notify_url` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '通知地址',
  `ext_param` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '扩展参数',
  `store_user_id` bigint(20) NULL DEFAULT NULL COMMENT '门店收银员ID',
  `success_time` datetime NULL DEFAULT NULL COMMENT '订单退款成功时间',
  `expired_time` datetime NULL DEFAULT NULL COMMENT '退款失效时间（失效后系统更改为退款任务关闭状态）',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `refund_type` tinyint(6) NULL DEFAULT 1 COMMENT '退款类型 1：全额退款 2：部分退款',
  PRIMARY KEY (`refund_order_id`) USING BTREE,
  UNIQUE INDEX `Uni_MchNo_MchRefundNo`(`mch_no`, `mch_refund_no`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '退款订单表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_settle_info
-- ----------------------------
DROP TABLE IF EXISTS `t_settle_info`;
CREATE TABLE `t_settle_info`  (
  `settle_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '结算编号',
  `bill_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '通道结算账单号',
  `appid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `mch_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户号(原先的商户号)',
  `mch_ext_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号 也就是申请单编号 现在改成商户号了',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `mch_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户名称',
  `channel_mch_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '通道商户编号',
  `settle_type` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'D0 D1 T1',
  `plan_amt` bigint(15) NULL DEFAULT 0 COMMENT '预付金额',
  `settle_amt` bigint(15) NULL DEFAULT 0 COMMENT '结算金额',
  `fee` bigint(10) NULL DEFAULT 0 COMMENT '手续费',
  `state` tinyint(2) NOT NULL DEFAULT 0 COMMENT '结算状态 -1：付款失败 0：待付款 1：付款中  2：付款成功，3：暂缓 4：冻结 5：退票 98:待查看(针对部分通道没有结算记录的情况下，使用该状态让客户核实银行卡的到账流水) 99：其他',
  `account_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结算账户号',
  `account_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结算账户名',
  `settle_date` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结算日期',
  `ext_flow_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '扩展流水号',
  `channel_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '通道错误码',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注 一般用于存储通道相关的返回信息',
  `extra` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '扩展参数',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '通道类型',
  `bank_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行名称',
  `channel_state` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '通道返回的结算状态',
  PRIMARY KEY (`settle_no`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_stats_channel
-- ----------------------------
DROP TABLE IF EXISTS `t_stats_channel`;
CREATE TABLE `t_stats_channel`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `stats_date` date NOT NULL COMMENT '统计日期',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `total_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '订单总笔数',
  `total_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '订单总金额，单位分',
  `success_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '成交订单笔数，含退款',
  `success_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '成交订单金额，单位分，含退款金额和手续费',
  `fee` bigint(20) NOT NULL DEFAULT 0 COMMENT '商户手续费，单位分',
  `refund_fee` bigint(20) NOT NULL DEFAULT 0 COMMENT '商户手续费回退，单位分，退款时退还的手续费',
  `real_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '实收金额，单位分，成交订单金额减去手续费',
  `refund_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '退款总笔数，一笔订单多次退款，则计多次',
  `refund_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '退款金额，单位分',
  `success_rate` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '交易成功率，成交订单笔数/订单总笔数',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '状态，1-完成  0-异常',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `Uni_Date_If_MchNo`(`stats_date`, `if_code`, `mch_no`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '通道数据统计表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_stats_device
-- ----------------------------
DROP TABLE IF EXISTS `t_stats_device`;
CREATE TABLE `t_stats_device`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `stats_date` date NOT NULL COMMENT '统计日期',
  `device_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备类型，参考t_pay_order',
  `device_no` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备号',
  `provider` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备厂商：参考配置表',
  `store_id` bigint(20) NOT NULL COMMENT '门店ID',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `total_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '订单总笔数',
  `total_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '订单总金额，单位分',
  `success_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '成交订单笔数，含退款',
  `success_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '成交订单金额，单位分，含退款金额和手续费',
  `fee` bigint(20) NOT NULL DEFAULT 0 COMMENT '商户手续费，单位分',
  `real_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '实收金额，单位分，成交订单金额减去手续费',
  `refund_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '退款总笔数，一笔订单多次退款，则计多次',
  `refund_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '退款金额，单位分',
  `success_rate` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '交易成功率，成交订单笔数/订单总笔数',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '状态，1-完成  0-异常',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `Uni_Date_Device_StoreId`(`stats_date`, `device_type`, `device_no`, `store_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '设备数据统计表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_stats_pay_way
-- ----------------------------
DROP TABLE IF EXISTS `t_stats_pay_way`;
CREATE TABLE `t_stats_pay_way`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `stats_date` date NOT NULL COMMENT '统计日期',
  `way_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `way_code_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码类型',
  `store_id` bigint(20) NOT NULL COMMENT '门店ID',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `total_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '订单总笔数',
  `total_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '订单总金额，单位分',
  `success_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '成交订单笔数，含退款',
  `success_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '成交订单金额，单位分，含退款金额和手续费',
  `fee` bigint(20) NOT NULL DEFAULT 0 COMMENT '商户手续费，单位分',
  `real_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '实收金额，单位分，成交订单金额减去手续费',
  `refund_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '退款总笔数，一笔订单多次退款，则计多次',
  `refund_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '退款金额，单位分',
  `success_rate` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '交易成功率，成交订单笔数/订单总笔数',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '状态，1-完成  0-异常',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `Uni_Date_WayCode_StoreId`(`stats_date`, `way_code`, `store_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '支付方式数据统计表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_stats_task_record
-- ----------------------------
DROP TABLE IF EXISTS `t_stats_task_record`;
CREATE TABLE `t_stats_task_record`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `task_type` tinyint(6) NOT NULL COMMENT '任务类型： 1-统计定时任务  2-平台数据修复',
  `begin_time` datetime NOT NULL COMMENT '任务开始时间',
  `end_time` datetime NULL DEFAULT NULL COMMENT '任务结束时间',
  `stats_begin_date` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '统计开始日期',
  `stats_end_date` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '统计结束日期',
  `state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '状态，0-任务进行中 1-任务完成 2-任务失败',
  `err_msg` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '任务成功/失败描述',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1034 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '数据统计任务记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_stats_trade
-- ----------------------------
DROP TABLE IF EXISTS `t_stats_trade`;
CREATE TABLE `t_stats_trade`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `stats_date` date NOT NULL COMMENT '统计日期',
  `store_id` bigint(20) NOT NULL COMMENT '门店ID',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `total_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '订单总笔数',
  `total_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '订单总金额，单位分',
  `success_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '成交订单笔数，含退款',
  `success_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '成交订单金额，单位分，含退款金额和手续费',
  `fee` bigint(20) NOT NULL DEFAULT 0 COMMENT '商户手续费，单位分',
  `refund_fee` bigint(20) NOT NULL DEFAULT 0 COMMENT '商户手续费回退，单位分，退款时退还的手续费',
  `real_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '实收金额，单位分，成交订单金额减去手续费',
  `refund_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '退款总笔数，一笔订单多次退款，则计多次',
  `refund_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '退款金额，单位分',
  `agent_profit` bigint(20) NOT NULL DEFAULT 0 COMMENT '代理商佣金，单位分',
  `success_rate` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '交易成功率，成交订单笔数/订单总笔数',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '状态，1-完成  0-异常',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `Uni_Date_StoreId`(`stats_date`, `store_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 867 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '交易数据统计表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_store_user_work_record
-- ----------------------------
DROP TABLE IF EXISTS `t_store_user_work_record`;
CREATE TABLE `t_store_user_work_record`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `sys_user_id` bigint(20) NOT NULL COMMENT '用户ID',
  `login_username` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '登录用户名',
  `realname` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '真实姓名',
  `user_no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '员工编号',
  `store_id` bigint(20) NULL DEFAULT NULL COMMENT '门店ID',
  `mch_no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户编号',
  `success_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '成交订单笔数，含退款',
  `success_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '成交订单金额，单位分，含退款金额和手续费',
  `refund_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '退款总笔数，一笔订单多次退款，则计多次',
  `refund_amount` bigint(20) NOT NULL DEFAULT 0 COMMENT '退款金额，单位分',
  `work_start_time` datetime NULL DEFAULT NULL COMMENT '登录时间',
  `login_page_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '登录方式， 参考：JWTPayload',
  `work_end_time` datetime NULL DEFAULT NULL COMMENT '退出时间',
  `logout_page_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '登出方式， 参考：JWTPayload',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户员工交接班记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_advert_config
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_advert_config`;
CREATE TABLE `t_sys_advert_config`  (
  `advert_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '广告ID',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `title` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '广告标题',
  `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '广告内容',
  `img_url` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '广告图片',
  `link_url` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '广告连接',
  `app_place` tinyint(6) NULL DEFAULT NULL COMMENT '广告位置 1-启动页 2-首页 3-我的页',
  `app_place_type` tinyint(6) NULL DEFAULT NULL COMMENT 'APP广告类型 1-卡片广告 2-轮播广告',
  `app_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '参数json数组 [{\"imgUrl\":\"图片地址\",\"linkUrl\":\"链接地址\",\"sort\":\"排序正序\"}]',
  `advert_sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序字段, 规则：正序',
  `change_time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '广告轮播时间',
  `release_state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '发布状态 0-未发布 1-已发布',
  `advert_type` tinyint(6) NOT NULL COMMENT '广告类型：1-刷脸设备广告 2-支付后广告 3-商户通APP 4-展业宝APP 5-商户登录页 6-代理商登录页',
  `created_uid` bigint(20) NOT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者姓名',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`advert_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 100003 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统广告配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_article
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_article`;
CREATE TABLE `t_sys_article`  (
  `article_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '文章ID',
  `title` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文章标题',
  `subtitle` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文章副标题',
  `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文章主内容',
  `publisher` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '发布人',
  `publish_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '发布时间',
  `article_range` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文章范围',
  `article_type` tinyint(6) NOT NULL COMMENT '文章类型 1：公告 ',
  `created_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建者用户ID',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人名称',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`article_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1002 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统文章管理表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_client_version
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_client_version`;
CREATE TABLE `t_sys_client_version`  (
  `version_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'versionID',
  `version_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '版本名称',
  `version_serial_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '版本序列号',
  `version_desc` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '版本描述信息',
  `force_update` tinyint(6) NOT NULL COMMENT '是否需要强制更新 1-是, 0-否',
  `download_url` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '下载地址',
  `file_size` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文件大小，单位：M ',
  `client_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '客户端类型：MCH_APP: 商户APP, AGENT_APP: 代理商APP',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`version_id`) USING BTREE,
  UNIQUE INDEX `IDX_ClientType_VersionSerialNumber`(`client_type`, `version_serial_number`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '客户端更新表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_config
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_config`;
CREATE TABLE `t_sys_config`  (
  `config_key` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置KEY',
  `config_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置名称',
  `config_desc` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '描述信息',
  `group_key` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分组key',
  `group_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分组名称',
  `config_val` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '配置内容项',
  `type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'text' COMMENT '类型: text-输入框, textarea-多行文本, uploadImg-上传图片, switch-开关',
  `sort_num` bigint(20) NOT NULL DEFAULT 0 COMMENT '显示顺序',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`config_key`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_entitlement
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_entitlement`;
CREATE TABLE `t_sys_entitlement`  (
  `ent_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '权限ID[ENT_功能模块_子模块_操作], eg: ENT_ROLE_LIST_ADD',
  `ent_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '权限名称',
  `menu_icon` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单图标',
  `menu_uri` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单uri/路由地址',
  `component_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组件Name（前后端分离使用）',
  `ent_type` char(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '权限类型 ML-左侧显示菜单, MO-其他菜单, PB-页面/按钮',
  `quick_jump` tinyint(6) NOT NULL DEFAULT 0 COMMENT '快速开始菜单 0-否, 1-是',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '状态 0-停用, 1-启用',
  `pid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '父ID',
  `ent_sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序字段, 规则：正序',
  `sys_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属系统： 参考：SYS_ROLE_TYPE',
  `match_rule` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单匹配规则，具体规则匹配详见程序说明',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`ent_id`, `sys_type`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统权限表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_entitlement_copy1
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_entitlement_copy1`;
CREATE TABLE `t_sys_entitlement_copy1`  (
  `ent_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '权限ID[ENT_功能模块_子模块_操作], eg: ENT_ROLE_LIST_ADD',
  `ent_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '权限名称',
  `menu_icon` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单图标',
  `menu_uri` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单uri/路由地址',
  `component_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组件Name（前后端分离使用）',
  `ent_type` char(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '权限类型 ML-左侧显示菜单, MO-其他菜单, PB-页面/按钮',
  `quick_jump` tinyint(6) NOT NULL DEFAULT 0 COMMENT '快速开始菜单 0-否, 1-是',
  `state` tinyint(6) NOT NULL DEFAULT 1 COMMENT '状态 0-停用, 1-启用',
  `pid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '父ID',
  `ent_sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序字段, 规则：正序',
  `sys_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属系统： 参考：SYS_ROLE_TYPE',
  `match_rule` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '菜单匹配规则，具体规则匹配详见程序说明',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`ent_id`, `sys_type`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统权限表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_legal_day
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_legal_day`;
CREATE TABLE `t_sys_legal_day`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `date_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'holiday' COMMENT '日期类型 holiday-节假日 workday-工作日',
  `date_value` date NOT NULL COMMENT '日期',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `Uni_Date_Value`(`date_value`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 100001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '法定节假日配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_log
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_log`;
CREATE TABLE `t_sys_log`  (
  `sys_log_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `user_id` bigint(20) NULL DEFAULT NULL COMMENT '系统用户ID',
  `user_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户姓名',
  `user_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户IP',
  `sys_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属系统：参考：SYS_ROLE_TYPE',
  `method_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '方法名',
  `method_remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '方法描述',
  `req_url` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '请求地址',
  `opt_req_param` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '操作请求参数',
  `opt_res_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '操作响应结果',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  PRIMARY KEY (`sys_log_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 15842 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统操作日志表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_role
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_role`;
CREATE TABLE `t_sys_role`  (
  `role_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色ID, ROLE_开头',
  `role_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色名称',
  `sys_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属系统： 参考：SYS_ROLE_TYPE',
  `belong_info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '所属商户ID / 0(平台)',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`role_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统角色表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_role_ent_rela
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_role_ent_rela`;
CREATE TABLE `t_sys_role_ent_rela`  (
  `role_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色ID',
  `ent_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '权限ID',
  PRIMARY KEY (`role_id`, `ent_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统角色权限关联表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_user
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_user`;
CREATE TABLE `t_sys_user`  (
  `sys_user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '系统用户ID',
  `login_username` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '登录用户名',
  `realname` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '真实姓名',
  `telphone` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '手机号',
  `sex` tinyint(6) NOT NULL DEFAULT 0 COMMENT '性别 0-未知, 1-男, 2-女',
  `avatar_url` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '头像地址',
  `user_no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '员工编号',
  `invite_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邀请码',
  `user_type` tinyint(6) NOT NULL DEFAULT 3 COMMENT '用户类型： 1-超级管理员 2-普通用户 3-拓展员, 11-店长, 12-店员',
  `team_id` bigint(20) NULL DEFAULT NULL COMMENT '团队ID',
  `is_team_leader` tinyint(6) NOT NULL DEFAULT 0 COMMENT '是否队长 1-是 0-否',
  `state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '状态 0-停用 1-启用',
  `sys_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属系统： 参考：SYS_ROLE_TYPE',
  `belong_info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '所属商户ID / 0(平台)',
  `mfa_bind_state` tinyint(6) NULL DEFAULT 0 COMMENT 'MFA绑定状态 0-未绑定 1-已绑定',
  `mfa_secret_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'MFA验证秘钥',
  `safe_word` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '安全预留信息',
  `pwd_expired_time` datetime NOT NULL COMMENT '密码过期时间',
  `last_reset_pwd_time` datetime NULL DEFAULT NULL COMMENT '最后一次重置密码时间',
  `last_login_time` datetime NULL DEFAULT NULL COMMENT '上次登录时间',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`sys_user_id`) USING BTREE,
  UNIQUE INDEX `UQ_LOGIN_USERNAME`(`sys_type`, `login_username`) USING BTREE,
  UNIQUE INDEX `UQ_TELPHONE`(`sys_type`, `telphone`) USING BTREE,
  UNIQUE INDEX `UQ_USER_NO`(`sys_type`, `belong_info_id`, `user_no`) USING BTREE,
  UNIQUE INDEX `UQ_INVITE_CODE`(`invite_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 100073 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统用户表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_user_auth
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_user_auth`;
CREATE TABLE `t_sys_user_auth`  (
  `auth_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `user_id` bigint(20) NOT NULL COMMENT 'user_id',
  `identity_type` tinyint(6) NOT NULL DEFAULT 0 COMMENT '登录类型  1-登录账号 2-手机号 3-邮箱  10-微信  11-QQ 12-支付宝 13-微博',
  `identifier` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '认证标识 ( 用户名 | open_id )',
  `credential` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '密码凭证',
  `salt` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'salt',
  `sys_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属系统： 参考：SYS_ROLE_TYPE',
  PRIMARY KEY (`auth_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1086 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统用户认证表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_user_entrule_rela
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_user_entrule_rela`;
CREATE TABLE `t_sys_user_entrule_rela`  (
  `sys_user_id` bigint(20) NOT NULL COMMENT '系统用户ID',
  `rules` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '菜单匹配规则，具体规则匹配详见程序说明, JSONArray格式 ',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`sys_user_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户<->权限规则 关联表 ' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_user_mch_store_rela
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_user_mch_store_rela`;
CREATE TABLE `t_sys_user_mch_store_rela`  (
  `sys_user_id` bigint(20) NOT NULL COMMENT '操作员ID',
  `user_type` tinyint(6) NOT NULL DEFAULT 12 COMMENT '用户类型： 1-超级管理员 2-普通用户 3-拓展员, 11-店长, 12-店员',
  `store_id` bigint(20) NOT NULL COMMENT '绑定的门店ID，0-表示空',
  `store_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '门店名称',
  PRIMARY KEY (`sys_user_id`, `store_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '操作员和商户门店关联表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_user_role_rela
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_user_role_rela`;
CREATE TABLE `t_sys_user_role_rela`  (
  `user_id` bigint(20) NOT NULL COMMENT '用户ID',
  `role_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色ID',
  PRIMARY KEY (`user_id`, `role_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '操作员<->角色 关联表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_user_team
-- ----------------------------
DROP TABLE IF EXISTS `t_sys_user_team`;
CREATE TABLE `t_sys_user_team`  (
  `team_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '团队ID',
  `team_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '团队名',
  `team_no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '团队编号',
  `stat_range_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '统计周期',
  `sys_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属系统： 参考：SYS_ROLE_TYPE',
  `belong_info_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '所属代理商ID / 0(平台)',
  `remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`team_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '人员团队表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_transfer_order
-- ----------------------------
DROP TABLE IF EXISTS `t_transfer_order`;
CREATE TABLE `t_transfer_order`  (
  `transfer_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '转账订单号',
  `mch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户号',
  `mch_ext_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '新版商户号也就是申请单id',
  `isv_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务商号',
  `agent_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '代理商号',
  `app_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '应用ID',
  `mch_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户名称',
  `mch_type` tinyint(6) NOT NULL COMMENT '类型: 1-普通商户, 2-特约商户(服务商模式)',
  `mch_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商户订单号',
  `if_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '支付接口代码',
  `mch_fee_rate` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户转账手续费费率快照, 空表示没有配置费率信息，但是不影响转账。 无非就是统计数据不准确+代理商无法计算分润。',
  `mch_order_fee_amount` bigint(20) NULL DEFAULT NULL COMMENT '商户转账手续费,单位分 (订单快照)',
  `entry_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '入账方式： WX_CASH-微信零钱; ALIPAY_CASH-支付宝转账; BANK_CARD-银行卡;  BANK_CARD_CORPORATE-企业银行卡; CHANNEL_CASH-渠道预存账户',
  `amount` bigint(20) NOT NULL COMMENT '转账金额,单位分',
  `currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'cny' COMMENT '三位货币代码,人民币:cny',
  `account_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '收款账号',
  `account_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '收款人姓名',
  `bank_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '收款人开户行名称',
  `transfer_desc` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '转账备注信息',
  `client_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '客户端IP',
  `state` tinyint(6) NOT NULL DEFAULT 0 COMMENT '支付状态: 0-订单生成, 1-转账中, 2-转账成功, 3-转账失败, 4-订单关闭',
  `channel_extra` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '特定渠道发起额外参数',
  `channel_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道订单号',
  `err_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道支付错误码',
  `err_msg` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '渠道支付错误描述',
  `ext_param` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户扩展参数',
  `notify_url` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '异步通知地址',
  `success_time` datetime NULL DEFAULT NULL COMMENT '转账成功时间',
  `created_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  `updated_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
  PRIMARY KEY (`transfer_id`) USING BTREE,
  UNIQUE INDEX `Uni_MchNo_MchOrderNo`(`mch_no`, `mch_order_no`) USING BTREE,
  INDEX `created_at`(`created_at`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '转账订单表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for xxl_job_group
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_group`;
CREATE TABLE `xxl_job_group`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `app_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '执行器AppName',
  `title` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '执行器名称',
  `address_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '执行器地址类型：0=自动注册、1=手动录入',
  `address_list` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '执行器地址列表，多地址逗号分隔',
  `update_time` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for xxl_job_info
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_info`;
CREATE TABLE `xxl_job_info`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `job_group` int(11) NOT NULL COMMENT '执行器主键ID',
  `job_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `add_time` datetime NULL DEFAULT NULL,
  `update_time` datetime NULL DEFAULT NULL,
  `author` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '作者',
  `alarm_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '报警邮件',
  `schedule_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'NONE' COMMENT '调度类型',
  `schedule_conf` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '调度配置，值含义取决于调度类型',
  `misfire_strategy` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'DO_NOTHING' COMMENT '调度过期策略',
  `executor_route_strategy` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '执行器路由策略',
  `executor_handler` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '执行器任务handler',
  `executor_param` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '执行器任务参数',
  `executor_block_strategy` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '阻塞处理策略',
  `executor_timeout` int(11) NOT NULL DEFAULT 0 COMMENT '任务执行超时时间，单位秒',
  `executor_fail_retry_count` int(11) NOT NULL DEFAULT 0 COMMENT '失败重试次数',
  `glue_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'GLUE类型',
  `glue_source` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'GLUE源代码',
  `glue_remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'GLUE备注',
  `glue_updatetime` datetime NULL DEFAULT NULL COMMENT 'GLUE更新时间',
  `child_jobid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '子任务ID，多个逗号分隔',
  `trigger_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '调度状态：0-停止，1-运行',
  `trigger_last_time` bigint(13) NOT NULL DEFAULT 0 COMMENT '上次调度时间',
  `trigger_next_time` bigint(13) NOT NULL DEFAULT 0 COMMENT '下次调度时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for xxl_job_lock
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_lock`;
CREATE TABLE `xxl_job_lock`  (
  `lock_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '锁名称',
  PRIMARY KEY (`lock_name`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for xxl_job_log
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_log`;
CREATE TABLE `xxl_job_log`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `job_group` int(11) NOT NULL COMMENT '执行器主键ID',
  `job_id` int(11) NOT NULL COMMENT '任务，主键ID',
  `executor_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '执行器地址，本次执行的地址',
  `executor_handler` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '执行器任务handler',
  `executor_param` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '执行器任务参数',
  `executor_sharding_param` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '执行器任务分片参数，格式如 1/2',
  `executor_fail_retry_count` int(11) NOT NULL DEFAULT 0 COMMENT '失败重试次数',
  `trigger_time` datetime NULL DEFAULT NULL COMMENT '调度-时间',
  `trigger_code` int(11) NOT NULL COMMENT '调度-结果',
  `trigger_msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '调度-日志',
  `handle_time` datetime NULL DEFAULT NULL COMMENT '执行-时间',
  `handle_code` int(11) NOT NULL COMMENT '执行-状态',
  `handle_msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '执行-日志',
  `alarm_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '告警状态：0-默认、1-无需告警、2-告警成功、3-告警失败',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `I_trigger_time`(`trigger_time`) USING BTREE,
  INDEX `I_handle_code`(`handle_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 471267 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for xxl_job_log_report
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_log_report`;
CREATE TABLE `xxl_job_log_report`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `trigger_day` datetime NULL DEFAULT NULL COMMENT '调度-时间',
  `running_count` int(11) NOT NULL DEFAULT 0 COMMENT '运行中-日志数量',
  `suc_count` int(11) NOT NULL DEFAULT 0 COMMENT '执行成功-日志数量',
  `fail_count` int(11) NOT NULL DEFAULT 0 COMMENT '执行失败-日志数量',
  `update_time` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `i_trigger_day`(`trigger_day`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 39 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for xxl_job_logglue
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_logglue`;
CREATE TABLE `xxl_job_logglue`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `job_id` int(11) NOT NULL COMMENT '任务，主键ID',
  `glue_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'GLUE类型',
  `glue_source` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'GLUE源代码',
  `glue_remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'GLUE备注',
  `add_time` datetime NULL DEFAULT NULL,
  `update_time` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for xxl_job_registry
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_registry`;
CREATE TABLE `xxl_job_registry`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `registry_group` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `registry_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `registry_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `update_time` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `i_g_k_v`(`registry_group`, `registry_key`(191), `registry_value`(191)) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 24 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for xxl_job_user
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_user`;
CREATE TABLE `xxl_job_user`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '账号',
  `password` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '密码',
  `role` tinyint(4) NOT NULL COMMENT '角色：0-普通用户、1-管理员',
  `permission` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限：执行器ID列表，多个逗号分割',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `i_username`(`username`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;
