-- ----------------------------
-- Table structure for qimall_addons_rebate
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_rebate`;
CREATE TABLE `qimall_addons_rebate`  (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL COMMENT '商城id',
  `title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '活动名称',
  `start_at` int(10) NOT NULL DEFAULT 0 COMMENT '开始时间，单位：秒',
  `end_at` int(10) NOT NULL DEFAULT 0 COMMENT '结束时间，单位：秒',
  `initiate_type` tinyint(2) NULL DEFAULT 0 COMMENT '发起人权限类型[0:全部;1:新会员;2:等级会员]',
  `initiate_level` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '等级会员json串[initiate_type=2时使用]',
  `consume_type` tinyint(2) NULL DEFAULT 0 COMMENT '参与人权限类型[0:全部;1:新会员;2:等级会员]',
  `consume_level` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '等级会员json串[consume_type=2时使用]',
  `item_id` int(10) NOT NULL DEFAULT 0 COMMENT '活动商品id',
  `item_info` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '商品信息json',
  `reward_type` tinyint(2) NOT NULL DEFAULT 1 COMMENT '奖励类型[1:奖励条件;2:阶梯奖励]',
  `reward_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '奖励详情json',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id`(`mall_id`) USING BTREE,
  INDEX `start_time`(`start_at`) USING BTREE,
  INDEX `end_time`(`end_at`) USING BTREE,
  INDEX `item_id`(`item_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '推三返一活动表' ROW_FORMAT = COMPACT;

-- ----------------------------
-- Table structure for qimall_addons_rebate_buy
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_rebate_buy`;
CREATE TABLE `qimall_addons_rebate_buy`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL COMMENT '商城id',
  `r_id` int(10) NOT NULL DEFAULT 0 COMMENT '对应qimall_addons_rebate.id',
  `pid` int(10) NOT NULL DEFAULT 0 COMMENT '分享者id',
  `order_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '订单号',
  `pay_at` int(10) NOT NULL DEFAULT 0 COMMENT '支付时间',
  `pay_money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '实付金额，单位：元',
  `goods_info` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '商品信息',
  `user_id` int(10) NOT NULL DEFAULT 0 COMMENT '消费者用户id',
  `is_settlement` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否已结算[0:否;1:是]',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id+r_id+user_id`(`mall_id`, `r_id`, `user_id`) USING BTREE,
  INDEX `mall_id+r_id+p_id`(`mall_id`, `r_id`, `pid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '推三返一活动用户购买表' ROW_FORMAT = COMPACT;

-- ----------------------------
-- Table structure for qimall_addons_rebate_recommend_num
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_rebate_recommend_num`;
CREATE TABLE `qimall_addons_rebate_recommend_num`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL COMMENT '商城id',
  `r_id` int(10) NOT NULL DEFAULT 0 COMMENT '对应qimall_addons_rebate.id',
  `user_id` int(10) NOT NULL DEFAULT 0 COMMENT '用户id',
  `share_num` int(10) NULL DEFAULT 0 COMMENT '推荐数量',
  `pay_num` int(10) NULL DEFAULT 0 COMMENT '已支付订单数量',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id+r_id+user_id`(`mall_id`, `r_id`, `user_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '推三返一活动用户推荐数量表' ROW_FORMAT = COMPACT;

-- ----------------------------
-- Table structure for qimall_addons_rebate_reward_log
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_rebate_reward_log`;
CREATE TABLE `qimall_addons_rebate_reward_log`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL COMMENT '商城id',
  `r_id` int(10) NOT NULL DEFAULT 0 COMMENT '对应qimall_addons_rebate.id',
  `user_id` int(10) NOT NULL DEFAULT 0 COMMENT '用户id',
  `reward_title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '奖励名称',
  `content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '奖励内容',
  `setting` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '结算时的配置',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id+r_id+user_id`(`mall_id`, `r_id`, `user_id`) USING BTREE,
  INDEX `created_at`(`created_at`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '推三返一活动奖励记录表' ROW_FORMAT = COMPACT;

-- ----------------------------
-- Table structure for qimall_addons_rebate_share
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_rebate_share`;
CREATE TABLE `qimall_addons_rebate_share`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL COMMENT '商城id',
  `r_id` int(10) NOT NULL DEFAULT 0 COMMENT '对应qimall_addons_rebate.id',
  `pid` int(10) NOT NULL DEFAULT 0 COMMENT '分享者id',
  `user_id` int(10) NOT NULL DEFAULT 0 COMMENT '用户id',
  `item_id` int(10) NOT NULL DEFAULT 0 COMMENT '活动关联的商品id',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id+r_id+user_id`(`mall_id`, `r_id`, `user_id`) USING BTREE,
  INDEX `mall_id+r_id+p_id`(`mall_id`, `r_id`, `pid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '推三返一活动用户分享表' ROW_FORMAT = COMPACT;

-- ----------------------------
-- Table structure for qimall_addons_rebate_statistics
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_rebate_statistics`;
CREATE TABLE `qimall_addons_rebate_statistics`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL COMMENT '商城id',
  `r_id` int(10) NOT NULL DEFAULT 0 COMMENT '对应qimall_addons_rebate.id',
  `join_num` int(10) NULL DEFAULT 0 COMMENT '参与人数',
  `pay_num` int(10) NULL DEFAULT 0 COMMENT '已支付订单数量',
  `pay_money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '实付金额，单位：元',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id+r_id`(`mall_id`, `r_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '推三返一活动统计表' ROW_FORMAT = COMPACT;

