<?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="org.dromara.system.mapper.SysTenantAccountMapper">

    <resultMap type="org.dromara.system.domain.vo.SysTenantAccountVo" id="SysTenantAccountResult">
        <result property="id" column="id"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="integralBalance" column="integral_balance"/>
        <result property="totalIntegralBalance" column="total_integral_balance"/>
        <result property="moneyBalance" column="money_balance"/>
        <result property="wallet" column="wallet"/>
        <result property="revenue" column="revenue"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
        <result property="type" column="type"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="storeName" column="store_name"/>
    </resultMap>

    <select id="selectTenantAccountPage" resultMap="SysTenantAccountResult">
        SELECT
        ta.id,
        ta.tenant_id,
        ta.money_balance,
        ta.wallet,
        ta.revenue,
        ta.create_by,
        ta.update_by,
        ta.type,
        ta.create_time,
        t.store_name,
        t.company_name
        FROM sys_tenant_account ta
        LEFT JOIN sys_tenant t ON ta.tenant_id = t.tenant_id
        <where>
            <if test="bo.storeName != null and bo.storeName != ''">
                AND t.store_name LIKE CONCAT('%', #{bo.storeName}, '%')
            </if>
            <if test="bo.type != null">
                AND ta.type = #{bo.type}
            </if>
        </where>
    </select>

</mapper>
