alter table cust_customer add `cust_province_id` INT(11) COMMENT '所在省ID' after cust_address;
alter table cust_customer add `cust_province` VARCHAR(90) COMMENT '所在省' after cust_province_id;
alter table cust_customer add `cust_city_id` INT(11) COMMENT '所在市ID' after cust_province;
alter table cust_customer add `cust_city` VARCHAR(90) COMMENT '所在市' after cust_city_id;
alter table cust_customer add `cust_region_id` INT(11) COMMENT '所在区县ID' after cust_city;
alter table cust_customer add `cust_region` VARCHAR(90) COMMENT '所在区县' after cust_region_id;
alter table cust_customer modify `cust_status` VARCHAR(4) DEFAULT 10 COMMENT '客户状态(10 待领取 20 领取审批 30 已领取)';
alter table cust_customer add `follow_up_man` VARCHAR(90) COMMENT '最后跟进人' after follow_up_date;
alter table ctr_contract_invoice modify `appro_status` varchar(4) DEFAULT NULL COMMENT '审核状态 10 待提交审核 20 待审核 30 审核已同意 40 审核已拒绝 50 审核已撤销';

alter table ctr_contract add `signatory_type` varchar(255) DEFAULT NULL COMMENT '签订单位类型 10 终端用户 20 经销商 30 代理商' after signatory_name;
alter table ctr_contract modify `incharge_name` varchar(90) COMMENT '负责人(销售工程师)';

alter table ctr_contract modify `appro_status` varchar(4) NOT NULL COMMENT '审核状态 10 待提交审核 20 待审核 30 审核已同意 40 审核已拒绝 50 审核已撤销',

alter table ctr_contract  add `cust_province_id` INT(11) COMMENT '所在省ID' after cust_name;
alter table ctr_contract  add `cust_province` VARCHAR(90) COMMENT '所在省' after cust_province_id;
alter table ctr_contract  add `cust_city_id` INT(11) COMMENT '所在市ID' after cust_province;
alter table ctr_contract  add `cust_city` VARCHAR(90) COMMENT '所在市' after cust_city_id;

alter table ctr_contract  add  `product_line` varchar(4) NOT NULL COMMENT '产品线' after cust_name;

alter table cust_customer drop column  cust_dist_code;
alter table cust_customer drop column  cust_location;
alter table ctr_contract modify `contract_end_time` datetime COMMENT '合同结束时间'

alter table base_distributor add `invoice_header` varchar(255) DEFAULT NULL COMMENT '开票抬头' after sale_num;
alter table cust_customer add `invoice_header` varchar(255) DEFAULT NULL COMMENT '开票抬头' after follow_up_man;



-- 2023-05-05
alter table ctr_contract  add  `contract_sign_time` datetime COMMENT '合同签订时间' after contract_end_time;
alter table ctr_contract  add  `signatory_unit` varchar(90) COMMENT '合同签订单位' after signatory_type;
alter table ctr_contract  add  `earnest_money` decimal(24, 6) COMMENT '质量/履约保证金（元）' after signatory_unit;

alter table ctr_contract_product  add `contract_code` varchar(32) NOT NULL COMMENT '合同编号' after contract_id;
alter table ctr_contract_product add `purchase_cost` decimal(24, 6) DEFAULT NULL COMMENT '采购成本' after contract_prive;
alter table ctr_contract_product add `dev_cost` decimal(24, 6) DEFAULT NULL COMMENT '二次开发成本' after purchase_cost;
alter table ctr_contract_product add `maintain_cost` decimal(24, 6) DEFAULT NULL COMMENT '产品维保成本' after dev_cost;
alter table ctr_contract_product add `direct_cost` decimal(24, 6) DEFAULT NULL COMMENT '直接成本' after maintain_cost;
alter table ctr_contract_product add `maintain_period` int(11) DEFAULT NULL COMMENT '质保期(天)' after direct_cost;
alter table ctr_contract_product add `warrant_period` int(11) DEFAULT NULL COMMENT '运维期(天)' after maintain_period;
alter table ctr_contract_product add `maintain_start_time` datetime DEFAULT NULL COMMENT '运维开始时间' after warrant_period;
alter table ctr_contract_product add `maintain_remark` text DEFAULT NULL COMMENT '运维约定条款' after maintain_start_time;
alter table ctr_contract_product add `accept_time` datetime DEFAULT NULL COMMENT '验收时间' after maintain_remark;

alter table ctr_contract_collection_plan add `plan_scale` decimal(24, 6) COMMENT '计划回款比例' after plan_datetime;
alter table ctr_contract_collection_plan add `plan_condition` text COMMENT '回款条件' after plan_scale;



-- 2023-05-11
alter table base_distributor add `dist_type` varchar(4) DEFAULT '10' COMMENT '经销商类型 10 经销商 20 代理商' after invoice_header;
alter table base_distributor add `customer_type` varchar(255) NOT NULL COMMENT  '授权客户类型' after dist_type;
alter table base_distributor add `existed_product` text DEFAULT NULL COMMENT '已有代理品牌和产品' after customer_type;
alter table base_distributor add `assistant_sale_id` text DEFAULT NULL COMMENT '助理人员Id' after existed_product;
alter table base_distributor add `assistant_sale` text DEFAULT NULL COMMENT '助理人员' after assistant_sale_id;
alter table base_distributor add `register_district`  varchar(255) DEFAULT NULL COMMENT '注册地' after assistant_sale;
alter table base_distributor add `history_customer` text DEFAULT NULL COMMENT '历史合作的终端客户名称' after register_district;
alter table base_distributor add `proxy_start_time` datetime DEFAULT NULL COMMENT '代理签约有效期开始(代理商)' after history_customer;
alter table base_distributor add `proxy_end_time` datetime DEFAULT NULL COMMENT '代理签约有效期结束(代理商)' after proxy_start_time;
alter table base_distributor add `proxy_district` varchar(255) DEFAULT NULL COMMENT '授权代理区域(代理商)' after proxy_end_time;
alter table base_distributor add `contract_url` text DEFAULT NULL COMMENT '代理合同(代理商)' after proxy_district;
CREATE TABLE `base_distributor_dynamics` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `dist_id` int(11) NOT NULL COMMENT '经销商/代理商ID',
  `opn_people_id` int(11) NOT NULL COMMENT '操作人ID',
  `opn_people` varchar(90) NOT NULL COMMENT '操作人',
  `opn_date` datetime NOT NULL COMMENT '操作日期',
  `opn_type` varchar(10) NOT NULL COMMENT '操作类型',
  `opn_content` text DEFAULT NULL COMMENT '操作内容',
  `remark` text DEFAULT NULL COMMENT '备注',
  `created_by` int(11) NOT NULL COMMENT '创建者',
  `created_name` varchar(90) NOT NULL COMMENT '创建人',
  `created_time` datetime NOT NULL COMMENT '创建时间',
  `updated_by` int(11) DEFAULT NULL COMMENT '更新者',
  `updated_name` varchar(90) DEFAULT NULL COMMENT '更新人',
  `updated_time` datetime DEFAULT NULL COMMENT '更新时间',
  `deleted_time` datetime DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '经销商/代理商动态';
alter table base_distributor_contact add `honorific` varchar(255) DEFAULT NULL COMMENT '尊称' after mail;
alter table base_distributor_contact add `territory` text DEFAULT NULL COMMENT '负责区域/业务线' after honorific;
CREATE TABLE `base_distributor_record` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `dist_id` int(11) NOT NULL COMMENT '所属经销商',
  `dist_type` varchar(4) DEFAULT '10' COMMENT '经销商类型 10 经销商 20 代理商',
  `business_scope` varchar(255) NOT NULL COMMENT '业务范围',
  `customer_type` varchar(255) NOT NULL COMMENT '授权客户类型',
  `proxy_district` varchar(255) DEFAULT NULL COMMENT '授权代理区域(代理商)',
  `proxy_start_time` datetime DEFAULT NULL COMMENT '代理签约有效期开始(代理商)',
  `proxy_end_time` datetime DEFAULT NULL COMMENT '代理签约有效期结束(代理商)',
  `contract_url` text DEFAULT NULL COMMENT '代理合同(代理商)',
  `existed_product` text DEFAULT NULL COMMENT '已有代理品牌和产品',
  `history_customer` text DEFAULT NULL COMMENT '历史合作的终端客户名称',
  `to_dist_reason` text DEFAULT NULL COMMENT '转移经销商原因',
  `remark` text DEFAULT NULL COMMENT '备注',
  `created_by` int(11) NOT NULL COMMENT '创建者',
  `created_name` varchar(90) NOT NULL COMMENT '创建人',
  `created_time` datetime NOT NULL COMMENT '创建时间',
  `updated_by` int(11) DEFAULT NULL COMMENT '更新者',
  `updated_name` varchar(90) DEFAULT NULL COMMENT '更新人',
  `updated_time` datetime DEFAULT NULL COMMENT '更新时间',
  `deleted_time` datetime DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMMENT = '历史代理记录';
CREATE TABLE `base_distributor_target` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `dist_id` int(11) NOT NULL COMMENT '所属经销商',
  `year` int(11) NOT NULL COMMENT '年度',
  `q1` decimal(24, 6) NOT NULL COMMENT 'q1指标(万元)',
  `q2` decimal(24, 6) NOT NULL COMMENT 'q2指标(万元)',
  `q3` decimal(24, 6) NOT NULL COMMENT 'q3指标(万元)',
  `q4` decimal(24, 6) NOT NULL COMMENT 'q4指标(万元)',
  `total` decimal(24, 6) NOT NULL COMMENT '年度指标(万元)',
  `remark` text DEFAULT NULL COMMENT '备注',
  `created_by` int(11) NOT NULL COMMENT '创建者',
  `created_name` varchar(90) NOT NULL COMMENT '创建人',
  `created_time` datetime NOT NULL COMMENT '创建时间',
  `updated_by` int(11) DEFAULT NULL COMMENT '更新者',
  `updated_name` varchar(90) DEFAULT NULL COMMENT '更新人',
  `updated_time` datetime DEFAULT NULL COMMENT '更新时间',
  `deleted_time` datetime DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMMENT = '代理商业务指标';
-- alter table base_distributor_contact modify `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键';
