<?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.ss.orderOper.mapper.OrderOperMapper">

    <resultMap type="OrderOper" id="RlOrderOperResult" autoMapping="true" />

    <sql id="selectRlOrderOperVo">
        select oper_id, order_no, oper_type, details, before_amount, after_amount, before_status, after_status,
               oper_user_id, create_time, oper_phone from ss_order_oper
    </sql>

    <select id="selectRlOrderOperList" parameterType="OrderOper" resultMap="RlOrderOperResult">
        <include refid="selectRlOrderOperVo"/>
        <where>
            <if test="orderNo != null  and orderNo != ''"> and order_no = #{orderNo}</if>
            <if test="operType != null  and operType != ''"> and oper_type = #{operType}</if>
            <if test="details != null  and details != ''"> and details = #{details}</if>
            <if test="operUserId != null "> and oper_user_id = #{operUserId}</if>
            <if test="operPhone != null  and operPhone != ''"> and oper_phone = #{operPhone}</if>
        </where>
        order by create_time
    </select>

    <select id="selectRlOrderOperByOperId" parameterType="Long" resultMap="RlOrderOperResult">
        <include refid="selectRlOrderOperVo"/>
        where oper_id = #{operId}
    </select>

    <insert id="insertRlOrderOper" parameterType="OrderOper" useGeneratedKeys="true" keyProperty="operId">
        insert into ss_order_oper
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderNo != null and orderNo != ''">order_no,</if>
            <if test="operType != null and operType != ''">oper_type,</if>
            <if test="details != null">details,</if>
            <if test="beforeAmount != null">before_amount,</if>
            <if test="afterAmount != null">after_amount,</if>
            <if test="beforeStatus != null">before_status,</if>
            <if test="afterStatus != null">after_status,</if>
            <if test="operUserId != null">oper_user_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="operPhone != null">oper_phone,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderNo != null and orderNo != ''">#{orderNo},</if>
            <if test="operType != null and operType != ''">#{operType},</if>
            <if test="details != null">#{details},</if>
            <if test="beforeAmount != null">#{beforeAmount},</if>
            <if test="afterAmount != null">#{afterAmount},</if>
            <if test="beforeStatus != null">#{beforeStatus},</if>
            <if test="afterStatus != null">#{afterStatus},</if>
            <if test="operUserId != null">#{operUserId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="operPhone != null">#{operPhone},</if>
         </trim>
    </insert>

    <update id="updateRlOrderOper" parameterType="OrderOper">
        update ss_order_oper
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderNo != null and orderNo != ''">order_no = #{orderNo},</if>
            <if test="operType != null and operType != ''">oper_type = #{operType},</if>
            <if test="details != null">details = #{details},</if>
            <if test="beforeAmount != null">before_amount = #{beforeAmount},</if>
            <if test="afterAmount != null">after_amount = #{afterAmount},</if>
            <if test="beforeStatus != null">before_status = #{beforeStatus},</if>
            <if test="afterStatus != null">after_status = #{afterStatus},</if>
            <if test="operUserId != null">oper_user_id = #{operUserId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="operPhone != null">oper_phone = #{operPhone},</if>
        </trim>
        where oper_id = #{operId}
    </update>

    <delete id="deleteRlOrderOperByOperId" parameterType="Long">
        delete from ss_order_oper where oper_id = #{operId}
    </delete>

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