<iftest="query.salesmanId != null and query.creator">
AND (o.`salesman_id` = #{query.salesmanId} or o.`customer_id` in(select cus.id from ecw_customer cus where cus.is_customer_service_confirmed = 1 and cus.customer_service = #{query.salesmanId} ) or o.`creator` = #{query.creator})
AND (o.`salesman_id` = #{query.salesmanId} or o.`customer_id` in(select cus.id from ecw_customer cus where
cus.is_customer_service_confirmed = 1 and cus.customer_service = #{query.salesmanId} ) or o.`creator` =
#{query.creator})
</if>
<iftest="query.customsType != null">
AND o.`customs_type` = #{query.customsType}
</if>
<iftest="query.productRecord != null">
AND o.`product_record` = #{query.productRecord}
</if>
<!-- <if test="query.customsType != null">-->
<!-- AND o.`customs_type` = #{query.customsType}-->
<!-- </if>-->
<!-- <if test="query.productRecord != null">-->
<!-- AND o.`product_record` = #{query.productRecord}-->
<!-- </if>-->
<iftest="query.customsTypes != null and query.customsTypes.size()>0">
<iftest="query.customsTypes != null and query.customsTypes.size()==1 ">
<!-- <if test="query.startWarehouseId !=null and query.startWarehouseIds.size() > 0 and (query.destWarehouseId==null or query.destWarehouseIds.size() == 0) ">-->
AND (o.`salesman_id` = #{query.salesmanId} or o.`customer_id` in(select cus.id from ecw_customer cus where cus.is_customer_service_confirmed = 1 and cus.customer_service = #{query.salesmanId} ))
</if>
<!-- <if test = "query.customsType != null">-->
<!-- AND o.`customs_type` = #{query.customsType}-->
<!-- </if>-->
<iftest="query.customsType != null and query.customsType.size()>0">
<iftest="query.customsType != null and query.customsType != '' and query.customsType.size()==1 ">
<iftest ="query.tidanNo != null and query.tidanNo != '' ">
AND o.`tidan_no` like concat('%',concat(#{query.tidanNo},'%'))
</if>
<iftest ="query.customerId != null">
AND o.`customer_id` = #{query.customerId}
</if>
<iftest ="query.beginRucangTime != null and query.endRucangTime != null ">
AND o.order_id in(select distinct wi.order_id from ecw_order_warehouse_in wi where wi.deleted = 0 and wi.`in_time` between #{query.beginRucangTime} and #{query.endRucangTime})
</if>
<iftest ="query.beginQingguanTime != null and query.endQingguanTime != null ">
AND o.`qingguan_time` between #{query.beginQingguanTime} and #{query.endQingguanTime}
</if>
<iftest ="query.beginDaogangTime != null and query.endDaogangTime != null ">
AND o.`daogang_time` between #{query.beginDaogangTime} and #{query.endDaogangTime}
</if>
<iftest ="query.beginPreLoadTime != null and query.endPreLoadTime != null ">
AND o.`status` > 5 AND o.`pre_load_time` between #{query.beginPreLoadTime} and #{query.endPreLoadTime}
</if>
<iftest ="query.beginOutboundTime != null and query.endOutboundTime != null ">
AND o.`status` > 5 AND o.container_number in(select distinct b.self_no from ecw_box_air_checkout bc join ecw_box b ON bc.shipment_id = b.id
where b.deleted = 0 and bc.deleted = 0 and bc.`checkout_time` between #{query.beginOutboundTime} and #{query.endOutboundTime})
</if>
<iftest ="query.beginLoadTime != null and query.endLoadTime != null ">
AND o.`load_time` between #{query.beginLoadTime} and #{query.endLoadTime}
</if>
<iftest ="query.beginUnloadTime != null and query.endUnloadTime != null ">
AND o.`unload_time` between #{query.beginUnloadTime} and #{query.endUnloadTime}
</if>
<iftest ="query.beginTakeTime != null and query.endTakeTime != null ">
AND o.`status` > 19 AND o.`take_time` between #{query.beginTakeTime} and #{query.endTakeTime}
</if>
<iftest ="query.beginSplitTime != null and query.endSplitTime != null ">
AND o.`split_time` between #{query.beginSplitTime} and #{query.endSplitTime}
</if>
<iftest ="query.beginCreateTime != null and query.endCreateTime != null ">
AND o.`create_time` between #{query.beginCreateTime} and #{query.endCreateTime}
</if>
<iftest ="query.beginPickTime != null and query.endPickTime != null ">
AND o.order_id in(select distinct op.order_id from ecw_order_cargo_control_pick op where op.deleted = 0 and op.status in(1,3) and op.`create_time` between #{query.beginPickTime} and #{query.endPickTime})
</if>
<iftest ="query.beginPickUpTime != null and query.endPickUpTime != null ">
AND o.order_no in(select distinct op.order_id from ecw_order_pickup op where op.deleted = 0 and op.`create_time` between #{query.beginPickUpTime} and #{query.endPickUpTime})
</if>
<iftest ="query.beginWarehouseInTime != null and query.endWarehouseInTime != null ">
AND o.order_id in(select distinct wi.order_id from ecw_order_warehouse_in wi where wi.deleted = 0 and wi.`update_time` between #{query.beginWarehouseInTime} and #{query.endWarehouseInTime})
</if>
<iftest ="query.creator != null and query.creator != '' ">
AND o.`creator` = #{query.creator} and (o.user_id is null or o.user_id = 0)
</if>
<iftest ="query.searchKey != null and query.searchKey != '' ">
AND concat(IFNULL(o.`order_no`,''), IFNULL(o.`old_numbers`,'') ,IFNULL(o.`marks`,''),IFNULL(o.`tidan_no`,''),IFNULL(o.`container_number`,''),IFNULL(nee.`name`,''),IFNULL(nee.`phone`,'')) like concat('%',concat(#{query.searchKey},'%'))
</if>
<iftest ="query.consignorKey != null and query.consignorKey != '' ">
AND (concat(IFNULL(nor.`name`,''),IFNULL(nor.`name_en`,''),IFNULL(nor.`phone`,'')) like concat('%',concat(#{query.consignorKey},'%'))
OR nor.customer_id in (select c.id from ecw_customer c where c.number like concat('%',concat(#{query.consignorKey},'%'))))
</if>
<iftest ="query.notConsignorKey != null and query.notConsignorKey != '' ">
AND (concat(IFNULL(nor.`name`,''),IFNULL(nor.`name_en`,''),IFNULL(nor.`phone`,'')) not like concat('%',concat(#{query.notConsignorKey},'%'))
AND nor.customer_id not in (select c.id from ecw_customer c where c.number like concat('%',concat(#{query.notConsignorKey},'%'))))
</if>
<iftest ="query.consigneeKey != null and query.consigneeKey != '' ">
AND (concat(IFNULL(nee.`name`,''),IFNULL(nee.`name_en`,''),IFNULL(nee.`phone`,'')) like concat('%',concat(#{query.consigneeKey},'%'))
OR nee.customer_id in (select c.id from ecw_customer c where c.number like concat('%',concat(#{query.consigneeKey},'%'))))
</if>
<iftest ="query.notConsigneeKey != null and query.notConsigneeKey != '' ">
AND (concat(IFNULL(nee.`name`,''),IFNULL(nee.`name_en`,''),IFNULL(nee.`phone`,'')) not like concat('%',concat(#{query.notConsigneeKey},'%'))
AND nee.customer_id not in (select c.id from ecw_customer c where c.number like concat('%',concat(#{query.notConsigneeKey},'%'))))
</if>
<iftest ="query.numberKey != null and query.numberKey != '' ">
AND concat(IFNULL(o.`order_no`,''), IFNULL(o.`old_numbers`,''), IFNULL(o.`parent_number`,''), IFNULL(o.`initial_parent_order_no`,'') ,IFNULL(o.`marks`,''),IFNULL(o.`tidan_no`,''),IFNULL(o.`container_number`,''),IFNULL(o.`no_charge_record`,'')) like concat('%',concat(#{query.numberKey},'%'))
</if>
<iftest ="query.notNumberKey != null and query.notNumberKey != '' ">
AND concat(IFNULL(o.`order_no`,''), IFNULL(o.`old_numbers`,''), IFNULL(o.`parent_number`,''), IFNULL(o.`initial_parent_order_no`,'') ,IFNULL(o.`marks`,''),IFNULL(o.`tidan_no`,''),IFNULL(o.`container_number`,''),IFNULL(o.`no_charge_record`,'')) not like concat('%',concat(#{query.notNumberKey},'%'))
</if>
<iftest ="query.eqNumberKey != null and query.eqNumberKey != '' ">
AND (o.`order_no` = #{query.eqNumberKey}
or (o.`old_numbers` is not null and o.`old_numbers` != '' and o.`old_numbers` = #{query.eqNumberKey})
or (o.`parent_number` is not null and o.`parent_number` != '' and o.`parent_number` = #{query.eqNumberKey})
or (o.`marks` is not null and o.`marks` != '' and o.`marks` = #{query.eqNumberKey})
or (o.`tidan_no` is not null and o.`tidan_no` != '' and o.`tidan_no` = #{query.eqNumberKey})
or (o.`container_number` is not null and o.`container_number` != '' and o.`container_number` = #{query.eqNumberKey})
or (o.`no_charge_record` is not null and o.`no_charge_record` != '' and o.`no_charge_record` = #{query.eqNumberKey})
or (o.`initial_parent_order_no` is not null and o.`initial_parent_order_no` != '' and o.`initial_parent_order_no` = #{query.eqNumberKey}))
</if>
<iftest ="query.notEqNumberKey != null and query.notEqNumberKey != '' ">
AND o.`order_no` != #{query.notEqNumberKey}
AND (o.`old_numbers` is null or o.`old_numbers` = '' or o.`old_numbers` != #{query.notEqNumberKey})
AND (o.`parent_number` is null or o.`parent_number` = '' or o.`parent_number` != #{query.notEqNumberKey})
AND (o.`marks` is null or o.`marks` = '' or o.`marks` != #{query.notEqNumberKey})
AND (o.`tidan_no` is null or o.`tidan_no` = '' or o.`tidan_no` != #{query.notEqNumberKey})
AND (o.`container_number` is null or o.`container_number` = '' or o.`container_number` != #{query.notEqNumberKey})
AND (o.`no_charge_record` is null or o.`no_charge_record` = '' or o.`no_charge_record` != #{query.notEqNumberKey})
AND (o.`initial_parent_order_no` is null or o.`initial_parent_order_no` = '' or o.`initial_parent_order_no` != #{query.notEqNumberKey})
</if>
<iftest ="query.prodKey != null and query.prodKey != '' ">
and (o.order_id in(
select oi.order_id
from ecw_order_item oi
left join ecw_product p
on oi.prod_id = p.id
left join ecw_product_type pt
on pt.id = oi.prod_type
left join ecw_product_brank pb
on pb.id = oi.brand
where oi.deleted = 0
and concat(IFNULL(oi.`prod_title_zh`,''),IFNULL(oi.`prod_title_en`,''),IFNULL(pt.`title_zh`,''),IFNULL(pt.`title_en`,''),IFNULL(pb.`title_zh`,''),IFNULL(pb.`title_en`,''))
like concat('%',concat(#{query.prodKey},'%'))
))
</if>
<iftest ="query.notProdKey != null and query.notProdKey != '' ">
and (o.order_id not in(
select oi.order_id
from ecw_order_item oi
left join ecw_product p
on oi.prod_id = p.id
left join ecw_product_type pt
on pt.id = oi.prod_type
left join ecw_product_brank pb
on pb.id = oi.brand
where oi.deleted = 0 and concat(IFNULL(oi.`prod_title_zh`,''),IFNULL(oi.`prod_title_en`,''),IFNULL(pt.`title_zh`,''),IFNULL(pt.`title_en`,''),IFNULL(pb.`title_zh`,''),IFNULL(pb.`title_en`,'')) ,
like concat('%',concat(#{query.notProdKey},'%'))
))
</if>
<iftest ="query.eqProdKey != null and query.eqProdKey != '' ">
and (o.order_id in(
select oi.order_id
from ecw_order_item oi
left join ecw_product p
on oi.prod_id = p.id
left join ecw_product_type pt
on pt.id = oi.prod_type
left join ecw_product_brank pb
on pb.id = oi.brand
where oi.deleted = 0
and (oi.`prod_title_zh` = #{query.eqProdKey} or oi.`prod_title_en` = #{query.eqProdKey}
or pt.`title_zh` = #{query.eqProdKey} or pt.`title_en` = #{query.eqProdKey}
or pb.`title_zh` = #{query.eqProdKey} or pb.`title_en` = #{query.eqProdKey})
))
</if>
<iftest ="query.notEqProdKey != null and query.notEqProdKey != '' ">
and (o.order_id not in(
select oi.order_id
from ecw_order_item oi
left join ecw_product p
on oi.prod_id = p.id
left join ecw_product_type pt
on pt.id = oi.prod_type
left join ecw_product_brank pb
on pb.id = oi.brand
where oi.deleted = 0
and (oi.`prod_title_zh` = #{query.notEqProdKey} or oi.`prod_title_en` = #{query.notEqProdKey} ,
or pt.`title_zh` = #{query.notEqProdKey} or pt.`title_en` = #{query.notEqProdKey}
or pb.`title_zh` = #{query.notEqProdKey} or pb.`title_en` = #{query.notEqProdKey})
))
</if>
<iftest ="query.startWarehouseId != null and query.destWarehouseId != null ">