<?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="cn.ezhizao.project.business.mapper.BizInboundOrderMapper">

    <resultMap type="cn.ezhizao.project.business.domain.BizInboundOrder" id="BizInboundOrderResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizInboundOrder" resultMap="BizInboundOrderResult">
        SELECT t1.*, t2.alias as tenant_name FROM biz_inbound_order t1 left join biz_tenant t2 on t2.id = t1.tenant_id
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            t1.deleted = 0
            <if test="type != null "> AND t1.type = #{type}</if>
            <if test="deptName != null  and deptName != ''"> AND t1.dept_name like concat('%', #{deptName}, '%')</if>
            <if test="inboundTime != null "> AND t1.inbound_time = #{inboundTime}</if>
            <if test="inboundNumber != null  and inboundNumber != ''"> AND t1.inbound_number like concat('%', #{inboundNumber}, '%')</if>
            <if test="productDescription != null  and productDescription != ''"> AND t1.product_description like concat('%', #{productDescription}, '%')</if>
            <if test="deptId != null "> and t1.dept_id = #{deptId}</if>
            <if test="companyAlias != null  and companyAlias != ''"> AND t1.company_alias = #{companyAlias}</if>
            <if test="companyCode != null  and companyCode != ''"> AND t1.company_code = #{companyCode}</if>
            <if test="storageUserName != null  and storageUserName != ''"> AND t1.storage_user_name like concat('%', #{storageUserName}, '%')</if>
            <if test="storageNickName != null  and storageNickName != ''"> AND t1.storage_nick_name like concat('%', #{storageNickName}, '%')</if>
            <if test="packageResourceGroupName != null  and packageResourceGroupName != ''"> AND t1.package_resource_group_name like concat('%', #{packageResourceGroupName}, '%')</if>
            <if test="packageResourceGroupLineNo != null "> AND t1.package_resource_group_line_no = #{packageResourceGroupLineNo}</if>
            <if test="productCode != null  and productCode != ''"> AND t1.product_code = #{productCode}</if>
            <if test="productType != null "> AND t1.product_type = #{productType}</if>
            <if test="isSubItem != null "> AND t1.is_sub_item = #{isSubItem}</if>
            <if test="inputUserName != null  and inputUserName != ''"> AND t1.input_user_name like concat('%', #{inputUserName}, '%')</if>
            <if test="inputNickName != null  and inputNickName != ''"> AND t1.input_nick_name like concat('%', #{inputNickName}, '%')</if>
            <if test="inboundTotalNum != null "> AND t1.inbound_total_num = #{inboundTotalNum}</if>
            <if test="storageArea != null  and storageArea != ''"> AND t1.storage_area = #{storageArea}</if>
            <if test="labelNumber != null "> AND t1.label_number = #{labelNumber}</if>
            <if test="transferCode != null  and transferCode != ''"> AND t1.transfer_code = #{transferCode}</if>
            <if test="originalTransferCode != null  and originalTransferCode != ''"> AND t1.original_transfer_code = #{originalTransferCode}</if>
            <if test="isPrint != null "> AND is_print = #{isPrint}</if>
            <if test="reSelectOutgoingOrderNumber != null  and reSelectOutgoingOrderNumber != ''"> AND t1.re_select_outgoing_order_number like concat('%', #{reSelectOutgoingOrderNumber}, '%')</if>
            <if test="boxNumber != null "> AND t1.box_number = #{boxNumber}</if>
            <if test="factoryWarehouse != null  and factoryWarehouse != ''"> AND t1.factory_warehouse = #{factoryWarehouse}</if>
            <if test="unit != null  and unit != ''"> AND t1.unit = #{unit}</if>
            <if test="packageType != null  and packageType != ''"> AND t1.package_type = #{packageType}</if>
            <if test="status != null  and status != ''"> AND t1.status = #{status}</if>
            <if test="isAllInbound != null "> AND t1.is_all_inbound = #{isAllInbound}</if>
            <if test="startTime != null ">AND date_format(t1.create_time,'%y%m%d') &gt;=date_format(#{startTime},'%y%m%d') </if>
            <if test="endTime != null ">AND date_format(t1.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')</if>
            <if test="id != null">and t1.id = #{id}</if>
        </trim>
        order by t1.is_print asc, t1.status asc , t1.create_time desc
    </select>

    <delete id="physicalDelete">
        DELETE FROM biz_inbound_order
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            <if test="id != null">
                id = #{id} AND
            </if>
       <!-- 删除条件为其他外键可以在这里加 -->
        </trim>
    </delete>
</mapper>
