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.BPOWEB_DB_NAME,
  REDIS_DB: process.env.BPOWEB_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 || 3333,
  reqEsAddr: function () {
    if (this.env == "dev") {
      var localsettings = require("./localsettings");
      return localsettings.reqEsDevUrl;
    } else {
      return "http://43.247.184.94:7200/";
    }
  },
  apiconfig: {
    AES: {
      key: "qUPsMflPfgpPP1Ua", //密钥
      iv: '1012133205963708', //偏移向量
      padding: 'PKCS7Padding' //补全值
    },
    settleApiConfig: function () {
      let domain;
      if(settings.env == "dev") {
        domain = "http://39.106.185.66:8000";
      } else {
        // domain = "http://39.106.185.66:8000";
        domain = "http://payadmin.gongsibao.com";
      }
      return {
        createMerchantApi: domain + "/merchant/busi/reg"
      }
    },
    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";
      }
    },
    //e签宝appId
    eSignBaoAppId: function () {
      if (settings.env == "dev") {
        // return "4438757581";
        return "5111588557";
      } else {
        // return "5111566617"
        return "5111588557"
      }
    },

    //有赞商户创建  代征主体  //代征主体 67731101  测试 67731504
    getmainId : function(){
      if (settings.env == "dev") {
        return "67731504";
      } else {
        return "67731101"
      }
    },

    //e签宝appKey
    eSignBaoAppKey: function () {
      if (settings.env == "dev") {
        // return "0d798cdf01ecb31bf9949f319f8d77db";
        return "1595787e8d5b7d19f7b6798f16f41fc2";
      } else {
        // return "ea386dfd9063b3669b38b78ed36792cc"
        return "1595787e8d5b7d19f7b6798f16f41fc2"
      }
    },
    // e签宝企业accountId
    companyAccountId: function() {
      return "5c25eb4ee3b448da90babec3ce8d1144";
    },

    sign3rdHomePage: function () {
      if(settings.env == "dev") {
        return "http://127.0.0.1:3333/h5";
      } else {
        return "https://bpohhr.gongsibao.com/h5";
      }
    },

    lbwConfig: function () {
      if(settings.env == "dev") {
        let domain = "https://99num.com";
        return {
          validate_bank: `${domain}/dsp-simple/api/validate/bank`,
          puk: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvuoB1YqsDa1oUlPWZEUe\n" +
            "jK1y7Ja4W3AjTLfiqbo9Z6rY7h8ui/CbiZxpJuDg3H0cTI0k8UJWNO+CbYVioLo3\n" +
            "bK0Hj10jYkPdzRlQsaQ6gnJaj4DMVjmAjUUsBPnimnGsKvxLwPZTUiOMsVCOWYVH\n" +
            "rEdCrB4GVQSI9XVQFECYZTCzbtTilFB40NUlnKZ0IBbScA+c1A7buMUoR6E3hr93\n" +
            "8Mnls+szyO3J9/qA4XIq4tQIp6/UklYXn2ZkIRpk+Jb3Rm57wzfAw8VxCSVFHLxd\n" +
            "z5RXFLDeyvZuqSiA/9WX41IlSWjrcuqgHhWngnsv44LF/AsDJg/LRzLxWGK2k3Xa\n" +
            "qwIDAQAB",
          pik: "MIIEogIBAAKCAQEAtkFN3EfRuUwuzKXwwkEtDQ8YfmtfbTmODe0hY33l9qqk7SC3\n" +
            "AErUYNyDbtDkb22v5kaDfCgGxQysAKC9xgMxeR/+IBG9WNvm+L/22Vz/+vFW45lv\n" +
            "d2F30TzNC16g0gDyFCI97ZdNWMgGFkRPhtQL4x5oArmBjQ2eVxq0zzR/Hvh3ujEO\n" +
            "GGjed19rY8H/zm9QQi5OJ05nsDULtE1AUgN22uuGbXAzqP3YuOejVeaYOuY9IQh/\n" +
            "5Tac/+Eh/AobSXT1PoyARLY01ZMn6kOYuo+iLIa3Wfkld2v6uhUTAMSugM19eVN3\n" +
            "G5flirOqPoSaTvH7dfQW/nnBXL+0qkVZ2Yo//wIDAQABAoIBAFD1gViwroDZTpCp\n" +
            "xeEEgraiVgcSOzmRr4CQLZy8eEKyWsDbH2+Jzf2Y9ulq8Y5t8w0flZi5TwiJMH62\n" +
            "6JXlJTzg8Undl3a5eEhXPZggr7URL7+6kME/ErJnh83dIyMmOGKpM0kvRLSDZfDO\n" +
            "N2V1HDKvdxR+wwWdXxDiVB8W+sEObnaDSQv4iObtXk/rQrw3VWwIJ7leL1SMNosY\n" +
            "j1MacOGsbFfSlRSUUq8wnpcocpiLG+e3ot1ypWkIWQdmVqeQWPVu9EUzmMDSjFsY\n" +
            "rMGMsINyTYXiD+nYvsQG19/k3dJqFpW1Z3X5GG2fHfqbIwSG1a4cDyim8l1MCdAS\n" +
            "VgfoEoECgYEA2nJpJgQ5G1yGsLkIip5mnQX9OOauynoUEd3TEi3csy0/bEJ+kMFG\n" +
            "C1OO2bKbnSg7TorZxgfv0dTY3Ioi+eHmZn/NQNaRD8OOj08ylQf7/K4KRD/TUbCQ\n" +
            "sILegaHoDFJ+tbX1w0qpu9d3g0Uy/Y70ptPxTGoXy2/R8BjPM6ETnMcCgYEA1ZYi\n" +
            "YRXub3by2lkJEcoCfrmlMjkLT/G36u4NVDz4FoNqjezDy8kIkceGZLBi4k0l3Od5\n" +
            "jf4CvbL3Xo/OhoO0ip0w/LPutnFh1VZulHTMMFyfnZdfZGFEUMlZWzaCm10FL72h\n" +
            "90BJs3Rq1RKQdHFkuWZE8YLz6IWZo2XPBErpWwkCgYAWrPezRY70AyfMInj7grPe\n" +
            "Kuf9Rxzv0bpRnHgzk+UsCE9kGobu2dE+jb7vZDX5G1sErS8r+ljvrCuSwRgeXk+/\n" +
            "ZhbVWzCVtVQQFkWG6NxEf4B7UzDJcw2h9QPJ6xeeZ9XVYP0Q96gk4pn6W22Omo9U\n" +
            "3f1XVFACAyqExN6FWnwhswKBgDOJxMX0itJuu28gqOWX/z4hAdG6nhYuV5ji1GiN\n" +
            "Rbf5Ag85II3d9qlmofFN9q5wu0Awws4WiwbHVpWE0er3gOspvxZbPLDdbyQRdSFx\n" +
            "hYvt7b4TNrt8FQYBcARohN+EdKnuclS9OIuK/fRoRF80tX9fRCea18w14Lri6C86\n" +
            "/FAxAoGAL12Mui51jjbfZgj1nipEm2sTYUODEHngo545zr3uYgmvpLxBA6M5UYqC\n" +
            "4qPwuEUCnbE7/p1dG0GgIII/ctUpE8RcdGOAsYHK8kkF8PXXpXagrRsqhT4WLzca\n" +
            "yKEOEa4dbFzU1LXFqjD3Xv/c5mqcgYG1IMskAo9R00+XvTn8a6o=",
        };
      } else {
        return {};
      }
    }
  },
  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;
