<?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.jsowell.pile.mapper.AdapayRefundRecordMapper">

    <resultMap type="com.jsowell.pile.domain.AdapayRefundRecord" id="AdapayRefundRecordResult">
        <result property="id"    column="id"    />
        <result property="memberId"    column="member_id"    />
        <result property="orderCode"    column="order_code"    />
        <result property="status"    column="status"    />
        <result property="refundId"    column="refund_id"    />
        <result property="refundOrderNo"    column="refund_order_no"    />
        <result property="paymentId"    column="payment_id"    />
        <result property="paymentOrderNo"    column="payment_order_no"    />
        <result property="refundAmt"    column="refund_amt"    />
        <result property="feeAmt"    column="fee_amt"    />
        <result property="channelNo"    column="channel_no"    />
        <result property="createdTime"    column="created_time"    />
        <result property="succeedTime"    column="succeed_time"    />
        <result property="appId"    column="app_id"    />
        <result property="reason"    column="reason"    />
        <result property="prodMode"    column="prod_mode"    />
        <result property="object"    column="object"    />
        <result property="createTime"    column="create_time"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectAdapayRefundRecordVo">
        select id, member_id, order_code, status, refund_id, refund_order_no, payment_id, payment_order_no, refund_amt, fee_amt, channel_no, created_time, succeed_time, app_id, reason, prod_mode, object, create_time, del_flag from adapay_refund_record
    </sql>

    <select id="selectAdapayRefundRecordList" parameterType="com.jsowell.pile.domain.AdapayRefundRecord" resultMap="AdapayRefundRecordResult">
        <include refid="selectAdapayRefundRecordVo"/>
        <where>
            <if test="memberId != null  and memberId != ''"> and member_id = #{memberId}</if>
            <if test="orderCode != null  and orderCode != ''"> and order_code = #{orderCode}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="refundId != null  and refundId != ''"> and refund_id = #{refundId}</if>
            <if test="refundOrderNo != null  and refundOrderNo != ''"> and refund_order_no = #{refundOrderNo}</if>
            <if test="paymentId != null  and paymentId != ''"> and payment_id = #{paymentId}</if>
            <if test="paymentOrderNo != null  and paymentOrderNo != ''"> and payment_order_no = #{paymentOrderNo}</if>
            <if test="refundAmt != null "> and refund_amt = #{refundAmt}</if>
            <if test="feeAmt != null "> and fee_amt = #{feeAmt}</if>
            <if test="channelNo != null  and channelNo != ''"> and channel_no = #{channelNo}</if>
            <if test="createdTime != null  and createdTime != ''"> and created_time = #{createdTime}</if>
            <if test="succeedTime != null  and succeedTime != ''"> and succeed_time = #{succeedTime}</if>
            <if test="appId != null  and appId != ''"> and app_id = #{appId}</if>
            <if test="reason != null  and reason != ''"> and reason = #{reason}</if>
            <if test="prodMode != null  and prodMode != ''"> and prod_mode = #{prodMode}</if>
            <if test="object != null  and object != ''"> and object = #{object}</if>
        </where>
    </select>

    <select id="selectAdapayRefundRecordById" parameterType="Integer" resultMap="AdapayRefundRecordResult">
        <include refid="selectAdapayRefundRecordVo"/>
        where id = #{id}
    </select>

    <insert id="insertAdapayRefundRecord" parameterType="com.jsowell.pile.domain.AdapayRefundRecord" useGeneratedKeys="true" keyProperty="id">
        insert into adapay_refund_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="memberId != null">member_id,</if>
            <if test="orderCode != null">order_code,</if>
            <if test="status != null">status,</if>
            <if test="refundId != null">refund_id,</if>
            <if test="refundOrderNo != null">refund_order_no,</if>
            <if test="paymentId != null">payment_id,</if>
            <if test="paymentOrderNo != null">payment_order_no,</if>
            <if test="refundAmt != null">refund_amt,</if>
            <if test="feeAmt != null">fee_amt,</if>
            <if test="channelNo != null">channel_no,</if>
            <if test="createdTime != null">created_time,</if>
            <if test="succeedTime != null">succeed_time,</if>
            <if test="appId != null">app_id,</if>
            <if test="reason != null">reason,</if>
            <if test="prodMode != null">prod_mode,</if>
            <if test="object != null">object,</if>
            <if test="createTime != null">create_time,</if>
            <if test="delFlag != null">del_flag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="memberId != null">#{memberId},</if>
            <if test="orderCode != null">#{orderCode},</if>
            <if test="status != null">#{status},</if>
            <if test="refundId != null">#{refundId},</if>
            <if test="refundOrderNo != null">#{refundOrderNo},</if>
            <if test="paymentId != null">#{paymentId},</if>
            <if test="paymentOrderNo != null">#{paymentOrderNo},</if>
            <if test="refundAmt != null">#{refundAmt},</if>
            <if test="feeAmt != null">#{feeAmt},</if>
            <if test="channelNo != null">#{channelNo},</if>
            <if test="createdTime != null">#{createdTime},</if>
            <if test="succeedTime != null">#{succeedTime},</if>
            <if test="appId != null">#{appId},</if>
            <if test="reason != null">#{reason},</if>
            <if test="prodMode != null">#{prodMode},</if>
            <if test="object != null">#{object},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
        </trim>
    </insert>

    <update id="updateAdapayRefundRecord" parameterType="com.jsowell.pile.domain.AdapayRefundRecord">
        update adapay_refund_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="memberId != null">member_id = #{memberId},</if>
            <if test="orderCode != null">order_code = #{orderCode},</if>
            <if test="status != null">status = #{status},</if>
            <if test="refundId != null">refund_id = #{refundId},</if>
            <if test="refundOrderNo != null">refund_order_no = #{refundOrderNo},</if>
            <if test="paymentId != null">payment_id = #{paymentId},</if>
            <if test="paymentOrderNo != null">payment_order_no = #{paymentOrderNo},</if>
            <if test="refundAmt != null">refund_amt = #{refundAmt},</if>
            <if test="feeAmt != null">fee_amt = #{feeAmt},</if>
            <if test="channelNo != null">channel_no = #{channelNo},</if>
            <if test="createdTime != null">created_time = #{createdTime},</if>
            <if test="succeedTime != null">succeed_time = #{succeedTime},</if>
            <if test="appId != null">app_id = #{appId},</if>
            <if test="reason != null">reason = #{reason},</if>
            <if test="prodMode != null">prod_mode = #{prodMode},</if>
            <if test="object != null">object = #{object},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAdapayRefundRecordById" parameterType="Integer">
        delete from adapay_refund_record where id = #{id}
    </delete>

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