CREATE TABLE `qimall_addons_double_copy_commission` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城id',
  `user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  `buy_uid` int(10) DEFAULT '0' COMMENT '下单用户id',
  `is_frozen` tinyint(2) NOT NULL DEFAULT '0' COMMENT '是否冻结[0:否，1:是]',
  `order_id` int(10) DEFAULT '0' COMMENT '订单ID',
  `order_no` varchar(60) NOT NULL DEFAULT '' COMMENT '订单编号',
  `pay_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '支付金额，单位:元',
  `money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '金额，单位:元',
  `goods_name` varchar(255) DEFAULT '' COMMENT '商品名称',
  `pic_url` varchar(255) DEFAULT '' COMMENT '商品封面图',
  `price` decimal(10,2) DEFAULT '0.00' COMMENT '商品价格',
  `source_table` varchar(100) NOT NULL DEFAULT '' COMMENT '来源表',
  `source_table_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作来源业务id',
  `capital_type` varchar(255) NOT NULL DEFAULT '' COMMENT '资金类型',
  `settlement_type` tinyint(2) NOT NULL DEFAULT '0' COMMENT '结算状态[-1:已失效,0:未结算,1:已结算]',
  `setting` varchar(255) DEFAULT '' COMMENT '生成数据时配置',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间戳',
  `updated_at` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间戳',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_mall_user` (`mall_id`,`user_id`) USING BTREE,
  KEY `order_no` (`order_no`) USING BTREE,
  KEY `order_id` (`order_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='二二复制分佣记录表';


CREATE TABLE `qimall_addons_double_copy_commission_item_setting`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL COMMENT '商城ID',
  `is_partake` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否参与老板分红：0:否;1是',
  `is_enable` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否独立设置：0:否;1是',
  `item_id` int(11) NOT NULL DEFAULT 0 COMMENT '项目id',
  `item_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '项目类型：商品goods',
  `settings` tinyint(4) NOT NULL DEFAULT 0 COMMENT '分销佣金设置:0:按商品设置;1:按规格设置',
  `commission_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '分佣类型：积分score;佣金：commission',
  `is_percent` 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,
  INDEX `mall_id`(`mall_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '二二复制项目分佣设置' ROW_FORMAT = Dynamic;


CREATE TABLE `qimall_addons_double_copy_commission_item_setting_detail`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL COMMENT '商城ID',
  `commission_item_setting_id` int(11) NOT NULL,
  `level` int(11) NOT NULL DEFAULT 0,
  `first_prize` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '直推奖',
  `second_prize` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '平台补贴',
  `equal_prize` decimal(10, 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,
  INDEX `mall_id`(`mall_id`) USING BTREE,
  INDEX `commission_item_setting_id`(`commission_item_setting_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '二二复制项目分佣设置详情' ROW_FORMAT = Dynamic;


CREATE TABLE `qimall_addons_double_copy_level`  (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL DEFAULT 0 COMMENT '商城id',
  `level` int(10) NOT NULL DEFAULT 0 COMMENT '等级权重',
  `name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '等级名称',
  `is_auto_upgrade` int(10) NOT NULL DEFAULT 0 COMMENT '是否启用自动升级：0-不；1-是；',
  `upgrade_type_condition` smallint(6) NOT NULL DEFAULT 0 COMMENT '条件升级  0关闭 1 开启',
  `condition_type` smallint(6) NOT NULL DEFAULT 0 COMMENT '0 未选择、1满足其一  2、满足所有',
  `checked_condition_keys` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '升级条件选中的key集合',
  `checked_condition_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '升级条件',
  `upgrade_type_goods` smallint(6) NOT NULL DEFAULT 0 COMMENT '购买商品升级  0关闭 1 开启',
  `buy_goods_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0订单完成 1下单 完成',
  `goods_type` smallint(6) NOT NULL DEFAULT 0 COMMENT '商品升级类型',
  `goods_ids` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '商品仓库的ID',
  `goods_list` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '商品列表',
  `explain` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '等级说明',
  `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否启用',
  `created_at` int(10) NOT NULL DEFAULT 0,
  `updated_at` int(10) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id`(`mall_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '二二复制等级表' ROW_FORMAT = Compact;


CREATE TABLE `qimall_addons_double_copy_level_setting`  (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL COMMENT '商城ID',
  `level_id` int(10) NULL DEFAULT 0 COMMENT '对应qimall_addons_double_copy_level.id',
  `level` int(10) NOT NULL DEFAULT 0 COMMENT '等级',
  `commission_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '分佣类型：积分score;佣金：commission',
  `from_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '分佣类型：二二复制',
  `first_prize_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '直推奖类型 0百分比 1 固定金额',
  `first_prize` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '直推奖励',
  `second_prize_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '平台补贴类型 0 百分比 1 固定金额',
  `second_prize` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '平台补贴',
  `equal_prize_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '培育奖类型 0百分比 1 固定金额',
  `equal_prize` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '培育奖',
  `freeze_fund_prize` decimal(5, 2) NULL DEFAULT 0.00 COMMENT '冻结基金每单比例',
  `freeze_fund_num` int(10) NULL DEFAULT 0 COMMENT '解冻达标团队人数',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(10) NOT NULL DEFAULT 0,
  `updated_at` int(10) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id`(`mall_id`) USING BTREE,
  INDEX `level`(`level`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '二二复制等级分佣配置表' ROW_FORMAT = Dynamic;


CREATE TABLE `qimall_addons_double_copy_user` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL DEFAULT '0' COMMENT '商城ID',
  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
  `level` tinyint(4) NOT NULL DEFAULT '0' COMMENT '等级',
  `commission` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '已结算佣金，单位：元',
  `frozen_commission` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '未结算佣金，单位：元',
  `frozen_fund` decimal(10,0) DEFAULT '0' COMMENT '冻结基金，单位：元',
  `pid` int(10) DEFAULT '0' COMMENT '上级uid',
  `topid` int(10) DEFAULT '0' COMMENT '上级老板id',
  `pos` int(10) DEFAULT '0' COMMENT '相对上级的位置',
  `help_num` varchar(255) NOT NULL DEFAULT '0' COMMENT '助力用户数量',
  `team_num` int(10) DEFAULT '0' COMMENT '团队数量(代理+老板)',
  `upgrade_status` smallint(6) NOT NULL DEFAULT '0' COMMENT '1条件升级，2购买指定商品升级，3手动升级',
  `upgrade_level_at` int(10) NOT NULL DEFAULT '0' COMMENT '股东等级升级时间',
  `is_thaw` tinyint(4) DEFAULT '0' COMMENT '是否已解冻[0:否，1:是]',
  `status` tinyint(4) 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,
  KEY `mall_id+user_id` (`mall_id`,`user_id`) USING BTREE,
  KEY `pid` (`pid`) USING BTREE,
  KEY `topid` (`topid`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='二二复制用户表';

