CREATE TABLE `qimall_addons_blind_box_bonus_log` (
                                                     `id` int(11) NOT NULL AUTO_INCREMENT,
                                                     `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
                                                     `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id',
                                                     `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '类型：1：消费订单；2：直推消费；3：推荐新人',
                                                     `order_no` varchar(255) NOT NULL DEFAULT '' COMMENT '订单编号',
                                                     `total_times` int(11) NOT NULL DEFAULT '0' COMMENT '总分红次数',
                                                     `divided_times` int(11) NOT NULL DEFAULT '0' COMMENT '已分次数',
                                                     `divided_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '已分金额',
                                                     `contribution` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '贡献值',
                                                     `is_feedback` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否退款：0：否；1：是',
                                                     `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
                                                     `created_at` int(11) NOT NULL DEFAULT '0',
                                                     `updated_at` int(11) NOT NULL DEFAULT '0',
                                                     PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='奖金盲盒分红记录表';

CREATE TABLE `qimall_addons_blind_box_bonus_log_detail` (
                                                            `id` bigint(20) NOT NULL AUTO_INCREMENT,
                                                            `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
                                                            `bonus_log_id` int(11) NOT NULL DEFAULT '0' COMMENT '分红记录id',
                                                            `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id',
                                                            `order_no` varchar(255) NOT NULL DEFAULT '' COMMENT '订单编号',
                                                            `money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '订单贡献金额',
                                                            `total_contribution` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '总贡献值',
                                                            `contribution` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '订单贡献值',
                                                            `total_bonus` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '分红总额',
                                                            `order_bonus` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '订单分红',
                                                            `is_settlement` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否结算：0：否：1：是',
                                                            `settlement_time` int(11) NOT NULL DEFAULT '0' COMMENT '结算时间',
                                                            `is_feedback` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否退款：0：否；1：是',
                                                            `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
                                                            `created_at` int(11) NOT NULL DEFAULT '0',
                                                            `updated_at` int(11) NOT NULL DEFAULT '0',
                                                            PRIMARY KEY (`id`) USING BTREE,
                                                            KEY `idx_bonus_log_id` (`bonus_log_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='奖金盲盒分红记录详情表';

CREATE TABLE `qimall_addons_blind_box_cate` (
                                                `id` int(11) NOT NULL AUTO_INCREMENT,
                                                `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
                                                `name` varchar(255) NOT NULL DEFAULT '' COMMENT '分类名称',
                                                `goods_num` int(11) NOT NULL DEFAULT '0' COMMENT '绑定商品数量',
                                                `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
                                                `created_at` int(11) NOT NULL DEFAULT '0',
                                                `updated_at` int(11) NOT NULL DEFAULT '0',
                                                PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='奖金盲盒分类表';

CREATE TABLE `qimall_addons_blind_box_goods` (
                                                 `id` int(11) NOT NULL AUTO_INCREMENT,
                                                 `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
                                                 `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '商品id',
                                                 `cate_id` int(11) NOT NULL DEFAULT '0' COMMENT '分类id',
                                                 `contribution` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '贡献值',
                                                 `contribution_percent` tinyint(1) NOT NULL DEFAULT '0' COMMENT '贡献值类型：1：百分比；0:固定值',
                                                 `profit` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '利润值',
                                                 `profit_percent` tinyint(1) NOT NULL DEFAULT '0' COMMENT '利润值类型：1：百分比；0:固定值',
                                                 `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
                                                 `created_at` int(11) NOT NULL DEFAULT '0',
                                                 `updated_at` int(11) NOT NULL DEFAULT '0',
                                                 PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='奖金盲盒商品表';

CREATE TABLE `qimall_addons_blind_box_notice` (
                                                  `id` bigint(20) NOT NULL AUTO_INCREMENT,
                                                  `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
                                                  `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id',
                                                  `content` varchar(1000) NOT NULL DEFAULT '' COMMENT '内容',
                                                  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
                                                  `created_at` int(11) NOT NULL DEFAULT '0',
                                                  `updated_at` int(11) NOT NULL DEFAULT '0',
                                                  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='奖金盲盒通知表';

CREATE TABLE `qimall_addons_blind_box_user` (
                                                `id` int(11) NOT NULL AUTO_INCREMENT,
                                                `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
                                                `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id',
                                                `frozen_commission` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '冻结佣金',
                                                `total_commission` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '总佣金（已结算）',
                                                `total_pay_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '总消费金额',
                                                `remaining_pay_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '剩余消费金额',
                                                `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
                                                `created_at` int(11) NOT NULL DEFAULT '0',
                                                `updated_at` int(11) NOT NULL DEFAULT '0',
                                                PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='奖金盲盒用户表';

CREATE TABLE `qimall_addons_blind_box_recommend_user_log` (
                                                              `id` int(11) NOT NULL AUTO_INCREMENT,
                                                              `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
                                                              `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id',
                                                              `parent_id` int(11) NOT NULL DEFAULT '0' COMMENT '上级id',
                                                              `bonus_log_id` int(11) NOT NULL DEFAULT '0' COMMENT '分红记录id',
                                                              `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
                                                              `created_at` int(11) NOT NULL DEFAULT '0',
                                                              `updated_at` int(11) NOT NULL DEFAULT '0',
                                                              PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='奖金盲盒推荐用户表日志表';


INSERT INTO `qimall_link_category`( `name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES ( 'blind_box_cate', '盲盒分类', 19, 1, '', 1, 1663318842, 1663318854);
INSERT INTO `qimall_link_category`( `name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES ( 'blind_box_goods', '盲盒商品', 19, 1, '', 1, 1663318877, 1663318889);
INSERT INTO `qimall_global_var_map`(`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('BlindBox', '奖金盲盒', 'FromTypeMap', 1, 1, 1661841988, 1661841988);
INSERT INTO `qimall_global_var_map`(`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('BlindBox', '奖金盲盒', 'IncomeMap', 1, 1, 1661841988, 1661841988);
INSERT INTO `qimall_global_var_map`( `name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ( 'blind_box_bonus', '分红', 'CapitalTypeMap', 0, 1, 1661841988, 1661841988);

INSERT INTO `qimall_link_category`( `name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES ('blind_box_cate', '盲盒分类', 19, 1, '', 1, 1663318842, 1663318854);
INSERT INTO `qimall_link_category`( `name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES ('blind_box_goods', '盲盒商品', 19, 1, '', 1, 1663318877, 1663318889);

