package com.ruoyi.web.modules.merchant.support;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.modules.merchant.constant.MerchantConstants;
import com.ruoyi.web.modules.merchant.domain.BizMerchant;

/**
 * 商户展示工具
 */
public final class MerchantDisplayUtils
{
    private MerchantDisplayUtils()
    {
    }

    public static String unitName(BizMerchant m)
    {
        if (MerchantConstants.TYPE_ENTERPRISE.equals(m.getMerchantType()))
        {
            return m.getCompanyName();
        }
        return m.getPersonName();
    }

    public static String displayMerchantName(BizMerchant m)
    {
        if (StringUtils.isNotEmpty(m.getMerchantName()))
        {
            return m.getMerchantName();
        }
        return "待完善";
    }

    public static String maskIdCard(String idCard)
    {
        if (StringUtils.isEmpty(idCard) || idCard.length() < 8)
        {
            return idCard;
        }
        return idCard.substring(0, 3) + "***********" + idCard.substring(idCard.length() - 4);
    }

    public static String maskBankAccount(String account)
    {
        if (StringUtils.isEmpty(account) || account.length() < 4)
        {
            return account;
        }
        return "****" + account.substring(account.length() - 4);
    }
}
