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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.member.account.CuMemberAuthentication">
        <id column="PK_ID" property="pkId"/>
        <result column="DEL_FLAG" property="delFlag"/>
        <result column="CREATION_TIME" property="creationTime"/>
        <result column="MODIFIED_TIME" property="modifiedTime"/>
        <result column="PK_COUNTRY" property="pkCountry"/>
        <result column="PK_CREATOR" property="pkCreator"/>
        <result column="PK_MODIFIED" property="pkModified"/>
        <result column="PK_MEMBER" property="pkMember"/>
        <result column="ID_CARD" property="idCard"/>
        <result column="SEX" property="sex"/>
        <result column="ID_TYPE" property="idType"/>
        <result column="SUB_BANK_NAME" property="subBankName"/>
        <result column="ACCOUNT_NAME" property="accountName"/>
        <result column="CARD_NUMBER" property="cardNumber"/>
        <result column="PHONE" property="phone"/>
        <result column="PK_BANK" property="pkBank"/>
        <result column="BANK_NAME" property="bankName"/>
        <result column="PK_PROVINCE" property="pkProvince"/>
        <result column="PK_CITY" property="pkCity"/>
        <result column="PK_COUNTY" property="pkCounty"/>
        <result column="ADDRESS" property="address"/>
        <result column="ID_FRONT" property="idFront"/>
        <result column="ID_BACK" property="idBack"/>
    </resultMap>

    <select id="selectAuthenticationByPkMember" resultType="com.hzs.common.domain.member.account.CuMemberAuthenticationExt">
        select a.*,
               p.name           province,
               c.name           city,
               pc.name          county,
               b.background_img backgroundImg,
               b.bank_name      bankName
        from cu_member_authentication a
                 left join bd_area p
                           on p.pk_id = a.pk_province
                               and p.del_flag = 0
                 left join bd_area c
                           on c.pk_id = a.pk_city
                               and c.del_flag = 0
                 left join bd_area pc
                           on pc.pk_id = a.pk_county
                               and pc.del_flag = 0
                 left join bd_bank b
                           on a.pk_bank = b.pk_id
                               and b.del_flag = 0
                               and b.enable_state = 0
        where a.del_flag = 0
          and a.pk_member = #{pkMember}
          and a.pk_country = #{pkCountry}
    </select>

    <update id="deleteByPkMembers">
        update cu_member_authentication a
        set a.del_flag = 1 ,a.modified_time=sysdate ,a.pk_modified= #{updatePkMember}
        where a.del_flag = 0
        and a.pk_member in
        <foreach collection="pkMembers" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
    </update>

</mapper>
