<?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.xingxi.business.Order.mapper.OrderDeliveryExprMapper">
    <resultMap type="OrderDeliveryExpr" id="OrderDeliveryExprResult">
        <result property="id"    column="id"    />
        <result property="orderDetailId"    column="orderDetailId"    />
        <result property="orderDeliveryId"    column="orderDeliveryId"    />
        <result property="expressNo"    column="expressNo"    />
        <result property="deliveryTime"    column="deliveryTime"    />
        <result property="confirmTime"    column="confirmTime"    />
        <result property="delFlag"    column="delFlag"    />
        <result property="createUser"    column="createUser"    />
        <result property="createTime"    column="createTime"    />
        <result property="updateUser"    column="updateUser"    />
        <result property="updateTime"    column="updateTime"    />
    </resultMap>

    <sql id="selectOrderDeliveryExpr">
        select id, orderDetailId, orderDeliveryId, expressNo, deliveryTime, confirmTime, delFlag, createUser, createTime, updateUser, updateTime from t_order_delivery_expr
    </sql>

    <sql id="selectOrderDeliveryExprExt">
        select
            ${tableAlias}.id,
            ${tableAlias}.orderDetailId,
            ${tableAlias}.orderDeliveryId,
            ${tableAlias}.expressNo,
            ${tableAlias}.deliveryTime,
            ${tableAlias}.confirmTime,
            ${tableAlias}.delFlag,
            ${tableAlias}.createUser,
            ${tableAlias}.createTime,
            ${tableAlias}.updateUser,
            ${tableAlias}.updateTime
        from t_order_delivery_expr ${tableAlias}
    </sql>

    <select id="selectOrderDeliveryExprList" parameterType="OrderDeliveryExpr" resultMap="OrderDeliveryExprResult">
        <include refid="selectOrderDeliveryExpr"/>
        <where>  
            <if test="orderDetailId != null "> and orderDetailId = #{orderDetailId}</if>
            <if test="orderDeliveryId != null "> and orderDeliveryId = #{orderDeliveryId}</if>
            <if test="expressNo != null  and expressNo != ''"> and expressNo = #{expressNo}</if>
            <if test="deliveryTime != null "> and deliveryTime = #{deliveryTime}</if>
            <if test="confirmTime != null "> and confirmTime = #{confirmTime}</if>
            <if test="delFlag != null  and delFlag != ''"> and delFlag = #{delFlag}</if>
            <if test="createUser != null  and createUser != ''"> and createUser = #{createUser}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="updateUser != null  and updateUser != ''"> and updateUser = #{updateUser}</if>
            <if test="updateTime != null "> and updateTime = #{updateTime}</if>
        </where>
    </select>
    
    <select id="selectOrderDeliveryExprById" parameterType="Long" resultMap="OrderDeliveryExprResult">
        <include refid="selectOrderDeliveryExpr"/>
        where id = #{id}
    </select>
        
    <insert id="insertOrderDeliveryExpr" parameterType="OrderDeliveryExpr" useGeneratedKeys="true" keyProperty="id">
        insert into t_order_delivery_expr
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderDetailId != null">orderDetailId,</if>
            <if test="orderDeliveryId != null">orderDeliveryId,</if>
            <if test="expressNo != null">expressNo,</if>
            <if test="deliveryTime != null">deliveryTime,</if>
            <if test="confirmTime != null">confirmTime,</if>
            <if test="delFlag != null">delFlag,</if>
            <if test="createUser != null">createUser,</if>
            <if test="createTime != null">createTime,</if>
            <if test="updateUser != null">updateUser,</if>
            <if test="updateTime != null">updateTime,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderDetailId != null">#{orderDetailId},</if>
            <if test="orderDeliveryId != null">#{orderDeliveryId},</if>
            <if test="expressNo != null">#{expressNo},</if>
            <if test="deliveryTime != null">#{deliveryTime},</if>
            <if test="confirmTime != null">#{confirmTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createUser != null">#{createUser},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateUser != null">#{updateUser},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <insert id="batchInsertOrderDeliveryExpr">
        insert into t_order_delivery_expr( orderDetailId, orderDeliveryId, expressNo, deliveryTime, confirmTime, delFlag, createUser, createTime, updateUser, updateTime) values
        <foreach item="item" index="index" collection="list" separator=",">
            ( #{item.orderDetailId}, #{item.orderDeliveryId}, #{item.expressNo}, #{item.deliveryTime}, #{item.confirmTime}, #{item.delFlag}, #{item.createUser}, #{item.createTime}, #{item.updateUser}, #{item.updateTime})
        </foreach>
    </insert>

    <update id="updateOrderDeliveryExpr" parameterType="OrderDeliveryExpr">
        update t_order_delivery_expr
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderDetailId != null">orderDetailId = #{orderDetailId},</if>
            <if test="orderDeliveryId != null">orderDeliveryId = #{orderDeliveryId},</if>
            <if test="expressNo != null">expressNo = #{expressNo},</if>
            <if test="deliveryTime != null">deliveryTime = #{deliveryTime},</if>
            <if test="confirmTime != null">confirmTime = #{confirmTime},</if>
            <if test="delFlag != null">delFlag = #{delFlag},</if>
            <if test="createUser != null">createUser = #{createUser},</if>
            <if test="createTime != null">createTime = #{createTime},</if>
            <if test="updateUser != null">updateUser = #{updateUser},</if>
            <if test="updateTime != null">updateTime = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderDeliveryExprById" parameterType="Long">
        delete from t_order_delivery_expr where id = #{id}
    </delete>

    <delete id="deleteOrderDeliveryExprByIds" parameterType="String">
        delete from t_order_delivery_expr where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <update id="logicDeleteOrderDeliveryExprById" parameterType="Long">
        update t_order_delivery_expr
            set delFlag = '1'
        where id = #{id}
    </update>

    <update id="logicDeleteOrderDeliveryExprByIds" parameterType="String">
        update t_order_delivery_expr
        set delFlag = '1'
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <update id="logicDeleteOrderDeliveryExprByCondition" parameterType="OrderDeliveryExpr">
        update t_order_delivery_expr
        set delFlag = '1'
        <where>
            <if test="orderDetailId != null "> and orderDetailId = #{orderDetailId}</if>
            <if test="orderDeliveryId != null "> and orderDeliveryId = #{orderDeliveryId}</if>
            <if test="expressNo != null  and expressNo != ''"> and expressNo = #{expressNo}</if>
            <if test="deliveryTime != null "> and deliveryTime = #{deliveryTime}</if>
            <if test="confirmTime != null "> and confirmTime = #{confirmTime}</if>
            <if test="delFlag != null  and delFlag != ''"> and delFlag = #{delFlag}</if>
            <if test="createUser != null  and createUser != ''"> and createUser = #{createUser}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="updateUser != null  and updateUser != ''"> and updateUser = #{updateUser}</if>
            <if test="updateTime != null "> and updateTime = #{updateTime}</if>
        </where>
    </update>
</mapper>