var path = require('path');
var ENVINPUT = {
    DB_HOST: process.env.DB_HOST,
    DB_PORT: process.env.DB_PORT,
    DB_USER: process.env.DB_USER,
    DB_PWD: process.env.DB_PWD,
    DB_NAME: process.env.DELIVERY_DB_NAME,
    REDIS_HOST: process.env.REDIS_HOST,
    REDIS_PORT: process.env.REDIS_PORT,
    REDIS_PWD: process.env.REDIS_PWD,
    REDIS_DB: process.env.PAAS_REDIS_DB,
    APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "dev"
};
var settings = {
    env: ENVINPUT.APP_ENV,
    salt: "%iatpD1gcxz7iF#B",
    defaultpwd: "gsb2020",
    basepath: path.normalize(path.join(__dirname, '../..')),
    port: process.env.NODE_PORT || 8002,
    logindex: "center_manage",
    appname: "icp_deliver",
    appKey: "202003231118",
    secret: "7cbb846246874167b5c7e01cd0016c99",
    kongurl: function() { if (this.env == "dev") { var localsettings = require("./localsettings"); return localsettings.kongurl; } else { return ENVINPUT.KONG_ADMIAN; } },
    txurl: function() {
        if (this.env == "dev") { var localsettings = require("./localsettings"); return localsettings.txurl; } else { return "http://brg-user-center-service"; }
    },
    logUrl: function() {
        if (this.env == "dev") {
            return "http://192.168.18.101:4019/api/queueAction/producer/springBoard";
        } else {
            return "http://logs-sytxpublic-msgq-service.chaolai/api/queueAction/producer/springBoard";
        }
    },
    requrl: function() {
        if (this.env == "dev") {
            return "http://192.168.1.128:4018";
        } else {
            return "http://sytxpublic-msgq-service";
        }
    },
    centerChannelUrl: function() { //---------center-channel
        if (this.env == "dev") {
            return "http://alitm.qifu-dev.gongsibao.com";
        } else {
            return "http://center-channel-service.chaolai";
        }
    },
    qifutongUrl: function() { //---------center-channel
        if (this.env == "dev") {
            return "http://gsbweb.qifu-dev.gongsibao.com";
        } else {
            return "https://fqgsbweb.gongsibao.com";
        }
    },
    queueUrl: function() {
        if (this.env == "dev") {
            return "http://192.168.18.101:4018/api/queueAction/producer/springBoard";
        } else {
            return "http://sytxpublic-msgq-service.chaolai/api/queueAction/producer/springBoard";
        }
    },
    ydzUrl: function() { // 易代账URL
        if (this.env == "dev") { //集测环境
            return "https://inte-openapi.chanjet.com";
        } else {
            return "https://openapi.chanjet.com";
        }
    },
    ydzKey: function() { // 易代账Key
        if (this.env == "dev") {
            return {
                "appKey": "qP2tgcfw",
                "appSecret": "D25E0435ACFB4844DB75E7E0F87B9F71",
                "msgSecret": "1234567890123456"
            };
        } else {
            return {
                "appKey": "cXqZIzIl",
                "appSecret": "B5AE885F55652CE9A4686F96A4CD90D8",
                "msgSecret": "WzeZ6EwkIAzUsa56"
            };
        }
    },
    javaUrl: function() {
        if (this.env == "dev") {
            return "";
        } else {
            return "";
        }
    },
    pmappid: 1,
    pmcompanyid: 1,
    pmroleid: { "ta": 1, "pr": 2 },
    redis: function() {
        if (this.env == "dev") {
            var localsettings = require("./localsettings");
            return localsettings.redis;
        } else {
            return {
                host: ENVINPUT.REDIS_HOST,
                port: ENVINPUT.REDIS_PORT,
                password: ENVINPUT.REDIS_PWD,
                db: ENVINPUT.REDIS_DB,
            };
        }
    },
    database: function() {
        if (this.env == "dev") {
            var localsettings = require("./localsettings");
            return localsettings.database;
        } else {
            return {
                dbname: ENVINPUT.DB_NAME,
                user: ENVINPUT.DB_USER,
                password: ENVINPUT.DB_PWD,
                config: {
                    host: ENVINPUT.DB_HOST,
                    port: ENVINPUT.DB_PORT,
                    dialect: 'mysql',
                    operatorsAliases: false,
                    pool: {
                        max: 5,
                        min: 0,
                        acquire: 90000000,
                        idle: 1000000
                    },
                    debug: false,
                    timezone: '+08:00',
                    dialectOptions: {
                        requestTimeout: 999999,
                        // instanceName:'DEV'
                    } //设置MSSQL超时时间
                },
            };
        }
    }
};
settings.ENVINPUT = ENVINPUT;
module.exports = settings;