<?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.OrderFrozenFundsMapper">
    
    <resultMap type="OrderFrozenFunds" id="OrderFrozenFundsResult">
        <result property="orderFrozenFundsId"    column="order_frozen_funds_id"    />
        <result property="volunteerMoney"    column="volunteer_money"    />
        <result property="platformBrokerage"    column="platform_brokerage"    />
        <result property="scoreMoney"    column="score_money"    />
        <result property="secondOrderMoney"    column="second_order_money"    />
        <result property="status"    column="status"    />
        <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="selectOrderFrozenFundsVo">
        select order_frozen_funds_id, volunteer_money, platform_brokerage, score_money, second_order_money, status, second_order_id, volunteer_id, create_by, create_time, update_by, update_time, remark from l_order_frozen_funds
    </sql>

    <select id="selectOrderFrozenFundsList" parameterType="OrderFrozenFunds" resultMap="OrderFrozenFundsResult">
        <include refid="selectOrderFrozenFundsVo"/>
        <where>  
            <if test="volunteerMoney != null "> and volunteer_money = #{volunteerMoney}</if>
            <if test="platformBrokerage != null "> and platform_brokerage = #{platformBrokerage}</if>
            <if test="scoreMoney != null "> and score_money = #{scoreMoney}</if>
            <if test="secondOrderMoney != null "> and second_order_money = #{secondOrderMoney}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="secondOrderId != null "> and second_order_id = #{secondOrderId}</if>
            <if test="volunteerId != null "> and volunteer_id = #{volunteerId}</if>
        </where>
    </select>
    
    <select id="selectOrderFrozenFundsByOrderFrozenFundsId" parameterType="Long" resultMap="OrderFrozenFundsResult">
        <include refid="selectOrderFrozenFundsVo"/>
        where order_frozen_funds_id = #{orderFrozenFundsId}
    </select>

    <insert id="insertOrderFrozenFunds" parameterType="OrderFrozenFunds" useGeneratedKeys="true" keyProperty="orderFrozenFundsId">
        insert into l_order_frozen_funds
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="volunteerMoney != null">volunteer_money,</if>
            <if test="platformBrokerage != null">platform_brokerage,</if>
            <if test="scoreMoney != null">score_money,</if>
            <if test="secondOrderMoney != null">second_order_money,</if>
            <if test="status != null">status,</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="volunteerMoney != null">#{volunteerMoney},</if>
            <if test="platformBrokerage != null">#{platformBrokerage},</if>
            <if test="scoreMoney != null">#{scoreMoney},</if>
            <if test="secondOrderMoney != null">#{secondOrderMoney},</if>
            <if test="status != null">#{status},</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="updateOrderFrozenFunds" parameterType="OrderFrozenFunds">
        update l_order_frozen_funds
        <trim prefix="SET" suffixOverrides=",">
            <if test="volunteerMoney != null">volunteer_money = #{volunteerMoney},</if>
            <if test="platformBrokerage != null">platform_brokerage = #{platformBrokerage},</if>
            <if test="scoreMoney != null">score_money = #{scoreMoney},</if>
            <if test="secondOrderMoney != null">second_order_money = #{secondOrderMoney},</if>
            <if test="status != null">status = #{status},</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 order_frozen_funds_id = #{orderFrozenFundsId}
    </update>

    <delete id="deleteOrderFrozenFundsByOrderFrozenFundsId" parameterType="Long">
        delete from l_order_frozen_funds where order_frozen_funds_id = #{orderFrozenFundsId}
    </delete>

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