<?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.hzs.member.account.mapper.CuMemberBankMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.member.account.CuMemberBank">
        <id column="PK_ID" property="pkId" />
        <result column="DEL_FLAG" property="delFlag" />
        <result column="PK_CREATOR" property="pkCreator" />
        <result column="CREATION_TIME" property="creationTime" />
        <result column="PK_MODIFIED" property="pkModified" />
        <result column="MODIFIED_TIME" property="modifiedTime" />
        <result column="PK_COUNTRY" property="pkCountry" />
        <result column="PK_MEMBER" property="pkMember"/>
        <result column="BANK_NAME" property="bankName" />
        <result column="SUB_BANK_NAME" property="subBankName" />
        <result column="ACCOUNT_NAME" property="accountName" />
        <result column="CARD_NUMBER" property="cardNumber" />
        <result column="ID_CARD" property="idCard" />
        <result column="PHONE" property="phone" />
        <result column="PK_BANK" property="pkBank" />
        <result column="DEFAULT_CARD" property="defaultCard" />
        <result column="ACCOUNT_PROVINCE" property="accountProvince" />
        <result column="ACCOUNT_CITY" property="accountCity" />
        <result column="VALID_START_DATE" property="validStartDate" />
        <result column="VALID_END_DATE" property="validEndDate" />
        <result column="IS_LONG_TERM" property="isLongTerm" />
    </resultMap>

    <update id="batchUpdateBankBypkMembers">
        update cu_member_bank b
        set b.del_flag = 1, b.modified_time = sysdate, b.pk_modified = #{updatePkMember}
        where b.pk_member in
        <foreach collection="businessMemberList" item="item" open="(" close=")" separator=",">
            #{item.pkMember}
        </foreach>
    </update>

    <select id="selectBankCardByPkMember" resultType="com.hzs.common.domain.member.account.CuMemberBankExt">
          select mb.pk_id         pkId,
               mb.card_number   cardNumber,
               mb.default_card  defaultCard,
               b.pk_transaction pkBank,
               b.background_img backgroundImg,
               b.bank_name bankName,
               b.logo
          from cu_member_bank mb
          left join bd_bank b
            on mb.pk_bank = b.pk_id
           and b.del_flag = 0
           and b.enable_state = 0
         where mb.del_flag = 0
           and mb.pk_country = #{pkCountry}
           and mb.pk_member = #{pkMember}
         order by mb.default_card desc
    </select>


</mapper>
