-- 兰博明添加的业务字段与表补充sql脚本
alter table `ecw_order`
    add column `has_consignee` bit(1) DEFAULT b'1' COMMENT '是否有收货人，1-是，0-否';

alter table `ecw_order`
    add column `yeji_create_date` datetime DEFAULT NULL COMMENT '订单业绩产生时间';

alter table `ecw_order`
    add column `yeji_type` int DEFAULT NULL COMMENT '业绩类型，1是新客户业绩，0是老客户业绩';

alter table `ecw_order`
    add column `cal_v_value` decimal(15,2) DEFAULT NULL COMMENT '根据体积或重量计算出的V值';


CREATE TABLE `compare_air_customer_result` (
       `id` bigint NOT NULL AUTO_INCREMENT,
       `number` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'name',
       `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'name',
       `phone` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'phone',
       `old_customer_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'old_customerName',
       `customer_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'customerName',
       `enter_open_sea_time` datetime DEFAULT NULL COMMENT '入公海时间',
       `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
       `create_time` datetime DEFAULT NULL COMMENT '创建时间',
       `type` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'type',
       PRIMARY KEY (`id`)
) ENGINE=InnoDB COMMENT='客户比对表结果表';


CREATE TABLE `customer_old_new_tmp` (
                                        `id` int NOT NULL AUTO_INCREMENT,
                                        `old_number` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
                                        `old_id` int DEFAULT NULL,
                                        `new_number` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
                                        `new_id` int DEFAULT NULL,
                                        PRIMARY KEY (`id`)
) ENGINE=InnoDB ;

CREATE TABLE `ecw_vz` (
                          `id` int NOT NULL AUTO_INCREMENT,
                          `title_zh` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '中文名称',
                          `title_en` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '英文名称',
                          `fuhao` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '单位符号',
                          `vz` float DEFAULT NULL COMMENT 'v值',
                          `status` tinyint(1) DEFAULT '0' COMMENT '0显示 1不显示',
                          `aorder` int DEFAULT NULL COMMENT '排序',
                          `create_time` datetime DEFAULT NULL,
                          `update_time` datetime DEFAULT NULL,
                          `creator` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
                          `updater` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
                          `deleted` tinyint(1) DEFAULT '0' COMMENT '0显示 1不显示',
                          PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC COMMENT='计量单位表';


alter table `ecw_target_log`
    add column `loglev` int DEFAULT NULL COMMENT '逻辑计算来源';
alter table `ecw_target_log`
    add column `gsf` varchar(800) COLLATE utf8mb4_general_ci DEFAULT NULL;
alter table `ecw_target_log`
    add column `gstype` int DEFAULT NULL;

-- 新增订单产生业绩时归属客户状态

alter table `ecw_order`
    add column `is_in_open_sea` tinyint DEFAULT '0' COMMENT '是否公海客户',


 -- 2024-07-25 刷新订单业绩客户新老客户状态冗余参数
update ecw_order o left join ecw_customer c on c.id = o.customer_id set o.yeji_type = IFNULL(c.is_new, 1);

-- 2027-08-07 仓库路线新增落款信息和图章名称
alter table ecw_warehouse_line add column lk_left varchar(600) DEFAULT NULL COMMENT '左侧落款',add column lk_right varchar(600) DEFAULT NULL COMMENT '右侧落款',add column tz_name varchar(255) DEFAULT NULL COMMENT '图章名称';

