<?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.yiqi.order.mapper.OrderRefundInfoMapper">

    <resultMap type="OrderRefundInfo" id="OrderRefundInfoResult">
        <result property="id" column="id"/>
        <result property="storeId" column="store_id"/>
        <result property="originOrderNo" column="origin_order_no"/>
        <result property="refundOrderNo" column="refund_order_no"/>
        <result property="requestNo" column="request_no"/>
        <result property="payAmount" column="pay_amount"/>
        <result property="refundAmount" column="refund_amount"/>
        <result property="payMno" column="pay_mno"/>
        <result property="payType" column="pay_type"/>
        <result property="refundStatus" column="refund_status"/>
        <result property="msg" column="msg"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <sql id="selectOrderRefundInfoVo">
        select id, store_id, origin_order_no, refund_order_no, request_no, pay_amount, refund_amount, pay_mno, pay_type, refund_status, msg, create_time
        from order_refund_info
    </sql>

    <select id="selectOrderRefundInfoList" parameterType="OrderRefundInfo" resultMap="OrderRefundInfoResult">
        <include refid="selectOrderRefundInfoVo"/>
        <where>
            <if test="storeId != null ">
                and store_id = #{storeId}
            </if>
            <if test="originOrderNo != null  and originOrderNo != ''">
                and origin_order_no = #{originOrderNo}
            </if>
            <if test="refundOrderNo != null  and refundOrderNo != ''">
                and refund_order_no = #{refundOrderNo}
            </if>
            <if test="requestNo != null  and requestNo != ''">
                and request_no = #{requestNo}
            </if>
            <if test="payAmount != null ">
                and pay_amount = #{payAmount}
            </if>
            <if test="refundAmount != null ">
                and refund_amount = #{refundAmount}
            </if>
            <if test="payMno != null  and payMno != ''">
                and pay_mno = #{payMno}
            </if>
            <if test="payType != null  and payType != ''">
                and pay_type = #{payType}
            </if>
            <if test="refundStatus != null  and refundStatus != ''">
                and refund_status = #{refundStatus}
            </if>
            <if test="msg != null  and msg != ''">
                and msg = #{msg}
            </if>
        </where>
    </select>

    <select id="selectOrderRefundInfoById" parameterType="Long"
            resultMap="OrderRefundInfoResult">
        <include refid="selectOrderRefundInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertOrderRefundInfo" parameterType="OrderRefundInfo" useGeneratedKeys="true"
            keyProperty="id">
        insert into order_refund_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="storeId != null">store_id,
            </if>
            <if test="originOrderNo != null">origin_order_no,
            </if>
            <if test="refundOrderNo != null">refund_order_no,
            </if>
            <if test="requestNo != null">request_no,
            </if>
            <if test="payAmount != null">pay_amount,
            </if>
            <if test="refundAmount != null">refund_amount,
            </if>
            <if test="payMno != null">pay_mno,
            </if>
            <if test="payType != null">pay_type,
            </if>
            <if test="refundStatus != null">refund_status,
            </if>
            <if test="msg != null">msg,
            </if>
            <if test="createTime != null">create_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="storeId != null">#{storeId},
            </if>
            <if test="originOrderNo != null">#{originOrderNo},
            </if>
            <if test="refundOrderNo != null">#{refundOrderNo},
            </if>
            <if test="requestNo != null">#{requestNo},
            </if>
            <if test="payAmount != null">#{payAmount},
            </if>
            <if test="refundAmount != null">#{refundAmount},
            </if>
            <if test="payMno != null">#{payMno},
            </if>
            <if test="payType != null">#{payType},
            </if>
            <if test="refundStatus != null">#{refundStatus},
            </if>
            <if test="msg != null">#{msg},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
        </trim>
    </insert>

    <update id="updateOrderRefundInfo" parameterType="OrderRefundInfo">
        update order_refund_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="storeId != null">store_id =
                #{storeId},
            </if>
            <if test="originOrderNo != null">origin_order_no =
                #{originOrderNo},
            </if>
            <if test="refundOrderNo != null">refund_order_no =
                #{refundOrderNo},
            </if>
            <if test="requestNo != null">request_no =
                #{requestNo},
            </if>
            <if test="payAmount != null">pay_amount =
                #{payAmount},
            </if>
            <if test="refundAmount != null">refund_amount =
                #{refundAmount},
            </if>
            <if test="payMno != null">pay_mno =
                #{payMno},
            </if>
            <if test="payType != null">pay_type =
                #{payType},
            </if>
            <if test="refundStatus != null">refund_status =
                #{refundStatus},
            </if>
            <if test="msg != null">msg =
                #{msg},
            </if>
            <if test="createTime != null">create_time =
                #{createTime},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderRefundInfoById" parameterType="Long">
        delete from order_refund_info where id = #{id}
    </delete>

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



</mapper>