<?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.muchinfo.mtp3interface.mapper.IBankCusbankinfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.muchinfo.mtp3pojos.entity.BankCusbankinfo">
        <id column="CUSBANKID" property="cusbankid" />
        <result column="CUSBANKNAME" property="cusbankname" />
        <result column="CUSBANKSHORTNAME" property="cusbankshortname" />
        <result column="EXCHBANKID" property="exchbankid" />
        <result column="EXCHPAYBANKACCNO" property="exchpaybankaccno" />
        <result column="EXCHPAYBANKACCNAME" property="exchpaybankaccname" />
        <result column="CURRENCY" property="currency" />
        <result column="CANSIGN" property="cansign" />
        <result column="CANRELEASE" property="canrelease" />
        <result column="CANINAMOUNT" property="caninamount" />
        <result column="CANOUTAMOUNT" property="canoutamount" />
        <result column="RISKINFO" property="riskinfo" />
        <result column="CANSIGN2" property="cansign2" />
        <result column="CANRELEASE2" property="canrelease2" />
        <result column="CANINAMOUNT2" property="caninamount2" />
        <result column="CANOUTAMOUNT2" property="canoutamount2" />
        <result column="CANBINDCARD" property="canbindcard" />
        <result column="ISNEEDCLEAR" property="isneedclear" />
        <result column="CANMODIFYPHONE" property="canmodifyphone" />
        <result column="CANMODIFYSIGNINFO" property="canmodifysigninfo" />
        <result column="ISNEEDCHECK" property="isneedcheck" />
        <result column="CANMODIFYBANKCARD" property="canmodifybankcard" />
        <result column="CANALLOT" property="canallot" />
        <result column="CANALLOTQUERY" property="canallotquery" />
        <result column="EXPUTBANKID" property="exputbankid" />
        <result column="EXPUTPAYBANKACCNO" property="exputpaybankaccno" />
        <result column="EXPUTPAYBANKACCNAME" property="exputpaybankaccname" />
        <result column="EXPUTPAYBANKACCSUBNO" property="exputpaybankaccsubno" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        CUSBANKID, CUSBANKNAME, CUSBANKSHORTNAME, EXCHBANKID, EXCHPAYBANKACCNO, EXCHPAYBANKACCNAME, CURRENCY, CANSIGN, CANRELEASE, CANINAMOUNT, CANOUTAMOUNT, RISKINFO, CANSIGN2, CANRELEASE2, CANINAMOUNT2, CANOUTAMOUNT2, CANBINDCARD, ISNEEDCLEAR, CANMODIFYPHONE, CANMODIFYSIGNINFO, ISNEEDCHECK, CANMODIFYBANKCARD, CANALLOT, CANALLOTQUERY, EXPUTBANKID, EXPUTPAYBANKACCNO, EXPUTPAYBANKACCNAME, EXPUTPAYBANKACCSUBNO
    </sql>

    <select id="getBankInfoByCusBank" resultType="com.muchinfo.mtp3pojos.vo.common.CusBankInfoResult"
            parameterType="java.lang.String">
        select t.bankid as bankId,b.bankname as bankName
        from bank_cusbanksignbank t,bank_bankinfo b
        <where>
            t.bankid = b.bankid
            <if test="cusBankId !=null and cusBankId !=''">
                and t.cusbankid = #{cusBankId}
            </if>
            <if test="bankName !=null and bankName !=''">
                and b.bankname like '%'||#{bankName}||'%'
            </if>
        </where>
        and  rownum &lt;=10
        order by t.bankid
    </select>

    <select id="queryFieldById" resultType="com.muchinfo.mtp3pojos.vo.bankcusbank.BankCusBankExtendResult">
            select t.*, b.usabletype,b.fieldname,b.fieldcode from BANK_CUSBANKEXTENDCONFIG t, bank_extendfield b
        <where>
            and t.fieldid = b.fieldid
            <if test="extendbiztype != null ">
                and t.extendbiztype=#{extendbiztype}
            </if>
            <if test="cusbankid != null and cusbankid !='' ">
                and t.cusbankid=#{cusbankid}
            </if>
            <if test="usabletype != null">
                <choose>
                    <when test="usabletype == 1">
                        and b.usabletype in (1,3)
                    </when>
                    <when test="usabletype == 2">
                        and b.usabletype in (1,2)
                    </when>
                </choose>
            </if>
        </where>
    </select>
</mapper>
