Commit e0c8aec6 authored by 杨钧's avatar 杨钧

code_review修改

parent 9f68ff79
......@@ -85,9 +85,9 @@ public class OperateLogAspect {
if (jsonObject.containsKey("opState")) {
Integer opStateFlag = jsonObject.getInteger("opState");
if(opStateFlag == 1){
opState = "设置有效";
opState = "添加白名单";
}else{
opState = "设置无效";
opState = "移除白名单";
}
}
......@@ -109,7 +109,11 @@ public class OperateLogAspect {
moduleName = module;
}
moduleName = moduleName.concat(opState);
// 针对特殊情形,需要取不同操作
if(StringUtils.isNotBlank(opState)){
moduleName = opState;
}
log.info("{} 处理结果:{}", logPre, String.valueOf(result));
OpUser opUser = UserThreadLocal.get();
......
......@@ -4,9 +4,7 @@ import cn.quantgroup.customer.config.http.mvc.converter.DateConverter;
import cn.quantgroup.customer.config.http.mvc.converter.IEnumConverterFactory;
import cn.quantgroup.customer.config.http.mvc.converter.LocalDateConverter;
import cn.quantgroup.customer.config.http.mvc.converter.LocalDateTimeConverter;
import cn.quantgroup.customer.config.http.mvc.filter.UserTokenInterceptor;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.MediaType;
......
......@@ -10,4 +10,7 @@ public interface OperateLogRepo extends JpaRepository<OperateLogModel, Long> {
@Query(value = "select * from operate_log where loan_id =?1 ORDER BY id DESC", nativeQuery = true)
List<OperateLogModel> findLogsByLoanId(Long loanId);
@Query(value = "select count(1) from operate_log where loan_id =?1", nativeQuery = true)
Long findLogsCountsByLoanId(Long loanId);
}
......@@ -25,15 +25,15 @@ public class OperateRest {
private IOrderService orderService;
/**
* 提前一次性结清订单白名单配置
* 添加或移除白名单
*
* @param operateEntryParam
* @return
*/
@PostMapping("/setOrCancelEarlySettleUpWhiteLists")
@OperateLog(moduleName = "提前一次性结清白名单操作")
public JsonResult setOrCancelEarlySettleUpEntry(OperateEntryParam operateEntryParam) {
@PostMapping("/set_or_cancel_settleUp_white_list")
@OperateLog(moduleName = "添加或移除白名单")
public JsonResult setOrCancelSettleUpWhiteList(OperateEntryParam operateEntryParam) {
log.info("[结清白名单设置操作],请求参数:operateEntryParam={}", operateEntryParam);
return orderService.operateEntry(operateEntryParam);
return orderService.setOrCancelSettleUpWhiteList(operateEntryParam);
}
}
......@@ -56,7 +56,7 @@ public class OrderRest {
* @param orderQuery
* @return
*/
@GetMapping("/queryEarlySettleUpOrders")
@GetMapping("/query_early_settleUp_order")
public JsonResult queryEarlySettleUpOrders(EarlySettleUpOrderQueryParam orderQuery) {
log.info("[订单提前一次性结清查询],请求参数:orderQuery={}", orderQuery);
return orderService.queryEarlySettleUpOrders(orderQuery);
......@@ -69,7 +69,7 @@ public class OrderRest {
* @param loanId
* @return
*/
@GetMapping("/earlySettleUpTrial/{loanId}")
@GetMapping("/early_settleUp_trial/{loanId}")
public JsonResult earlySettleUpTrial(@PathVariable Long loanId) {
log.info("[提前一次性结清金额试算],请求参数:loanId={}", loanId);
return orderService.earlySettleUpTrial(loanId);
......@@ -81,7 +81,7 @@ public class OrderRest {
* @param loanId
* @return
*/
@GetMapping("/queryOperateLog/{loanId}")
@GetMapping("/query_operateLog/{loanId}")
public JsonResult queryOperateLog(@PathVariable Long loanId) {
log.info("[操作日志查询],请求参数:loanId={}", loanId);
return orderService.queryOperateLog(loanId);
......
......@@ -10,4 +10,6 @@ public interface IOperateLogService {
void saveOperateLog(OperateLogModel logModel);
List<OpLog> findLogsByLoanId(Long loanId);
Long findLogsCountsByLoanId(Long loanId);
}
......@@ -42,12 +42,12 @@ public interface IOrderService{
JsonResult<List<EarlySettleUpOrder>> queryEarlySettleUpOrders(EarlySettleUpOrderQueryParam orderQuery);
/**
* 显示or隐藏操作
* 设置/取消提前结清白名单入口
*
* @param operateEntryParam
* @return
*/
JsonResult<Boolean> operateEntry(OperateEntryParam operateEntryParam);
JsonResult<Boolean> setOrCancelSettleUpWhiteList(OperateEntryParam operateEntryParam);
/**
* 提前一次性结清金额试算
......
......@@ -80,7 +80,7 @@ public interface IXyqbService {
* @param operateEntryParam
* @return
*/
JsonResult<Boolean> operateEntry(OperateEntryParam operateEntryParam);
JsonResult<Boolean> setOrCancelSettleUpWhiteList(OperateEntryParam operateEntryParam);
/**
* 提前一次性结清金额试算
......
......@@ -37,4 +37,9 @@ public class OperateLogServiceImpl implements IOperateLogService {
opLogs.add(JSONObject.parseObject(JSONObject.toJSONString(it), OpLog.class)));
return opLogs;
}
@Override
public Long findLogsCountsByLoanId(Long loanId) {
return operateLogRepo.findLogsCountsByLoanId(loanId);
}
}
......@@ -4,7 +4,6 @@ import cn.quantgroup.customer.constant.Constant;
import cn.quantgroup.customer.entity.OpLog;
import cn.quantgroup.customer.enums.ErrorCodeEnum;
import cn.quantgroup.customer.model.kaordermapping.ApplyRequestHistory;
import cn.quantgroup.customer.model.kaordermapping.ChannelConfigurationResult;
import cn.quantgroup.customer.model.kaordermapping.LoanOrderMapping;
import cn.quantgroup.customer.model.order.*;
import cn.quantgroup.customer.model.xyqbuser.UserBasicInfo;
......@@ -22,7 +21,6 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author Wang Xiangwei
......@@ -43,17 +41,6 @@ public class OrderServiceImpl implements IOrderService {
@Autowired
private IUserService userService;
private static Map<String, String> earlySettleUpFieldMap = new HashMap<>();
static {
earlySettleUpFieldMap.put("principal","应还本金");
earlySettleUpFieldMap.put("interest","应还利息");
earlySettleUpFieldMap.put("serviceFee","应还担保费");
earlySettleUpFieldMap.put("premium","应还保费");
earlySettleUpFieldMap.put("overDueInterest","应还罚息");
earlySettleUpFieldMap.put("liquidatedDamages","结清违约金");
earlySettleUpFieldMap.put("otherFee","应还其他费用");
earlySettleUpFieldMap.put("totalAmount","应还总额");
}
@Override
public JsonResult<List<FlowNode>> findFlowChart(String applyOrderNo) {
......@@ -160,8 +147,6 @@ public class OrderServiceImpl implements IOrderService {
@Override
public JsonResult<List<EarlySettleUpOrder>> queryEarlySettleUpOrders(EarlySettleUpOrderQueryParam orderQuery) {
String logPre = "OrderServiceImpl.queryEarlySettleUpOrders";
if (!existAtLestOneParam(orderQuery)) {
return JsonResult.buildErrorStateResult("至少输入一个请求参数", null);
}
......@@ -173,53 +158,32 @@ public class OrderServiceImpl implements IOrderService {
// 获取用户userId
JsonResult<UserBasicInfo> userInfo = this.queryAndCheckUserInfo(orderQuery);
if (Objects.isNull(userInfo) || !userInfo.isSuccess()) {
if (!userInfo.isSuccess()) {
return JsonResult.buildErrorStateResult("查询不到用户信息", null);
}
// 获取订单loanId
JsonResult<LoanOrderMapping> loanOrder = this.queryAndCheckOrderInfo(orderQuery);
if (Objects.isNull(loanOrder) || !loanOrder.isSuccess()) {
return JsonResult.buildErrorStateResult("查询不到订单信息", null);
}
// 请求xyqb
UserBasicInfo userBasicInfo = userInfo.getData();
LoanOrderMapping loanOrderMapping = loanOrder.getData();
orderQuery.setUserId(userBasicInfo.getUserId());
orderQuery.setLoanId(loanOrderMapping.getLoanId());
JsonResult<List<EarlySettleUpOrder>> xyqbOrderResult = this.xyqbService.findLoanOrder4EarlySettleUp(orderQuery);
if (Objects.isNull(xyqbOrderResult) || !xyqbOrderResult.isSuccess()) {
return JsonResult.buildErrorStateResult("查询订单信息出错", null);
}
/**
* 查询渠道配置信息
*/
JsonResult<List<ChannelConfigurationResult>> channelConfigs = this.kaService.getAllChannelConfiguration();
if (Objects.isNull(channelConfigs) || !channelConfigs.isSuccess()) {
return JsonResult.buildErrorStateResult("查询渠道配置出错", null);
}
List<ChannelConfigurationResult> channelConfigLists = channelConfigs.getData();
Map<Long, List<ChannelConfigurationResult>> configurationResultMap = channelConfigLists.stream().collect(Collectors.groupingBy(ChannelConfigurationResult::getRegisteredFrom));
/**
* 处理数据转换
*/
List<EarlySettleUpOrder> settleUpOrders = xyqbOrderResult.getData();
settleUpOrders.forEach(e -> {
ChannelConfigurationResult configurationResult = null;
if (configurationResultMap.get(e.getChannelId()).size() != 1 ||
(configurationResultMap.get(e.getChannelId()).size() == 1 && Objects.isNull(configurationResult = configurationResultMap.get(e.getChannelId()).get(0)))) {
return;
}
OrderQueryParam orderQueryParam = new OrderQueryParam();
orderQueryParam.setLoanId(e.getLoanId());
JsonResult<LoanOrderMapping> orderMappingJsonResult = this.kaService.findOrderMapping(orderQueryParam);
if (Objects.isNull(orderMappingJsonResult) || !orderMappingJsonResult.isSuccess()) {
log.error("{} 查询渠道订单表数据为空 loanId={}", logPre, e.getLoanId());
return;
}
LoanOrderMapping loanOrderMapping = orderMappingJsonResult.getData();
e.setChannelName(configurationResult.getChannelName());
e.setChannelOrderNo(loanOrderMapping.getChannelOrderNo());
e.setChannelId(configurationResult.getRegisteredFrom());
e.setPhoneNo(userBasicInfo.getPhoneNo());
e.setShowOplog(dealWithShowOplog(e.getLoanId()));
});
......@@ -234,64 +198,82 @@ public class OrderServiceImpl implements IOrderService {
* @return
*/
private Boolean dealWithShowOplog(Long loanId) {
List<OpLog> list = operateLogService.findLogsByLoanId(loanId);
return (Objects.nonNull(list) && list.size() > 0);
return operateLogService.findLogsCountsByLoanId(loanId) > 0;
}
/**
* 查询用户信息
* 查询订单loanId
*
* @param orderQuery
* @return
*/
private JsonResult<LoanOrderMapping> queryAndCheckOrderInfo(EarlySettleUpOrderQueryParam orderQuery) {
String logPre = "OrderServiceImpl.queryAndCheckOrderInfo";
boolean isExistOrderParam = existOrderParam(orderQuery);
if (!isExistOrderParam) {
log.error("{} 查询订单信息,订单相关参数为空 orderQuery={}", logPre, orderQuery);
return JsonResult.buildErrorStateResult("查询订单信息,订单参数为空", null);
}
OrderQueryParam orderQueryParam = new OrderQueryParam();
orderQueryParam.setLoanId(orderQuery.getLoanId());
orderQueryParam.setChannelId(orderQuery.getChannelId());
orderQueryParam.setChannelOrderNo(orderQuery.getChannelOrderNo());
JsonResult<LoanOrderMapping> orderMappingJsonResult = this.kaService.findOrderMapping(orderQueryParam);
if (Objects.isNull(orderMappingJsonResult) || !orderMappingJsonResult.isSuccess()) {
log.error("{} 查询订单失败 result={}", logPre, orderMappingJsonResult);
return JsonResult.buildErrorStateResult("请求参数有误,查询不到订单信息", null);
}
return orderMappingJsonResult;
}
/**
* 查询用户userId
*
* @param orderQuery
* @return
*/
private JsonResult<UserBasicInfo> queryAndCheckUserInfo(EarlySettleUpOrderQueryParam orderQuery) {
String logPre = "OrderServiceImpl.queryAndCheckUserInfo";
// 说明业务参数和用户参数都为空
boolean isExistOrderParam = existOrderParam(orderQuery);
boolean isExistUserParam = existUserParam(orderQuery);
if (!(isExistOrderParam || isExistUserParam)) {
log.error("{} 根据请求参数查询不到用户信息 orderQuery={}", logPre, orderQuery);
return JsonResult.buildErrorStateResult("查询不到用户信息", null);
if (!isExistUserParam) {
log.error("{} 查询用户信息请求参数为空 orderQuery={}", logPre, orderQuery);
return JsonResult.buildErrorStateResult("查询用户信息,用户参数为空", null);
}
JsonResult<UserBasicInfo> userInfoByOrder = null;
// 有订单信息存在,根据订单查询用户userId
if (isExistOrderParam) {
OrderQueryParam orderQueryParam = new OrderQueryParam();
orderQueryParam.setLoanId(orderQuery.getLoanId());
orderQueryParam.setChannelId(orderQuery.getChannelId());
orderQueryParam.setChannelOrderNo(orderQuery.getChannelOrderNo());
userInfoByOrder = this.userService.findUserInfoByOrderParam(orderQueryParam);
if (Objects.isNull(userInfoByOrder) || !userInfoByOrder.isSuccess()) {
log.error("{} 查询用户失败 result={}", logPre, userInfoByOrder);
return userInfoByOrder;
}
//用户参数查询
UserQueryParam userQueryParam = new UserQueryParam();
userQueryParam.setPhoneNo(orderQuery.getPhoneNo());
userQueryParam.setUserId(orderQuery.getUserId());
JsonResult<UserBasicInfo> userInfoByUserParam = this.userService.findUserInfo(userQueryParam);
if (Objects.isNull(userInfoByUserParam) || !userInfoByUserParam.isSuccess()) {
log.error("{} 查询用户失败 result={}", logPre, userInfoByUserParam);
return JsonResult.buildErrorStateResult("请求参数有误,查询不到用户信息", null);
}
JsonResult<UserBasicInfo> userInfoByPhone = null;
if (isExistUserParam) {
//用户参数查询
UserQueryParam userQueryParam = new UserQueryParam();
userQueryParam.setPhoneNo(orderQuery.getPhoneNo());
userQueryParam.setUserId(orderQuery.getUserId());
userInfoByPhone = this.userService.findUserInfo(userQueryParam);
if (Objects.isNull(userInfoByPhone) || !userInfoByPhone.isSuccess()) {
log.error("{} 查询用户失败 result={}", logPre, userInfoByPhone);
return userInfoByPhone;
UserBasicInfo userBasicInfo = userInfoByUserParam.getData();
if (StringUtils.isNotBlank(orderQuery.getPhoneNo())) {
if (!orderQuery.getPhoneNo().equals(userBasicInfo.getPhoneNo())) {
log.error("{} 用户输入手机号和查询结果不一致 orderQuery.getPhoneNo()={}, userBasicInfo={}", logPre, orderQuery.getPhoneNo(), userBasicInfo);
return JsonResult.buildErrorStateResult("请求参数有误,查询不到用户信息", null);
}
}
if (isExistOrderParam && isExistUserParam) {
UserBasicInfo userBasicInfoByOrder = userInfoByOrder.getData();
UserBasicInfo userBasicInfoByUser = userInfoByOrder.getData();
if (userBasicInfoByOrder.getUserId().equals(userBasicInfoByUser.getUserId())) {
return userInfoByOrder;
} else {
return JsonResult.buildErrorStateResult("根据订单信息和用户信息查询的用户不一致", null);
if (Objects.nonNull(orderQuery.getUserId())) {
if (!orderQuery.getUserId().equals(userBasicInfo.getUserId())) {
log.error("{} 用户输入userId和查询结果不一致 orderQuery.getUserId()={}, userBasicInfo={}", logPre, orderQuery.getUserId(), userBasicInfo);
return JsonResult.buildErrorStateResult("请求参数有误,查询不到用户信息", null);
}
} else if (isExistOrderParam) {
return userInfoByOrder;
} else {
return userInfoByPhone;
}
return userInfoByUserParam;
}
/**
......@@ -331,13 +313,13 @@ public class OrderServiceImpl implements IOrderService {
}
@Override
public JsonResult<Boolean> operateEntry(OperateEntryParam operateEntryParam) {
return this.xyqbService.operateEntry(operateEntryParam);
public JsonResult<Boolean> setOrCancelSettleUpWhiteList(OperateEntryParam operateEntryParam) {
return this.xyqbService.setOrCancelSettleUpWhiteList(operateEntryParam);
}
@Override
public JsonResult<List<Map<String, Object>>> earlySettleUpTrial(Long loanId) {
String logPre = "OrderServiceImpl.queryAndCheckUserInfo";
String logPre = "OrderServiceImpl.earlySettleUpTrial";
JsonResult<EarlySettleUpTrial> jsonResult = this.xyqbService.earlySettleUpTrial(loanId);
if (Objects.isNull(jsonResult) || !jsonResult.isSuccess()) {
......@@ -360,13 +342,30 @@ public class OrderServiceImpl implements IOrderService {
JSONObject dataJson = JSONObject.parseObject(JSONObject.toJSONString(data));
Iterator<Map.Entry<String, Object>> iterator = dataJson.entrySet().iterator();
List<Map<String, Object>> dataList = new ArrayList<>();
while (iterator.hasNext()) {
Map.Entry<String, Object> me = iterator.next();
String key = me.getKey();
Object value = me.getValue();
if(Objects.nonNull(value) && new BigDecimal(String.valueOf(value)).compareTo(new BigDecimal(0))>0){
if (Objects.nonNull(value) && new BigDecimal(String.valueOf(value)).compareTo(new BigDecimal(0)) > 0) {
Map<String, Object> fieldDataMap = new HashMap<>(4);
fieldDataMap.put("title", earlySettleUpFieldMap.get(key));
if ("principal".equals(key)) {
fieldDataMap.put("title", "应还本金");
} else if ("interest".equals(key)) {
fieldDataMap.put("title", "应还利息");
} else if ("serviceFee".equals(key)) {
fieldDataMap.put("title", "应还担保费");
} else if ("premium".equals(key)) {
fieldDataMap.put("title", "应还保费");
} else if ("overDueInterest".equals(key)) {
fieldDataMap.put("title", "应还罚息");
} else if ("liquidatedDamages".equals(key)) {
fieldDataMap.put("title", "结清违约金");
} else if ("otherFee".equals(key)) {
fieldDataMap.put("title", "应还其他费用");
} else if ("totalAmount".equals(key)) {
fieldDataMap.put("title", "应还总额");
}
fieldDataMap.put("value", Constant.DECIMAL_FORMAT2.format(value));
dataList.add(fieldDataMap);
}
......
......@@ -395,8 +395,8 @@ public class XyqbServiceImpl implements IXyqbService {
}
@Override
public JsonResult<Boolean> operateEntry(OperateEntryParam operateEntryParam) {
String logPre = "[XyqbServiceImpl.operateEntry] 处理新增或删除白名单操作";
public JsonResult<Boolean> setOrCancelSettleUpWhiteList(OperateEntryParam operateEntryParam) {
String logPre = "[XyqbServiceImpl.setOrCancelSettleUpWhiteList] 处理新增或删除白名单操作";
String url = xyqbSysUrl + "/ex/operate/config/earlysettle/opt_white_list";
Map<String, Object> queryParam = new HashMap<>(8);
if (Objects.isNull(operateEntryParam.getLoanId()) &&
......@@ -415,11 +415,11 @@ public class XyqbServiceImpl implements IXyqbService {
Map<String, String> header = new HashMap<>(2);
header.put("Accept", "application/json");
header.put("Content-Type", "application/x-www-form-urlencoded");
String result = null;
try{
String result;
try {
result = httpService.post(url, header, queryParam);
}catch (Exception e){
log.error("{} 系统异常 e:{}",logPre, ExceptionUtils.getStackTrace(e));
} catch (Exception e) {
log.error("{} 系统异常 e:{}", logPre, ExceptionUtils.getStackTrace(e));
return JsonResult.buildErrorStateResult("[处理失败]", Boolean.FALSE);
}
......
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