Commit cb3f3acd authored by 王向伟's avatar 王向伟

客服系统自测,修改问题,添加渠道查询接口

parent b3d6b32c
......@@ -3,6 +3,7 @@ package cn.quantgroup.customer.config.http.security;
import cn.quantgroup.customer.config.http.mvc.filter.CsrfHeaderFilter;
import cn.quantgroup.customer.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
......@@ -21,6 +22,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
private final IUserService userService;
private final PasswordEncoder passwordEncoder;
@Value("${allowed.routes}")
private String allowedRoutes;
@Autowired
public WebSecurityConfig(IUserService userService, PasswordEncoder passwordEncoder) {
this.userService = userService;
......@@ -30,8 +33,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
//String allowedRoutes = "/test/**,/error/**,/user/**,/repay/**";
String allowedRoutes = "/test/**,/error/**,/user/login";
//String allowedRoutes = "/test/**,/error/**,/user/login";
String[] allowedRoutesArr = allowedRoutes.split(",");
http.httpBasic().and()
.authorizeRequests()
......
package cn.quantgroup.customer.model.kaordermapping;
import lombok.Data;
/**
* Created by wudi on 2016/11/28.
*/
@Data
public class ChannelConfigurationResult {
private Long id;
private String channelName;
private String channelCode;
private Long registeredFrom;
}
\ No newline at end of file
......@@ -133,8 +133,6 @@ public class Repayment {
}
repayment.setRepaymentStatus(repayStatus);
//还款类型 待确定
repayment.setRepayType(repaymentPlanItem.getRepaymentType());
repayment.setOverdueDays(repaymentPlanItem.getOverdueDays());
return repayment;
......
package cn.quantgroup.customer.rest;
import cn.quantgroup.customer.model.kaordermapping.ChannelConfigurationResult;
import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.service.IKaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 渠道相关
*
* @author Wang Xiangwei
* @version 2020/3/13
*/
@Slf4j
@RestController
@RequestMapping("/channel")
public class ChannelRest {
@Autowired
private IKaService kaService;
@GetMapping("/all")
public JsonResult<List<ChannelConfigurationResult>> getAllChannel() {
JsonResult<List<ChannelConfigurationResult>> allChannelConfiguration = kaService.getAllChannelConfiguration();
return allChannelConfiguration;
}
}
package cn.quantgroup.customer.service;
import cn.quantgroup.customer.model.kaordermapping.ChannelConfigurationResult;
import cn.quantgroup.customer.model.kaordermapping.LoanOrderMapping;
import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam;
import cn.quantgroup.customer.rest.vo.JsonResult;
......@@ -17,9 +18,12 @@ public interface IKaService {
/**
* key 申请订单号 value 渠道订单号
*
* @param applyOrderNos
* @return
*/
JsonResult<Map<String,String>> findMap(List<String> applyOrderNos);
JsonResult<Map<String, String>> findMap(List<String> applyOrderNos);
JsonResult<List<ChannelConfigurationResult>> getAllChannelConfiguration();
}
package cn.quantgroup.customer.service;
import cn.quantgroup.customer.model.xyqbuser.UserBasicInfo;
import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam;
import cn.quantgroup.customer.rest.param.phone.ModifyPhoneAudit;
import cn.quantgroup.customer.rest.param.phone.ModifyPhoneFeedback;
......@@ -24,16 +25,15 @@ public interface IUserService extends UserDetailsService {
/**
* 用户基本信息
*
* @param userQueryParam
* @return
*/
JsonResult findUserInfo(UserQueryParam userQueryParam);
JsonResult<UserBasicInfo> findUserInfo(UserQueryParam userQueryParam);
JsonResult findUserInfoByOrderParam(OrderQueryParam orderQueryParam);
JsonResult<UserBasicInfo> findUserInfoByOrderParam(OrderQueryParam orderQueryParam);
JsonResult findUserCombination(UserCombinationParam userCombinationParam);
}
......@@ -2,11 +2,14 @@ package cn.quantgroup.customer.service.impl;
import cn.quantgroup.customer.enums.ErrorCodeEnum;
import cn.quantgroup.customer.exception.BusinessException;
import cn.quantgroup.customer.model.kaordermapping.ChannelConfigurationResult;
import cn.quantgroup.customer.model.kaordermapping.LoanOrderMapping;
import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam;
import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.service.IKaService;
import cn.quantgroup.customer.service.http.IHttpService;
import cn.quantgroup.customer.util.JSONTools;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
......@@ -21,8 +24,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.StringJoiner;
import static cn.quantgroup.customer.constant.Constant.GSON;
/**
* @author Wang Xiangwei
* @version 2020/3/9
......@@ -32,7 +33,7 @@ import static cn.quantgroup.customer.constant.Constant.GSON;
public class KaServiceImpl implements IKaService {
@Value("${ka.api.http}")
@Value("${qapi.http}")
private String kaSysUrl;
@Autowired
......@@ -51,34 +52,40 @@ public class KaServiceImpl implements IKaService {
String applyOrderNo = orderQueryParam.getApplyOrderNo();
String channelOrderNo = orderQueryParam.getChannelOrderNo();
Long loanId = orderQueryParam.getLoanId();
Long channelId = orderQueryParam.getChannelId();
String url = kaSysUrl + "/external/get/orderMapping";
try {
Map<String, Object> param = Maps.newHashMap();
if (!Objects.isNull(applyOrderNo)) {
if (Objects.nonNull(applyOrderNo)) {
param.put("applyOrderNo", applyOrderNo);
}
if (StringUtils.isNotBlank(channelOrderNo)) {
param.put("channelOrderNo", channelOrderNo);
}
if (!Objects.isNull(loanId)) {
if (Objects.nonNull(channelId)) {
param.put("channelId", channelId);
}
if (Objects.nonNull(loanId)) {
param.put("loanId", loanId);
}
String result = httpService.get(url, param);
String result = null;
try {
result = httpService.get(url, param);
} catch (Exception e) {
log.error(" {}查询orderMapping失败http请求异常 url={},param={}", logPre, url, param, e);
return JsonResult.buildErrorStateResult("通讯异常", null);
}
log.info("{} 请求ka系统返回值:{}", logPre, result);
JsonResult jsonResult = GSON.fromJson(result, JsonResult.class);
if (Objects.isNull(jsonResult) || !jsonResult.isSuccess()) {
log.error("{} 查询orderMapping失败 jsonResult={}", logPre, jsonResult);
if (StringUtils.isBlank(result)) {
log.error("{} 查询orderMapping失败 jsonResult={}", logPre, result);
return JsonResult.buildErrorStateResult("查询orderMapping失败", null);
}
Object data = jsonResult.getData();
LoanOrderMapping loanOrderMapping = GSON.fromJson(data.toString(), LoanOrderMapping.class);
jsonResult.setData(loanOrderMapping);
TypeReference<JsonResult<LoanOrderMapping>> typeToken = new TypeReference<JsonResult<LoanOrderMapping>>() {
};
JsonResult<LoanOrderMapping> jsonResult = JSONTools.deserialize(result, typeToken);
return jsonResult;
......@@ -106,15 +113,49 @@ public class KaServiceImpl implements IKaService {
Map<String, Object> param = Maps.newHashMap();
param.put("applyNos", stringJoiner.toString());
String result = httpService.get(url, param);
String result;
try {
result = httpService.get(url, param);
} catch (Exception e) {
log.error("{} 通过申请订单号获取渠道订单号失败", logPre, e);
return JsonResult.buildErrorStateResult("查询渠道订单号失败", null);
}
log.info("{} 请求ka系统返回值:{}", logPre, result);
JsonResult jsonResult = GSON.fromJson(result, JsonResult.class);
if (Objects.isNull(jsonResult) || !jsonResult.isSuccess()) {
log.error("{} 获得渠道订单号 jsonResult={}", logPre, jsonResult);
if (StringUtils.isBlank(result)) {
log.error("{} 获得渠道订单号 jsonResult={}", logPre, result);
return JsonResult.buildErrorStateResult("获得渠道订单号", null);
}
TypeReference<JsonResult<Map<String, String>>> typeToken = new TypeReference<JsonResult<Map<String, String>>>() {
};
JsonResult<Map<String, String>> jsonResult = JSONTools.deserialize(result, typeToken);
return jsonResult;
}
@Override
public JsonResult<List<ChannelConfigurationResult>> getAllChannelConfiguration() {
String logPre = "KaServiceImpl.getAllChannelConfiguration";
log.info("{},获得所有渠道", logPre);
String url = kaSysUrl + "/external//query/all/channelConfiguration";
String result;
try {
result = httpService.get(url);
} catch (Exception e) {
log.error("{} 获得所有渠道失败", logPre, e);
return JsonResult.buildErrorStateResult("获得所有渠道失败", null);
}
if (StringUtils.isBlank(result)) {
log.error("{} 获得所有渠道 jsonResult={}", logPre, result);
return JsonResult.buildErrorStateResult("获得所有渠道失败", null);
}
TypeReference<JsonResult<List<ChannelConfigurationResult>>> typeToken = new TypeReference<JsonResult<List<ChannelConfigurationResult>>>() {
};
JsonResult<List<ChannelConfigurationResult>> jsonResult = JSONTools.deserialize(result, typeToken);
return jsonResult;
}
}
......@@ -43,11 +43,12 @@ public class OrderServiceImpl implements IOrderService {
JsonResult<List<FlowNode>> flowChart = xyqbService.findFlowChart(applyOrderNo);
if (!flowChart.isSuccess()) {
log.error("{} 流程图查询失败 result={}", logPre, flowChart);
return flowChart;
}
List<FlowNode> flowNodeList = flowChart.getData();
if (!Objects.isNull(head)) {
if (Objects.nonNull(head)) {
FlowNode flowNode = new FlowNode();
flowNode.setName("渠道用户信息导入");
flowNode.setStatus(1);
......@@ -66,8 +67,8 @@ public class OrderServiceImpl implements IOrderService {
JsonResult<LoanOrder> loanOrder = xyqbService.findLoanOrder(loanId);
if (!loanOrder.isSuccess()) {
log.error("{} 提现订单查询失败 loanId={}, result={}",logPre,loanId,loanOrder);
return JsonResult.buildErrorStateResult(loanOrder.getMsg(),loanOrder.getData());
log.error("{} 提现订单查询失败 loanId={}, result={}", logPre, loanId, loanOrder);
return JsonResult.buildErrorStateResult(loanOrder.getMsg(), loanOrder.getData());
}
......@@ -80,13 +81,12 @@ public class OrderServiceImpl implements IOrderService {
List<Repayment> repaymentList = new ArrayList<>();
List<RepaymentPlanItem> repaymentPlans = orderRepaymentJsonResult.getData().getRepaymentPlans();
repaymentPlans.forEach(e->repaymentList.add(Repayment.valueOf(e)));
repaymentPlans.forEach(e -> repaymentList.add(Repayment.valueOf(e)));
LoanOrderDetail loanOrderDetail = new LoanOrderDetail();
loanOrderDetail.setLoanOrder(loanOrder.getData());
loanOrderDetail.setRepaymentList(repaymentList);
return JsonResult.buildSuccessResult("",loanOrderDetail);
return JsonResult.buildSuccessResult("", loanOrderDetail);
}
}
......@@ -24,11 +24,13 @@ import cn.quantgroup.customer.service.IXyqbService;
import cn.quantgroup.customer.service.http.IHttpService;
import cn.quantgroup.customer.util.DateUtil;
import cn.quantgroup.customer.util.IdcardUtils;
import cn.quantgroup.customer.util.JSONTools;
import cn.quantgroup.customer.util.ValidationUtil;
import cn.quantgroup.riskcontrol.model.AuthenticationUserDetail;
import cn.quantgroup.user.retbean.XUserDetail;
import cn.quantgroup.user.retbean.XUserFullInfo;
import cn.quantgroup.user.vo.UserSysResult;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
......@@ -153,11 +155,10 @@ public class UserServiceImpl implements IUserService {
@Override
public JsonResult findUserInfo(UserQueryParam userQueryParam) {
public JsonResult<UserBasicInfo> findUserInfo(UserQueryParam userQueryParam) {
final String LOG_PRE = "UserServiceImpl.findUserInfo";
log.info("{} 查询用户信息 userCombinationParam={}", LOG_PRE, userQueryParam);
//通过userId查询
if (Objects.nonNull(userQueryParam.getUserId())) {
log.info("{} 通过userId查询 userId={}", LOG_PRE, userQueryParam.getUserId());
......@@ -186,7 +187,7 @@ public class UserServiceImpl implements IUserService {
}
//通过身份证号获得
if (Objects.nonNull(userQueryParam.getIdNo())) {
if (StringUtils.isNotBlank(userQueryParam.getIdNo())) {
//通过业务系统获得
log.info("{} 通过phoneNo查询 idNo={}", LOG_PRE, userQueryParam.getIdNo());
return findUserDetailByIdNo(userQueryParam.getIdNo());
......@@ -202,40 +203,47 @@ public class UserServiceImpl implements IUserService {
Map<String, Object> param = Maps.newHashMap();
param.put("idNo", idNo);
String result = httpService.post(url, param);
log.info("[user][findUserDetailByIdNo ] 请求业务系统返回值:{}", result);
JsonResult jsonResult = GSON.fromJson(result, JsonResult.class);
if (!Objects.isNull(jsonResult) && jsonResult.isSuccess()) {
Object data = jsonResult.getData();
if (data instanceof List) {
List list = (List) data;
if (list.size() > 1) {
return JsonResult.buildErrorStateResult("身份证查询返回多条数据,请用其他参数查询", null);
}
if (list.size() == 0) {
return JsonResult.buildErrorStateResult("不存在相关用户信息", null);
}
Object o = list.get(0);
XUserDetail userDetail = GSON.fromJson(o.toString(), XUserDetail.class);
UserBasicInfo userBasicInfo = new UserBasicInfo();
String createAt = DateUtil.format(userDetail.getCreatedAt(), DateUtil.DATE_FORMAT_1);
userBasicInfo.setCreateAt(createAt);
userBasicInfo.setGender(userDetail.getGender().getName());
userBasicInfo.setIdNo(userDetail.getIdNo());
userBasicInfo.setName(userDetail.getName());
userBasicInfo.setPhoneNo(userDetail.getPhoneNo());
userBasicInfo.setStatus(userDetail.getEnable() ? "正常" : "封禁");
return JsonResult.buildSuccessResult(null, userBasicInfo);
}
if (StringUtils.isBlank(result)) {
log.error("UserServiceImpl.findUserDetailByIdNo请求业务系统返回值:{}", result);
return JsonResult.buildErrorStateResult(ErrorCodeEnum.RETURN_ERROR.getMessage(), ErrorCodeEnum.RETURN_ERROR.getCode());
}
TypeReference<JsonResult<List<XUserDetail>>> typeToken = new TypeReference<JsonResult<List<XUserDetail>>>() {
};
JsonResult<List<XUserDetail>> jsonResult = JSONTools.deserialize(result, typeToken);
if (!jsonResult.isSuccess()) {
log.error("UserServiceImpl.findUserDetailByIdNo 查询失败 result={}", jsonResult);
return jsonResult;
}
List<XUserDetail> xUserDetails = jsonResult.getData();
if (xUserDetails.size() > 1) {
return JsonResult.buildErrorStateResult("身份证查询返回多条数据,请用其他参数查询", null);
}
if (xUserDetails.size() == 0) {
return JsonResult.buildErrorStateResult("不存在相关用户信息", null);
}
Object o = xUserDetails.get(0);
XUserDetail userDetail = GSON.fromJson(o.toString(), XUserDetail.class);
UserBasicInfo userBasicInfo = new UserBasicInfo();
String createAt = DateUtil.format(userDetail.getCreatedAt(), DateUtil.DATE_FORMAT_1);
userBasicInfo.setCreateAt(createAt);
userBasicInfo.setGender(userDetail.getGender().getName());
userBasicInfo.setIdNo(userDetail.getIdNo());
userBasicInfo.setName(userDetail.getName());
userBasicInfo.setPhoneNo(userDetail.getPhoneNo());
userBasicInfo.setUserId(userDetail.getUserId());
userBasicInfo.setStatus(userDetail.getEnable() == null ? "未知":(userDetail.getEnable()? "正常" : "封禁"));
return JsonResult.buildSuccessResult(null, userBasicInfo);
} catch (Exception e) {
log.error("[user][findUserDetailByIdNo ] 网络通讯异常,idNo:{},ex:{}", idNo, ExceptionUtils.getStackTrace(e));
throw new BusinessException(ErrorCodeEnum.NET_ERROR);
}
return JsonResult.buildErrorStateResult("查询用户信息错误", null);
}
private JsonResult getUserBasicInfoResult(UserSysResult userSysResult) {
......@@ -249,12 +257,11 @@ public class UserServiceImpl implements IUserService {
userBasicInfo.setIdNo(userDetail.getIdNo());
userBasicInfo.setName(userDetail.getName());
userBasicInfo.setPhoneNo(userDetail.getPhoneNo());
userBasicInfo.setStatus(userDetail.getEnable() ? "正常" : "封禁");
userBasicInfo.setUserId(userDetail.getUserId());
userBasicInfo.setStatus(userDetail.getEnable() == null ? "未知":(userDetail.getEnable()? "正常" : "封禁"));
} else {
return (JsonResult) data;
}
return JsonResult.buildSuccessResult(null, userBasicInfo);
}
......@@ -283,6 +290,7 @@ public class UserServiceImpl implements IUserService {
* @return Tuple<Boolean, String> false 参数验证失败 value失败描述 true表示参数验证成功 value 表示使用哪类参数 1 表示order 2 表示user
*/
private Tuple<Boolean, String> validate(UserCombinationParam userCombinationParam) {
log.info("综合查询参数验证 param={}", userCombinationParam);
Tuple<Boolean, String> result = new Tuple<>();
int userParam = 0;
int orderParam = 0;
......@@ -313,7 +321,7 @@ public class UserServiceImpl implements IUserService {
orderParam++;
}
if (!Objects.isNull(userCombinationParam.getUserId())) {
if (Objects.nonNull(userCombinationParam.getUserId())) {
userParam++;
}
......@@ -340,7 +348,7 @@ public class UserServiceImpl implements IUserService {
return result;
}
//分类参数验证
//分类参数验证 订单参数优先
if (orderParam == 1) {
result.setKey(true);
result.setValue("1");
......@@ -351,8 +359,6 @@ public class UserServiceImpl implements IUserService {
result.setValue("2");
return result;
}
result.setKey(false);
result.setValue("参数过多");
return result;
......@@ -369,8 +375,8 @@ public class UserServiceImpl implements IUserService {
log.error("{},参数验证失败,{}", logPre, tuple.getValue());
return JsonResult.buildErrorStateResult(tuple.getValue(), null);
}
JsonResult<UserBasicInfo> userInfo;
JsonResult<List<ApplyOrder>> applyOrders;
JsonResult userInfo;
if ("1".equals(tuple.getValue())) {
//订单参数查询
OrderQueryParam orderQueryParam = new OrderQueryParam();
......@@ -379,7 +385,11 @@ public class UserServiceImpl implements IUserService {
orderQueryParam.setChannelId(userCombinationParam.getChannelId());
orderQueryParam.setChannelOrderNo(userCombinationParam.getChannelOrderNo());
userInfo = this.findUserInfoByOrderParam(orderQueryParam);
applyOrders = findApplyOrders(orderQueryParam);
if (!userInfo.isSuccess()) {
log.error("{} 查询用户失败 result={}", logPre, userInfo);
return userInfo;
}
applyOrders = this.findApplyOrders(orderQueryParam);
} else {
//用户参数查询
UserQueryParam userQueryParam = new UserQueryParam();
......@@ -388,18 +398,21 @@ public class UserServiceImpl implements IUserService {
userQueryParam.setUserId(userCombinationParam.getUserId());
userQueryParam.setUuid(userCombinationParam.getUuid());
userInfo = this.findUserInfo(userQueryParam);
applyOrders = findApplyOrders(userQueryParam);
if (!userInfo.isSuccess()) {
log.error("{} 查询用户失败 result={}", logPre, userInfo);
return userInfo;
}
userQueryParam.setUserId(userInfo.getData().getUserId());
applyOrders = this.findApplyOrders(userQueryParam);
}
if (!userInfo.isSuccess()) {
return userInfo;
}
if (!applyOrders.isSuccess()) {
log.error("{} 查询申请订单失败 result={}", logPre, applyOrders);
return applyOrders;
}
UserBasicInfo userBasicInfo = (UserBasicInfo) userInfo.getData();
UserBasicInfo userBasicInfo = userInfo.getData();
List<ApplyOrder> applyOrderList = applyOrders.getData();
//通过申请订单号获得渠道订单号
List<String> applyOrderNoList = applyOrderList.stream().map(e -> e.getApplyOrderNo()).distinct().collect(Collectors.toList());
......@@ -421,6 +434,7 @@ public class UserServiceImpl implements IUserService {
//订单信息综合查询
private JsonResult findApplyOrders(OrderQueryParam orderQueryParam) {
String logPre = "UserService.findApplyOrders";
log.info("{} 通过订单参数查询申请订单 orderQueryParam={}", logPre, orderQueryParam);
ApplyOrderQuery applyOrderQuery = new ApplyOrderQuery();
Long loanId = orderQueryParam.getLoanId();
String applyNo = orderQueryParam.getApplyOrderNo();
......@@ -444,7 +458,8 @@ public class UserServiceImpl implements IUserService {
//用户信息综合查询
private JsonResult findApplyOrders(UserQueryParam userQueryParam) {
String logPre = "UserServiceImpl.findApplyOrders";
log.info("{} 通过用户参数查询申请订单 userQueryParam={}", logPre, userQueryParam);
ApplyOrderQuery applyOrderQuery = new ApplyOrderQuery();
applyOrderQuery.setUserId(userQueryParam.getUserId());
//申请订单查询
......@@ -454,9 +469,10 @@ public class UserServiceImpl implements IUserService {
}
@Override
public JsonResult findUserInfoByOrderParam(OrderQueryParam orderQueryParam) {
public JsonResult<UserBasicInfo> findUserInfoByOrderParam(OrderQueryParam orderQueryParam) {
String logPre = "UserServiceImpl.findUserInfoByOrderParam";
log.info("{} 订单参数查询用户信息 orderQueryParam={}", logPre, orderQueryParam);
//渠道订单号需要有渠道号
boolean channelParam = StringUtils.isNotBlank(orderQueryParam.getChannelOrderNo()) && Objects.nonNull(orderQueryParam.getChannelId());
if (Objects.nonNull(orderQueryParam.getLoanId()) ||
......@@ -466,7 +482,7 @@ public class UserServiceImpl implements IUserService {
JsonResult<LoanOrderMapping> orderMapping = kaService.findOrderMapping(orderQueryParam);
if (!orderMapping.isSuccess() || Objects.isNull(orderMapping.getData())) {
log.error("{} 查询orderMapping失败 param={} result={}", logPre, orderQueryParam, orderMapping);
return orderMapping;
return JsonResult.buildErrorStateResult(orderMapping.getMsg(), null);
}
Long qgUserId = orderMapping.getData().getQgUserId();
UserSysResult<XUserDetail> userDetailByUserId = userSdk.getService().findUserDetailByUserId(qgUserId);
......@@ -480,4 +496,6 @@ public class UserServiceImpl implements IUserService {
}
return JsonResult.buildErrorStateResult("参数全部为空", null);
}
}
package cn.quantgroup.customer.service.impl;
import cn.quantgroup.customer.model.order.*;
import cn.quantgroup.customer.model.order.ApplyOrder;
import cn.quantgroup.customer.model.order.FlowNode;
import cn.quantgroup.customer.model.order.LoanOrder;
import cn.quantgroup.customer.model.order.OrderRepayment;
import cn.quantgroup.customer.rest.param.applyorder.ApplyOrderQuery;
import cn.quantgroup.customer.rest.param.card.ModifyReservePhone;
import cn.quantgroup.customer.rest.param.card.UnBindCardModel;
......@@ -18,9 +21,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.*;
import static cn.quantgroup.customer.constant.Constant.GSON;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Slf4j
@Service("xyqbService")
......@@ -29,8 +33,14 @@ public class XyqbServiceImpl implements IXyqbService {
@Value("${api.http}")
private String xyqbSysUrl;
@Value("${clotho.api.http}")
private String clothoSysUrl;
private final IHttpService httpService;
@Autowired
public XyqbServiceImpl(IHttpService httpService) {
this.httpService = httpService;
......@@ -61,31 +71,29 @@ public class XyqbServiceImpl implements IXyqbService {
String orderNo = applyOrderQuery.getOrderNo();
Long loanId = applyOrderQuery.getLoanId();
Long userId = applyOrderQuery.getUserId();
String url = xyqbSysUrl + "/ex/inside/customer_sys/query/applyOrder";
String url = clothoSysUrl + "/ex/customer_sys/query/applyOrder";
Map<String, Object> param = Maps.newHashMap();
if (StringUtils.isNotEmpty(orderNo)) {
param.put("orderNo", orderNo);
}
if (Objects.nonNull(userId)) {
param.put("userId", userId);
param.put("userId", userId.toString());
}
if (Objects.nonNull(loanId)) {
param.put("loanId", loanId);
param.put("loanId", loanId.toString());
}
Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/x-www-form-urlencoded");
JsonResult jsonResult = httpService.post(url, header, param, JsonResult.class);
if (Objects.isNull(jsonResult) || jsonResult.isSuccess()) {
log.error("{} 调用信用钱包失败 url={}, header={},param={},result={}", logPre, url, header, param, jsonResult);
header.put("Content-Type", "application/x-www-form-urlencoded");
String result = httpService.post(url, header, param);
if (StringUtils.isBlank(result)) {
log.error("{} 调用信用钱包失败 url={}, header={},param={},result={}", logPre, url, header, param, result);
return JsonResult.buildErrorStateResult("申请订单查询失败", null);
}
List<ApplyOrder> applyOrderList = new ArrayList<>();
List list = (List) jsonResult.getData();
list.forEach(e -> {
ApplyOrder applyOrder = GSON.fromJson(e.toString(), ApplyOrder.class);
applyOrderList.add(applyOrder);
});
jsonResult.setData(applyOrderList);
TypeReference<JsonResult<List<ApplyOrder>>> typeToken = new TypeReference<JsonResult<List<ApplyOrder>>>() {
};
JsonResult<List<ApplyOrder>> jsonResult = JSONTools.deserialize(result, typeToken);
return jsonResult;
}
......@@ -93,7 +101,7 @@ public class XyqbServiceImpl implements IXyqbService {
public JsonResult<List<FlowNode>> findFlowChart(String orderNo) {
String logPre = "XyqbServiceImpl.findFlowChart";
log.info("{} 流程日志查询 orderNo={}", logPre, orderNo);
String url = xyqbSysUrl + "/ex/inside/customer_sys/query/applyOrder";
String url = xyqbSysUrl + "/excustomer_sys/query/flow";
if (StringUtils.isEmpty(orderNo)) {
log.error("{} 申请订单号为空 orderNo={}", logPre, orderNo);
return JsonResult.buildErrorStateResult("申请订单号为空", null);
......@@ -102,20 +110,22 @@ public class XyqbServiceImpl implements IXyqbService {
param.put("orderNo", orderNo);
Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/x-www-form-urlencoded");
JsonResult jsonResult = httpService.post(url, header, param, JsonResult.class);
header.put("Content-Type", "application/x-www-form-urlencoded");
String result = null;
try {
result = httpService.post(url, header, param);
} catch (Exception e) {
log.error("{} 通讯异常 url={},param={}", logPre, url, param, e);
return JsonResult.buildErrorStateResult("通讯异常", null);
}
if (Objects.isNull(jsonResult) || !jsonResult.isSuccess()) {
log.error("{} 调用信用钱包失败 url={}, header={},param={},result={}", logPre, url, header, param, jsonResult);
if (StringUtils.isBlank(result)) {
log.error("{} 调用信用钱包失败 url={}, header={},param={},result={}", logPre, url, header, param, result);
return JsonResult.buildErrorStateResult("流程日志查询失败", null);
}
List data = (List) jsonResult.getData();
List<FlowNode> flowNodeList = new ArrayList<>();
data.forEach(e -> {
flowNodeList.add(GSON.fromJson(e.toString(), FlowNode.class));
});
jsonResult.setData(flowNodeList);
TypeReference<JsonResult<List<FlowNode>>> typeToken = new TypeReference<JsonResult<List<FlowNode>>>() {
};
JsonResult<List<FlowNode>> jsonResult = JSONTools.deserialize(result, typeToken);
return jsonResult;
}
......@@ -124,17 +134,23 @@ public class XyqbServiceImpl implements IXyqbService {
public JsonResult<LoanOrder> findLoanOrder(Long loanId) {
String logPre = "XyqbServiceImpl.findLoanOrder";
log.info("{} 提现订单详情 loanId={}", logPre, loanId);
String url = xyqbSysUrl + "/ex/inside/customer_sys/loan/detail";
String url = clothoSysUrl + "/ex/customer_sys/loan/detail";
if (Objects.isNull(loanId)) {
log.error("{} 借款订单号为空 orderNo={}", logPre, loanId);
return JsonResult.buildErrorStateResult("借款订单号为空", null);
}
Map<String, Object> param = Maps.newHashMap();
param.put("loanId", loanId);
param.put("loanId", loanId.toString());
Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/x-www-form-urlencoded");
String result = httpService.post(url, header, param);
header.put("Content-Type", "application/x-www-form-urlencoded");
String result = null;
try {
result = httpService.post(url, header, param);
} catch (Exception e) {
log.error("{} 远程调用异常 url={},param={}", logPre, url, param,e);
return JsonResult.buildErrorStateResult("网络异常", null);
}
if (StringUtils.isBlank(result)) {
log.error("{} 调用信用钱包失败 url={}, header={},param={},result={}", logPre, url, header, param, result);
......@@ -163,8 +179,8 @@ public class XyqbServiceImpl implements IXyqbService {
TypeReference<JsonResult<OrderRepayment>> typeToken = new TypeReference<JsonResult<OrderRepayment>>() {
};
JsonResult<OrderRepayment> result1 = JSONTools.deserialize(result, typeToken);
if (result1 != null && result1.isSuccess()) {
return JsonResult.buildSuccessResult("", result1);
if (result1 != null ) {
return result1;
} else {
return JsonResult.buildErrorStateResult("还款计划查询失败", null);
}
......@@ -180,7 +196,7 @@ public class XyqbServiceImpl implements IXyqbService {
*/
@Override
public String queryCardLists(Long userId) {
String url = xyqbSysUrl + "/ex/inside/customer_sys/query/bankcard";
String url = xyqbSysUrl + "/ex/customer_sys/query/bankcard";
Map<String, Object> param = new HashMap<>(4);
if (Objects.nonNull(userId)) {
param.put("userId", userId);
......@@ -197,7 +213,7 @@ public class XyqbServiceImpl implements IXyqbService {
@Override
public String queryCardRelation(Long bankId) {
String url = xyqbSysUrl + "/ex/inside/customer_sys/query/cardrelation";
String url = xyqbSysUrl + "/ex/customer_sys/query/cardrelation";
Map<String, Object> param = new HashMap<>(4);
if (Objects.nonNull(bankId)) {
param.put("bankId", bankId);
......@@ -215,7 +231,7 @@ public class XyqbServiceImpl implements IXyqbService {
@Override
public String unBindCardRelation(UnBindCardModel unBindCardModel) {
String url = xyqbSysUrl + "/ex/inside/customer_sys/unbundle/relation";
String url = xyqbSysUrl + "/ex/customer_sys/unbundle/relation";
Map<String, Object> param = new HashMap<>(4);
Long userId = unBindCardModel.getUserId();
Long bindCardRecordId = unBindCardModel.getBindCardRecordId();
......@@ -237,7 +253,7 @@ public class XyqbServiceImpl implements IXyqbService {
@Override
public String modifyReservePhone(ModifyReservePhone modifyReservePhone) {
String url = xyqbSysUrl + "/ex/inside/customer_sys/modify/reservedphone";
String url = xyqbSysUrl + "/ex/customer_sys/modify/reservedphone";
Map<String, Object> param = new HashMap<>(8);
Long userId = modifyReservePhone.getUserId();
Long bankId = modifyReservePhone.getBankId();
......@@ -264,7 +280,7 @@ public class XyqbServiceImpl implements IXyqbService {
@Override
public String queryRepayInfo(RepayOrderInfoQuery repayOrderQuery) {
String url = xyqbSysUrl + "/ex/inside/customer_sys/query/repayment";
String url = xyqbSysUrl + "/ex/customer_sys/query/repayment";
Map<String, Object> param = new HashMap<>(4);
Long loanId = repayOrderQuery.getLoanId();
Integer termNo = repayOrderQuery.getTermNo();
......@@ -287,7 +303,7 @@ public class XyqbServiceImpl implements IXyqbService {
@Override
public String queryRepayOptRecords(String businessFlowNo) {
String url = xyqbSysUrl + "/ex/inside/customer_sys/repayment/detail";
String url = xyqbSysUrl + "/ex/customer_sys/repayment/detail";
Map<String, Object> param = new HashMap<>(4);
if (StringUtils.isNotBlank(businessFlowNo)) {
param.put("businessFlowNo", businessFlowNo);
......
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