<?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.crm.ucard.dao.mapper.CardGlobalAvailableBankCitiesMapper">

    <insert id="batchSave" parameterType="com.crm.rely.backend.core.pojo.table.ucard.CardGlobalAvailableBankCitiesTable">
        insert into ucard_global_available_bank_cities(
        `payout_currency`,
        `parent_code_id`,
        `bank_cities_key`,
        `bank_cities_value`,
        `add_time`
        )
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (
             #{item.payoutCurrency},
             #{item.parentCodeId},
             #{item.bankCitiesKey},
             #{item.bankCitiesValue},
             now()
             )
        </foreach>
    </insert>
    <delete id="deleteAll">
        delete from ucard_global_available_bank_cities
    </delete>
    <select id="queryAllByCountryAndPayoutCurrency"
            resultType="com.crm.rely.backend.core.dto.ucard.CardBankCitiesDto">
        select
        bc.payout_currency,
        bc.parent_code_id,
        bc.bank_cities_key,
        bc.bank_cities_value
        from ucard_global_available_bank_cities bc
                 left join ucard_global_states s on bc.parent_code_id = s.code
        where s.country_standard_code = #{country}
        and bc.payout_currency = #{payoutCurrency}
    </select>

</mapper> 