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,
  REDIS_DB:process.env.TASK_REDIS_DB,
  DB_NAME:process.env.TASK_DB_NAME,
  APP_ENV:process.env.APP_ENV?process.env.APP_ENV:"dev"
};
var settings = {
  env:ENVINPUT.APP_ENV,
  basepath   : path.normalize(path.join(__dirname, '../..')),
  fkweb:function(){
    if(this.env=="dev"){
      return "http://localhost:3003/api/rpt/rptApi/saveRptHistory";
    }else {
      return "http://fktaxctl-service.chaolai/api/rpt/rptApi/saveRptHistory";
    }
  },
  igirlWeburl: function(){
    if (this.env == "dev") {
      return "http://192.168.18.34:3000/";
    } else {
      return "http://igirl-service.chaolai/";
    }
  },
  
  aliTmurl: function(){
    if (this.env == "dev") {
      return "http://alitm.qifu.gongsibao.com/";
    } else {
      return "http://igirl-service.chaolai/";
    }
  },
  centerOrderUrl: function () {
    if (this.env == "dev") {
      return "http://gsb.qifu.gongsibao.com:4011/";
    } else {
      return "http://center-order-service.chaolai/";
    }
  },
  centerChannelUrl: function () {
    if (this.env == "dev") {
      return "http://192.168.0.106:4012/";
    } else {
      return "http://center-channel-service.chaolai/";
    }
  },
  gsbDeliver: function () {
    if (this.env == "dev") {
      return "http://icpdeliver-service.newtime/";// 2020 1116 lin 新增 本地测试用（测试环境没定时任务）
    } else {
      return "http://icpdeliver-service.newtime/";
    }
  },
  fqbossUrl: function () {
    if (this.env == "dev") {
      return "http://192.168.0.106:4012/";
    } else {
      return "https://fqgirl.gongsibao.com/";
    }
  },
  tmnotifyUrl: function () {
    if (this.env == "dev") {
      return "https://fqdev.gongsibao.com/tmnotify";
    } else {
      return "https://fq.gongsibao.com/tmnotify";
    }
  },
  tmnotifyhbUrl: function () {
    if (this.env == "dev") {
      return "https://tmtest.gongsibao.com/tmnotify";
    } else {
      return "https://tm.gongsibao.com/tmnotify";
    }
  },
  zhugeioUrl: function () {
    if (this.env == "dev") {
      return "https://mmc.gongsibao.com";
    } else {
      return "https://mmc.gongsibao.com";
    }
  },
  reqTransferurl: function () {
    if (this.env == "dev") {
      return "http://192.168.18.61:3003/";
    } else {
      return "http://jiaxiya-service.chaolai/";
    }
  },
  openapiUrl: function () {
    if (this.env == "dev") {
      return "https://oapidev.gongsibao.com/open-task/";
    } else {
      return "https://oapi.gongsibao.com/open-task/";
    }
  },
  redis:function(){
    if(this.env=="dev"){
      console.log("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"){
      console.log("===========================");
      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超时时间
       },
     };
    }
  }
};
settings.ENVINPUT=ENVINPUT;
module.exports = settings;
