-- ----------------------------
-- Table structure for qimall_addons_area_agent
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_area_agent`;
CREATE TABLE `qimall_addons_area_agent`  (
  `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',
  `total_commission` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '累计佣金',
  `level` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0普通用户 4、镇代 4、区代 2、市代 1、省代',
  `province_id` int(11) NOT NULL DEFAULT 0 COMMENT '省id',
  `city_id` int(11) NOT NULL DEFAULT 0 COMMENT '市id',
  `district_id` int(11) NOT NULL DEFAULT 0 COMMENT '区id',
  `town_id` int(11) NOT NULL DEFAULT 0 COMMENT '镇id',
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '省市区镇地址名称',
  `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_mall_id_user_id`(`mall_id`, `user_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '区域代理商信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for qimall_addons_area_apply
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_area_apply`;
CREATE TABLE `qimall_addons_area_apply`  (
  `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',
  `address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '地址',
  `realname` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '真实姓名',
  `mobile` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '手机号码',
  `level` tinyint(1) NOT NULL COMMENT '区域等级;1镇级;2区级;3市级;4省级;',
  `province_id` int(11) NOT NULL DEFAULT 0 COMMENT '省id',
  `city_id` int(11) NOT NULL DEFAULT 0 COMMENT '市id',
  `district_id` int(11) NOT NULL DEFAULT 0 COMMENT '区id',
  `town_id` int(11) NOT NULL DEFAULT 0 COMMENT '镇id',
  `marks` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '备注',
  `check_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0未审核;1审核通过;2不通过',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_mall_id_user_id`(`mall_id`, `user_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '区域代理申请记录' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for qimall_addons_area_commission_item_setting
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_area_commission_item_setting`;
CREATE TABLE `qimall_addons_area_commission_item_setting`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL COMMENT '商城ID',
  `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',
  `commission_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '分佣类型：积分score;佣金：commission',
  `is_percent_team` tinyint(1) NOT NULL DEFAULT 0 COMMENT '团队奖类型 0百分比 1 固定金额',
  `is_percent_equal` 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 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '区域代理项目分佣设置' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for qimall_addons_area_commission_item_setting_detail
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_area_commission_item_setting_detail`;
CREATE TABLE `qimall_addons_area_commission_item_setting_detail`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL COMMENT '商城ID',
  `area_commission_item_setting_id` int(11) NOT NULL,
  `level` int(11) NOT NULL DEFAULT 0,
  `agent_team_prize` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '团队奖',
  `agent_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 `area_commission_item_setting_id`(`area_commission_item_setting_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '区域代理项目分佣设置详情' ROW_FORMAT = Dynamic;


alter table  qimall_addons_area_agent add  `total_score` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '累计积分';

