package com.ruoyi.ibs.list.domain;

import java.util.*;

public class Constans {
    //个人,商户,企业
    public static String retail = "0";
    public static String merchant = "1";
    public static String business = "2";
    //活动分配规则，手动指定，管户归属，地址归属,随机平均分配
    public static String sd_campaignDistributeType = "0";
    public static String dz_campaignDistributeType = "2";
    public static String sj_campaignDistributeType = "3";
    public static String gh_campaignDistributeType = "1";
    //认领类型，强制认领,可选认领
    public static String qz_claimType = "0";
    public static String kx_claimType = "1";

    //活动执行人，个人，机构，混合分配
    public static String jg_executer = "0";
    public static String gr_executer = "1";
    public static String hh_executer = "2";

    public static final String ROLE_HEAD = "head";
    public static final String ROLE_HeadPublic = "public";
    public static final String ROLE_HeadPrivate = "private";
    public static final String ROLE_HeadOps = "ops";
    public static final String ROLE_BRANCH = "branch";
    public static final String ROLE_Outlet = "outlet";

    public static final String RETAIL_TABLE = "cust_info_retail";

    public static final String MERCHANT_TABLE = "cust_info_merchant";

    public static final String BUSINESS_TABLE = "cust_info_business";


    public static String getTableName (String type){
        return type.equals(retail) ? RETAIL_TABLE : type.equals(merchant) ? MERCHANT_TABLE : type.equals(business) ? BUSINESS_TABLE : "";
    }


    public static Map<String, Map<String, String>> convertSignedProducts(SignedProducts signedProducts) {
        Map<String, Map<String, String>> map = new HashMap<>();
        if ("1".equals(signedProducts.getCurrdeposFlag())) {
            Map<String, String> pros = new HashMap<>();
            pros.put("currdeposFlag", "活期储蓄存款");
            map.put("deposit", pros);
        }
        Map<String, String> pros2 = new HashMap<>();
        if ("1".equals(signedProducts.getHatflowcostbookFlag()) || "1".equals(signedProducts.getPhmortgloanFlag())
                || "1".equals(signedProducts.getZheliloanFlag())) {
            if ("1".equals(signedProducts.getHatflowcostbookFlag())) {
                pros2.put("hatflowcostbookFlag", "随心花");
            }
            if ("1".equals(signedProducts.getPhmortgloanFlag())) {
                pros2.put("phmortgloanFlag", "个人住房按揭贷款");
            }
            if ("1".equals(signedProducts.getZheliloanFlag())) {
                pros2.put("zheliloanFlag", "浙里贷");
            }
            map.put("loan", pros2);
        }
        Map<String, String> pros3 = new HashMap<>();
        if ("1".equals(signedProducts.getFrcdFlag()) || "1".equals(signedProducts.getFinancialbookFlag())
                || "1".equals(signedProducts.getFundbookFlag()) || "1".equals(signedProducts.getInsurbookFlag())
                || "1".equals(signedProducts.getBondbookFlag())) {
            if ("1".equals(signedProducts.getFrcdFlag())) {
                pros3.put("frcdFlag", "大额存单");
            }
            if ("1".equals(signedProducts.getFinancialbookFlag())) {
                pros3.put("financialbookFlag", "理财业务签约");
            }
            if ("1".equals(signedProducts.getFundbookFlag())) {
                pros3.put("fundbookFlag", "基金业务签约");
            }
            if ("1".equals(signedProducts.getInsurbookFlag())) {
                pros3.put("insurbookFlag", "保险业务签约");
            }
            if ("1".equals(signedProducts.getBondbookFlag())) {
                pros3.put("bondbookFlag", "债券业务签约");
            }
            map.put("wealth", pros3);
        }
        Map<String, String> pros4 = new HashMap<>();
        if ("1".equals(signedProducts.getWatfeeWhcFlag()) || "1".equals(signedProducts.getElefeeWhcFlag())
                || "1".equals(signedProducts.getGasfeeWhcFlag()) || "1".equals(signedProducts.getEtcFlag())) {
            if ("1".equals(signedProducts.getWatfeeWhcFlag())) {
                pros4.put("watfeeWhcFlag", "水费代扣签约");
            }
            if ("1".equals(signedProducts.getElefeeWhcFlag())) {
                pros4.put("elefeeWhcFlag", "电费代扣签约");
            }
            if ("1".equals(signedProducts.getGasfeeWhcFlag())) {
                pros4.put("gasfeeWhcFlag", "燃气费代扣签约");
            }
            if ("1".equals(signedProducts.getEtcFlag())) {
                pros4.put("etcFlag", "etc");
            }
            map.put("intermediate", pros4);
        }
        return map;
    }

    public static List<Products> convertProducts(SignedProducts signedProducts) {
        List<Products> products = new ArrayList<>();
        Products pros1 = new Products();
        pros1.setProductGroup("存款");
        Products pros2 = new Products();
        pros2.setProductGroup("贷款");
        Products pros3 = new Products();
        pros3.setProductGroup("理财");
        Products pros4 = new Products();
        pros4.setProductGroup("中间业务");
        if (signedProducts != null && signedProducts.getCurrdeposFlag() != null && !signedProducts.getCurrdeposFlag().equals("")) {
            if ("1".equals(signedProducts.getCurrdeposFlag())) {
                pros1.setProductName("活期储蓄存款");
            }
            if ("1".equals(signedProducts.getHatflowcostbookFlag()) || "1".equals(signedProducts.getPhmortgloanFlag())
                    || "1".equals(signedProducts.getZheliloanFlag())) {
                String productName = "";
                if ("1".equals(signedProducts.getHatflowcostbookFlag())) {
                    productName = productName + "随心花" + ",";
                }
                if ("1".equals(signedProducts.getPhmortgloanFlag())) {
                    productName = productName + "个人住房按揭贷款" + ",";
                }
                if ("1".equals(signedProducts.getZheliloanFlag())) {
                    productName = productName + "浙里贷" + ",";
                }
                if (productName.length() > 1) {
                    productName = productName.substring(0, productName.length() - 1);
                }
                pros2.setProductName(productName);

            }

            if ("1".equals(signedProducts.getFrcdFlag()) || "1".equals(signedProducts.getFinancialbookFlag())
                    || "1".equals(signedProducts.getFundbookFlag()) || "1".equals(signedProducts.getInsurbookFlag())
                    || "1".equals(signedProducts.getBondbookFlag())) {
                String productName = "";
                if ("1".equals(signedProducts.getFrcdFlag())) {
                    productName = productName + "大额存单" + ",";
                }
                if ("1".equals(signedProducts.getFinancialbookFlag())) {
                    productName = productName + "理财业务签约" + ",";
                }
                if ("1".equals(signedProducts.getFundbookFlag())) {
                    productName = productName + "基金业务签约" + ",";
                }
                if ("1".equals(signedProducts.getInsurbookFlag())) {
                    productName = productName + "保险业务签约" + ",";
                }
                if ("1".equals(signedProducts.getBondbookFlag())) {
                    productName = productName + "债券业务签约" + ",";
                }
                if (productName.length() > 1) {
                    productName = productName.substring(0, productName.length() - 1);
                }
                pros3.setProductName(productName);
            }

            if ("1".equals(signedProducts.getWatfeeWhcFlag()) || "1".equals(signedProducts.getElefeeWhcFlag())
                    || "1".equals(signedProducts.getGasfeeWhcFlag()) || "1".equals(signedProducts.getEtcFlag())) {
                String productName = "";
                if ("1".equals(signedProducts.getWatfeeWhcFlag())) {
                    productName = productName + "水费代扣签约" + ",";
                }
                if ("1".equals(signedProducts.getElefeeWhcFlag())) {
                    productName = productName + "电费代扣签约" + ",";
                }
                if ("1".equals(signedProducts.getGasfeeWhcFlag())) {
                    productName = productName + "燃气费代扣签约" + ",";
                }
                if ("1".equals(signedProducts.getEtcFlag())) {
                    productName = productName + "etc" + ",";
                }
                if (productName.length() > 1) {
                    productName = productName.substring(0, productName.length() - 1);
                }
                pros4.setProductName(productName);
            }
            products.add(pros1);
            products.add(pros2);
            products.add(pros3);
            products.add(pros4);
        }
        return products;
    }


    public static Map<String, String> convertCmpm(String custType) {
        if ("0".equals(custType)) {
            Map<String, String> retail = new HashMap<>();
            retail.put("203205", "信用卡营销");
            retail.put("203207", "信用卡责任");
            retail.put("207201", "国际业务结算");
            retail.put("207202", "国际业务贸易融资");
            return retail;
        } else {
            Map<String, String> business = new HashMap<>();
            business.put("204202", "代发工资有效户");
            business.put("207201", "国际业务结算");
            business.put("207202", "国际业务贸易融资");
            return business;
        }

    }

    public static Boolean labelDuplicate(String label) {
        String[] labels = label.split(",");
        HashSet<String> set = new HashSet<>();
        if (labels.length > 0) {
            for (String str : labels) {
                if (!set.add(str)) {
                    return true;
                }
            }
        }
        return false;
    }

    public static String strReplace(String str){
        if (str.length()>1&&str.charAt(str.length()-1)==','){
            str = str.substring(0,str.length()-1);
        }
        return str;
    }


}
