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,
  REDIS_HOST: process.env.REDIS_HOST,
  REDIS_PORT: process.env.REDIS_PORT,
  REDIS_PWD: process.env.REDIS_PWD,
  DB_NAME: process.env.BPOADMIN_DB_NAME,
  REDIS_DB: process.env.BPOADMIN_REDIS_DB,
  APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "dev",
};
var settings = {
  env: ENVINPUT.APP_ENV,
  salt: "%iatpD1gcxz7iF#B",
  wxconfig: {
    appId: "wx76a324c5d201d1a4",
    appname: "工具箱",
    secret: "f99d413b767f09b5dff0b3610366cc46",
  },
  basepath: path.normalize(path.join(__dirname, '../..')),
  port: process.env.NODE_PORT || 3000,
  reqEsAddr: function () {
    if (this.env == "dev") {
      var localsettings = require("./localsettings");
      return localsettings.reqEsDevUrl;
    } else {
      return "http://43.247.184.94:7200/";
    }
  },
  FQYF: function() {
    if (settings.env == "dev") {
      return {
        k: "203756805",
        v: "crkyej0xlmqa6bmvqijun6ltxparllyn",
        productId: "5e6b02cc3290c3000a3a63dc",// 云服产品id
        pushOrderApi: "http://yunfuapi-dev.gongsibao.com/crm/order/submit",// 云服产品id
      };
    } else {
      return {
        k: "203763771",
        v: "e5e2ytnn6nrkr9qnqk4w5e6z0xlhkznu",
        productId: "5e6c89d54c52bf000a750bc5",// 云服产品id (生产环境)
        pushOrderApi: "http://yunfuapi.gongsibao.com/crm/order/submit",// 云服产品id (生产环境)
      };
    }
  },
  apiconfig: {
    AES: {
        key: "qUPsMflPfgpPP1Ua", //密钥
        iv: '1012133205963708', //偏移向量
        padding: 'PKCS7Padding' //补全值
    },
    opLogUrl: function () {
      return settings.reqEsAddr() + "bigdata_zc_op_log/_doc?pretty";
    },
    opLogEsIsAdd: function () {
      return 1;
    },
    yunzhanghuDealer_id: function () {
      //商户平台ID(dealer_id)——自己
      return "27403253";
    },
    //e签宝签署状态变化完成后跳转boss页面Url地址（拒签、签署完成），在合同模板创建合同 5.4.2指定redirectUrl
    eSignBaoRedirectBossUrl: function () {
      return "https://bpohhr.gongsibao.com/h5";
    },

    //e签宝接口Url
    eSignBaoUrl: function () {
      if (settings.env == "dev") {
        // return "https://smlo.tsign.cn/opentreaty-service";
        return "https://o.tsign.cn/opentreaty-service";
      } else {
        return "https://o.tsign.cn/opentreaty-service";
      }
    },

    //e签宝银行验证接口Url
    eSignBaoBankVerifyUrl: function () {
      if (settings.env == "dev") {
        // return "https://smlo.tsign.cn/openrealname-service";
        return "https://o.tsign.cn/openrealname-service";
      } else {
        return "https://o.tsign.cn/openrealname-service";
      }
    },
    companyAccountId: function() {
      return "5c25eb4ee3b448da90babec3ce8d1144";
    },
    //e签宝appId
    eSignBaoAppId: function () {
      if (settings.env == "dev") {
        // return "4438757581";
        return "5111588557";
      } else {
        // return "5111566617"
        return "5111588557"
      }
    },
    //e签宝appKey
    eSignBaoAppKey: function () {
      if (settings.env == "dev") {
        // return "0d798cdf01ecb31bf9949f319f8d77db";
        return "1595787e8d5b7d19f7b6798f16f41fc2";
      } else {
        // return "ea386dfd9063b3669b38b78ed36792cc"
        return "1595787e8d5b7d19f7b6798f16f41fc2"
      }
    },
  },
  reqEsDevUrl: "http://192.168.4.249:9200/",
  domain: function () {
    if (this.env == "dev") {
      var localsettings = require("./localsettings");
      return localsettings.reqHomePageDevUrl;
    } else {
      return "https://bpohhr.gongsibao.com/";
    }
  },
  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,
          dialect: 'mysql',
          operatorsAliases: false,
          pool: {
            max: 5,
            min: 0,
            acquire: 90000000,
            idle: 1000000
          },
          debug: false,
          dialectOptions: {
            requestTimeout: 999999,
            // instanceName:'DEV'
          } //设置MSSQL超时时间
        },
      };
    }
  },
  settleDB: function () {
    return {
      dbname: "smart_account",
      user: "wangkun",
      password: "$zdZ7Q5PKMm6#Hy",
      config: {
        host: 'rm-2ze3yx851i59uvgg5jo.mysql.rds.aliyuncs.com',
        port: 3306,
        dialect: 'mysql',
        operatorsAliases: false,
        pool: {
          max: 5,
          min: 0,
          acquire: 90000000,
          idle: 1000000
        },
        logging: true,
        debug: true,
        dialectOptions: {
          requestTimeout: 999999,
          // instanceName:'DEV'
        } //设置MSSQL超时时间
      },
    };
  }
};
settings.ENVINPUT = ENVINPUT;
module.exports = settings;