<?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.younike.system.mapper.MerchantSettleRecordMapper">
    
    <resultMap type="MerchantSettleRecord" id="MerchantSettleRecordResult">
        <result property="settleId"    column="settle_id"    />
        <result property="merchantId"    column="merchant_id"    />
        <result property="amount"    column="amount"    />
        <result property="retCode"    column="ret_code"    />
        <result property="retMsg"    column="ret_msg"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="loginIp"    column="login_ip"    />
        <result property="loginDate"    column="login_date"    />
        <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="column1"    column="column1"    />
        <result property="column2"    column="column2"    />
        <result property="column3"    column="column3"    />
    </resultMap>

    <sql id="selectMerchantSettleRecordVo">
        select settle_id, merchant_id, amount, ret_code, ret_msg, del_flag, login_ip, login_date, create_by, create_time, update_by, update_time, column1, column2, column3 from merchant_settle_record
    </sql>

    <select id="selectMerchantSettleRecordList" parameterType="MerchantSettleRecord" resultMap="MerchantSettleRecordResult">
        <include refid="selectMerchantSettleRecordVo"/>
        <where>  
            <if test="merchantId != null  and merchantId != ''"> and merchant_id = #{merchantId}</if>
            <if test="amount != null "> and amount = #{amount}</if>
            <if test="retCode != null  and retCode != ''"> and ret_code = #{retCode}</if>
            <if test="retMsg != null  and retMsg != ''"> and ret_msg = #{retMsg}</if>
            <if test="loginIp != null  and loginIp != ''"> and login_ip = #{loginIp}</if>
            <if test="loginDate != null "> and login_date = #{loginDate}</if>
            <if test="column1 != null  and column1 != ''"> and column1 = #{column1}</if>
            <if test="column2 != null  and column2 != ''"> and column2 = #{column2}</if>
            <if test="column3 != null  and column3 != ''"> and column3 = #{column3}</if>
        </where>
    </select>
    
    <select id="selectMerchantSettleRecordBySettleId" parameterType="Long" resultMap="MerchantSettleRecordResult">
        <include refid="selectMerchantSettleRecordVo"/>
        where settle_id = #{settleId}
    </select>
        
    <insert id="insertMerchantSettleRecord" parameterType="MerchantSettleRecord" useGeneratedKeys="true" keyProperty="settleId">
        insert into merchant_settle_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="merchantId != null">merchant_id,</if>
            <if test="amount != null">amount,</if>
            <if test="retCode != null">ret_code,</if>
            <if test="retMsg != null">ret_msg,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="loginIp != null">login_ip,</if>
            <if test="loginDate != null">login_date,</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="column1 != null">column1,</if>
            <if test="column2 != null">column2,</if>
            <if test="column3 != null">column3,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="merchantId != null">#{merchantId},</if>
            <if test="amount != null">#{amount},</if>
            <if test="retCode != null">#{retCode},</if>
            <if test="retMsg != null">#{retMsg},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="loginIp != null">#{loginIp},</if>
            <if test="loginDate != null">#{loginDate},</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="column1 != null">#{column1},</if>
            <if test="column2 != null">#{column2},</if>
            <if test="column3 != null">#{column3},</if>
         </trim>
    </insert>

    <update id="updateMerchantSettleRecord" parameterType="MerchantSettleRecord">
        update merchant_settle_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="merchantId != null">merchant_id = #{merchantId},</if>
            <if test="amount != null">amount = #{amount},</if>
            <if test="retCode != null">ret_code = #{retCode},</if>
            <if test="retMsg != null">ret_msg = #{retMsg},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="loginIp != null">login_ip = #{loginIp},</if>
            <if test="loginDate != null">login_date = #{loginDate},</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="column1 != null">column1 = #{column1},</if>
            <if test="column2 != null">column2 = #{column2},</if>
            <if test="column3 != null">column3 = #{column3},</if>
        </trim>
        where settle_id = #{settleId}
    </update>

    <delete id="deleteMerchantSettleRecordBySettleId" parameterType="Long">
        delete from merchant_settle_record where settle_id = #{settleId}
    </delete>

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