<?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.xingxi.business.RefundInfo.mapper.RefundInfoMapper">
    
    <resultMap type="RefundInfo" id="RefundInfoResult">
        <result property="id"    column="id"    />
        <result property="delFlag"    column="delFlag"    />
        <result property="createUser"    column="createUser"    />
        <result property="createTime"    column="createTime"    />
        <result property="updateUser"    column="updateUser"    />
        <result property="updateTime"    column="updateTime"    />
        <result property="transactionId"    column="transactionId"    />
        <result property="outTradeNo"    column="outTradeNo"    />
        <result property="outRefundNo"    column="outRefundNo"    />
        <result property="reason"    column="reason"    />
        <result property="notifyUrl"    column="notifyUrl"    />
        <result property="amountRefund"    column="amountRefund"    />
        <result property="amountTotal"    column="amountTotal"    />
        <result property="refundId"    column="refundId"    />
        <result property="channel"    column="channel"    />
        <result property="userReceivedAccount"    column="userReceivedAccount"    />
        <result property="successTime"    column="successTime"    />
        <result property="refundTime"    column="refundTime"    />
        <result property="status"    column="status"    />
        <result property="fundsAccount"    column="fundsAccount"    />
        <result property="payerTotal"    column="payerTotal"    />
        <result property="payerRefund"    column="payerRefund"    />
        <result property="settlementRefund"    column="settlementRefund"    />
        <result property="settlementTotal"    column="settlementTotal"    />
        <result property="discountRefund"    column="discountRefund"    />
    </resultMap>

    <sql id="selectRefundInfoVo">
        select id, delFlag, createUser, createTime, updateUser, updateTime, transactionId, outTradeNo, outRefundNo, reason, notifyUrl, amountRefund, amountTotal, refundId, channel, userReceivedAccount, successTime, refundTime, status, fundsAccount, payerTotal, payerRefund, settlementRefund, settlementTotal, discountRefund from t_refund_info
    </sql>

    <select id="selectRefundInfoList" parameterType="RefundInfo" resultMap="RefundInfoResult">
        <include refid="selectRefundInfoVo"/>
        <where>  
            <if test="delFlag != null  and delFlag != ''"> and delFlag = #{delFlag}</if>
            <if test="createUser != null  and createUser != ''"> and createUser = #{createUser}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="updateUser != null  and updateUser != ''"> and updateUser = #{updateUser}</if>
            <if test="updateTime != null "> and updateTime = #{updateTime}</if>
            <if test="transactionId != null  and transactionId != ''"> and transactionId = #{transactionId}</if>
            <if test="outTradeNo != null  and outTradeNo != ''"> and outTradeNo = #{outTradeNo}</if>
            <if test="outRefundNo != null  and outRefundNo != ''"> and outRefundNo = #{outRefundNo}</if>
            <if test="reason != null  and reason != ''"> and reason = #{reason}</if>
            <if test="notifyUrl != null  and notifyUrl != ''"> and notifyUrl = #{notifyUrl}</if>
            <if test="amountRefund != null "> and amountRefund = #{amountRefund}</if>
            <if test="amountTotal != null "> and amountTotal = #{amountTotal}</if>
            <if test="refundId != null  and refundId != ''"> and refundId = #{refundId}</if>
            <if test="channel != null  and channel != ''"> and channel = #{channel}</if>
            <if test="userReceivedAccount != null  and userReceivedAccount != ''"> and userReceivedAccount = #{userReceivedAccount}</if>
            <if test="successTime != null "> and successTime = #{successTime}</if>
            <if test="refundTime != null  and refundTime != ''"> and refundTime = #{refundTime}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="fundsAccount != null  and fundsAccount != ''"> and fundsAccount = #{fundsAccount}</if>
            <if test="payerTotal != null "> and payerTotal = #{payerTotal}</if>
            <if test="payerRefund != null "> and payerRefund = #{payerRefund}</if>
            <if test="settlementRefund != null "> and settlementRefund = #{settlementRefund}</if>
            <if test="settlementTotal != null "> and settlementTotal = #{settlementTotal}</if>
            <if test="discountRefund != null "> and discountRefund = #{discountRefund}</if>
        </where>
    </select>
    
    <select id="selectRefundInfoById" parameterType="Long" resultMap="RefundInfoResult">
        <include refid="selectRefundInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertRefundInfo" parameterType="RefundInfo" useGeneratedKeys="true" keyProperty="id">
        insert into t_refund_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">delFlag,</if>
            <if test="createUser != null">createUser,</if>
            <if test="createTime != null">createTime,</if>
            <if test="updateUser != null">updateUser,</if>
            <if test="updateTime != null">updateTime,</if>
            <if test="transactionId != null">transactionId,</if>
            <if test="outTradeNo != null">outTradeNo,</if>
            <if test="outRefundNo != null">outRefundNo,</if>
            <if test="reason != null">reason,</if>
            <if test="notifyUrl != null">notifyUrl,</if>
            <if test="amountRefund != null">amountRefund,</if>
            <if test="amountTotal != null">amountTotal,</if>
            <if test="refundId != null">refundId,</if>
            <if test="channel != null">channel,</if>
            <if test="userReceivedAccount != null">userReceivedAccount,</if>
            <if test="successTime != null">successTime,</if>
            <if test="refundTime != null">refundTime,</if>
            <if test="status != null">status,</if>
            <if test="fundsAccount != null">fundsAccount,</if>
            <if test="payerTotal != null">payerTotal,</if>
            <if test="payerRefund != null">payerRefund,</if>
            <if test="settlementRefund != null">settlementRefund,</if>
            <if test="settlementTotal != null">settlementTotal,</if>
            <if test="discountRefund != null">discountRefund,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createUser != null">#{createUser},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateUser != null">#{updateUser},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="transactionId != null">#{transactionId},</if>
            <if test="outTradeNo != null">#{outTradeNo},</if>
            <if test="outRefundNo != null">#{outRefundNo},</if>
            <if test="reason != null">#{reason},</if>
            <if test="notifyUrl != null">#{notifyUrl},</if>
            <if test="amountRefund != null">#{amountRefund},</if>
            <if test="amountTotal != null">#{amountTotal},</if>
            <if test="refundId != null">#{refundId},</if>
            <if test="channel != null">#{channel},</if>
            <if test="userReceivedAccount != null">#{userReceivedAccount},</if>
            <if test="successTime != null">#{successTime},</if>
            <if test="refundTime != null">#{refundTime},</if>
            <if test="status != null">#{status},</if>
            <if test="fundsAccount != null">#{fundsAccount},</if>
            <if test="payerTotal != null">#{payerTotal},</if>
            <if test="payerRefund != null">#{payerRefund},</if>
            <if test="settlementRefund != null">#{settlementRefund},</if>
            <if test="settlementTotal != null">#{settlementTotal},</if>
            <if test="discountRefund != null">#{discountRefund},</if>
         </trim>
    </insert>

    <insert id="batchInsertRefundInfo">
        insert into t_refund_info( delFlag, createUser, createTime, updateUser, updateTime, transactionId, outTradeNo, outRefundNo, reason, notifyUrl, amountRefund, amountTotal, refundId, channel, userReceivedAccount, successTime, refundTime, status, fundsAccount, payerTotal, payerRefund, settlementRefund, settlementTotal, discountRefund) values
        <foreach item="item" index="index" collection="list" separator=",">
            ( #{item.delFlag}, #{item.createUser}, #{item.createTime}, #{item.updateUser}, #{item.updateTime}, #{item.transactionId}, #{item.outTradeNo}, #{item.outRefundNo}, #{item.reason}, #{item.notifyUrl}, #{item.amountRefund}, #{item.amountTotal}, #{item.refundId}, #{item.channel}, #{item.userReceivedAccount}, #{item.successTime}, #{item.refundTime}, #{item.status}, #{item.fundsAccount}, #{item.payerTotal}, #{item.payerRefund}, #{item.settlementRefund}, #{item.settlementTotal}, #{item.discountRefund})
        </foreach>
    </insert>

    <update id="updateRefundInfo" parameterType="RefundInfo">
        update t_refund_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">delFlag = #{delFlag},</if>
            <if test="createUser != null">createUser = #{createUser},</if>
            <if test="createTime != null">createTime = #{createTime},</if>
            <if test="updateUser != null">updateUser = #{updateUser},</if>
            <if test="updateTime != null">updateTime = #{updateTime},</if>
            <if test="transactionId != null">transactionId = #{transactionId},</if>
            <if test="outTradeNo != null">outTradeNo = #{outTradeNo},</if>
            <if test="outRefundNo != null">outRefundNo = #{outRefundNo},</if>
            <if test="reason != null">reason = #{reason},</if>
            <if test="notifyUrl != null">notifyUrl = #{notifyUrl},</if>
            <if test="amountRefund != null">amountRefund = #{amountRefund},</if>
            <if test="amountTotal != null">amountTotal = #{amountTotal},</if>
            <if test="refundId != null">refundId = #{refundId},</if>
            <if test="channel != null">channel = #{channel},</if>
            <if test="userReceivedAccount != null">userReceivedAccount = #{userReceivedAccount},</if>
            <if test="successTime != null">successTime = #{successTime},</if>
            <if test="refundTime != null">refundTime = #{refundTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="fundsAccount != null">fundsAccount = #{fundsAccount},</if>
            <if test="payerTotal != null">payerTotal = #{payerTotal},</if>
            <if test="payerRefund != null">payerRefund = #{payerRefund},</if>
            <if test="settlementRefund != null">settlementRefund = #{settlementRefund},</if>
            <if test="settlementTotal != null">settlementTotal = #{settlementTotal},</if>
            <if test="discountRefund != null">discountRefund = #{discountRefund},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRefundInfoById" parameterType="Long">
        delete from t_refund_info where id = #{id}
    </delete>

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

    <update id="logicDeleteRefundInfoById" parameterType="Long">
        update t_refund_info
            set delFlag = '1'
        where id = #{id}
    </update>

    <update id="logicDeleteRefundInfoByIds" parameterType="String">
        update t_refund_info
        set delFlag = '1'
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <update id="logicDeleteRefundInfoByCondition" parameterType="RefundInfo">
        update t_refund_info
        set delFlag = '1'
        <where>
            <if test="delFlag != null  and delFlag != ''"> and delFlag = #{delFlag}</if>
            <if test="createUser != null  and createUser != ''"> and createUser = #{createUser}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="updateUser != null  and updateUser != ''"> and updateUser = #{updateUser}</if>
            <if test="updateTime != null "> and updateTime = #{updateTime}</if>
            <if test="transactionId != null  and transactionId != ''"> and transactionId = #{transactionId}</if>
            <if test="outTradeNo != null  and outTradeNo != ''"> and outTradeNo = #{outTradeNo}</if>
            <if test="outRefundNo != null  and outRefundNo != ''"> and outRefundNo = #{outRefundNo}</if>
            <if test="reason != null  and reason != ''"> and reason = #{reason}</if>
            <if test="notifyUrl != null  and notifyUrl != ''"> and notifyUrl = #{notifyUrl}</if>
            <if test="amountRefund != null "> and amountRefund = #{amountRefund}</if>
            <if test="amountTotal != null "> and amountTotal = #{amountTotal}</if>
            <if test="refundId != null  and refundId != ''"> and refundId = #{refundId}</if>
            <if test="channel != null  and channel != ''"> and channel = #{channel}</if>
            <if test="userReceivedAccount != null  and userReceivedAccount != ''"> and userReceivedAccount = #{userReceivedAccount}</if>
            <if test="successTime != null "> and successTime = #{successTime}</if>
            <if test="refundTime != null  and refundTime != ''"> and refundTime = #{refundTime}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="fundsAccount != null  and fundsAccount != ''"> and fundsAccount = #{fundsAccount}</if>
            <if test="payerTotal != null "> and payerTotal = #{payerTotal}</if>
            <if test="payerRefund != null "> and payerRefund = #{payerRefund}</if>
            <if test="settlementRefund != null "> and settlementRefund = #{settlementRefund}</if>
            <if test="settlementTotal != null "> and settlementTotal = #{settlementTotal}</if>
            <if test="discountRefund != null "> and discountRefund = #{discountRefund}</if>
        </where>
    </update>

</mapper>