<?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.leromro.core.mapper.VolunteerPaymentRecordsMapper">
    
    <resultMap type="VolunteerPaymentRecords" id="VolunteerPaymentRecordsResult">
        <result property="volunteerPaymentRecordsId"    column="volunteer_payment_records_id"    />
        <result property="paymentOrderNumber"    column="payment_order_number"    />
        <result property="isVerified"    column="is_verified"    />
        <result property="paymentStatus"    column="payment_status"    />
        <result property="paymentTime"    column="payment_time"    />
        <result property="failedPaymentAttempts"    column="failed_payment_attempts"    />
        <result property="failedPaymentReason"    column="failed_payment_reason"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="deleted"    column="deleted"    />
        <result property="totalPaymentAmount"    column="total_payment_amount"    />
        <result property="actualPaymentAmount"    column="actual_payment_amount"    />
        <result property="successfulPaymentAmount"    column="successful_payment_amount"    />
        <result property="failedPaymentAmount"    column="failed_payment_amount"    />
        <result property="jsonContent"    column="json_content"    />
        <result property="updateBy"    column="update_by"    />
        <result property="payType"    column="pay_type"    />
        <result property="createBy"    column="create_by"    />
    </resultMap>

    <sql id="selectVolunteerPaymentRecordsVo">
        select * from l_volunteer_payment_records
    </sql>

    <select id="selectVolunteerPaymentRecordsList" parameterType="VolunteerPaymentRecords" resultMap="VolunteerPaymentRecordsResult">
        <include refid="selectVolunteerPaymentRecordsVo"/>
        <where>  
            <if test="paymentOrderNumber != null  and paymentOrderNumber != ''"> and payment_order_number = #{paymentOrderNumber}</if>
            <if test="isVerified != null  and isVerified != ''"> and is_verified = #{isVerified}</if>
            <if test="paymentStatus != null  and paymentStatus != ''"> and payment_status = #{paymentStatus}</if>
            <if test="paymentTime != null "> and payment_time = #{paymentTime}</if>
            <if test="failedPaymentAttempts != null "> and failed_payment_attempts = #{failedPaymentAttempts}</if>
            <if test="failedPaymentReason != null  and failedPaymentReason != ''"> and failed_payment_reason = #{failedPaymentReason}</if>
            <if test="deleted != null  and deleted != ''"> and deleted = #{deleted}</if>
            <if test="totalPaymentAmount != null "> and total_payment_amount = #{totalPaymentAmount}</if>
            <if test="actualPaymentAmount != null "> and actual_payment_amount = #{actualPaymentAmount}</if>
            <if test="successfulPaymentAmount != null "> and successful_payment_amount = #{successfulPaymentAmount}</if>
            <if test="failedPaymentAmount != null "> and failed_payment_amount = #{failedPaymentAmount}</if>
            <if test="jsonContent != null  and jsonContent != ''"> and json_content = #{jsonContent}</if>
            <if test="payType != null  and payType != ''"> and pay_type = #{payType}</if>
        </where>
    </select>
    
    <select id="selectVolunteerPaymentRecordsByVolunteerPaymentRecordsId" parameterType="Long" resultMap="VolunteerPaymentRecordsResult">
        <include refid="selectVolunteerPaymentRecordsVo"/>
        where volunteer_payment_records_id = #{volunteerPaymentRecordsId}
    </select>

    <insert id="insertVolunteerPaymentRecords" parameterType="VolunteerPaymentRecords">
        insert into l_volunteer_payment_records
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="volunteerPaymentRecordsId != null">volunteer_payment_records_id,</if>
            <if test="paymentOrderNumber != null and paymentOrderNumber != ''">payment_order_number,</if>
            <if test="isVerified != null and isVerified != ''">is_verified,</if>
            <if test="paymentStatus != null and paymentStatus != ''">payment_status,</if>
            <if test="paymentTime != null">payment_time,</if>
            <if test="failedPaymentAttempts != null">failed_payment_attempts,</if>
            <if test="failedPaymentReason != null">failed_payment_reason,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="deleted != null and deleted != ''">deleted,</if>
            <if test="totalPaymentAmount != null">total_payment_amount,</if>
            <if test="actualPaymentAmount != null">actual_payment_amount,</if>
            <if test="successfulPaymentAmount != null">successful_payment_amount,</if>
            <if test="failedPaymentAmount != null">failed_payment_amount,</if>
            <if test="jsonContent != null">json_content,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="payType != null">pay_type,</if>
            <if test="createBy != null">create_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="volunteerPaymentRecordsId != null">#{volunteerPaymentRecordsId},</if>
            <if test="paymentOrderNumber != null and paymentOrderNumber != ''">#{paymentOrderNumber},</if>
            <if test="isVerified != null and isVerified != ''">#{isVerified},</if>
            <if test="paymentStatus != null and paymentStatus != ''">#{paymentStatus},</if>
            <if test="paymentTime != null">#{paymentTime},</if>
            <if test="failedPaymentAttempts != null">#{failedPaymentAttempts},</if>
            <if test="failedPaymentReason != null">#{failedPaymentReason},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="deleted != null and deleted != ''">#{deleted},</if>
            <if test="totalPaymentAmount != null">#{totalPaymentAmount},</if>
            <if test="actualPaymentAmount != null">#{actualPaymentAmount},</if>
            <if test="successfulPaymentAmount != null">#{successfulPaymentAmount},</if>
            <if test="failedPaymentAmount != null">#{failedPaymentAmount},</if>
            <if test="jsonContent != null">#{jsonContent},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="payType != null">#{payType},</if>
            <if test="createBy != null">#{createBy},</if>
         </trim>
    </insert>

    <update id="updateVolunteerPaymentRecords" parameterType="VolunteerPaymentRecords">
        update l_volunteer_payment_records
        <trim prefix="SET" suffixOverrides=",">
            <if test="paymentOrderNumber != null and paymentOrderNumber != ''">payment_order_number = #{paymentOrderNumber},</if>
            <if test="isVerified != null and isVerified != ''">is_verified = #{isVerified},</if>
            <if test="paymentStatus != null and paymentStatus != ''">payment_status = #{paymentStatus},</if>
            <if test="paymentTime != null">payment_time = #{paymentTime},</if>
            <if test="failedPaymentAttempts != null">failed_payment_attempts = #{failedPaymentAttempts},</if>
            <if test="failedPaymentReason != null">failed_payment_reason = #{failedPaymentReason},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="deleted != null and deleted != ''">deleted = #{deleted},</if>
            <if test="totalPaymentAmount != null">total_payment_amount = #{totalPaymentAmount},</if>
            <if test="actualPaymentAmount != null">actual_payment_amount = #{actualPaymentAmount},</if>
            <if test="successfulPaymentAmount != null">successful_payment_amount = #{successfulPaymentAmount},</if>
            <if test="failedPaymentAmount != null">failed_payment_amount = #{failedPaymentAmount},</if>
            <if test="jsonContent != null">json_content = #{jsonContent},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="payType != null">pay_type = #{payType},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
        </trim>
        where volunteer_payment_records_id = #{volunteerPaymentRecordsId}
    </update>

    <delete id="deleteVolunteerPaymentRecordsByVolunteerPaymentRecordsId" parameterType="Long">
        delete from l_volunteer_payment_records where volunteer_payment_records_id = #{volunteerPaymentRecordsId}
    </delete>

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