<?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.iformall.mapper.WxPayAccountBillMapper">
    <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxPayAccountBill">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="mch_id" jdbcType="VARCHAR" property="mchId"/>
        <result column="sub_mch_id" jdbcType="VARCHAR" property="subMchId"/>
        <result column="api_key" jdbcType="VARCHAR" property="apiKey"/>
        <result column="notify_url" jdbcType="VARCHAR" property="notifyUrl"/>
        <result column="cert_path" jdbcType="VARCHAR" property="certPath"/>
        <result column="type" jdbcType="INTEGER" property="type"/>
        <result column="share" jdbcType="INTEGER" property="share"/>
        <result column="rate" jdbcType="INTEGER" property="rate"/>
        <result column="real_rate" jdbcType="INTEGER" property="realRate"/>
        <result column="bank_account_name" jdbcType="VARCHAR" property="bankAccountName"/>
        <result column="bank_card_id" jdbcType="VARCHAR" property="bankCardId"/>
    </resultMap>

    <sql id="allColumns">
	    `id`,`mch_id`,`sub_mch_id`,`api_key`,`notify_url`,`cert_path`,`type`,`share`,`rate`,`real_rate`
	</sql>

    <sql id="dynamicWhereConditions">
        where 1 = 1

        <if test=" null != id ">
            and `id` = #{id}
        </if>

        <if test=" null != mchId ">
            and `mch_id` = #{mchId}
        </if>

        <if test=" null != subMchId ">
            and `sub_mch_id` = #{subMchId}
        </if>

        <if test=" null != apiKey ">
            and `api_key` like concat('%', #{apiKey},'%')
        </if>

        <if test=" null != notifyUrl ">
            and `notify_url` like concat('%', #{notifyUrl},'%')
        </if>

        <if test=" null != certPath ">
            and `cert_path` like concat('%', #{certPath},'%')
        </if>
        <if test=" null != type ">
            and `type` = #{type}
        </if>
        <if test=" null != share ">
            and `share` = #{share}
        </if>
        <if test=" null != rate ">
            and `rate` = #{rate}
        </if>
        <if test=" null != realRate ">
            and `real_rate` = #{realRate}
        </if>
        <if test=" null != ids ">
            and id in
            <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
                #{idItem}
            </foreach>
        </if>
        <if test=" null != sortColumns">order by ${sortColumns}</if>
    </sql>

    <select id="findList" parameterType="com.iformall.domain.po.WxPayAccount" resultMap="BaseResultMap">
        select
        <include refid="allColumns"/>
        from wx_pay_account
        <include refid="dynamicWhereConditions"/>
    </select>


</mapper>
