<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.prolog.cs.biz.outbound.dao.FreightEnterMapper">

    <select id="queryFreightEnter" resultType="com.prolog.cs.biz.outbound.model.dto.FreightEnterDto">
        select
        t2.id,
        t2.ship_bill_no shipNo,
        t1.shipper_code customerCode,
        t1.shipper_name customerName,
        t1.contact_tel contactWay
        from wms_wave_bill t1,wms_wave_bill_d t2,wms_pick_task_d pickd,wms_wave_storage yz
        where t1.id=t2.bill_id
        and pickd.wave_storage_id = yz.id
        and yz.wave_id = t1.wave_id
        and t1.status = 'OUT_CHECKED'   -- 外复核
        and t1.carrier_name = '创新物流'
        and t1.warehouse_id=#{warehouseId}
        <if test="shipNo != null and shipNo != ''">
            AND t2.ship_bill_no = #{shipNo}
        </if>
        <if test="itemNo != null and itemNo != ''">
            AND t2.ship_bill_no = #{itemNo}
        </if>
        <if test="customerName != null and customerName != ''">
            AND t1.shipper_name = #{customerName}
        </if>

        <if test="outStartDate != null and outStartDate != ''">
            AND pickd.check_time <![CDATA[ >= ]]> #{outStartDate}   -- 复核时间
        </if>
        <if test="outEndDate != null and outEndDate != ''">
            AND pickd.check_time <![CDATA[ <= ]]> #{outEndDate}
        </if>
    </select>
</mapper>