<?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.ruoyi.frequency.orderreceiving.mapper.OrderReceivingMapper">
    
    <resultMap type="com.ruoyi.frequency.orderreceiving.entity.OrderReceiving" id="OrderReceivingResult">
        <result property="id"    column="id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="orderId"    column="order_id"    />
        <result property="storeId"    column="store_id"    />
        <result property="receivingStatus"    column="receiving_status"    />
    </resultMap>

    <sql id="selectOrderReceivingVo">
        select id, create_by, create_time, update_by, update_time, del_flag, order_id, store_id, receiving_status from t_order_receiving
    </sql>

    <select id="selectOrderReceivingList" parameterType="com.ruoyi.frequency.orderreceiving.entity.OrderReceiving" resultMap="OrderReceivingResult">
        <include refid="selectOrderReceivingVo"/>
        <where>  
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="storeId != null "> and store_id = #{storeId}</if>
            <if test="receivingStatus != null "> and receiving_status = #{receivingStatus}</if>
        </where>
    </select>
    
    <select id="selectOrderReceivingById" parameterType="Long" resultMap="OrderReceivingResult">
        <include refid="selectOrderReceivingVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertOrderReceiving" parameterType="com.ruoyi.frequency.orderreceiving.entity.OrderReceiving">
        insert into t_order_receiving
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="orderId != null">order_id,</if>
            <if test="storeId != null">store_id,</if>
            <if test="receivingStatus != null">receiving_status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="storeId != null">#{storeId},</if>
            <if test="receivingStatus != null">#{receivingStatus},</if>
         </trim>
    </insert>

    <update id="updateOrderReceiving" parameterType="com.ruoyi.frequency.orderreceiving.entity.OrderReceiving">
        update t_order_receiving
        <trim prefix="SET" suffixOverrides=",">
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="storeId != null">store_id = #{storeId},</if>
            <if test="receivingStatus != null">receiving_status = #{receivingStatus},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderReceivingById" parameterType="Long">
        delete from t_order_receiving where id = #{id}
    </delete>

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