<?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.OrderRechargeRefundMapper">

    <resultMap type="OrderRechargeRefund" id="OrderRechargeRefundResult">
        <result property="id" column="id"/>
        <result property="orderNo" column="order_no"/>
        <result property="refundNo" column="refund_no"/>
        <result property="cardNo" column="card_no"/>
        <result property="rechargeStoreId" column="recharge_store_id"/>
        <result property="useBindStoreId" column="use_bind_store_id"/>
        <result property="rechargeUserId" column="recharge_user_id"/>
        <result property="payAmount" column="pay_amount"/>
        <result property="rechargeAmount" column="recharge_amount"/>
        <result property="giveAmount" column="give_amount"/>
        <result property="rechargeBalance" column="recharge_balance"/>
        <result property="giveBalance" column="give_balance"/>
        <result property="refundAmount" column="refund_amount"/>
        <result property="refundApplyTime" column="refund_apply_time"/>
        <result property="refundReason" column="refund_reason"/>
        <result property="refundStatus" column="refund_status"/>
        <result property="rejectReason" column="reject_reason"/>
        <result property="refundTime" column="refund_time"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createById" column="create_by_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateById" column="update_by_id"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectOrderRechargeRefundVo">
        select * from order_recharge_refund
    </sql>

    <select id="selectOrderRechargeRefundList" resultType="com.yiqi.order.domain.OrderRechargeRefund" >
        <include refid="selectOrderRechargeRefundVo"/>
        <where>
            and del_flag='0'
            <if test="orderNo != null  and orderNo != ''">
                and order_no = #{orderNo}
            </if>
            <if test="refundNo != null  and refundNo != ''">
                and refund_no = #{refundNo}
            </if>
            <if test="cardNo != null  and cardNo != ''">
                and card_no = #{cardNo}
            </if>
            <if test="rechargeStoreId != null ">
                and recharge_store_id = #{rechargeStoreId}
            </if>
            <if test="useBindStoreId != null ">
                and use_bind_store_id = #{useBindStoreId}
            </if>
            <if test="rechargeUserId != null ">
                and recharge_user_id = #{rechargeUserId}
            </if>
            <if test="payAmount != null ">
                and pay_amount = #{payAmount}
            </if>
            <if test="rechargeAmount != null ">
                and recharge_amount = #{rechargeAmount}
            </if>
            <if test="giveAmount != null ">
                and give_amount = #{giveAmount}
            </if>
            <if test="rechargeBalance != null ">
                and recharge_balance = #{rechargeBalance}
            </if>
            <if test="giveBalance != null ">
                and give_balance = #{giveBalance}
            </if>
            <if test="refundAmount != null ">
                and refund_amount = #{refundAmount}
            </if>
            <if test="refundApplyTime != null ">
                and refund_apply_time = #{refundApplyTime}
            </if>
            <if test="refundReason != null  and refundReason != ''">
                and refund_reason = #{refundReason}
            </if>
            <if test="refundStatus != null  and refundStatus != ''">
                and refund_status = #{refundStatus}
            </if>
            <if test="rejectReason != null  and rejectReason != ''">
                and reject_reason = #{rejectReason}
            </if>
            <if test="refundTime != null ">
                and refund_time = #{refundTime}
            </if>
        </where>
    </select>

    <select id="selectOrderRechargeRefundById" parameterType="Long"
            resultType="com.yiqi.order.domain.OrderRechargeRefund">
        <include refid="selectOrderRechargeRefundVo"/>
        where id = #{id}
        and del_flag='0'
    </select>

    <insert id="insertOrderRechargeRefund" parameterType="OrderRechargeRefund" useGeneratedKeys="true"
            keyProperty="id">
        insert into order_recharge_refund
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderNo != null">order_no,
            </if>
            <if test="refundNo != null">refund_no,
            </if>
            <if test="cardNo != null">card_no,
            </if>
            <if test="rechargeStoreId != null">recharge_store_id,
            </if>
            <if test="useBindStoreId != null">use_bind_store_id,
            </if>
            <if test="rechargeUserId != null">recharge_user_id,
            </if>
            <if test="payAmount != null">pay_amount,
            </if>
            <if test="rechargeAmount != null">recharge_amount,
            </if>
            <if test="giveAmount != null">give_amount,
            </if>
            <if test="rechargeBalance != null">recharge_balance,
            </if>
            <if test="giveBalance != null">give_balance,
            </if>
            <if test="refundAmount != null">refund_amount,
            </if>
            <if test="refundApplyTime != null">refund_apply_time,
            </if>
            <if test="refundReason != null">refund_reason,
            </if>
            <if test="refundStatus != null">refund_status,
            </if>
            <if test="rejectReason != null">reject_reason,
            </if>
            <if test="refundTime != null">refund_time,
            </if>
            <if test="delFlag != null">del_flag,
            </if>
            <if test="createById != null">create_by_id,
            </if>
            <if test="createBy != null">create_by,
            </if>
            <if test="createTime != null">create_time,
            </if>
            <if test="updateById != null">update_by_id,
            </if>
            <if test="updateBy != null">update_by,
            </if>
            <if test="updateTime != null">update_time,
            </if>
            <if test="remark != null">remark,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderNo != null">#{orderNo},
            </if>
            <if test="refundNo != null">#{refundNo},
            </if>
            <if test="cardNo != null">#{cardNo},
            </if>
            <if test="rechargeStoreId != null">#{rechargeStoreId},
            </if>
            <if test="useBindStoreId != null">#{useBindStoreId},
            </if>
            <if test="rechargeUserId != null">#{rechargeUserId},
            </if>
            <if test="payAmount != null">#{payAmount},
            </if>
            <if test="rechargeAmount != null">#{rechargeAmount},
            </if>
            <if test="giveAmount != null">#{giveAmount},
            </if>
            <if test="rechargeBalance != null">#{rechargeBalance},
            </if>
            <if test="giveBalance != null">#{giveBalance},
            </if>
            <if test="refundAmount != null">#{refundAmount},
            </if>
            <if test="refundApplyTime != null">#{refundApplyTime},
            </if>
            <if test="refundReason != null">#{refundReason},
            </if>
            <if test="refundStatus != null">#{refundStatus},
            </if>
            <if test="rejectReason != null">#{rejectReason},
            </if>
            <if test="refundTime != null">#{refundTime},
            </if>
            <if test="delFlag != null">#{delFlag},
            </if>
            <if test="createById != null">#{createById},
            </if>
            <if test="createBy != null">#{createBy},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
            <if test="updateById != null">#{updateById},
            </if>
            <if test="updateBy != null">#{updateBy},
            </if>
            <if test="updateTime != null">#{updateTime},
            </if>
            <if test="remark != null">#{remark},
            </if>
        </trim>
    </insert>

    <update id="updateOrderRechargeRefund" parameterType="OrderRechargeRefund">
        update order_recharge_refund
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderNo != null">order_no =
                #{orderNo},
            </if>
            <if test="refundNo != null">refund_no =
                #{refundNo},
            </if>
            <if test="cardNo != null">card_no =
                #{cardNo},
            </if>
            <if test="rechargeStoreId != null">recharge_store_id =
                #{rechargeStoreId},
            </if>
            <if test="useBindStoreId != null">use_bind_store_id =
                #{useBindStoreId},
            </if>
            <if test="rechargeUserId != null">recharge_user_id =
                #{rechargeUserId},
            </if>
            <if test="payAmount != null">pay_amount =
                #{payAmount},
            </if>
            <if test="rechargeAmount != null">recharge_amount =
                #{rechargeAmount},
            </if>
            <if test="giveAmount != null">give_amount =
                #{giveAmount},
            </if>
            <if test="rechargeBalance != null">recharge_balance =
                #{rechargeBalance},
            </if>
            <if test="giveBalance != null">give_balance =
                #{giveBalance},
            </if>
            <if test="refundAmount != null">refund_amount =
                #{refundAmount},
            </if>
            <if test="refundApplyTime != null">refund_apply_time =
                #{refundApplyTime},
            </if>
            <if test="refundReason != null">refund_reason =
                #{refundReason},
            </if>
            <if test="refundStatus != null">refund_status =
                #{refundStatus},
            </if>
            <if test="rejectReason != null">reject_reason =
                #{rejectReason},
            </if>
            <if test="refundTime != null">refund_time =
                #{refundTime},
            </if>
            <if test="delFlag != null">del_flag =
                #{delFlag},
            </if>
            <if test="createById != null">create_by_id =
                #{createById},
            </if>
            <if test="createBy != null">create_by =
                #{createBy},
            </if>
            <if test="createTime != null">create_time =
                #{createTime},
            </if>
            <if test="updateById != null">update_by_id =
                #{updateById},
            </if>
            <if test="updateBy != null">update_by =
                #{updateBy},
            </if>
            <if test="updateTime != null">update_time =
                #{updateTime},
            </if>
            <if test="remark != null">remark =
                #{remark},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderRechargeRefundById" parameterType="Long">
        update order_recharge_refund set del_flag='2' where id = #{id}
    </delete>

    <delete id="deleteOrderRechargeRefundByIds" parameterType="String">
        update order_recharge_refund set del_flag='2' where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>



</mapper>