<?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.mallrefundordergoods.mapper.MallRefundOrderGoodsMapper">

    <resultMap type="com.ruoyi.frequency.mallrefundordergoods.entity.MallRefundOrderGoods" id="MallRefundOrderGoodsResult">
        <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="refundId"    column="refund_id"    />
        <result property="orderGoodsId"    column="order_goods_id"    />
        <result property="refundNum"    column="refund_num"    />
        </resultMap>

    
    
    <sql id="selectMallRefundOrderGoodsVo">
        select
            t.id ,
            t.create_by ,
            t.create_time ,
            t.update_by ,
            t.update_time ,
            t.del_flag ,
            t.refund_id ,
            t.order_goods_id ,
            t.refund_num 
        from mall_refund_order_goods AS t
                
    </sql>

    <select id="selectMallRefundOrderGoodsList" parameterType="com.ruoyi.frequency.mallrefundordergoods.entity.MallRefundOrderGoods" resultMap="MallRefundOrderGoodsResult">
        <include refid="selectMallRefundOrderGoodsVo"/>
        <where> AND t.del_flag != 2
            <if test="refundId != null "> and t.refund_id = #{refundId}</if>
            <if test="orderGoodsId != null "> and t.order_goods_id = #{orderGoodsId}</if>
            <if test="refundNum != null "> and t.refund_num = #{refundNum}</if>
            <if test="delFlag != null and delFlag != ''"> and t.del_flag = #{delFlag}</if>
        </where>
        order by t.create_time desc
    </select>

    <select id="selectMallRefundOrderGoodsById" parameterType="Long" resultMap="MallRefundOrderGoodsResult">
        <include refid="selectMallRefundOrderGoodsVo"/>
        where t.id = #{id}
    </select>

    <insert id="insertMallRefundOrderGoods" parameterType="com.ruoyi.frequency.mallrefundordergoods.entity.MallRefundOrderGoods">
        insert into mall_refund_order_goods
        <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="refundId != null">refund_id,</if>
            <if test="orderGoodsId != null">order_goods_id,</if>
            <if test="refundNum != null">refund_num,</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="refundId != null">#{refundId},</if>
            <if test="orderGoodsId != null">#{orderGoodsId},</if>
            <if test="refundNum != null">#{refundNum},</if>
        </trim>
    </insert>

    <update id="updateMallRefundOrderGoods" parameterType="com.ruoyi.frequency.mallrefundordergoods.entity.MallRefundOrderGoods">
        update mall_refund_order_goods
        <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="refundId != null">refund_id = #{refundId},</if>
            <if test="orderGoodsId != null">order_goods_id = #{orderGoodsId},</if>
            <if test="refundNum != null">refund_num = #{refundNum},</if>
        </trim>
        where id = #{id}
    </update>
                                                                                                                        </mapper>