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

    <select id="countList" resultType="integer"
            parameterType="com.crm.rely.backend.core.entity.ucard.crypto.currency.vaultody.VaultodyDepositAddressPageEntity">
        SELECT COUNT(*)
        FROM
        ucard_wallet_address a
        LEFT JOIN ucard_merchant_user b ON a.unique_id = b.unique_id
        <where>
            <if test="isReset != null">
                and a.`is_reset` = #{isReset}
            </if>
            <if test="email != null and email != ''">
                and b.`email` like concat(#{email},'%')
            </if>
            <if test="mobile != null and mobile != ''">
                and b.`mobile` like concat(#{mobile},'%')
            </if>
            <if test="cId != null and cId > 0">
                and b.`c_id` = #{cId}
            </if>
        </where>
    </select>

    <select id="pageList" resultType="com.crm.rely.backend.core.dto.ucard.vaultody.VaultodyDepositAddressDto"
            parameterType="com.crm.rely.backend.core.entity.ucard.crypto.currency.vaultody.VaultodyDepositAddressPageEntity">
        SELECT
        a.`id`,
        a.`unique_id`,
        a.`address`,
        a.`blockchain`,
        a.`is_reset`,
        b.c_id,
        b.area_code,
        b.mobile,
        b.email,
        b.`last_name`,
        b.first_name,
        b.`country`
        FROM
        ucard_wallet_address a
        LEFT JOIN ucard_merchant_user b ON a.unique_id = b.unique_id
        <where>
        <if test="isReset != null">
            and a.`is_reset` = #{isReset}
        </if>
        <if test="email != null and email != ''">
            and b.`email` like concat(#{email},'%')
        </if>
        <if test="mobile != null and mobile != ''">
            and b.`mobile` like concat(#{mobile},'%')
        </if>
        <if test="cId != null and cId > 0">
            and b.`c_id` = #{cId}
        </if>
        </where>
        ORDER BY a.id DESC
        <if test="page != null">
            limit #{page.offset},#{page.row}
        </if>
    </select>

</mapper>