Commit 671b3602 authored by 杨钧's avatar 杨钧

review修改代码

parent aef1c054
...@@ -13,7 +13,7 @@ import java.util.Objects; ...@@ -13,7 +13,7 @@ import java.util.Objects;
* @Update * @Update
*/ */
@Data @Data
public class CallbackRecord { public class CallBackRecordVo {
/** /**
* 通知类型 * 通知类型
*/ */
...@@ -26,42 +26,8 @@ public class CallbackRecord { ...@@ -26,42 +26,8 @@ public class CallbackRecord {
* 期数 * 期数
*/ */
private Long termNo; private Long termNo;
/**
* 通知时间
*/
private Long dateTime;
/** /**
* 通知时间 YYYY-MM-dd HH:mm:ss * 通知时间 YYYY-MM-dd HH:mm:ss
*/ */
private String createAt; private String createAt;
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (Objects.isNull(obj)) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
CallbackRecord other = (CallbackRecord) obj;
if (StringUtils.isBlank(other.getNoticeType())) {
return false;
} else {
if(!this.getNoticeType().equals(other.getNoticeType())){
return false;
}else {
if(Objects.isNull(other.getTermNo())){
return true;
}else{
if(!this.getTermNo().equals(other.getTermNo())){
return false;
}
return true;
}
}
}
}
} }
package cn.quantgroup.customer.model.order;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author yangjun
* @Date 2020/3/24 13:11
* @Desc
* @Update
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CallbackRecordList {
private List<CallBackRecordVo> orderStatusNotices;
private List<CallBackRecordVo> repaymentNotices;
}
...@@ -5,8 +5,6 @@ import lombok.Builder; ...@@ -5,8 +5,6 @@ import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List;
/** /**
* @author yangjun * @author yangjun
* @Date 2020/3/20 16:27 * @Date 2020/3/20 16:27
...@@ -18,6 +16,6 @@ import java.util.List; ...@@ -18,6 +16,6 @@ import java.util.List;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class OrderInfoVo { public class OrderInfoVo {
private List<CallbackRecord> noticeList; private CallbackRecordList noticeList;
private OrderInfo orderInfo; private OrderInfo orderInfo;
} }
...@@ -3,7 +3,7 @@ package cn.quantgroup.customer.service; ...@@ -3,7 +3,7 @@ package cn.quantgroup.customer.service;
import cn.quantgroup.customer.model.kaordermapping.ApplyRequestHistory; import cn.quantgroup.customer.model.kaordermapping.ApplyRequestHistory;
import cn.quantgroup.customer.model.kaordermapping.ChannelConfigurationResult; import cn.quantgroup.customer.model.kaordermapping.ChannelConfigurationResult;
import cn.quantgroup.customer.model.kaordermapping.LoanOrderMapping; import cn.quantgroup.customer.model.kaordermapping.LoanOrderMapping;
import cn.quantgroup.customer.model.order.CallbackRecord; import cn.quantgroup.customer.model.order.CallbackRecordList;
import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam; import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam;
import cn.quantgroup.customer.rest.vo.JsonResult; import cn.quantgroup.customer.rest.vo.JsonResult;
...@@ -33,10 +33,9 @@ public interface IKaService { ...@@ -33,10 +33,9 @@ public interface IKaService {
* *
* @param applyNo 申请单号 * @param applyNo 申请单号
* @param channelId 渠道号 * @param channelId 渠道号
* @param aTrue true 成功 false 失败
* @return * @return
*/ */
JsonResult<List<CallbackRecord>> querySendRecords(String applyNo, Long channelId, Boolean aTrue); JsonResult<CallbackRecordList> querySendRecords(String applyNo, Long channelId);
/** /**
* 查询最新渠道进件请求流水 * 查询最新渠道进件请求流水
......
...@@ -2,6 +2,8 @@ package cn.quantgroup.customer.service; ...@@ -2,6 +2,8 @@ package cn.quantgroup.customer.service;
import cn.quantgroup.customer.model.order.FlowNode; import cn.quantgroup.customer.model.order.FlowNode;
import cn.quantgroup.customer.model.order.LoanOrderDetail; import cn.quantgroup.customer.model.order.LoanOrderDetail;
import cn.quantgroup.customer.model.order.OrderInfo;
import cn.quantgroup.customer.model.order.OrderInfoVo;
import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam; import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam;
import cn.quantgroup.customer.rest.vo.JsonResult; import cn.quantgroup.customer.rest.vo.JsonResult;
...@@ -28,5 +30,5 @@ public interface IOrderService{ ...@@ -28,5 +30,5 @@ public interface IOrderService{
* @param orderQuery * @param orderQuery
* @return * @return
*/ */
JsonResult queryOrderInfo(OrderQueryParam orderQuery); JsonResult<OrderInfoVo> queryOrderInfo(OrderQueryParam orderQuery);
} }
...@@ -5,7 +5,7 @@ import cn.quantgroup.customer.exception.BusinessException; ...@@ -5,7 +5,7 @@ import cn.quantgroup.customer.exception.BusinessException;
import cn.quantgroup.customer.model.kaordermapping.ApplyRequestHistory; import cn.quantgroup.customer.model.kaordermapping.ApplyRequestHistory;
import cn.quantgroup.customer.model.kaordermapping.ChannelConfigurationResult; import cn.quantgroup.customer.model.kaordermapping.ChannelConfigurationResult;
import cn.quantgroup.customer.model.kaordermapping.LoanOrderMapping; import cn.quantgroup.customer.model.kaordermapping.LoanOrderMapping;
import cn.quantgroup.customer.model.order.CallbackRecord; import cn.quantgroup.customer.model.order.CallbackRecordList;
import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam; import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam;
import cn.quantgroup.customer.rest.vo.JsonResult; import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.service.IKaService; import cn.quantgroup.customer.service.IKaService;
...@@ -163,9 +163,9 @@ public class KaServiceImpl implements IKaService { ...@@ -163,9 +163,9 @@ public class KaServiceImpl implements IKaService {
@Override @Override
public JsonResult<List<CallbackRecord>> querySendRecords(String applyNo, Long channelId, Boolean isSucc) { public JsonResult<CallbackRecordList> querySendRecords(String applyNo, Long channelId) {
String logPre = "[KaServiceImpl.querySendRecords] 查询发送通知记录"; String logPre = "[KaServiceImpl.querySendRecords] 查询发送通知记录";
log.info("{}, applyNo={},channelId={},isSucc={}", logPre, applyNo, channelId, isSucc); log.info("{}, applyNo={},channelId={}", logPre, applyNo, channelId);
String url = kaSysUrl + "/external/query/orderCallBack"; String url = kaSysUrl + "/external/query/orderCallBack";
try { try {
...@@ -178,27 +178,24 @@ public class KaServiceImpl implements IKaService { ...@@ -178,27 +178,24 @@ public class KaServiceImpl implements IKaService {
param.put("channelId", String.valueOf(channelId)); param.put("channelId", String.valueOf(channelId));
} }
param.put("isSucc", isSucc);
String result; String result;
try { try {
result = httpService.get(url, param); result = httpService.get(url, param);
} catch (Exception e) { } catch (Exception e) {
log.error(" {} http请求异常 url={},param={}", logPre, url, param, e); log.error(" {} http请求异常 url={},param={}", logPre, url, param, e);
return JsonResult.buildErrorStateResult("通讯异常", null); return JsonResult.buildErrorStateResult(ErrorCodeEnum.NET_ERROR.getMessage(), null);
} }
log.info("{} 请求ka系统返回值:{}", logPre, result); log.info("{} 请求ka系统返回值:{}", logPre, result);
if (StringUtils.isBlank(result)) { if (StringUtils.isBlank(result)) {
log.error("{} 返回结果为空,查询失败 jsonResult={}", logPre, result); log.error("{} 返回结果为空,查询失败 jsonResult={}", logPre, result);
return JsonResult.buildErrorStateResult("查询数据异常", null); return JsonResult.buildErrorStateResult(ErrorCodeEnum.RETURN_ERROR.getMessage(), null);
} }
TypeReference<JsonResult<List<CallbackRecord>>> typeToken = new TypeReference<JsonResult<List<CallbackRecord>>>() { TypeReference<JsonResult<CallbackRecordList>> typeToken = new TypeReference<JsonResult<CallbackRecordList>>() {
}; };
JsonResult<List<CallbackRecord>> jsonResult = JSONTools.deserialize(result, typeToken); return JSONTools.deserialize(result, typeToken);
return jsonResult;
} catch (Exception e) { } catch (Exception e) {
log.error("{} 网络通讯异常,applyNo={},channelId={},isSucc={},ex:{}", applyNo, channelId, isSucc, ExceptionUtils.getStackTrace(e)); log.error("{} 网络通讯异常,applyNo={},channelId={},ex:{}", applyNo, channelId, ExceptionUtils.getStackTrace(e));
throw new BusinessException(ErrorCodeEnum.NET_ERROR); throw new BusinessException(ErrorCodeEnum.NET_ERROR);
} }
} }
...@@ -225,13 +222,13 @@ public class KaServiceImpl implements IKaService { ...@@ -225,13 +222,13 @@ public class KaServiceImpl implements IKaService {
result = httpService.get(url, param); result = httpService.get(url, param);
} catch (Exception e) { } catch (Exception e) {
log.error(" {} http请求异常 url={},param={}", logPre, url, param, e); log.error(" {} http请求异常 url={},param={}", logPre, url, param, e);
return JsonResult.buildErrorStateResult("通讯异常", null); return JsonResult.buildErrorStateResult(ErrorCodeEnum.NET_ERROR.getMessage(), null);
} }
log.info("{} 请求ka系统返回值:{}", logPre, result); log.info("{} 请求ka系统返回值:{}", logPre, result);
if (StringUtils.isBlank(result)) { if (StringUtils.isBlank(result)) {
log.error("{} 返回结果为空,查询失败 jsonResult={}", logPre, result); log.error("{} 返回结果为空,查询失败 jsonResult={}", logPre, result);
return JsonResult.buildErrorStateResult("查询数据异常", null); return JsonResult.buildErrorStateResult(ErrorCodeEnum.RETURN_ERROR.getMessage(), null);
} }
TypeReference<JsonResult<ApplyRequestHistory>> typeToken = new TypeReference<JsonResult<ApplyRequestHistory>>() { TypeReference<JsonResult<ApplyRequestHistory>> typeToken = new TypeReference<JsonResult<ApplyRequestHistory>>() {
}; };
......
package cn.quantgroup.customer.service.impl; package cn.quantgroup.customer.service.impl;
import cn.quantgroup.customer.enums.ErrorCodeEnum; import cn.quantgroup.customer.enums.ErrorCodeEnum;
import cn.quantgroup.customer.model.Tuple;
import cn.quantgroup.customer.model.kaordermapping.ApplyRequestHistory; import cn.quantgroup.customer.model.kaordermapping.ApplyRequestHistory;
import cn.quantgroup.customer.model.kaordermapping.LoanOrderMapping; import cn.quantgroup.customer.model.kaordermapping.LoanOrderMapping;
import cn.quantgroup.customer.model.order.*; import cn.quantgroup.customer.model.order.*;
...@@ -102,12 +101,15 @@ public class OrderServiceImpl implements IOrderService { ...@@ -102,12 +101,15 @@ public class OrderServiceImpl implements IOrderService {
} }
@Override @Override
public JsonResult queryOrderInfo(OrderQueryParam orderQuery) { public JsonResult<OrderInfoVo> queryOrderInfo(OrderQueryParam orderQuery) {
String logPre = "OrderServiceImpl.queryOrderInfo"; String logPre = "OrderServiceImpl.queryOrderInfo 查询渠道订单信息";
Tuple<Boolean, String> tuple = validate(orderQuery); if (Objects.isNull(orderQuery)
if (!tuple.getKey()) { || (StringUtils.isBlank(orderQuery.getApplyOrderNo())
log.error("{},参数验证失败,{}", logPre, tuple.getValue()); && StringUtils.isBlank(orderQuery.getApplyOrderNo())
return JsonResult.buildErrorStateResult(tuple.getValue(), null); && Objects.isNull(orderQuery.getLoanId())
&& Objects.isNull(orderQuery.getChannelId()))) {
log.error("{} 请求参数为空 orderQuery={}", logPre, orderQuery);
return JsonResult.buildErrorStateResult(ErrorCodeEnum.PARAM_ERROR.getMessage(), ErrorCodeEnum.PARAM_ERROR.getCode());
} }
// 查询订单信息 查询ka // 查询订单信息 查询ka
...@@ -139,7 +141,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -139,7 +141,7 @@ public class OrderServiceImpl implements IOrderService {
* @param channelId * @param channelId
* @return * @return
*/ */
private JsonResult buildNoOrderMapping(String channelOrderNo, Long channelId) { private JsonResult<OrderInfoVo> buildNoOrderMapping(String channelOrderNo, Long channelId) {
String logPre = "OrderServiceImpl.buildNoOrderMapping"; String logPre = "OrderServiceImpl.buildNoOrderMapping";
// 查询进件流水信息 查询ka // 查询进件流水信息 查询ka
JsonResult<ApplyRequestHistory> orderMappingResult = kaService.queryLatestChannelRequestFlows(channelOrderNo, channelId); JsonResult<ApplyRequestHistory> orderMappingResult = kaService.queryLatestChannelRequestFlows(channelOrderNo, channelId);
...@@ -154,18 +156,15 @@ public class OrderServiceImpl implements IOrderService { ...@@ -154,18 +156,15 @@ public class OrderServiceImpl implements IOrderService {
return JsonResult.buildSuccessResult("订单不存在", null); return JsonResult.buildSuccessResult("订单不存在", null);
} }
// 存在进件流水,进件失败
final String statusStr = "进件失败";
OrderInfo orderInfo = OrderInfo.builder() OrderInfo orderInfo = OrderInfo.builder()
.channelOrderNo(channelOrderNo) .channelOrderNo(channelOrderNo)
.channelId(channelId) .channelId(channelId)
.status(statusStr) .status(applyRequestHistory.getIsSuccess() ? "进件成功" : "进件失败")
.remark(applyRequestHistory.getDescriptionDetail()) .remark(applyRequestHistory.getDescriptionDetail())
.build(); .build();
OrderInfoVo orderInfoVo = OrderInfoVo.builder() OrderInfoVo orderInfoVo = OrderInfoVo.builder()
.orderInfo(orderInfo) .orderInfo(orderInfo)
.noticeList(Collections.emptyList())
.build(); .build();
log.info("{} 查询订单信息,返回信息 orderInfoVo={}", logPre, orderInfoVo); log.info("{} 查询订单信息,返回信息 orderInfoVo={}", logPre, orderInfoVo);
return JsonResult.buildSuccessResult("处理成功", orderInfoVo); return JsonResult.buildSuccessResult("处理成功", orderInfoVo);
...@@ -178,7 +177,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -178,7 +177,7 @@ public class OrderServiceImpl implements IOrderService {
* @param loanOrderMapping * @param loanOrderMapping
* @return * @return
*/ */
private JsonResult buildHasOrderMapping(OrderQueryParam orderQuery, LoanOrderMapping loanOrderMapping) { private JsonResult<OrderInfoVo> buildHasOrderMapping(OrderQueryParam orderQuery, LoanOrderMapping loanOrderMapping) {
String logPre = "OrderServiceImpl.buildHasOrderMapping"; String logPre = "OrderServiceImpl.buildHasOrderMapping";
// 查询订单状态 xyqb // 查询订单状态 xyqb
...@@ -195,7 +194,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -195,7 +194,7 @@ public class OrderServiceImpl implements IOrderService {
orderStatus = orderStatusResult.getData(); orderStatus = orderStatusResult.getData();
// 查询通知记录 查询ka // 查询通知记录 查询ka
JsonResult<List<CallbackRecord>> callbackListResult = queryOrderCallback(orderQuery); JsonResult<CallbackRecordList> callbackListResult = kaService.querySendRecords(loanOrderMapping.getApplyNo(), loanOrderMapping.getRegisteredFrom());
if (!callbackListResult.isSuccess()) { if (!callbackListResult.isSuccess()) {
log.error("{} 查询发送记录失败 result={} orderQuery={}", logPre, callbackListResult, orderQuery); log.error("{} 查询发送记录失败 result={} orderQuery={}", logPre, callbackListResult, orderQuery);
return JsonResult.buildErrorStateResult("查询通知记录失败", ErrorCodeEnum.RETURN_ERROR.getCode()); return JsonResult.buildErrorStateResult("查询通知记录失败", ErrorCodeEnum.RETURN_ERROR.getCode());
...@@ -219,69 +218,4 @@ public class OrderServiceImpl implements IOrderService { ...@@ -219,69 +218,4 @@ public class OrderServiceImpl implements IOrderService {
log.info("{} 查询订单信息,返回信息 orderInfoVo={}", logPre, orderInfoVo); log.info("{} 查询订单信息,返回信息 orderInfoVo={}", logPre, orderInfoVo);
return JsonResult.buildSuccessResult("处理成功", orderInfoVo); return JsonResult.buildSuccessResult("处理成功", orderInfoVo);
} }
private Tuple<Boolean, String> validate(OrderQueryParam orderQuery) {
Tuple<Boolean, String> result = new Tuple<>();
result.setKey(false);
if (Objects.isNull(orderQuery)) {
result.setValue("请求参数为空");
return result;
}
if (StringUtils.isBlank(orderQuery.getApplyOrderNo())
&& StringUtils.isBlank(orderQuery.getApplyOrderNo())
&& Objects.isNull(orderQuery.getLoanId())
&& Objects.isNull(orderQuery.getChannelId())) {
result.setValue("请求参数为空");
return result;
}
result.setKey(true);
return result;
}
/**
* 处理Ka通知记录
*
* @param orderQuery
* @return
*/
private JsonResult<List<CallbackRecord>> queryOrderCallback(OrderQueryParam orderQuery) {
String logPre = "OrderServiceImpl.queryOrderCallback 处理Ka通知记录 ";
log.info("{} 请求信息 orderQuery :{}", logPre, orderQuery);
String applyNo = orderQuery.getApplyOrderNo();
Long channelId = orderQuery.getChannelId();
//查询发送成功记录
JsonResult<List<CallbackRecord>> sendSuccRecordResult = kaService.querySendRecords(applyNo, channelId, Boolean.TRUE);
if (!sendSuccRecordResult.isSuccess()) {
log.error("{} 查询发送成功记录失败 orderQuery :{},sendSuccRecordResult:{}", logPre, orderQuery, sendSuccRecordResult);
return sendSuccRecordResult;
}
//查询发送失败记录
JsonResult<List<CallbackRecord>> sendFailRecordResult = kaService.querySendRecords(applyNo, channelId, Boolean.FALSE);
if (!sendFailRecordResult.isSuccess()) {
log.error("{} 查询发送失败记录失败 orderQuery :{},sendFailRecordResult:{}", logPre, orderQuery, sendFailRecordResult);
return sendFailRecordResult;
}
//聚合信息
List<CallbackRecord> callbackRecords = doMergeLists(sendSuccRecordResult.getData(), sendFailRecordResult.getData());
return JsonResult.buildSuccessResult("查询成功", callbackRecords);
}
private List<CallbackRecord> doMergeLists(List<CallbackRecord> data, List<CallbackRecord> data1) {
data1.forEach(callbackRecord -> {
if (!data.contains(callbackRecord)) {
data.add(callbackRecord);
}
});
List<CallbackRecord> callbackRecords1 = data.stream().sorted(Comparator.comparing(CallbackRecord::getDateTime)).collect(Collectors.toList());
callbackRecords1.forEach(callbackRecord ->
{
callbackRecord.setCreateAt(DateUtil.format(DateUtil.getByLongTimes(callbackRecord.getDateTime()), DateUtil.DATE_FORMAT_1));
callbackRecord.setDateTime(null);
}
);
return callbackRecords1;
}
} }
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