<?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.younike.system.mapper.OrderModifyMapper">
    
    <resultMap type="OrderModify" id="OrderModifyResult">
        <result property="recordId"    column="record_id"    />
        <result property="orderId"    column="order_id"    />
        <result property="modifyIndex"    column="modify_index"    />
        <result property="originalPrice"    column="original_price"    />
        <result property="modifyPrice"    column="modify_price"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectOrderModifyVo">
        select record_id, order_id, modify_index, original_price, modify_price, create_by, create_time from order_modify
    </sql>

    <select id="selectOrderModifyList" parameterType="OrderModify" resultMap="OrderModifyResult">
        <include refid="selectOrderModifyVo"/>
        <where>  
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="modifyIndex != null "> and modify_index = #{modifyIndex}</if>
            <if test="originalPrice != null "> and original_price = #{originalPrice}</if>
            <if test="modifyPrice != null "> and modify_price = #{modifyPrice}</if>
        </where>
    </select>
    
    <select id="selectOrderModifyByRecordId" parameterType="Long" resultMap="OrderModifyResult">
        <include refid="selectOrderModifyVo"/>
        where record_id = #{recordId}
    </select>
        
    <insert id="insertOrderModify" parameterType="OrderModify">
        insert into order_modify
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="recordId != null">record_id,</if>
            <if test="orderId != null">order_id,</if>
            <if test="modifyIndex != null">modify_index,</if>
            <if test="originalPrice != null">original_price,</if>
            <if test="modifyPrice != null">modify_price,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="recordId != null">#{recordId},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="modifyIndex != null">#{modifyIndex},</if>
            <if test="originalPrice != null">#{originalPrice},</if>
            <if test="modifyPrice != null">#{modifyPrice},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateOrderModify" parameterType="OrderModify">
        update order_modify
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="modifyIndex != null">modify_index = #{modifyIndex},</if>
            <if test="originalPrice != null">original_price = #{originalPrice},</if>
            <if test="modifyPrice != null">modify_price = #{modifyPrice},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where record_id = #{recordId}
    </update>

    <delete id="deleteOrderModifyByRecordId" parameterType="Long">
        delete from order_modify where record_id = #{recordId}
    </delete>

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