CREATE TABLE `qimall_addons_agent_team_achievement` (
      `id` bigint(18) NOT NULL AUTO_INCREMENT,
      `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城ID',
      `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
      `personal_performance` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '个人业绩',
      `team_performance` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '渠道业绩',
      `month` varchar(255) NOT NULL DEFAULT '0.00' COMMENT '月份',
      `rate` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT '百分比',
      `level` tinyint(1) NOT NULL DEFAULT '0' COMMENT '渠道等级',
      `is_settlement` tinyint(1) NOT NULL DEFAULT '0' 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,
      KEY `mall_id` (`mall_id`) USING BTREE,
      KEY `user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COMMENT='渠道业绩';

CREATE TABLE `qimall_addons_agent_team_achievement_order_log` (
    `id` bigint(18) NOT NULL AUTO_INCREMENT,
    `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城ID',
    `order_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单编号',
    `settlement_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '结算类型：0：订单完成结算；1：按月结算',
    `buy_user_id` int(11) NOT NULL DEFAULT '0' COMMENT '购买者id',
   `user_id` 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' COMMENT '创建时间',
    `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `mall_id` (`mall_id`) USING BTREE,
    KEY `order_no` (`order_no`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COMMENT='渠道业绩订单记录';

INSERT INTO `qimall_crontab_task`( `name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('按月结算渠道业绩额外奖励', 'agent/agent/index', 2, '0 0 0 0 1 *', 0, 1, 1658479952, 1658479952);


INSERT INTO `qimall_global_var_map`(`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES
('Agent', '渠道分红', 'IncomeMap', 1, 1, 1654569888, 1654569888);
