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.IGIRL_DB_NAME,
  REDIS_DB:process.env.IGIRL_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",
  },
  //知圈圈进度推送平台
  wxopenplatformconfig:{
    appid: 'wxf63dd7b6d8081fc0',
    appsecret:'751e025f35e3871d14cbaf1e108a6a00',
    encodingaeskey: 'wxopigirl20190725chuangzhihoudedfhjlhswdfvg',
    checktoken: 'wxop20190725',
    domainname:"igirl.gongsibao.com",
  },
  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/";
    }
  },
  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: {
    zxyTransferAppId: function () {//智薪云应用id
      // return "1103817785";//线上
      // return "1108171693022142467";//bpo-ceshi
      return "1129284115540267010";
    },
    zxyTransferMchtId: function () {//智薪云商户id
      // return "1103817785420820481";//线上
      // return "2";//bpo-ceshi
      return "1127840460046393345";
    },
    zxyMainId: function () {//智薪云用户签约mainId ==签约主体id
      // return "57731585";//线上
      // return "3";//bpo-ceshi
      return "57731587";
    },
    zxyAppSecretKey: function () {//智薪云appSecretKey
      // return "ca47edd3ae8bac3f7a68d8126d891f52";//线上
      // return "ef1cd7146c1234d47f6bb4e49edfe";//bpo-ceshi
      return "ea4eafab8be1d0242399f39649bfabe0";
    },
    zxyUserSignUrl: function () {//智薪云用户签约接口地址
      return "https://payadmin.gongsibao.com";//线上
      // return "http://39.106.185.66:80";
    },
    zxyTransferUrl: function () {//智薪云转账接口地址
      return "https://pay.gongsibao.com";//线上
      // return "http://39.106.185.66:80";
    },
    imageQueryKey: "4S3ypgaRq19bhKwB",
    opLogUrl: function () {
      return settings.reqEsAddr() + "bigdata_zc_op_log/_doc?pretty";
    },
    opLogEsIsAdd: function () {
      return 1;
    },
    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";
    },
    opTmTransactionUrl: function () {//商标交易添加
      return settings.reqEsAddr() + "bigdata_trademark_transaction/_doc?pretty";
    },
    tmTransactionUrl: function () {//商标交易检索
      return settings.reqEsAddr() + "bigdata_trademark_transaction/_search";
    },
    tmTransactionUpdateUrl: function () {//商标交易检索更新
      return settings.reqEsAddr() + "bigdata_trademark_transaction/_doc/_update_by_query";
    },
    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";
    },
    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";
      }
    },
    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}";
      }

    },

    ichemingUrl: function () {//工商核名接口
      if (settings.env == "dev") {
        return "http://43.247.184.92:8100/heming/";
      } else {
        return "http://43.247.184.92:8100/heming/";
      }
    },

    // imageQueryKey:"4S3ypgaRq19bhKwB",
    MgphoneSearchUrl: function () {
      return settings.reqMgAddr() + "phones"
    },
    xzAllCompanySearchUrl: function () {
      return settings.reqEsAddr() + "bigdata_business_gsb_tm_company_op/_search";
    },

    //作品版权
    icworksCopyrightSearchUrl: function () {
      return settings.reqEsAddrIc() + "bigdata_works_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";
    },
    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",
    uploadStandardTmUrl: "https://bigdata.gongsibao.com/api/imghandle/uploadStandardTm",
    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";
      }
    },

    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}";
      }
    },
  },
  reqEsDevUrl: "http://192.168.4.249:9200/",
  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超时时间
        },
      };
 
    }
  }
};
settings.ENVINPUT=ENVINPUT;
module.exports = settings;
