<?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.PlatformFinanceMapper">
    
    <resultMap type="PlatformFinance" id="PlatformFinanceResult">
        <result property="platformFinanceId"    column="platform_finance_id"    />
        <result property="changeMoney"    column="change_money"    />
        <result property="changeType"    column="change_type"    />
        <result property="moneyType"    column="money_type"    />
        <result property="sourceType"    column="source_type"    />
        <result property="secondOrderId"    column="second_order_id"    />
        <result property="volunteerId"    column="volunteer_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectPlatformFinanceVo">
        select platform_finance_id, change_money, change_type, money_type, source_type, second_order_id, volunteer_id, create_by, create_time, update_by, update_time, remark from l_platform_finance
    </sql>

    <select id="selectPlatformFinanceList" parameterType="PlatformFinance" resultMap="PlatformFinanceResult">
        <include refid="selectPlatformFinanceVo"/>
        <where>  
            <if test="changeMoney != null "> and change_money = #{changeMoney}</if>
            <if test="changeType != null "> and change_type = #{changeType}</if>
            <if test="moneyType != null "> and money_type = #{moneyType}</if>
            <if test="sourceType != null "> and source_type = #{sourceType}</if>
            <if test="secondOrderId != null "> and second_order_id = #{secondOrderId}</if>
            <if test="volunteerId != null "> and volunteer_id = #{volunteerId}</if>
        </where>
    </select>
    
    <select id="selectPlatformFinanceByPlatformFinanceId" parameterType="Long" resultMap="PlatformFinanceResult">
        <include refid="selectPlatformFinanceVo"/>
        where platform_finance_id = #{platformFinanceId}
    </select>

    <insert id="insertPlatformFinance" parameterType="PlatformFinance" useGeneratedKeys="true" keyProperty="platformFinanceId">
        insert into l_platform_finance
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="changeMoney != null">change_money,</if>
            <if test="changeType != null">change_type,</if>
            <if test="moneyType != null">money_type,</if>
            <if test="sourceType != null">source_type,</if>
            <if test="secondOrderId != null">second_order_id,</if>
            <if test="volunteerId != null">volunteer_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</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="changeMoney != null">#{changeMoney},</if>
            <if test="changeType != null">#{changeType},</if>
            <if test="moneyType != null">#{moneyType},</if>
            <if test="sourceType != null">#{sourceType},</if>
            <if test="secondOrderId != null">#{secondOrderId},</if>
            <if test="volunteerId != null">#{volunteerId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updatePlatformFinance" parameterType="PlatformFinance">
        update l_platform_finance
        <trim prefix="SET" suffixOverrides=",">
            <if test="changeMoney != null">change_money = #{changeMoney},</if>
            <if test="changeType != null">change_type = #{changeType},</if>
            <if test="moneyType != null">money_type = #{moneyType},</if>
            <if test="sourceType != null">source_type = #{sourceType},</if>
            <if test="secondOrderId != null">second_order_id = #{secondOrderId},</if>
            <if test="volunteerId != null">volunteer_id = #{volunteerId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</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 platform_finance_id = #{platformFinanceId}
    </update>

    <delete id="deletePlatformFinanceByPlatformFinanceId" parameterType="Long">
        delete from l_platform_finance where platform_finance_id = #{platformFinanceId}
    </delete>

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