Authored by ken.hu

u

@@ -11,6 +11,7 @@ import com.yoho.global.model.constant.ApiCode; @@ -11,6 +11,7 @@ import com.yoho.global.model.constant.ApiCode;
11 import org.apache.commons.lang3.StringUtils; 11 import org.apache.commons.lang3.StringUtils;
12 import org.slf4j.Logger; 12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory; 13 import org.slf4j.LoggerFactory;
  14 +import org.springframework.beans.factory.annotation.Value;
14 import org.springframework.web.client.RestTemplate; 15 import org.springframework.web.client.RestTemplate;
15 16
16 import java.util.HashMap; 17 import java.util.HashMap;
@@ -29,6 +30,9 @@ public class YHRestCaller { @@ -29,6 +30,9 @@ public class YHRestCaller {
29 30
30 private String yhbUrl = "http://api.yoho.cn"; 31 private String yhbUrl = "http://api.yoho.cn";
31 32
  33 + @Value("${erp.gateway.address}")
  34 + private String erpGatewayAddress;
  35 +
32 private String yhbClientType = "web"; 36 private String yhbClientType = "web";
33 37
34 private String yhbClientKey = "0ed29744ed318fd28d2c07985d3ba633"; 38 private String yhbClientKey = "0ed29744ed318fd28d2c07985d3ba633";
@@ -82,13 +86,19 @@ public class YHRestCaller { @@ -82,13 +86,19 @@ public class YHRestCaller {
82 } 86 }
83 // TODO: 2017/11/29 增加临时写死低版本号 87 // TODO: 2017/11/29 增加临时写死低版本号
84 requestParams.put("app_version","6.2.3"); 88 requestParams.put("app_version","6.2.3");
  89 + String sign = getSign(requestParams);
  90 + requestParams.put("client_secret", sign);
  91 +
  92 + ApiResponse apiResp;
85 //not YHMethodContants.APP_PASSPORT_VERIFY 93 //not YHMethodContants.APP_PASSPORT_VERIFY
86 if (!StringUtils.equals(YHMethodContants.APP_PASSPORT_VERIFY,method)){ 94 if (!StringUtils.equals(YHMethodContants.APP_PASSPORT_VERIFY,method)){
  95 + //调用erp-gateway
87 requestParams.put("_sncp", "NGJjYjhkNmwwZGM0OTk0YmQyMTMwZjlmoTZmzjY4cjN"); 96 requestParams.put("_sncp", "NGJjYjhkNmwwZGM0OTk0YmQyMTMwZjlmoTZmzjY4cjN");
  97 + apiResp = get(erpGatewayAddress, requestParams, ApiResponse.class);
  98 + }else {
  99 + //调用gateway
  100 + apiResp = get(yhbUrl, requestParams, ApiResponse.class);
88 } 101 }
89 - String sign = getSign(requestParams);  
90 - requestParams.put("client_secret", sign);  
91 - ApiResponse apiResp = get(yhbUrl, requestParams, ApiResponse.class);  
92 if(apiResp == null || apiResp.getCode() != 200) { 102 if(apiResp == null || apiResp.getCode() != 200) {
93 logger.warn("yhbGetMethod failed, respCode: {}, respMessage: {}, url: {}, requestParams: {}", apiResp.getCode(), apiResp.getMessage(), yhbUrl, requestParams); 103 logger.warn("yhbGetMethod failed, respCode: {}, respMessage: {}, url: {}, requestParams: {}", apiResp.getCode(), apiResp.getMessage(), yhbUrl, requestParams);
94 throw new ServiceException(ServiceError.SYSTEM); 104 throw new ServiceException(ServiceError.SYSTEM);
@@ -33,4 +33,7 @@ redis.pool.testOnBorrow=false @@ -33,4 +33,7 @@ redis.pool.testOnBorrow=false
33 redis.pool.testWhileIdle=true 33 redis.pool.testWhileIdle=true
34 34
35 global.task.host=172.16.6.73 35 global.task.host=172.16.6.73
36 -file.saveDir=d:/upload/  
  36 +file.saveDir=d:/upload/
  37 +
  38 +#erp-gateway
  39 +erp.gateway.address=http://192.168.103.73:8089/erp-gateway
@@ -33,3 +33,6 @@ redis.pool.testWhileIdle=${redis.pool.testWhileIdle} @@ -33,3 +33,6 @@ redis.pool.testWhileIdle=${redis.pool.testWhileIdle}
33 33
34 global.task.host=${global.task.host} 34 global.task.host=${global.task.host}
35 file.saveDir=${file.saveDir} 35 file.saveDir=${file.saveDir}
  36 +
  37 +#erp-gateway
  38 +erp.gateway.address=${erp.gateway.address}