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.ZC_CHANNEL_WEB_DB_NAME,
  REDIS_HOST: process.env.REDIS_HOST,
  REDIS_PORT: process.env.REDIS_PORT,
  REDIS_PWD: process.env.REDIS_PWD,
  REDIS_DB: process.env.ZC_CHANNEL_WEB_REDIS_DB,
  APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "dev"
};
var settings = {
  env: ENVINPUT.APP_ENV,
  appKey: "201911061258",
  paasKey: "wx76a324c5d201d1a4",
  secret: "1671ab5405fa49c8b5dd0b0c55c279b8",
  salt: "%iatpD1gcxz7iF#B",
  basepath: path.normalize(path.join(__dirname, '../..')),
  port: process.env.NODE_PORT || 4004,
  channelApiUrl: function () {
    if (this.env == "dev") {
      return "http://zcchannel.apps.com:4003";
    } else {
      return "http://zc-channel-service";
    }
  },
  paasUrl: function () {
    if (this.env == "dev") {
      return "http://p.apps.com:4001/";
    } else {
      return "http://open.gongsibao.com/";
    }
  },
  teleDomain: function () {
    if (this.env == "dev") {
      return "http://teledata.gongsibao.com/";
    } else {
      return "http://www.telecredit.cn/";
    }
  },
  reqEsAddr: function () {
    if (this.env == "dev") {
      var localsettings = require("./localsettings");
      return "http://43.247.184.94:7200/";//localsettings.reqEsDevUrl;
    } else {
      return "http://43.247.184.94:7200/";
    }
  },
  reqEsAddrIc: function () {
    if (this.env == "dev") {
      var localsettings = require("./localsettings");
      return "http://43.247.184.94:9200/";//localsettings.reqEsDevUrl;
    } else {
      return "http://43.247.184.94:9200/";
    }
  },
  apiconfig: {
    imageQueryKey: "4S3ypgaRq19bhKwB",
    MgphoneSearchUrl: function () {
      return settings.reqMgAddr() + "phones"
    },
    xzAllCompanySearchUrl: function () {
      return settings.reqEsAddr() + "bigdata_business_gsb_tm_company_op/_search";
    },
    //e签宝签署状态变化完成后跳转boss页面Url地址（拒签、签署完成），在合同模板创建合同 5.4.2指定redirectUrl
    eSignBaoRedirectBossUrl: function () {
      return "https://ec.gongsibao.com/h5";
    },
    //e签宝接口Url
    eSignBaoUrl: function () {
      return "https://smlo.tsign.cn/opentreaty-service";
    },
    //e签宝银行验证接口Url
    eSignBaoBankVerifyUrl: function () {
      return "https://smlo.tsign.cn/openrealname-service";
    },
    //e签宝appId
    eSignBaoAppId: function () {
      return "4438757581";
    },
    //e签宝appKey
    eSignBaoAppKey: function () {
      return "0d798cdf01ecb31bf9949f319f8d77db";
    },
    //作品版权
    icworksCopyrightSearchUrl: function () {
      return settings.reqEsAddrIc() + "bigdata_works_copyright_op/_search";
    },
    //软件版权
    icsoftwareCopyrightSearchUrl: function () {
      return settings.reqEsAddrIc() + "bigdata_software_copyright_op/_search";
    },
    //专利查询
    paSearchUrl: function () {
      return settings.reqEsAddrIc() + "bigdata_patent_op/_search";
    },
    icmemberSearchUrl: function () {
      return settings.reqEsAddrIc() + "bigdata_ic_gsb_member_op/_search";
    },
    icshareholderSearchUrl: function () {
      return settings.reqEsAddrIc() + "bigdata_ic_gsb_shareholder_op/_search";
    },
    icinvestSearchUrl: function () {
      return settings.reqEsAddrIc() + "bigdata_ic_gsb_invest_op/_search";
    },
    icchangeSearchUrl: function () {
      return settings.reqEsAddrIc() + "bigdata_ic_gsb_change_op/_search";
    },
    iccompanynameSearchUrl: function () {
      return settings.reqEsAddrIc() + "bigdata_ic_gsb_company_op/_search";
    },
    agencynameSearchUrl: function () {
      return settings.reqEsAddr() + "bigdata_agency_company/_search";
    },
    iccompanycodeSearchUrl: function () {
      return settings.reqEsAddrIc() + "bigdata_ic_gsb_company_op/_search";
    },
    iccompanyNumSearchUrl: function () {
      return settings.reqEsAddrIc() + "bigdata_ic_gsb_company_op/_search";
    },
    icbranchSearchUrl: function () {
      return settings.reqEsAddrIc() + "bigdata_ic_gsb_branch_op/_search";
    },
    magicSearchUrl: function () {
      return settings.reqEsAddrIc() + "bigdata_magic_ic_op/_search";
    },
    xzCompanySearchUrl: function () {
      return settings.reqEsAddr() + "bigdata_business_gsb_tm_company/_search";
    },
    xzDetailSearchUrl: function () {
      return settings.reqEsAddr() + "bigdata_business_gsb_renewals_business/_search";
    },
    byslTmUrl: function () {
      return settings.reqEsAddr() + "bigdata_business_gsb_no_accepted_business/_search";
    },
    byslDetailUrl: function () {
      return settings.reqEsAddr() + "bigdata_business_gsb_no_accepted_business/_search";
    },
    tmSearchUrl: function () {
      return settings.reqEsAddr() + "bigdata_middle_gsb_tm_info/_search";
    },
    tmFlowUrl: function () {
      return settings.reqEsAddr() + "bigdata_middle_gsb_tm_flow/_search";
    },
    tmNclUrl: function () {
      return settings.reqEsAddr() + "bigdata_bdc_ncl_info/_search";
    },
    agencycompanySearchUrl: function () {//代理机构名称查询
      return settings.reqEsAddr() + "bigdata_agency_company/_search";
    },
    yyDetailSearchUrl: function () {//商标异议详情查询
      return settings.reqEsAddr() + "bigdata_business_gsb_dissent_business/_search";
    },
    bgDetailSearchUrl: function () {//商标变更详情查询
      return settings.reqEsAddr() + "bigdata_business_gsb_tm_change_business/_search";
    },
    nclUrl: function () {
      return settings.reqEsAddr() + "bigdata_bdc_gsb_tm_ncl/_search";
    },
    opLogUrl: function () {
      return settings.reqEsAddr() + "bigdata_zc_op_log/_doc?pretty";
    },
    opLogEsIsAdd: function () {
      return 1;
    },
    qcurl: "http://59.110.124.51:8250/qc?detailLink={address}",
    bzLicenseForTMUrl: "http://bigdata.gongsibao.com/api/imghandle/bzLicenseForTM",
    wtsUrl: "http://bigdata.gongsibao.com/api/imghandle/deleForTM",
    adjustTMSizeUrl: "http://bigdata.gongsibao.com/api/imghandle/adjustTMSize",
    onLineMakeTMUrl: "http://bigdata.gongsibao.com/api/imghandle/onLineMakeTM",
    toblackUrl: "https://bigdata.gongsibao.com/api/imghandle/toblack",
    makeDeleForTMUrl: "http://boss.gongsibao.com/api/imghandle/makeDeleForTM",
    LbsAddressUrl: "http://43.247.184.92:8880/lbs/api/addresssearch",//地址查询
    LbsLalUrl: "http://43.247.184.92:8889/lbs/api/lalsearch",//坐标查询
    LbsCityUrl: "http://43.247.184.92:8886/lbs/api/cityseicsoftwareCopyrightSearchUrlarch",//城市查询
    pdf2wordUrl: function () {
      if (settings.env == "dev") {
        return "http://59.110.125.77:3000/api/pdf2word/pdf2word";
      } else {
        return "http://59.110.125.77:3000/api/pdf2word/pdf2word";
      }
    },
    imageQueryUrl: function () {//商标图像检索
      if (settings.env == "dev") {
        return "http://43.247.184.92:8004/gsb/api/v1";
      } else {
        return "http://43.247.184.92:8004/gsb/api/v1";
      }
    },
    tmZntjQueryUrl: function () {//商标智能推荐
      if (settings.env == "dev") {
        return "http://192.168.18.123:8005/companybusiness?appKey=343aff200d18be6637d&name={companyName}";
      } else {
        return "http://43.247.184.92:8005/companybusiness?appKey=343aff200d18be6637d&name={companyName}";
      }
    },
    tmtjdlQueryUrl: function () {//根据经营范围推荐
      if (settings.env == "dev") {
        return "http://192.168.18.181:7000/companynclone?appKey=343aff200d18be6637d&name={companyName}&tmName={tmName}";
      } else {
        return "http://43.247.184.92:8006/companynclone?appKey=343aff200d18be6637d&name={companyName}&tmName={tmName}";
      }
    },
    tmncloneQueryUrl: function () {//计算通过率
      if (settings.env == "dev") {
        return "http://192.168.18.44:7000/tmnclone?appKey=343aff200d18be6637d&nclonecode={nclonecode}&tmName={tmName}";
      } else {
        return "http://43.247.184.92:8007/tmnclone?appKey=343aff200d18be6637d&nclonecode={nclonecode}&tmName={tmName}";
      }
    },
    yunzhanghuApiUrl: function () {//云帐户提现接口url
      return "https://api-jiesuan.yunzhanghu.com/api/payment/v1/order-realtime";
    },
    yunzhanghuCallbackApiUrl: function () {
      //云帐户提现回调接口url
      return "http://bigdata.gongsibao.com/api/banktrade/tradecallback";
    },
    yunzhanghuDealer_id: function () {
      //商户平台ID(dealer_id)——自己
      return "27403253";
    },
    yunzhanghuBroker_id: function () {
      //代征主体ID(broker_id)
      return "27532644";
    },
    yunzhanghuAppKey: function () {
      //云帐户提供的App Key
      return "V5bVuact66Lm55pWKdOTbdQn8XTjP749";
    },
    yunzhanghuDESKey: function () {
      //云帐户提供的3DES Key
      return "2GZeq2YnKtiPJpH9S4K4L7lj";
    },
    yunzhanghuQueryAccountsUrl: function () {//云帐户商户查询余额接口url
      return "https://api-jiesuan.yunzhanghu.com/api/payment/v1/query-accounts";
    },
    yunzhanghuVerifyBankCardUrl: function () {//云帐户验证银行卡的有效性接口url
      return "https://api-jiesuan.yunzhanghu.com/authentication/verify-bankcard-three-factor";
    },
    yunzhanghuTxXz: function () {//云帐户提现限制
      if (settings.env == "dev") {
        return "-1";
      } else {
        return "-1";//不受限制
      }
    },
    bossWithdrawApplyingKey: function () {//提现发放key
      return "3898EFhijklmCDEFGHIJKLMN";
    },
  },

  homePage: function () {
    if (this.env == "dev") {
      var localsettings = require("./localsettings");
      return localsettings.reqHomePageDevUrl;
    } else {
      return "http://boss.gongsibao.com/";
    }
  },
  authUrl: function () {
    if (this.env == "dev") {
      var localsettings = require("./localsettings");
      return localsettings.reqAuthUrl;
    } else {
      return "http://zcchannelweb.gongsibao.com/admin";
    }
  },
  reqMgAddr: function () {
    if (this.env == "dev") {
      var localsettings = require("./localsettings");
      return localsettings.reqMgDevUrl;
    } else {
      return "mongodb://wdy1:123456@43.247.184.94:27017/";
    }
  },
  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超时时间
        },
      };
    }
  }
};
module.exports = settings;
