|
@@ -1,19 +1,23 @@
|
|
|
package com.hrsk.cloud.eg.domain.api.channel.customized.threedocking.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.google.common.base.Function;
|
|
|
import com.hrsk.cloud.eg.client.dto.plan.command.EgLoanApiConfigInfoCmd;
|
|
|
import com.hrsk.cloud.eg.client.dto.plan.command.PlanCmd;
|
|
|
import com.hrsk.cloud.eg.client.dto.user.command.UserBaseInfoCmd;
|
|
|
-import com.hrsk.cloud.eg.clinet.vo.DataVo;
|
|
|
-import com.hrsk.cloud.eg.infrastructure.config.client.HessianUtils;
|
|
|
-import com.hrsk.cloud.eg.infrastructure.loanMannager.threedocking.LoanDockingApi;
|
|
|
-import com.hrsk.cloud.eg.infrastructure.service.EgApiService;
|
|
|
-import com.hrsk.cloud.eg.infrastructure.utils.Md5Util;
|
|
|
+
|
|
|
+import com.hrsk.cloud.eg.client.vo.DataVo;
|
|
|
+import com.hrsk.cloud.eg.domain.api.channel.customized.common.ServerCodeEnums;
|
|
|
+import com.hrsk.cloud.eg.domain.api.channel.customized.threedocking.LoanDockingApi;
|
|
|
+import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequest;
|
|
|
+import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequestConfig;
|
|
|
+import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiResponse;
|
|
|
+import com.hrsk.cloud.eg.domain.common.HessianUtils;
|
|
|
+import com.hrsk.cloud.eg.domain.common.Md5Util;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
import javax.crypto.Cipher;
|
|
|
import javax.crypto.SecretKey;
|
|
|
import javax.crypto.spec.IvParameterSpec;
|
|
@@ -29,11 +33,7 @@ import java.util.Base64;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class ChengHongHuiCreditService implements LoanDockingApi {
|
|
|
- @Resource
|
|
|
- private EgApiService egApiService;
|
|
|
|
|
|
- @Resource
|
|
|
- private RetryRestTemplate httpRestTemplate;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -78,10 +78,10 @@ public class ChengHongHuiCreditService implements LoanDockingApi {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public DataVo qualityCheck(UserBaseInfoCmd userInfo, PlanCmd product, EgLoanApiConfigInfoCmd configInfo) {
|
|
|
+ public DataVo qualityCheck(UserBaseInfoCmd userInfo, PlanCmd product, EgLoanApiConfigInfoCmd configInfo, Function<HttpApiRequest, HttpApiResponse> httpClientFunc) {
|
|
|
try {
|
|
|
// log.info("credit ChengHongHuiCreditService qualityCheck begin...userId:{}", userInfo.getUserId());
|
|
|
-
|
|
|
+
|
|
|
byte[] requestConfig = configInfo.getRequestConfig();
|
|
|
Object deserialize = HessianUtils.deserialize(requestConfig);
|
|
|
JSONObject config = JSONObject.parseObject(deserialize.toString());
|
|
@@ -89,18 +89,18 @@ public class ChengHongHuiCreditService implements LoanDockingApi {
|
|
|
CheckInfo checkInfo = new CheckInfo();
|
|
|
checkInfo.setTel((userInfo.getUserMobileMD5() == null ? Md5Util.encoderByMd5(userInfo.getUserMobile()) : userInfo.getUserMobileMD5()));
|
|
|
String url = config.getString("checkUrl");
|
|
|
- log.info("credit qualityCheck ChengHongHuiCreditService request userId:{}, url:{}, CheckInfo:{}", userInfo.getUserId(), url, checkInfo);
|
|
|
- String response = null;
|
|
|
+ HttpApiResponse response = null;
|
|
|
try {
|
|
|
- response =httpRestTemplate.restTemplate().postForObject(url,checkInfo, String.class);
|
|
|
- } catch (Exception e) {
|
|
|
+ HttpApiRequest request=new HttpApiRequest(HttpApiRequestConfig.postRequest(JSON.toJSONString(checkInfo),"post",url));
|
|
|
+ response =httpClientFunc.apply(request);
|
|
|
+ } catch (Exception e) {
|
|
|
log.error("晨宏汇准入异常,异常信息:{}", e.getMessage(), e);
|
|
|
}
|
|
|
log.info("credit qualityCheck ChengHongHuiCreditService response userId:{}, result:{}", userInfo.getUserId(), response);
|
|
|
if (response == null) {
|
|
|
return DataVo.timeout(product.getPlanId(),product.getPlanName());
|
|
|
}
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(response);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(response.getData().toString());
|
|
|
// log.info("credit qualityCheck ChengHongHuiCreditService response userId:{}, jsonObject:{}", userInfo.getUserId(), jsonObject);
|
|
|
if (jsonObject == null) {
|
|
|
return DataVo.timeout(product.getPlanId(), product.getPlanName());
|