package com.tax.token.constants;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class TokenConstants {

    //token请求最大次数
    public static int REQ_MAX_TIMES = 5;

    public static int TOKEN_VALID_TIME = 5 * 60;
    //token在途重试最大次数
    public static int RETRY_MAX_TIMES = 10;

    public static final String TOKEN_INIT = "0";

    //token有效
    public static final String TOKEN_VALID = "1";
    //token在途
    public static String TOKEN_ON_THE_WAY = "2";
    //token排队中
    public static String TOKEN_ON_THE_WAIT = "3";
    //
    public static String SERVER_LOCAL = "1";
    //第三方服务
    public static String SERVER_THIRD = "2";
    //
    public static String SERVER_WEBSOCKET = "3";


    //第三方token所需信息
    public static String TOKEN_CHECK_RUNGETTOKEN = null;
    public static String TOKEN_CHECK_USERNAME = null;
    public static String TOKEN_CHECK_PASSWORD = null;

    public static String TOKEN_FROM = null;

    public static String BRANCH_ZONECODES = null;

    public static int TOKEN_RETRY_TIMES_START = 0;

    public static int TOKEN_RETRY_TIMES = 10;
    public static String TOKEN_VALID_URL = null;




    public static Map<String, String> urlMap;

    public static String WEB_SOCKET_URL = "ws://127.0.0.1:8888/ws";
    public static String NATION_URL;
    public static String TOKEN_CORE_URL = "http://60.205.224.101:8182/token/step";
    public static String IS_DEBUG;

    public static String CHECK_USERS = null;
    public static List<String> ELE_TAX_ERROR_CODE_LIST = null;

    public static List<String> ELE_TAX_COUNT_CODE_LIST = null;

    public static int ELE_TAX_COUNT_SMALL = 5;
    public static int ELE_TAX_COUNT = 20;
    public static String CLEAN_COOKIE_URL = null;
    public static String PUSH_COOKIE_URL = null;

    public static String NUONUO_APPKEY = "46030111";
    public static String NUONUO_APPSECRET = "19007012B74A4439";
    public static String NUONUO_URL = "https://sdk.nuonuo.com/open/v1/services";
    public static String NUONUO_TOKEN = "7176fb23bbca56e0d822ef0vwiatikls";
    public static String NUONUO_TAXNUM = "339901123456789";

    static {
        urlMap = new HashMap<String, String>();
        urlMap.put("1100", "https://fpdk.bjsat.gov.cn/");
        urlMap.put("1200", "https://fpdk.tjsat.gov.cn/");
        urlMap.put("1300", "https://fpdk.he-n-tax.gov.cn:81/");
        urlMap.put("1400", "https://fpdk.tax.sx.cn/");
        urlMap.put("1500", "https://fpdk.nm-n-tax.gov.cn/");
        urlMap.put("2100", "https://fpdk.tax.ln.cn/");
        urlMap.put("2102", "https://fpdk.dlntax.gov.cn/");
        urlMap.put("2200", "https://fpdk.jl-n-tax.gov.cn:4431/");
        urlMap.put("2300", "https://fpdk.hl-n-tax.gov.cn/");
        urlMap.put("3100", "https://fpdk.tax.sh.gov.cn/");
        urlMap.put("3200", "https://fpdk.jsgs.gov.cn:81/");
        urlMap.put("3300", "https://fpdk.zjtax.gov.cn/");
        urlMap.put("3302", "https://fpdk.nb-n-tax.gov.cn/");
        urlMap.put("3400", "https://fpdk.ah-n-tax.gov.cn/");
        urlMap.put("3500", "https://fpdk.fj-n-tax.gov.cn/");
        urlMap.put("3502", "https://fpdk.xm-n-tax.gov.cn/");
        urlMap.put("3600", "https://fpdk.jxgs.gov.cn/");
        urlMap.put("3700", "https://fpdk.sd-n-tax.gov.cn/");
        urlMap.put("3702", "https://fpdk.qd-n-tax.gov.cn/");
        urlMap.put("4100", "https://fpdk.ha-n-tax.gov.cn/");
        urlMap.put("4200", "https://fpdk.hb-n-tax.gov.cn/");
        urlMap.put("4300", "https://fpdk.hntax.gov.cn/");
        urlMap.put("4400", "https://fpdk.gd-n-tax.gov.cn/");
        urlMap.put("4403", "https://fpdk.szgs.gov.cn/");
        urlMap.put("4500", "https://fpdk.gxgs.gov.cn/");
        urlMap.put("4600", "https://fpdk.hitax.gov.cn/");
        urlMap.put("5000", "https://fpdk.cqsw.gov.cn/");
        urlMap.put("5100", "https://fpdk.sc-n-tax.gov.cn/");
        urlMap.put("5200", "https://fpdk.gz-n-tax.gov.cn/");
        urlMap.put("5300", "https://fpdk.yngs.gov.cn/");
        urlMap.put("5400", "https://fpdk.xztax.gov.cn/");
        urlMap.put("6100", "https://fprzweb.sn-n-tax.gov.cn/");
        urlMap.put("6200", "https://fpdk.gs-n-tax.gov.cn/");
        urlMap.put("6300", "http://fpdk.qh-n-tax.gov.cn/");
        urlMap.put("6400", "https://fpdk.nxgs.gov.cn/");
        urlMap.put("6500", "https://fpdk.xj-n-tax.gov.cn/");
    }


    @Value("${token.check.runGetToken}")
    public void setTokenCheckRungettoken(String tokenCheckRungettoken) {
        TOKEN_CHECK_RUNGETTOKEN = tokenCheckRungettoken;
    }

    @Value("${token.check.username}")
    public void setTokenCheckUsername(String tokenCheckUsername) {
        TOKEN_CHECK_USERNAME = tokenCheckUsername;
    }

    @Value("${token.check.password}")
    public void setTokenCheckPassword(String tokenCheckPassword) {
        TOKEN_CHECK_PASSWORD = tokenCheckPassword;
    }

    @Value("${token.from}")
    public void setTokenFrom(String tokenFrom) {
        TOKEN_FROM = tokenFrom;
    }

    @Value("${token.zonecodes}")
    public void setBranchZonecodes(String branchZonecodes) {
        BRANCH_ZONECODES = branchZonecodes;
    }

    @Value("${token.valid.url}")
    public void setTokenValidUrl(String tokenValidUrl) {
        TOKEN_VALID_URL = tokenValidUrl;
    }

    @Value("${token.websocketUrl}")
    public void setWebSocketUrl(String webSocketUrl) {
        WEB_SOCKET_URL = webSocketUrl;
    }

    @Value("${token.nationUrl}")
    public void setNationUrl(String nationUrl) {
        NATION_URL = nationUrl;
    }

    @Value("${token.tokenCoreUrl}")
    public  void setTokenCoreUrl(String tokenCoreUrl) {
        TOKEN_CORE_URL = tokenCoreUrl;
    }

    @Value("${token.isDebug}")
    public void setIsDebug(String isDebug) {
        IS_DEBUG = isDebug;
    }

    public static boolean isDebug(){return "1".equals(IS_DEBUG);}


    @Value("${token.checkUsers}")
    public void setCheckUsers(String checkUsers) {
        CHECK_USERS = checkUsers;
    }


    @Value("#{'${token.eleTaxErrorCodeList}'.split(',')}")
    public void setEleTaxErrorCodeList(List<String> eleTaxErrorCodeList) {
        ELE_TAX_ERROR_CODE_LIST = eleTaxErrorCodeList;
    }

    @Value("#{'${token.eleTaxCountCodeList}'.split(',')}")
    public void setEleTaxCountCodeList(List<String> eleTaxCountCodeList) {
        ELE_TAX_COUNT_CODE_LIST = eleTaxCountCodeList;
    }

    @Value("${token.eleTaxCountSmall}")
    public void setEleTaxCountSmall(int eleTaxCountSmall) {
        ELE_TAX_COUNT_SMALL = eleTaxCountSmall;
    }

    @Value("${token.eleTaxCount}")
    public void setEleTaxCount(int eleTaxCount) {
        ELE_TAX_COUNT = eleTaxCount;
    }


    @Value("${token.cleanCookieUrl}")
    public void setCleanCookieUrl(String cleanCookieUrl) {
        CLEAN_COOKIE_URL = cleanCookieUrl;
    }

    @Value("${token.pushCookieUrl}")
    public void setPushCookieUrl(String pushCookieUrl) {
        PUSH_COOKIE_URL = pushCookieUrl;
    }


    /**用户类型 0-小号 1-正常 2-人工 start*/
    /**
     * 用户类型 0-小号
     */
    public static final String USER_TYPE_SMALL = "0";
    /**
     * 用户类型 1-正常
     */
    public static final String USER_TYPE_NORMAL = "1";
    /**
     * 用户类型 2-人工
     */
    public static final String USER_TYPE_HAND = "2";
    /**
     * 用户类型 3- 一次性
     */
    public static final String USER_TYPE_ONE = "3";


    /**地区转码标志 0-否 1-是*/
    /**
     * 地区转码标志 0-否
     */
    public static final String ZONE_FLAG_NO = "0";
    /**
     * 地区转码标志 1-是
     */
    public static final String ZONE_FLAG_YES = "1";

    /**99-发票云 01-电子税局*/
    public static final String FUNCTION_NO_FPY = "99";
    public static final String FUNCTION_NO_DZSJ = "01";
}
