/*
 Navicat Premium Dump SQL

 Source Server         : 101.200.130.134
 Source Server Type    : MySQL
 Source Server Version : 50728 (5.7.28)
 Source Host           : 101.200.130.134:3306
 Source Schema         : mallink

 Target Server Type    : MySQL
 Target Server Version : 50728 (5.7.28)
 File Encoding         : 65001

 Date: 15/08/2024 15:28:13
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for wx_offline_activity
-- ----------------------------
DROP TABLE IF EXISTS `wx_offline_activity`;
CREATE TABLE `wx_offline_activity`  (
                                        `id` bigint(20) NOT NULL COMMENT '主键ID',
                                        `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID',
                                        `parent_tenant_id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '父租户ID',
                                        `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '活动名称',
                                        `start_time` datetime NULL DEFAULT NULL COMMENT '开始时间',
                                        `end_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
                                        `status` smallint(2) NOT NULL DEFAULT 0 COMMENT '状态（0:未上架 1:已上架)',
                                        `create_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                        `update_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
                                        `all_merchant` smallint(1) NOT NULL DEFAULT 0 COMMENT '是否全部商户',
                                        PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线下活动' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wx_offline_activity_awards_item
-- ----------------------------
DROP TABLE IF EXISTS `wx_offline_activity_awards_item`;
CREATE TABLE `wx_offline_activity_awards_item`  (
                                                    `id` bigint(20) NOT NULL COMMENT '主键ID',
                                                    `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID',
                                                    `parent_tenant_id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '父租户ID',
                                                    `activity_item_id` bigint(20) NOT NULL COMMENT '活动项id',
                                                    `name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '奖项名称',
                                                    `grade` int(11) NULL DEFAULT NULL COMMENT '奖项等级',
                                                    `min_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '限制最小金额',
                                                    `max_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '限制最大金额',
                                                    `cash_back_ratio` decimal(10, 2) NULL DEFAULT NULL COMMENT '返现比例',
                                                    `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '奖项价值',
                                                    `money_rule` smallint(1) NOT NULL COMMENT '分担规则(0-商管 1-商户 2-分担)',
                                                    `mall_share_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '商管分担比例',
                                                    `merchant_share_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '商户分担比例',
                                                    `create_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                                    `update_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
                                                    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线下活动奖项' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wx_offline_activity_grant_award
-- ----------------------------
DROP TABLE IF EXISTS `wx_offline_activity_grant_award`;
CREATE TABLE `wx_offline_activity_grant_award`  (
                                                    `id` bigint(20) NOT NULL COMMENT '主键ID',
                                                    `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID',
                                                    `parent_tenant_id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '父租户ID',
                                                    `activity_id` bigint(20) NOT NULL COMMENT '活动ID',
                                                    `order_money_sum` decimal(10, 2) NULL DEFAULT NULL COMMENT '订单总金额',
                                                    `order_count` int(11) NULL DEFAULT NULL COMMENT '订单数量',
                                                    `cus_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户姓名',
                                                    `cus_phone` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户电话',
                                                    `real_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '实际领奖人',
                                                    `real_card` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '实际领奖人身份证号',
                                                    `sign_img` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '签名图片',
                                                    `create_by` bigint(20) NULL DEFAULT NULL,
                                                    `create_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                                    `update_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
                                                    `lottery_num` json NULL COMMENT '抽奖券编码',
                                                    `lottery_count` int(11) NULL DEFAULT NULL COMMENT '抽奖券数量',
                                                    `anniversary_lottery_num` json NULL COMMENT '周年庆抽奖编码',
                                                    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线下活动发放奖励' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wx_offline_activity_grant_item
-- ----------------------------
DROP TABLE IF EXISTS `wx_offline_activity_grant_item`;
CREATE TABLE `wx_offline_activity_grant_item`  (
                                                   `id` bigint(20) NOT NULL,
                                                   `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID',
                                                   `parent_tenant_id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '父租户ID',
                                                   `grant_id` bigint(20) NOT NULL COMMENT '发放id',
                                                   `activity_id` bigint(20) NOT NULL COMMENT '活动id',
                                                   `activity_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '活动名称',
                                                   `activity_item_id` bigint(20) NOT NULL COMMENT '活动项id',
                                                   `activity_item_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '活动项名称',
                                                   `activity_item_type` smallint(1) NULL DEFAULT NULL COMMENT '活动项类型',
                                                   `award_itam_id` bigint(20) NOT NULL COMMENT '奖项id',
                                                   `award_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '奖项名称',
                                                   `award_grade` int(11) NULL DEFAULT NULL COMMENT '奖项等级',
                                                   `award_min_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '奖项限制最小金额',
                                                   `award_max_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '奖项限制最大金额',
                                                   `awards_item_rule` smallint(1) NULL DEFAULT NULL COMMENT '奖项计算规则',
                                                   `cash_back_ratio` decimal(10, 2) NULL DEFAULT NULL COMMENT '返现比例',
                                                   `award_price` decimal(10, 2) NOT NULL COMMENT '奖项价值',
                                                   `award_count` int(11) NULL DEFAULT NULL COMMENT '奖项数量',
                                                   `money_rule` smallint(1) NOT NULL COMMENT '分担规则(0-商管 1-商户 2-分担)',
                                                   `mall_share_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '商管分担比例',
                                                   `merchant_share_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '商户分担比例',
                                                   `create_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                                   `update_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
                                                   PRIMARY KEY (`id`) USING BTREE,
                                                   UNIQUE INDEX `activity_id`(`grant_id`, `activity_item_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线下活动发放奖励' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wx_offline_activity_grant_settlement
-- ----------------------------
DROP TABLE IF EXISTS `wx_offline_activity_grant_settlement`;
CREATE TABLE `wx_offline_activity_grant_settlement`  (
                                                         `id` bigint(20) NOT NULL,
                                                         `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID',
                                                         `parent_tenant_id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '父租户ID',
                                                         `record_id` bigint(20) NOT NULL COMMENT '参与记录id',
                                                         `order_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '订单编号',
                                                         `order_money` decimal(10, 2) NULL DEFAULT NULL COMMENT '订单金额',
                                                         `merchant_id` bigint(20) NOT NULL COMMENT '商户id',
                                                         `activity_id` bigint(20) NOT NULL COMMENT '活动id',
                                                         `activity_item_id` bigint(20) NOT NULL COMMENT '活动项id',
                                                         `award_itam_id` bigint(20) NOT NULL COMMENT '奖项id',
                                                         `grant_id` bigint(20) NOT NULL COMMENT '发放id',
                                                         `grant_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '发放总价值',
                                                         `mall_share_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '商管承担比率',
                                                         `merchant_share_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '商户承担比率',
                                                         `order_ratio` decimal(10, 2) NULL DEFAULT NULL COMMENT '订单占比',
                                                         `real_grant_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '实际发放总价值',
                                                         `real_mall_share_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '实际商管承担总金额',
                                                         `real_merchant_share_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '实际商户承担总金额',
                                                         `create_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                                         `update_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
                                                         PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线下活动发放奖励结算' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wx_offline_activity_item
-- ----------------------------
DROP TABLE IF EXISTS `wx_offline_activity_item`;
CREATE TABLE `wx_offline_activity_item`  (
                                             `id` bigint(20) NOT NULL COMMENT '主键ID',
                                             `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID',
                                             `parent_tenant_id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '父租户ID',
                                             `activity_id` bigint(20) NOT NULL COMMENT '活动id',
                                             `type` smallint(1) NOT NULL COMMENT '活动项类型',
                                             `name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '活动项名称',
                                             `limit_money` decimal(10, 2) NOT NULL COMMENT '参与金额',
                                             `awards_item_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '奖项单价',
                                             `awards_item_limit` int(11) NULL DEFAULT NULL COMMENT '奖项限制',
                                             `awards_item_count` int(11) NULL DEFAULT NULL COMMENT '奖项总数量',
                                             `awards_item_rule` smallint(1) NULL DEFAULT NULL COMMENT '奖项计算规则',
                                             `create_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                             `update_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
                                             PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线下活动项目' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wx_offline_activity_merchant
-- ----------------------------
DROP TABLE IF EXISTS `wx_offline_activity_merchant`;
CREATE TABLE `wx_offline_activity_merchant`  (
                                                 `id` bigint(20) NOT NULL COMMENT '主键ID',
                                                 `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID',
                                                 `parent_tenant_id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '父租户ID',
                                                 `activity_id` bigint(20) NOT NULL COMMENT '活动编号',
                                                 `merchant_id` bigint(20) NOT NULL COMMENT '商户编号',
                                                 `whether_in` smallint(1) NOT NULL COMMENT '是否参加',
                                                 `create_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                                 `update_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
                                                 PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线下活动商户' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wx_offline_activity_record
-- ----------------------------
DROP TABLE IF EXISTS `wx_offline_activity_record`;
CREATE TABLE `wx_offline_activity_record`  (
                                               `id` bigint(20) NOT NULL COMMENT '主键ID',
                                               `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID',
                                               `parent_tenant_id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '父租户ID',
                                               `order_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '订单号',
                                               `order_money` decimal(10, 2) NULL DEFAULT NULL COMMENT '订单金额',
                                               `cus_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户姓名',
                                               `real_cus_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
                                               `cus_phone` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户电话',
                                               `cus_address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '客户地址',
                                               `cus_card` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '身份证号',
                                               `lottery_num` json NULL COMMENT '抽奖券编码',
                                               `lottery_count` int(11) NULL DEFAULT NULL COMMENT '抽奖券数量',
                                               `anniversary_lottery_num` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '周年庆抽奖编码',
                                               `create_by` bigint(11) NULL DEFAULT NULL,
                                               `merchant_id` bigint(20) NOT NULL COMMENT '商户编号',
                                               `business_id` int(11) NULL DEFAULT NULL COMMENT '业态',
                                               `create_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                               `update_date` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
                                               `audit_remark` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '审批意见',
                                               `audit_status` int(1) NOT NULL DEFAULT 0 COMMENT '审批状态',
                                               `audit_by` bigint(20) NULL DEFAULT NULL COMMENT '审核人',
                                               `audit_time` datetime NULL DEFAULT NULL COMMENT '审核时间',
                                               PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线下活动参与登记' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wx_offline_activity_record_grant
-- ----------------------------
DROP TABLE IF EXISTS `wx_offline_activity_record_grant`;
CREATE TABLE `wx_offline_activity_record_grant`  (
                                                     `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID',
                                                     `parent_tenant_id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '父租户ID',
                                                     `activity_id` bigint(20) NOT NULL COMMENT '活动id',
                                                     `record_id` bigint(20) NOT NULL COMMENT '参与记录id',
                                                     `grant_id` bigint(20) NOT NULL COMMENT '发放id',
                                                     UNIQUE INDEX `activity_id`(`activity_id`, `record_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线下活动参与登记与发放关联表' ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;



ALTER TABLE `mallink`.`wx_offline_activity_grant_item`
DROP INDEX `activity_id`;