-- 当订单无收货人时，收货方式无法保存的bug修复
alter table `ecw_order`
    add column `harvest_method` tinyint DEFAULT '1' COMMENT '收货方式：1 自提 2 送货上门';
alter table `ecw_order`
    add column `city` bigint DEFAULT NULL COMMENT '收货地址市';
alter table `ecw_order`
    add column `province` bigint DEFAULT NULL COMMENT '收货地址省';
alter table `ecw_order`
    add column `country` bigint DEFAULT NULL COMMENT '收货地址国家';
alter table `ecw_order`
    add column `consignee_address` varchar(255) DEFAULT '' COMMENT '收货地址';

-- 放货箱数与放货率
alter table `ecw_order`
    add column `release_ratio` decimal(5,2) DEFAULT '0.00' COMMENT '放货率';
alter table `ecw_order`
    add column `release_num` int DEFAULT 0 COMMENT '放货箱数';

-- 批量刷新订单放货数量、放货率
update ecw_order t LEFT JOIN (select ccp.order_id , ifnull(sum(ccp.pick_num),0) as releaseNum from ecw_order_cargo_control_pick ccp where
    ccp.status in(1,2,3,4,5,6) group by ccp.order_id) t1 on t.order_id=t1.order_id set t.release_num=IFNULL(t1.releaseNum,0), t.release_ratio=IFNULL(ROUND(t1.releaseNum/t.sum_num,2)*100, 0);