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

    <select id="countList" resultType="integer"
            parameterType="com.crm.rely.backend.core.entity.ucard.EncryptedWalletTransactionPageEntity">
        SELECT COUNT(*)
        FROM
        ucard_crypto_callback_record a
        LEFT JOIN ucard_merchant_user b ON a.unique_id = b.unique_id
        <where>
            <if test="unit != null and unit != ''">
                and a.`unit` = #{unit}
            </if>
            <if test="address != null and address != ''">
                and a.`address` = #{address}
            </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.EncryptedWalletTransactionDto"
            parameterType="com.crm.rely.backend.core.entity.ucard.EncryptedWalletTransactionPageEntity">
        SELECT
        a.*,
        b.c_id,
        b.area_code,
        b.mobile,
        b.email,
        b.`last_name`,
        b.first_name,
        b.`country`
        FROM
        ucard_crypto_callback_record a
        LEFT JOIN ucard_merchant_user b ON a.unique_id = b.unique_id
        <where>
            <if test="unit != null and unit != ''">
                and a.`unit` = #{unit}
            </if>
            <if test="address != null and address != ''">
                and a.`address` = #{address}
            </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>