<?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.MerchantSettleInfoMapper">

    <resultMap type="MerchantSettleInfo" id="MerchantSettleInfoResult">
        <result property="merchantId"    column="merchant_id"    />
        <result property="email"    column="email"    />
        <result property="merchantNo"    column="merchant_no"    />
        <result property="delFlag"    column="del_flag"    />
        <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="selectMerchantSettleInfoVo">
        select merchant_id, email, merchant_no, del_flag, create_by, create_time, update_by, update_time, column1, column2, column3 from merchant_settle_info
    </sql>

    <select id="selectMerchantSettleInfoList" parameterType="MerchantSettleInfo" resultMap="MerchantSettleInfoResult">
        <include refid="selectMerchantSettleInfoVo"/>
        <where>
            <if test="email != null  and email != ''"> and email = #{email}</if>
            <if test="merchantNo != null  and merchantNo != ''"> and merchant_no = #{merchantNo}</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="selectMerchantSettleInfoByMerchantId" parameterType="Long" resultMap="MerchantSettleInfoResult">
        <include refid="selectMerchantSettleInfoVo"/>
        where merchant_id = #{merchantId}
        and del_flag = 0
    </select>

    <insert id="insertMerchantSettleInfo" parameterType="MerchantSettleInfo">
        insert into merchant_settle_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="merchantId != null">merchant_id,</if>
            <if test="email != null and email != ''">email,</if>
            <if test="merchantNo != null">merchant_no,</if>
            <if test="delFlag != null">del_flag,</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="email != null and email != ''">#{email},</if>
            <if test="merchantNo != null">#{merchantNo},</if>
            <if test="delFlag != null">#{delFlag},</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="updateMerchantSettleInfo" parameterType="MerchantSettleInfo">
        update merchant_settle_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="email != null and email != ''">email = #{email},</if>
            <if test="merchantNo != null">merchant_no = #{merchantNo},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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 merchant_id = #{merchantId}
    </update>

    <delete id="deleteMerchantSettleInfoByMerchantId" parameterType="String">
        delete from merchant_settle_info where merchant_id = #{merchantId}
    </delete>

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