<?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.mallrefund.mapper.MallRefundMapper">

    <resultMap type="com.ruoyi.frequency.mallrefund.entity.MallRefund" id="MallRefundResult">
        <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="status"    column="status"    />
        <result property="refundType"    column="refund_type"    />
        <result property="comCourierId"    column="com_courier_id"    />
        <result property="comLogisticsCode"    column="com_logistics_code"    />
        <result property="comLogistics"    column="com_logistics"    />
        <result property="refundReason"    column="refund_reason"    />
        <result property="refundImages"    column="refund_images"    />
        <result property="refuseReason"    column="refuse_reason"    />
        <result property="refundExplain"    column="refund_explain"    />
        <result property="checkTime"    column="check_time"    />
        <result property="storeId"    column="store_id"    />
        <result property="orderType"    column="order_type"    />
        <result property="refundNum"    column="refund_num"    />
        <result property="refundPrice"    column="refund_price"    />
        <result property="affirmTime"    column="affirm_time"    />
        </resultMap>

    
    
    <sql id="selectMallRefundVo">
        select
            t.id ,
            t.create_by ,
            t.create_time ,
            t.update_by ,
            t.update_time ,
            t.del_flag ,
            t.order_id ,
            t.status ,
            t.refund_type ,
            t.com_courier_id ,
            t.com_logistics_code ,
            t.com_logistics ,
            t.refund_reason ,
            t.refund_images ,
            t.refuse_reason ,
            t.refund_explain ,
            t.check_time ,
            t.store_id ,
            t.order_type ,
            t.refund_num ,
            t.refund_price ,
            t.affirm_time 
        from mall_refund AS t
                
    </sql>

    <select id="selectMallRefundList" parameterType="com.ruoyi.frequency.mallrefund.entity.MallRefund" resultMap="MallRefundResult">
        <include refid="selectMallRefundVo"/>
        <where> AND t.del_flag != 2
            <if test="orderId != null "> and t.order_id = #{orderId}</if>
            <if test="status != null "> and t.status = #{status}</if>
            <if test="refundType != null "> and t.refund_type = #{refundType}</if>
            <if test="comCourierId != null  and comCourierId != ''"> and t.com_courier_id = #{comCourierId}</if>
            <if test="comLogisticsCode != null  and comLogisticsCode != ''"> and t.com_logistics_code = #{comLogisticsCode}</if>
            <if test="comLogistics != null  and comLogistics != ''"> and t.com_logistics = #{comLogistics}</if>
            <if test="refundReason != null  and refundReason != ''"> and t.refund_reason = #{refundReason}</if>
            <if test="refundImages != null  and refundImages != ''"> and t.refund_images = #{refundImages}</if>
            <if test="refuseReason != null  and refuseReason != ''"> and t.refuse_reason = #{refuseReason}</if>
            <if test="refundExplain != null  and refundExplain != ''"> and t.refund_explain = #{refundExplain}</if>
            <if test="checkTime != null "> and t.check_time = #{checkTime}</if>
            <if test="storeId != null "> and t.store_id = #{storeId}</if>
            <if test="orderType != null "> and t.order_type = #{orderType}</if>
            <if test="refundNum != null "> and t.refund_num = #{refundNum}</if>
            <if test="refundPrice != null "> and t.refund_price = #{refundPrice}</if>
            <if test="affirmTime != null "> and t.affirm_time = #{affirmTime}</if>
            <if test="delFlag != null and delFlag != ''"> and t.del_flag = #{delFlag}</if>
        </where>
        order by t.create_time desc
    </select>

    <select id="selectMallRefundById" parameterType="Long" resultMap="MallRefundResult">
        <include refid="selectMallRefundVo"/>
        where t.id = #{id}
    </select>

    <insert id="insertMallRefund" parameterType="com.ruoyi.frequency.mallrefund.entity.MallRefund">
        insert into mall_refund
        <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="status != null">status,</if>
            <if test="refundType != null">refund_type,</if>
            <if test="comCourierId != null">com_courier_id,</if>
            <if test="comLogisticsCode != null">com_logistics_code,</if>
            <if test="comLogistics != null">com_logistics,</if>
            <if test="refundReason != null">refund_reason,</if>
            <if test="refundImages != null">refund_images,</if>
            <if test="refuseReason != null">refuse_reason,</if>
            <if test="refundExplain != null">refund_explain,</if>
            <if test="checkTime != null">check_time,</if>
            <if test="storeId != null">store_id,</if>
            <if test="orderType != null">order_type,</if>
            <if test="refundNum != null">refund_num,</if>
            <if test="refundPrice != null">refund_price,</if>
            <if test="affirmTime != null">affirm_time,</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="status != null">#{status},</if>
            <if test="refundType != null">#{refundType},</if>
            <if test="comCourierId != null">#{comCourierId},</if>
            <if test="comLogisticsCode != null">#{comLogisticsCode},</if>
            <if test="comLogistics != null">#{comLogistics},</if>
            <if test="refundReason != null">#{refundReason},</if>
            <if test="refundImages != null">#{refundImages},</if>
            <if test="refuseReason != null">#{refuseReason},</if>
            <if test="refundExplain != null">#{refundExplain},</if>
            <if test="checkTime != null">#{checkTime},</if>
            <if test="storeId != null">#{storeId},</if>
            <if test="orderType != null">#{orderType},</if>
            <if test="refundNum != null">#{refundNum},</if>
            <if test="refundPrice != null">#{refundPrice},</if>
            <if test="affirmTime != null">#{affirmTime},</if>
        </trim>
    </insert>

    <update id="updateMallRefund" parameterType="com.ruoyi.frequency.mallrefund.entity.MallRefund">
        update mall_refund
        <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="status != null">status = #{status},</if>
            <if test="refundType != null">refund_type = #{refundType},</if>
            <if test="comCourierId != null">com_courier_id = #{comCourierId},</if>
            <if test="comLogisticsCode != null">com_logistics_code = #{comLogisticsCode},</if>
            <if test="comLogistics != null">com_logistics = #{comLogistics},</if>
            <if test="refundReason != null">refund_reason = #{refundReason},</if>
            <if test="refundImages != null">refund_images = #{refundImages},</if>
            <if test="refuseReason != null">refuse_reason = #{refuseReason},</if>
            <if test="refundExplain != null">refund_explain = #{refundExplain},</if>
            <if test="checkTime != null">check_time = #{checkTime},</if>
            <if test="storeId != null">store_id = #{storeId},</if>
            <if test="orderType != null">order_type = #{orderType},</if>
            <if test="refundNum != null">refund_num = #{refundNum},</if>
            <if test="refundPrice != null">refund_price = #{refundPrice},</if>
            <if test="affirmTime != null">affirm_time = #{affirmTime},</if>
        </trim>
        where id = #{id}
    </update>
                                                                                                                        </mapper>