<?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.hotwj.platform.pay.mapper.PayWalletMapper">
    <select id="selectCompanyWalletPage" resultType="com.hotwj.platform.pay.domain.vo.PayCompanyWalletBalanceVo">
        SELECT
            w.freeze_status AS freezeStatus,
            w.id AS payWalletId,
            c.id AS companyId,
            c.company_name AS companyName,
            c.responsible_name AS responsibleName,
            c.responsible_mobile AS responsibleMobile,
            c.company_type AS companyType,
            c.industry AS industry,
            c.status AS status,
            IFNULL(w.balance, 0) AS balance
        FROM sys_company c
        LEFT JOIN pay_wallet w
            ON w.user_id = c.id
            AND w.wallet_type = 2
            AND w.is_deleted = 0
        WHERE c.is_deleted = 0
        <if test="keyword != null and keyword != ''">
            AND (
                c.company_name LIKE CONCAT('%', #{keyword}, '%')
                OR c.responsible_name LIKE CONCAT('%', #{keyword}, '%')
                OR c.responsible_mobile LIKE CONCAT('%', #{keyword}, '%')
            )
        </if>
        ORDER BY c.id DESC
    </select>
</mapper>
