Commit 935a1e78 authored by xiaozhe.chen's avatar xiaozhe.chen

运营系统替换中台接口

parent 8b390cbc
package cn.quantgroup.customer.service;
import cn.quantgroup.customer.model.order.OrderRepayment;
import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery;
import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.service.http.IHttpService;
import cn.quantgroup.customer.util.JSONTools;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
public interface ISidecarService {
JsonResult<OrderRepayment> repaymentPlanQuery(Long loanId);
String queryRepayInfo(RepayOrderInfoQuery repayOrderQuery);
String queryRepayOptRecords(String businessFlowNo);
}
...@@ -41,6 +41,9 @@ public class OrderServiceImpl implements IOrderService { ...@@ -41,6 +41,9 @@ public class OrderServiceImpl implements IOrderService {
@Autowired @Autowired
private IUserService userService; private IUserService userService;
@Autowired
private ISidecarService sidecarService;
@Override @Override
public JsonResult<List<FlowNode>> findFlowChart(String applyOrderNo) { public JsonResult<List<FlowNode>> findFlowChart(String applyOrderNo) {
...@@ -99,7 +102,9 @@ public class OrderServiceImpl implements IOrderService { ...@@ -99,7 +102,9 @@ public class OrderServiceImpl implements IOrderService {
} }
//还款计划查询 //还款计划查询
JsonResult<OrderRepayment> orderRepaymentJsonResult = xyqbService.repaymentPlanQuery(loanId); //JsonResult<OrderRepayment> orderRepaymentJsonResult = xyqbService.repaymentPlanQuery(loanId);
//todo 替换中台接口
JsonResult<OrderRepayment> orderRepaymentJsonResult = sidecarService.repaymentPlanQuery(loanId);
if (!orderRepaymentJsonResult.isSuccess()) { if (!orderRepaymentJsonResult.isSuccess()) {
log.error("{} 还款计划查询失败 result={}", logPre, orderRepaymentJsonResult); log.error("{} 还款计划查询失败 result={}", logPre, orderRepaymentJsonResult);
return JsonResult.buildErrorStateResult(orderRepaymentJsonResult.getMsg(), orderRepaymentJsonResult.getData()); return JsonResult.buildErrorStateResult(orderRepaymentJsonResult.getMsg(), orderRepaymentJsonResult.getData());
......
...@@ -3,16 +3,14 @@ package cn.quantgroup.customer.service.impl; ...@@ -3,16 +3,14 @@ package cn.quantgroup.customer.service.impl;
import cn.quantgroup.customer.constant.Constant; import cn.quantgroup.customer.constant.Constant;
import cn.quantgroup.customer.enums.ErrorCodeEnum; import cn.quantgroup.customer.enums.ErrorCodeEnum;
import cn.quantgroup.customer.exception.BusinessException; import cn.quantgroup.customer.exception.BusinessException;
import cn.quantgroup.customer.model.xyqbuser.UserBasicInfo;
import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam;
import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery; import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery;
import cn.quantgroup.customer.rest.param.repay.RepayOrderQuery; import cn.quantgroup.customer.rest.param.repay.RepayOrderQuery;
import cn.quantgroup.customer.rest.param.user.UserCombinationParam;
import cn.quantgroup.customer.rest.vo.JsonResult; import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.rest.vo.repay.RepayInfoResult; import cn.quantgroup.customer.rest.vo.repay.RepayInfoResult;
import cn.quantgroup.customer.rest.vo.repay.RepayOptRecord; import cn.quantgroup.customer.rest.vo.repay.RepayOptRecord;
import cn.quantgroup.customer.rest.vo.repay.XyqbRepayInfo; import cn.quantgroup.customer.rest.vo.repay.XyqbRepayInfo;
import cn.quantgroup.customer.service.IRepayService; import cn.quantgroup.customer.service.IRepayService;
import cn.quantgroup.customer.service.ISidecarService;
import cn.quantgroup.customer.service.IUserService; import cn.quantgroup.customer.service.IUserService;
import cn.quantgroup.customer.service.IXyqbService; import cn.quantgroup.customer.service.IXyqbService;
import cn.quantgroup.user.retbean.XUser; import cn.quantgroup.user.retbean.XUser;
...@@ -33,12 +31,14 @@ public class RepayServiceImpl implements IRepayService { ...@@ -33,12 +31,14 @@ public class RepayServiceImpl implements IRepayService {
private final IUserService userService; private final IUserService userService;
private final UserSdkImpl userSdk; private final UserSdkImpl userSdk;
private final IXyqbService xyqbService; private final IXyqbService xyqbService;
private final ISidecarService sidecarService;
@Autowired @Autowired
public RepayServiceImpl(IUserService userService, UserSdkImpl userSdk, IXyqbService xyqbService) { public RepayServiceImpl(IUserService userService, UserSdkImpl userSdk, IXyqbService xyqbService, ISidecarService sidecarService) {
this.userService = userService; this.userService = userService;
this.userSdk = userSdk; this.userSdk = userSdk;
this.xyqbService = xyqbService; this.xyqbService = xyqbService;
this.sidecarService = sidecarService;
} }
@Override @Override
...@@ -93,7 +93,9 @@ public class RepayServiceImpl implements IRepayService { ...@@ -93,7 +93,9 @@ public class RepayServiceImpl implements IRepayService {
//处理还款信息 //处理还款信息
String repayInfoStr = xyqbService.queryRepayInfo(repayOrderQuery); //String repayInfoStr = xyqbService.queryRepayInfo(repayOrderQuery);
//todo 替换中台接口
String repayInfoStr = sidecarService.queryRepayInfo(repayOrderQuery);
log.info("[查询xyqb返回还款信息],repayInfoStr={}", repayInfoStr); log.info("[查询xyqb返回还款信息],repayInfoStr={}", repayInfoStr);
if (StringUtils.isBlank(repayInfoStr)) { if (StringUtils.isBlank(repayInfoStr)) {
log.error("[查询xyqb返回还款信息],返回结果为null"); log.error("[查询xyqb返回还款信息],返回结果为null");
...@@ -129,8 +131,10 @@ public class RepayServiceImpl implements IRepayService { ...@@ -129,8 +131,10 @@ public class RepayServiceImpl implements IRepayService {
} }
//发起xyqb查询 //发起xyqb查询
String optRecordsStr = xyqbService.queryRepayOptRecords(businessFlowNo); //String optRecordsStr = xyqbService.queryRepayOptRecords(businessFlowNo);
log.info("[查询xyqb还款操作记录],optRecordsStr={}", optRecordsStr); //todo 替换中台接口
String optRecordsStr = sidecarService.queryRepayOptRecords(businessFlowNo);
log.info("[查询xyqb还款操作记录],optRecordsStr={}", optRecordsStr);
if (StringUtils.isBlank(optRecordsStr)) { if (StringUtils.isBlank(optRecordsStr)) {
log.error("[查询xyqb还款操作记录],返回结果为null"); log.error("[查询xyqb还款操作记录],返回结果为null");
return JsonResult.buildErrorStateResult(ErrorCodeEnum.RETURN_ERROR.getMessage(), ErrorCodeEnum.RETURN_ERROR.getCode()); return JsonResult.buildErrorStateResult(ErrorCodeEnum.RETURN_ERROR.getMessage(), ErrorCodeEnum.RETURN_ERROR.getCode());
......
package cn.quantgroup.customer.service.impl;
import cn.quantgroup.customer.model.order.OrderRepayment;
import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery;
import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.service.ISidecarService;
import cn.quantgroup.customer.service.http.IHttpService;
import cn.quantgroup.customer.util.JSONTools;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Slf4j
@Service("sidecarService")
public class SidecarServiceImpl implements ISidecarService {
@Value("${mo-sidecar.http}")
private String sidecarUrl;
private final IHttpService httpService;
@Autowired
public SidecarServiceImpl(IHttpService httpService) {
this.httpService = httpService;
}
@Override
public JsonResult<OrderRepayment> repaymentPlanQuery(Long loanId) {
String logPre = "sidecarService.repaymentPlanQuery";
log.info("{} 查询还款计划loanId={}", logPre, loanId);
String url = sidecarUrl + "/middle_office/repayment/plan_view";
Map<String, String> queryParam = new HashMap<>(2);
queryParam.put("loanId", loanId.toString());
String result = httpService.get(url, queryParam);
if (StringUtils.isBlank(result)) {
log.error("{} 查询还款计划失败 loanId={} result={}", logPre, loanId, result);
return JsonResult.buildErrorStateResult("查询还款计划失败", null);
} else {
TypeReference<JsonResult<OrderRepayment>> typeToken = new TypeReference<JsonResult<OrderRepayment>>() {
};
JsonResult<OrderRepayment> result1 = JSONTools.deserialize(result, typeToken);
if (result1 != null) {
return result1;
} else {
return JsonResult.buildErrorStateResult("还款计划查询失败", null);
}
}
}
@Override
public String queryRepayInfo(RepayOrderInfoQuery repayOrderQuery) {
String url = sidecarUrl + "/middle_office/repayment/plan_info";
Map<String, Object> param = new HashMap<>(4);
Long loanId = repayOrderQuery.getLoanId();
Integer termNo = repayOrderQuery.getTermNo();
if (Objects.nonNull(loanId)) {
param.put("loanId", loanId);
}
if (Objects.nonNull(termNo)) {
param.put("termNo", termNo);
}
String response = null;
try {
response = httpService.post(url, param);
log.info("[queryRepayInfo] param:{},请求业务系统返回值:{}", param, response);
} catch (Exception e) {
log.error("[queryRepayInfo] param:{},请求业务系统异常:{}", param, e);
}
return response;
}
@Override
public String queryRepayOptRecords(String businessFlowNo) {
String url = sidecarUrl + "/middle_office/repayment/repay_result";
Map<String, Object> param = new HashMap<>(4);
if (StringUtils.isNotBlank(businessFlowNo)) {
param.put("businessFlowNo", businessFlowNo);
}
String response = null;
try {
response = httpService.post(url, param);
log.info("[queryRepayOptRecords] param:{},请求业务系统返回值:{}", param, response);
} catch (Exception e) {
log.error("[queryRepayOptRecords] param:{},请求业务系统异常:{}", param, e);
}
return response;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment