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

import java.util.ArrayList;
import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.modules.merchant.constant.MerchantConstants;
import com.ruoyi.web.modules.merchant.domain.BizMerchant;

/**
 * 经营信息完整度评估（§9.2）
 */
public final class BizCompleteEvaluator
{
    private BizCompleteEvaluator()
    {
    }

    public static String evaluateCompleteFlag(BizMerchant m)
    {
        return pendingFields(m).isEmpty() ? MerchantConstants.BIZ_COMPLETE : MerchantConstants.BIZ_INCOMPLETE;
    }

    public static List<String> pendingFields(BizMerchant m)
    {
        List<String> pending = new ArrayList<>();
        if (m == null)
        {
            return pending;
        }
        boolean enterprise = MerchantConstants.TYPE_ENTERPRISE.equals(m.getMerchantType());
        check(pending, "商户名称", m.getMerchantName());
        check(pending, "客服电话", m.getServicePhone());
        if (StringUtils.isEmpty(m.getBizRegionCode()) || StringUtils.isEmpty(m.getBizRegionName()))
        {
            pending.add("经营地址");
        }
        check(pending, "经营详细地址", m.getBizDetailAddress());
        check(pending, "联系人姓名", m.getContactName());
        check(pending, "联系人手机", m.getContactPhone());
        check(pending, "联系人邮箱", m.getContactEmail());
        check(pending, "开户银行", m.getBankName());
        check(pending, "支行名称", m.getBankBranch());
        check(pending, "银行账号", m.getBankAccount());
        if (enterprise)
        {
            check(pending, "营业执照电子版", m.getBusinessLicense());
            check(pending, "开户许可证", m.getAccountPermit());
        }
        return pending;
    }

    private static void check(List<String> pending, String label, String value)
    {
        if (StringUtils.isEmpty(value))
        {
            pending.add(label);
        }
    }
}
