Commit 9eeb4613 authored by Java-陈 晓哲's avatar Java-陈 晓哲

Merge branch 'features/order-iteration-20200418' into 'master'

客服系统  一次性结清白名单需求

See merge request !3
parents d7b471d0 09a953d3
...@@ -2,10 +2,12 @@ package cn.quantgroup.customer; ...@@ -2,10 +2,12 @@ package cn.quantgroup.customer;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
@Configuration @Configuration
@ServletComponentScan
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
@SpringBootApplication(scanBasePackages = {"cn.quantgroup.customer"}) @SpringBootApplication(scanBasePackages = {"cn.quantgroup.customer"})
public class Bootstrap { public class Bootstrap {
......
package cn.quantgroup.customer.aop;
import java.lang.annotation.*;
/**
* @author yangjun
* @Date 2020/4/14 13:28
* @Desc
* @Update
*/
@Documented
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface OperateLog {
String moduleName() default "";
}
package cn.quantgroup.customer.aop;
import cn.quantgroup.customer.config.container.UserThreadLocal;
import cn.quantgroup.customer.constant.Constant;
import cn.quantgroup.customer.entity.OpUser;
import cn.quantgroup.customer.entity.OperateLogModel;
import cn.quantgroup.customer.service.IOperateLogService;
import cn.quantgroup.customer.util.DateUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.util.Objects;
/**
* @author yangjun
* @Date 2020/4/14 13:33
* @Desc
* @Update
*/
@Aspect
@Component
@Slf4j
public class OperateLogAspect {
@Autowired
private IOperateLogService operateLogService;
@Pointcut("@annotation(cn.quantgroup.customer.aop.OperateLog)")
public void operateLog() {
}
@Around(value = "operateLog()")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
String logPre = "OperateLogAspect.around";
log.info("{} 进入切面", logPre);
Object[] args = pjp.getArgs();
log.info("{} 请求参数 {}", logPre, args);
Object result = pjp.proceed(args);
log.info("{} 请求参数 {},返回结果 {} ", logPre, args, result);
addOperateLog(pjp, result);
return result;
}
private void addOperateLog(ProceedingJoinPoint pjp, Object result) {
String logPre = "OperateLogAspect.addOperateLog";
Object[] args = pjp.getArgs();
StringBuffer reqStrBuffer = new StringBuffer();
Long loanId = null;
String applyNo = null;
String remark = null;
String opState = "";
for (Object obj : args) {
reqStrBuffer.append(String.valueOf(obj));
try {
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(obj));
if (Objects.nonNull(jsonObject)) {
if (jsonObject.containsKey("loanId")) {
loanId = jsonObject.getLong("loanId");
}
if (jsonObject.containsKey("applyNo")) {
applyNo = jsonObject.getString("applyNo");
}
if (jsonObject.containsKey("remark")) {
remark = jsonObject.getString("remark");
}
if (jsonObject.containsKey("remark")) {
remark = jsonObject.getString("remark");
}
if (jsonObject.containsKey("opState")) {
Integer opStateFlag = jsonObject.getInteger("opState");
if(opStateFlag == 1){
opState = "添加白名单";
}else{
opState = "移除白名单";
}
}
}
} catch (Exception e) {
log.warn("{} obj={} 转化json失败", logPre, obj);
}
}
MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
Method method = methodSignature.getMethod();
OperateLog operateLog = method.getAnnotation(OperateLog.class);
log.info("{} 获得注解 operateLog={}", logPre, operateLog);
String className = pjp.getTarget().getClass().getName().substring(pjp.getTarget().getClass().getName().lastIndexOf(".") + 1);
String methodName = method.getName();
String moduleName = operateLog.moduleName();
String module = className.concat("|").concat(methodName);
if (StringUtils.isBlank(moduleName)) {
// 类名 + 方法签名为 moduleName
moduleName = module;
}
// 针对特殊情形,需要取不同操作
if(StringUtils.isNotBlank(opState)){
moduleName = opState;
}
log.info("{} 处理结果:{}", logPre, String.valueOf(result));
JSONObject resultJson = JSONObject.parseObject(JSONObject.toJSONString(result));
int status = 0;
if(resultJson.containsKey("code") && Constant.SUCCESS_CODE.equals(resultJson.getString("code"))){
status = 1;
}
OpUser opUser = UserThreadLocal.get();
OperateLogModel model = OperateLogModel.builder()
.userName(opUser.getName())
.userNo(opUser.getUser())
.module(module)
.moduleName(moduleName)
.request(reqStrBuffer.toString())
.response(String.valueOf(result))
.createdAt(DateUtil.getCurrentTimestamp())
.loanId(loanId)
.applyNo(applyNo)
.remark(remark)
.status(status)
.build();
operateLogService.saveOperateLog(model);
// 防止内存泄漏
UserThreadLocal.remove();
}
}
package cn.quantgroup.customer.config.container;
import cn.quantgroup.customer.entity.OpUser;
/**
* @author yangjun
* @Date 2020/4/16 10:46
* @Desc
* @Update
*/
public class UserThreadLocal {
private static ThreadLocal<OpUser> userThread =
new ThreadLocal<OpUser>();
public static void set(OpUser user){
userThread.set(user);
}
public static OpUser get(){
return userThread.get();
}
//防止内存泄漏
public static void remove(){
userThread.remove();
}
}
...@@ -32,6 +32,7 @@ public class WebMvcConfigure extends WebMvcConfigurerAdapter { ...@@ -32,6 +32,7 @@ public class WebMvcConfigure extends WebMvcConfigurerAdapter {
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
} }
...@@ -42,4 +43,6 @@ public class WebMvcConfigure extends WebMvcConfigurerAdapter { ...@@ -42,4 +43,6 @@ public class WebMvcConfigure extends WebMvcConfigurerAdapter {
registry.addConverter(new LocalDateTimeConverter("yyyy-MM-dd HH:mm:ss.SSS")); registry.addConverter(new LocalDateTimeConverter("yyyy-MM-dd HH:mm:ss.SSS"));
registry.addConverter(new DateConverter()); registry.addConverter(new DateConverter());
} }
} }
package cn.quantgroup.customer.config.http.mvc.filter;
import cn.quantgroup.customer.config.container.UserThreadLocal;
import cn.quantgroup.customer.entity.OpUser;
import cn.quantgroup.customer.enums.ErrorCodeEnum;
import cn.quantgroup.customer.exception.ValidTokenException;
import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.service.IOpSystemService;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Objects;
/**
* @author yangjun
* @Date 2020/4/17 16:02
* @Desc 鉴权过滤器
* @Update
*/
@WebFilter(filterName = "operatePermitFilter",urlPatterns = {"/operate/sys/*"})
@Slf4j
public class ValidOperatePermitFilter implements Filter {
@Autowired
private IOpSystemService IOpSystemService;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
if (HttpMethod.OPTIONS.toString().equals(request.getMethod())) {
log.info("OPTIONS请求,放行");
return;
}
String token = request.getHeader("x-auth-token");
//String system = request.getHeader("x-auth-system");
if (StringUtils.isBlank(token)) {
log.error("根据token信息查询用户信息,当前 requestUrl={}",request.getRequestURL());
renderErrorMsg(servletResponse,ErrorCodeEnum.NO_TOKEN);
return;
}
JsonResult<OpUser> opUserResult = IOpSystemService.findUserByToken(token, null);
if (Objects.isNull(opUserResult) || !opUserResult.isSuccess()) {
log.error("根据token查询不到用户信息 token:{}", token);
renderErrorMsg(servletResponse,ErrorCodeEnum.ILLEGAL_TOKEN);
return;
} else {
OpUser opUser = opUserResult.getData();
UserThreadLocal.set(opUser);
}
//执行
filterChain.doFilter(servletRequest, servletResponse);
}
/**
* 处理返回json格式数据
* @param servletResponse
* @param codeEnum
*/
private void renderErrorMsg(ServletResponse servletResponse, ErrorCodeEnum codeEnum) {
servletResponse.setCharacterEncoding("utf-8");
PrintWriter out = null;
JSONObject jsonObject = new JSONObject();
jsonObject.put("code",codeEnum.getCode());
jsonObject.put("msg",codeEnum.getMessage());
try {
out = servletResponse.getWriter();
servletResponse.setContentType("application/json; charset=utf-8");
out.print(jsonObject);
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
log.error("处理转换信息异常:{}",e.getMessage());
}
}
@Override
public void destroy() {
}
}
...@@ -3,6 +3,8 @@ package cn.quantgroup.customer.constant; ...@@ -3,6 +3,8 @@ package cn.quantgroup.customer.constant;
import com.google.gson.Gson; import com.google.gson.Gson;
import java.text.DecimalFormat;
public interface Constant { public interface Constant {
String HTTP = "http"; String HTTP = "http";
...@@ -19,6 +21,8 @@ public interface Constant { ...@@ -19,6 +21,8 @@ public interface Constant {
String SUCCESS_CODE = "0000"; String SUCCESS_CODE = "0000";
DecimalFormat DECIMAL_FORMAT2 = new DecimalFormat("#####0.00");
Gson GSON = new Gson(); Gson GSON = new Gson();
} }
package cn.quantgroup.customer.entity;
import lombok.Data;
import java.sql.Timestamp;
/**
* @author yangjun
* @Date 2020/4/16 17:12
* @Desc
* @Update
*/
@Data
public class OpLog {
private String userNo;
private String userName;
private Timestamp createdAt;
private String remark;
private Long loanId;
private String moduleName;
}
package cn.quantgroup.customer.entity;
import lombok.Data;
/**
* @author yangjun
* @Date 2020/4/16 10:01
* @Desc
* @Update
*/
@Data
public class OpUser {
private String user;
private String name;
}
package cn.quantgroup.customer.entity;
import lombok.*;
import javax.persistence.*;
import java.sql.Timestamp;
/**
* @author yangjun
* @Date 2020/4/13 17:37
* @Desc
* @Update
*/
@Entity
@Table(name = "operate_log")
@ToString
@Builder
@Getter
@Setter
@AllArgsConstructor
public class OperateLogModel {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_no")
private String userNo;
@Column(name = "user_name")
private String userName;
@Column(name = "module")
private String module;
@Column(name = "module_name")
private String moduleName;
@Column(name = "request")
private String request;
@Column(name = "response")
private String response;
@Column(name = "loan_id")
private Long loanId;
@Column(name = "apply_no")
private String applyNo;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "remark")
private String remark;
@Column(name = "status")
private Integer status;
public OperateLogModel() {
}
}
...@@ -5,7 +5,9 @@ public enum ErrorCodeEnum { ...@@ -5,7 +5,9 @@ public enum ErrorCodeEnum {
NET_ERROR(6001L, "网络通讯异常"), NET_ERROR(6001L, "网络通讯异常"),
RETURN_ERROR(7001L, "返回值异常"), RETURN_ERROR(7001L, "返回值异常"),
PARAM_ERROR(7002L, "参数异常"); PARAM_ERROR(7002L, "参数异常"),
NO_TOKEN(8001L,"缺少token信息"),
ILLEGAL_TOKEN(8002L,"token信息有误");
public String getMessage() { public String getMessage() {
......
package cn.quantgroup.customer.exception;
import cn.quantgroup.customer.enums.ErrorCodeEnum;
import lombok.Getter;
import org.springframework.stereotype.Component;
/**
* @author Jony
* @Date 2020/4/20 15:07
* @Desc
* @Update
*/
@Getter
@Component
public class ValidTokenException extends RuntimeException{
private Long code;
private String message;
public ValidTokenException() {
}
public ValidTokenException(String message, Long code) {
super(message);
this.code = code;
}
public ValidTokenException(ErrorCodeEnum errorCodeEnum) {
this.code = errorCodeEnum.getCode();
this.message = errorCodeEnum.getMessage();
}
}
package cn.quantgroup.customer.model.order;
import lombok.Data;
/**
* 有效申请订单
*
* @author Wang Xiangwei
* @version 2020/3/9
*/
@Data
public class ActiveApplyOrder {
/**
* 序号
*/
private Long num;
private String channelOrderNo;
private Long userId;
private String applyOrderNo;
private String applyStatus;
private String applyAt;
private String productDesc;
private String channelName;
private Long loanId;
private Boolean showBtn;
private String loanStatus;
private String amount;
private String paidAt;
private String termRepayment;
private String updateAt;
private String remark;
}
...@@ -2,37 +2,22 @@ package cn.quantgroup.customer.model.order; ...@@ -2,37 +2,22 @@ package cn.quantgroup.customer.model.order;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/** /**
* 申请订单 * 申请订单
*
* @author Wang Xiangwei * @author Wang Xiangwei
* @version 2020/3/9 * @version 2020/4/23
*/ */
@Data @Data
public class ApplyOrder { public class ApplyOrder {
private List<ActiveApplyOrder> activeOrders = new ArrayList<>();
private List<ActiveApplyOrder> invalidOrders = new ArrayList<>();
/** /**
* 序号 * 近期状况
*/ */
private Long num; private String description;
private String channelOrderNo;
private String channelNo;
private Long userId;
private String applyOrderNo;
private String applyStatus;
private String applyAt;
private String productDesc;
private String channelName;
private Long loanId;
private Boolean showBtn;
} }
package cn.quantgroup.customer.model.order;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author yangjun
* @Date 2020/4/13 17:37
* @Desc
* @Update
*/
@Data
public class EarlySettleUpOrder {
private Long loanId;
private String phoneNo;
private BigDecimal loanAmount;
private String fundOrder;
private Long fundCorpId;
private String fundName;
private String channelOrderNo;
private Long channelId;
private String channelName;
private Integer termSum;
private Integer noRepayTerm;
private Integer showAllRepay;
private Boolean showTrial;
private Boolean showOplog;
private Long userId;
}
package cn.quantgroup.customer.model.order;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author yangjun
* @Date 2020/4/13 17:37
* @Desc
* @Update
*/
@Data
public class EarlySettleUpTrial {
private BigDecimal principal;
private BigDecimal interest;
private BigDecimal overDueInterest;
private BigDecimal premium;
private BigDecimal liquidatedDamages;
private BigDecimal serviceFee;
private BigDecimal otherFee;
private BigDecimal totalAmount;
}
package cn.quantgroup.customer.model.order;
import lombok.Data;
/**
* 申请订单
*
* @author Wang Xiangwei
* @version 2020/3/9
*/
@Data
public class InvalidApplyOrder {
private String applyAt;
private Long userId;
private String applyStatus;
private String channelName;
private String productDesc;
private String amount;
private String applyOrderNo;
private String remark;
private String updatedAt;
private String channelNo;
}
package cn.quantgroup.customer.model.order; package cn.quantgroup.customer.model.order;
import cn.quantgroup.customer.util.MoneySerializer;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
/** /**
* @author Wang Xiangwei * @author Wang Xiangwei
...@@ -48,21 +52,25 @@ public class LoanOrder { ...@@ -48,21 +52,25 @@ public class LoanOrder {
/** /**
* 担保费 * 担保费
*/ */
@JsonSerialize(using = MoneySerializer.class)
private BigDecimal guaranteeFee; private BigDecimal guaranteeFee;
/** /**
* 其他费用 * 其他费用
*/ */
@JsonSerialize(using = MoneySerializer.class)
private BigDecimal otherFee; private BigDecimal otherFee;
/** /**
* 一次性服务费 * 一次性服务费
*/ */
@JsonSerialize(using = MoneySerializer.class)
private BigDecimal onceServiceFee; private BigDecimal onceServiceFee;
/** /**
* 月利率 * 月利率
*/ */
@JsonSerialize(using = MoneySerializer.class)
private BigDecimal monthlyInterestRate; private BigDecimal monthlyInterestRate;
/** /**
...@@ -94,4 +102,7 @@ public class LoanOrder { ...@@ -94,4 +102,7 @@ public class LoanOrder {
* 是否展示还款计划 * 是否展示还款计划
*/ */
private Boolean showPlans; private Boolean showPlans;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date paidAt;
} }
...@@ -2,6 +2,8 @@ package cn.quantgroup.customer.model.order; ...@@ -2,6 +2,8 @@ package cn.quantgroup.customer.model.order;
import cn.quantgroup.customer.enums.UserRepayType; import cn.quantgroup.customer.enums.UserRepayType;
import cn.quantgroup.customer.util.DateUtil; import cn.quantgroup.customer.util.DateUtil;
import cn.quantgroup.customer.util.MoneySerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -24,42 +26,50 @@ public class Repayment { ...@@ -24,42 +26,50 @@ public class Repayment {
/** /**
* 本金 * 本金
*/ */
@JsonSerialize(using = MoneySerializer.class)
private BigDecimal principal; private BigDecimal principal;
/** /**
* 利息 * 利息
*/ */
@JsonSerialize(using = MoneySerializer.class)
private BigDecimal interest; private BigDecimal interest;
/** /**
* 担保费 * 担保费
*/ */
@JsonSerialize(using = MoneySerializer.class)
private BigDecimal serviceFee; private BigDecimal serviceFee;
/** /**
* 其他担保 * 其他担保
*/ */
@JsonSerialize(using = MoneySerializer.class)
private BigDecimal otherFee; private BigDecimal otherFee;
/** /**
* 罚息 * 罚息
*/ */
@JsonSerialize(using = MoneySerializer.class)
private BigDecimal overdueInterest; private BigDecimal overdueInterest;
/** /**
* 当前减免 * 当前减免
*/ */
@JsonSerialize(using = MoneySerializer.class)
private BigDecimal reliefAmount; private BigDecimal reliefAmount;
/** /**
* 还款总额 * 还款总额
*/ */
@JsonSerialize(using = MoneySerializer.class)
private BigDecimal repayAmount; private BigDecimal repayAmount;
/** /**
* 应还总额 * 应还总额
*/ */
@JsonSerialize(using = MoneySerializer.class)
private BigDecimal requiredRepayment; private BigDecimal requiredRepayment;
/** /**
......
package cn.quantgroup.customer.model.xyqbuser; package cn.quantgroup.customer.model.xyqbuser;
import cn.quantgroup.customer.model.order.ActiveApplyOrder;
import cn.quantgroup.customer.model.order.ApplyOrder; import cn.quantgroup.customer.model.order.ApplyOrder;
import lombok.Data; import lombok.Data;
...@@ -13,7 +14,7 @@ import java.util.List; ...@@ -13,7 +14,7 @@ import java.util.List;
public class UserCombination { public class UserCombination {
private UserBasicInfo userInfo; private UserBasicInfo userInfo;
private List<ApplyOrder> applyOrderList; private ApplyOrder applyOrder;
} }
package cn.quantgroup.customer.repo;
import cn.quantgroup.customer.entity.OperateLogModel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface OperateLogRepo extends JpaRepository<OperateLogModel, Long> {
@Query(value = "select * from operate_log where loan_id =?1 and status = 1 ORDER BY created_at ASC", nativeQuery = true)
List<OperateLogModel> findLogsByLoanId(Long loanId);
@Query(value = "select count(1) from operate_log where loan_id =?1 and status = 1", nativeQuery = true)
Long findLogsCountsByLoanId(Long loanId);
}
...@@ -2,6 +2,7 @@ package cn.quantgroup.customer.rest; ...@@ -2,6 +2,7 @@ package cn.quantgroup.customer.rest;
import cn.quantgroup.customer.constant.Constant; import cn.quantgroup.customer.constant.Constant;
import cn.quantgroup.customer.exception.BusinessException; import cn.quantgroup.customer.exception.BusinessException;
import cn.quantgroup.customer.exception.ValidTokenException;
import cn.quantgroup.customer.rest.vo.JsonResult; import cn.quantgroup.customer.rest.vo.JsonResult;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -31,4 +32,13 @@ public class AdviceRest { ...@@ -31,4 +32,13 @@ public class AdviceRest {
} }
@ExceptionHandler({ValidTokenException.class})
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public JsonResult handleTokenException(ValidTokenException ex) {
log.info(ex.getMessage());
return JsonResult.buildErrorStateResult(ex.getMessage(), ex.getCode());
}
} }
package cn.quantgroup.customer.rest;
import cn.quantgroup.customer.aop.OperateLog;
import cn.quantgroup.customer.rest.param.ordermapping.OperateEntryParam;
import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author yangjun
* @Date 2020/4/17 15:57
* @Desc 需要鉴权的功能
* @Update
*/
@Slf4j
@RestController
@RequestMapping("/operate/sys")
public class OperateRest {
@Autowired
private IOrderService orderService;
/**
* 添加或移除白名单
*
* @param operateEntryParam
* @return
*/
@PostMapping("/set_or_cancel_settleUp_white_list")
@OperateLog(moduleName = "添加或移除白名单")
public JsonResult setOrCancelSettleUpWhiteList(OperateEntryParam operateEntryParam) {
log.info("[结清白名单设置操作],请求参数:operateEntryParam={}", operateEntryParam);
return orderService.setOrCancelSettleUpWhiteList(operateEntryParam);
}
}
package cn.quantgroup.customer.rest; package cn.quantgroup.customer.rest;
import cn.quantgroup.customer.aop.OperateLog;
import cn.quantgroup.customer.rest.param.ordermapping.EarlySettleUpOrderQueryParam;
import cn.quantgroup.customer.rest.param.ordermapping.OperateEntryParam;
import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam; import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam;
import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery;
import cn.quantgroup.customer.rest.vo.JsonResult; import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.service.IOrderService; import cn.quantgroup.customer.service.IOrderService;
import cn.quantgroup.customer.service.IXyqbService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import javax.validation.Valid; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @author Wang Xiangwei * @author Wang Xiangwei
...@@ -22,22 +24,22 @@ import javax.validation.Valid; ...@@ -22,22 +24,22 @@ import javax.validation.Valid;
public class OrderRest { public class OrderRest {
@Autowired @Autowired
private IOrderService orderService; private IOrderService orderService;
@GetMapping("/loan/{loanId}") @GetMapping("/loan/{loanId}")
public JsonResult getLoanOrderDetail(@PathVariable Long loanId){ public JsonResult getLoanOrderDetail(@PathVariable Long loanId) {
return orderService.getLoanOrderDetail(loanId); return orderService.getLoanOrderDetail(loanId);
} }
@GetMapping("/flowchart/{orderNo}") @GetMapping("/flowchart/{orderNo}")
public JsonResult getFlowChart(@PathVariable String orderNo){ public JsonResult getFlowChart(@PathVariable String orderNo) {
return orderService.findFlowChart(orderNo); return orderService.findFlowChart(orderNo);
} }
/** /**
* 订单信息查询 * 订单信息查询
*
* @param orderQuery * @param orderQuery
* @return * @return
*/ */
...@@ -46,4 +48,41 @@ public class OrderRest { ...@@ -46,4 +48,41 @@ public class OrderRest {
log.info("[查询订单信息],请求参数:orderQuery={}", orderQuery); log.info("[查询订单信息],请求参数:orderQuery={}", orderQuery);
return orderService.queryOrderInfo(orderQuery); return orderService.queryOrderInfo(orderQuery);
} }
/**
* 订单提前一次性结清查询
*
* @param orderQuery
* @return
*/
@GetMapping("/query_early_settleUp_order")
public JsonResult queryEarlySettleUpOrders(EarlySettleUpOrderQueryParam orderQuery) {
log.info("[订单提前一次性结清查询],请求参数:orderQuery={}", orderQuery);
return orderService.queryEarlySettleUpOrders(orderQuery);
}
/**
* 提前一次性结清金额试算
*
* @param loanId
* @return
*/
@GetMapping("/early_settleUp_trial/{loanId}")
public JsonResult earlySettleUpTrial(@PathVariable Long loanId) {
log.info("[提前一次性结清金额试算],请求参数:loanId={}", loanId);
return orderService.earlySettleUpTrial(loanId);
}
/**
* 操作日志查询
*
* @param loanId
* @return
*/
@GetMapping("/query_operateLog/{loanId}")
public JsonResult queryOperateLog(@PathVariable Long loanId) {
log.info("[操作日志查询],请求参数:loanId={}", loanId);
return orderService.queryOperateLog(loanId);
}
} }
package cn.quantgroup.customer.rest.param.ordermapping;
import lombok.Data;
/**
* @author yangjun
* @Date 2020/4/13 16:16
* @Desc
* @Update
*/
@Data
public class EarlySettleUpOrderQueryParam {
private String phoneNo;
private Long userId;
private Long loanId;
private String fundOrder;
private String channelOrderNo;
private Long channelId;
}
package cn.quantgroup.customer.rest.param.ordermapping;
import lombok.Data;
/**
* @author yangjun
* @Date 2020/4/13 16:16
* @Desc
* @Update
*/
@Data
public class OperateEntryParam {
private Long loanId;
private String remark;
/**
* 0 设置隐藏 1 设置显示
*/
private Integer opState;
}
...@@ -77,8 +77,9 @@ public class JsonResult<T> implements Serializable { ...@@ -77,8 +77,9 @@ public class JsonResult<T> implements Serializable {
@Override @Override
public String toString() { public String toString() {
return "JsonResult{" + return "JsonResult{" +
"businessCode='" + businessCode + '\'' + "msg='" + msg + '\'' +
", code='" + code + '\'' + ", code='" + code + '\'' +
", businessCode='" + businessCode + '\'' +
", data=" + data + ", data=" + data +
'}'; '}';
} }
......
...@@ -3,6 +3,7 @@ package cn.quantgroup.customer.service; ...@@ -3,6 +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.ApplyOrder;
import cn.quantgroup.customer.model.order.CallbackRecordList; 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;
...@@ -45,4 +46,5 @@ public interface IKaService { ...@@ -45,4 +46,5 @@ public interface IKaService {
* @return * @return
*/ */
JsonResult<ApplyRequestHistory> queryLatestChannelRequestFlows(String applyNo, Long channelId); JsonResult<ApplyRequestHistory> queryLatestChannelRequestFlows(String applyNo, Long channelId);
} }
package cn.quantgroup.customer.service;
import cn.quantgroup.customer.entity.OpUser;
import cn.quantgroup.customer.rest.vo.JsonResult;
/**
* 查询运营系统后台
*/
public interface IOpSystemService {
JsonResult<OpUser> findUserByToken(String token, String system);
}
package cn.quantgroup.customer.service;
import cn.quantgroup.customer.entity.OpLog;
import cn.quantgroup.customer.entity.OperateLogModel;
import java.util.List;
import java.util.Map;
public interface IOperateLogService {
void saveOperateLog(OperateLogModel logModel);
List<OpLog> findLogsByLoanId(Long loanId);
Long findLogsCountsByLoanId(Long loanId);
}
package cn.quantgroup.customer.service; package cn.quantgroup.customer.service;
import cn.quantgroup.customer.model.order.FlowNode; import cn.quantgroup.customer.entity.OpLog;
import cn.quantgroup.customer.model.order.LoanOrderDetail; import cn.quantgroup.customer.model.order.*;
import cn.quantgroup.customer.model.order.OrderInfo; import cn.quantgroup.customer.rest.param.ordermapping.EarlySettleUpOrderQueryParam;
import cn.quantgroup.customer.model.order.OrderInfoVo; import cn.quantgroup.customer.rest.param.ordermapping.OperateEntryParam;
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 java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author Wang Xiangwei * @author Wang Xiangwei
...@@ -31,4 +32,36 @@ public interface IOrderService{ ...@@ -31,4 +32,36 @@ public interface IOrderService{
* @return * @return
*/ */
JsonResult<OrderInfoVo> queryOrderInfo(OrderQueryParam orderQuery); JsonResult<OrderInfoVo> queryOrderInfo(OrderQueryParam orderQuery);
/**
* 查询提前一次性结清订单信息
*
* @param orderQuery
* @return
*/
JsonResult<List<EarlySettleUpOrder>> queryEarlySettleUpOrders(EarlySettleUpOrderQueryParam orderQuery);
/**
* 设置/取消提前结清白名单入口
*
* @param operateEntryParam
* @return
*/
JsonResult<Boolean> setOrCancelSettleUpWhiteList(OperateEntryParam operateEntryParam);
/**
* 提前一次性结清金额试算
*
* @param loanId
* @return
*/
JsonResult<List<Map<String, Object>>> earlySettleUpTrial(Long loanId);
/**
* 查询操作日志
*
* @param loanId
* @return
*/
JsonResult<List<OpLog>> queryOperateLog(Long loanId);
} }
...@@ -35,5 +35,4 @@ public interface IUserService extends UserDetailsService { ...@@ -35,5 +35,4 @@ public interface IUserService extends UserDetailsService {
JsonResult findUserCombination(UserCombinationParam userCombinationParam); JsonResult findUserCombination(UserCombinationParam userCombinationParam);
} }
...@@ -4,6 +4,8 @@ import cn.quantgroup.customer.model.order.*; ...@@ -4,6 +4,8 @@ import cn.quantgroup.customer.model.order.*;
import cn.quantgroup.customer.rest.param.card.ModifyReservePhone; import cn.quantgroup.customer.rest.param.card.ModifyReservePhone;
import cn.quantgroup.customer.rest.param.card.UnBindCardModel; import cn.quantgroup.customer.rest.param.card.UnBindCardModel;
import cn.quantgroup.customer.rest.param.applyorder.ApplyOrderQuery; import cn.quantgroup.customer.rest.param.applyorder.ApplyOrderQuery;
import cn.quantgroup.customer.rest.param.ordermapping.EarlySettleUpOrderQueryParam;
import cn.quantgroup.customer.rest.param.ordermapping.OperateEntryParam;
import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam; 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;
...@@ -20,7 +22,7 @@ public interface IXyqbService { ...@@ -20,7 +22,7 @@ public interface IXyqbService {
* @param applyOrderQuery * @param applyOrderQuery
* @return * @return
*/ */
JsonResult<List<ApplyOrder>> findApplyOrders(ApplyOrderQuery applyOrderQuery); JsonResult<ApplyOrder> findApplyOrders(ApplyOrderQuery applyOrderQuery);
/** /**
* 流程日志查看 * 流程日志查看
...@@ -63,4 +65,28 @@ public interface IXyqbService { ...@@ -63,4 +65,28 @@ public interface IXyqbService {
* @return * @return
*/ */
JsonResult<OrderStatus> orderStatusQuery(OrderQueryParam orderQuery); JsonResult<OrderStatus> orderStatusQuery(OrderQueryParam orderQuery);
/**
* 查询xyqb一次性结清订单相关信息
*
* @param orderQuery
* @return
*/
JsonResult<List<EarlySettleUpOrder>> findLoanOrder4EarlySettleUp(EarlySettleUpOrderQueryParam orderQuery);
/**
* 处理新增或删除白名单操作
*
* @param operateEntryParam
* @return
*/
JsonResult<Boolean> setOrCancelSettleUpWhiteList(OperateEntryParam operateEntryParam);
/**
* 提前一次性结清金额试算
*
* @param loanId
* @return
*/
JsonResult<EarlySettleUpTrial> earlySettleUpTrial(Long loanId);
} }
...@@ -5,6 +5,7 @@ import cn.quantgroup.customer.exception.BusinessException; ...@@ -5,6 +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.ApplyOrder;
import cn.quantgroup.customer.model.order.CallbackRecordList; 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;
......
package cn.quantgroup.customer.service.impl;
import cn.quantgroup.customer.entity.OpUser;
import cn.quantgroup.customer.enums.ErrorCodeEnum;
import cn.quantgroup.customer.exception.BusinessException;
import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.service.IOpSystemService;
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.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* @author yangjun
* @Date 2020/4/16 10:05
* @Desc
* @Update
*/
@Slf4j
@Service("opSystemService")
public class OpSystemServiceImpl implements IOpSystemService {
@Value("${opapi.http}")
private String kaSysUrl;
@Autowired
private IHttpService httpService;
@Override
public JsonResult<OpUser> findUserByToken(String token, String system) {
String logPre = "OpSystemServiceImpl.findUserByToken";
log.info("{} 通过token查询用户登录信息 token={},system={}", logPre, token, system);
String url = kaSysUrl + "/user/info";
try {
Map<String, String> param = Maps.newHashMap();
param.put("x-auth-token", token);
// 增加请求类型 api
param.put("request-type","api");
if(StringUtils.isNotBlank(system)){
param.put("x-auth-system", system);
}
String result;
try {
result = httpService.post(url, param, null);
} catch (Exception e) {
log.error(" {}查询用户登录信息失败http请求异常 url={},param={}", logPre, url, param, e);
return JsonResult.buildErrorStateResult("通讯异常", null);
}
log.info("{} 系统返回值:{}", logPre, result);
if (StringUtils.isBlank(result)) {
log.error("{} 查询用户登录信息失败 jsonResult={}", logPre, result);
return JsonResult.buildErrorStateResult("查询数据异常", null);
}
TypeReference<JsonResult<OpUser>> typeToken = new TypeReference<JsonResult<OpUser>>() {
};
JsonResult<OpUser> jsonResult = JSONTools.deserialize(result, typeToken);
return jsonResult;
} catch (Exception e) {
log.error("{} 网络通讯异常,token:{},system:{},ex:{}", logPre, token, system, ExceptionUtils.getStackTrace(e));
throw new BusinessException(ErrorCodeEnum.NET_ERROR);
}
}
}
package cn.quantgroup.customer.service.impl;
import cn.quantgroup.customer.entity.OpLog;
import cn.quantgroup.customer.entity.OperateLogModel;
import cn.quantgroup.customer.repo.OperateLogRepo;
import cn.quantgroup.customer.service.IOperateLogService;
import cn.quantgroup.customer.util.JSONTools;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author yangjun
* @Date 2020/4/15 12:00
* @Desc
* @Update
*/
@Service("operateLogService")
public class OperateLogServiceImpl implements IOperateLogService {
@Autowired
private OperateLogRepo operateLogRepo;
@Override
public void saveOperateLog(OperateLogModel logModel) {
operateLogRepo.save(logModel);
}
@Override
public List<OpLog> findLogsByLoanId(Long loanId) {
List<OperateLogModel> list = operateLogRepo.findLogsByLoanId(loanId);
List<OpLog> opLogs = new ArrayList<>(list.size());
list.forEach(it ->
opLogs.add(JSONObject.parseObject(JSONObject.toJSONString(it), OpLog.class)));
return opLogs;
}
@Override
public Long findLogsCountsByLoanId(Long loanId) {
return operateLogRepo.findLogsCountsByLoanId(loanId);
}
}
package cn.quantgroup.customer.service.impl; package cn.quantgroup.customer.service.impl;
import cn.quantgroup.customer.constant.Constant;
import cn.quantgroup.customer.entity.OpLog;
import cn.quantgroup.customer.enums.ErrorCodeEnum; import cn.quantgroup.customer.enums.ErrorCodeEnum;
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.*;
import cn.quantgroup.customer.model.xyqbuser.UserBasicInfo;
import cn.quantgroup.customer.rest.param.ordermapping.EarlySettleUpOrderQueryParam;
import cn.quantgroup.customer.rest.param.ordermapping.OperateEntryParam;
import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam; import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam;
import cn.quantgroup.customer.rest.param.user.UserQueryParam;
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.*;
import cn.quantgroup.customer.service.IOrderService; import com.alibaba.fastjson.JSONObject;
import cn.quantgroup.customer.service.IXyqbService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
/** /**
...@@ -29,6 +35,13 @@ public class OrderServiceImpl implements IOrderService { ...@@ -29,6 +35,13 @@ public class OrderServiceImpl implements IOrderService {
@Autowired @Autowired
private IXyqbService xyqbService; private IXyqbService xyqbService;
@Autowired
private IOperateLogService operateLogService;
@Autowired
private IUserService userService;
@Override @Override
public JsonResult<List<FlowNode>> findFlowChart(String applyOrderNo) { public JsonResult<List<FlowNode>> findFlowChart(String applyOrderNo) {
String logPre = "OrderServiceImpl.findFlowChart"; String logPre = "OrderServiceImpl.findFlowChart";
...@@ -132,6 +145,316 @@ public class OrderServiceImpl implements IOrderService { ...@@ -132,6 +145,316 @@ public class OrderServiceImpl implements IOrderService {
} }
} }
@Override
public JsonResult<List<EarlySettleUpOrder>> queryEarlySettleUpOrders(EarlySettleUpOrderQueryParam orderQuery) {
if (!existAtLestOneParam(orderQuery)) {
return JsonResult.buildErrorStateResult("至少输入一个请求参数", null);
}
// 渠道订单号和渠道号必须同时存在
if (!existChannelOrderNoAndChannelId(orderQuery)) {
return JsonResult.buildErrorStateResult("渠道号和渠道订单号必须同时存在", null);
}
// 获取用户userId
boolean isExistUserParam = existUserParam(orderQuery);
if (isExistUserParam) {
JsonResult<UserBasicInfo> userInfo = this.queryAndCheckUserInfo(orderQuery);
if (Objects.isNull(userInfo) || !userInfo.isSuccess()) {
return JsonResult.buildErrorStateResult("查询不到用户信息", null);
}
UserBasicInfo userBasicInfo = userInfo.getData();
if (Objects.nonNull(userBasicInfo)) {
orderQuery.setPhoneNo(userBasicInfo.getPhoneNo());
orderQuery.setUserId(userBasicInfo.getUserId());
}else {
return JsonResult.buildErrorStateResult("查询不到用户信息", null);
}
}
// 获取订单loanId
boolean isExistOrderParam = existOrderParam(orderQuery);
if (isExistOrderParam) {
JsonResult<LoanOrderMapping> loanOrder = this.queryAndCheckOrderInfo(orderQuery);
if (Objects.isNull(loanOrder) || !loanOrder.isSuccess()) {
return JsonResult.buildErrorStateResult("查询不到订单信息", null);
}
LoanOrderMapping loanOrderMapping = loanOrder.getData();
if(Objects.nonNull(loanOrderMapping)){
orderQuery.setLoanId(loanOrderMapping.getLoanId());
orderQuery.setChannelId(loanOrderMapping.getRegisteredFrom());
orderQuery.setChannelOrderNo(loanOrderMapping.getChannelOrderNo());
}
}
// 请求xyqb 为空或者不成功,直接返回
JsonResult<List<EarlySettleUpOrder>> xyqbOrderResult = this.xyqbService.findLoanOrder4EarlySettleUp(orderQuery);
if (Objects.isNull(xyqbOrderResult)) {
return JsonResult.buildErrorStateResult("查询订单信息出错", null);
}
if(!xyqbOrderResult.isSuccess()){
return xyqbOrderResult;
}
/**
* 处理数据转换
*/
List<EarlySettleUpOrder> settleUpOrders = xyqbOrderResult.getData();
settleUpOrders.forEach(e -> {
if(StringUtils.isNotBlank(orderQuery.getChannelOrderNo())){
e.setChannelOrderNo(orderQuery.getChannelOrderNo());
}else{
// 查询 订单信息 主要获取渠道订单号
OrderQueryParam orderQueryParam = new OrderQueryParam();
orderQueryParam.setLoanId(e.getLoanId());
JsonResult<LoanOrderMapping> mappingJsonResult = kaService.findOrderMapping(orderQueryParam);
LoanOrderMapping orderMapping;
if(Objects.nonNull(mappingJsonResult) && mappingJsonResult.isSuccess() && (Objects.nonNull(orderMapping = mappingJsonResult.getData()))){
e.setChannelOrderNo(orderMapping.getChannelOrderNo());
}
}
if(StringUtils.isNotBlank(orderQuery.getPhoneNo())){
e.setPhoneNo(orderQuery.getPhoneNo());
}else{
// 查询 用户信息 主要获取手机号
UserQueryParam userQueryParam = new UserQueryParam();
userQueryParam.setUserId(e.getUserId());
JsonResult<UserBasicInfo> userInfo = userService.findUserInfo(userQueryParam);
UserBasicInfo userBasicInfo;
if(Objects.nonNull(userInfo) && userInfo.isSuccess() && (Objects.nonNull(userBasicInfo = userInfo.getData()))){
e.setPhoneNo(userBasicInfo.getPhoneNo());
}
}
e.setUserId(null);
e.setShowOplog(dealWithShowOplog(e.getLoanId()));
});
return JsonResult.buildSuccessResult("处理成功", settleUpOrders);
}
/**
* 处理是否显示 操作日志按钮
*
* @param loanId
* @return
*/
private Boolean dealWithShowOplog(Long loanId) {
return operateLogService.findLogsCountsByLoanId(loanId) > 0;
}
/**
* 查询订单loanId
*
* @param orderQuery
* @return
*/
private JsonResult<LoanOrderMapping> queryAndCheckOrderInfo(EarlySettleUpOrderQueryParam orderQuery) {
String logPre = "OrderServiceImpl.queryAndCheckOrderInfo";
OrderQueryParam orderQueryParam = new OrderQueryParam();
if(Objects.nonNull(orderQuery.getChannelId()) && StringUtils.isNotBlank(orderQuery.getChannelOrderNo())){
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);
}
LoanOrderMapping loanOrderMapping = orderMappingJsonResult.getData();
if (Objects.isNull(loanOrderMapping)) {
log.error("{} 查询订单信息,返回结果为空 result={}", logPre, orderMappingJsonResult);
return JsonResult.buildErrorStateResult("请求参数有误,查询不到订单信息", null);
}
if (Objects.nonNull(orderQuery.getLoanId()) && !orderQuery.getLoanId().equals(loanOrderMapping.getLoanId())) {
log.error("{} 查询出订单信息与loanId不一致 loanId={},result={}", logPre, orderQuery.getLoanId(), orderMappingJsonResult);
return JsonResult.buildErrorStateResult("请求参数有误,查询不到订单信息", null);
}
return orderMappingJsonResult;
}else{
log.info("{} 渠道号和渠道订单号输入有问题,直接返回 channelId={},channelOrderNo={}", logPre,orderQuery.getChannelId(), orderQuery.getChannelOrderNo());
return JsonResult.buildSuccessResult("",null);
}
}
/**
* 查询用户userId
*
* @param orderQuery
* @return
*/
private JsonResult<UserBasicInfo> queryAndCheckUserInfo(EarlySettleUpOrderQueryParam orderQuery) {
String logPre = "OrderServiceImpl.queryAndCheckUserInfo";
//用户参数查询
UserQueryParam userQueryParam = new UserQueryParam();
UserBasicInfo userBasicInfo = null;
JsonResult<UserBasicInfo> userInfoByUserParam = null;
if (StringUtils.isNotBlank(orderQuery.getPhoneNo())) {
userQueryParam.setPhoneNo(orderQuery.getPhoneNo());
userInfoByUserParam = this.userService.findUserInfo(userQueryParam);
if (Objects.isNull(userInfoByUserParam) || !userInfoByUserParam.isSuccess() || Objects.isNull(userBasicInfo = userInfoByUserParam.getData())) {
log.error("{} 查询用户失败 userQueryParam={} result={}", logPre, userQueryParam, userInfoByUserParam);
return JsonResult.buildErrorStateResult("请求参数有误,查询不到用户信息", null);
}
}
if (Objects.isNull(orderQuery.getUserId())) {
// userId为空 手机号为空
if (Objects.isNull(userInfoByUserParam)) {
log.error("{} userId为空,手机号为空,无法查询用户信息 orderQuery={}", logPre, orderQuery);
return JsonResult.buildErrorStateResult("请求参数有误,查询不到用户信息", null);
} else {
// userId为空 手机号不为空,查询出数据,直接返回
log.info("{} userId为空 手机号不为空,查询出数据,直接返回 orderQuery={},userInfoByUserParam={}", logPre, orderQuery, userInfoByUserParam);
return userInfoByUserParam;
}
} else {
// userId 存在,手机号为空 此时需要根据userId单独查询
if (Objects.isNull(userInfoByUserParam)) {
userQueryParam.setUserId(orderQuery.getUserId());
userInfoByUserParam = this.userService.findUserInfo(userQueryParam);
if (Objects.isNull(userInfoByUserParam) || !userInfoByUserParam.isSuccess() || Objects.isNull(userInfoByUserParam.getData())) {
log.error("{} userId 存在,手机号为空 查询用户失败 result={}", logPre, userInfoByUserParam);
return JsonResult.buildErrorStateResult("请求参数有误,查询不到用户信息", null);
} else {
log.info("{} userId 存在,手机号为空,查询出数据,直接返回 userQueryParam={},userInfoByUserParam={}", logPre, userQueryParam, userInfoByUserParam);
return userInfoByUserParam;
}
} else {
// userId存在,手机号也存在,查询出数据 用户输入等于查询返回
if (orderQuery.getUserId().equals(userBasicInfo.getUserId())) {
log.info("{} userId 存在,手机号也存在,查询出数据,userId等于查询返回值,直接返回 orderQuery={},userInfoByUserParam={}", logPre, orderQuery, userInfoByUserParam);
return userInfoByUserParam;
} else {
// userId存在,手机号也存在,查询出数据 用户输入!等于查询返回
log.error("{} userId存在,手机号也存在,查询出数据 用户输入!等于查询返回 orderQuery={},userInfoByUserParam={}", logPre, orderQuery, userInfoByUserParam);
return JsonResult.buildErrorStateResult("请求参数有误,查询不到用户信息", null);
}
}
}
}
/**
* 判断是否存在用户基础字段
*
* @param orderQuery
* @return
*/
private boolean existUserParam(EarlySettleUpOrderQueryParam orderQuery) {
return !(StringUtils.isBlank(orderQuery.getPhoneNo()) && Objects.isNull(orderQuery.getUserId()));
}
/**
* 判断是否存在订单基础字段
*
* @param orderQuery
* @return
*/
private boolean existOrderParam(EarlySettleUpOrderQueryParam orderQuery) {
return !(Objects.isNull(orderQuery.getLoanId()) && Objects.isNull(orderQuery.getChannelId()) && StringUtils.isBlank(orderQuery.getChannelOrderNo()));
}
/**
* 渠道号和渠道订单号同时存在判断
*
* @param orderQuery
* @return
*/
private boolean existChannelOrderNoAndChannelId(EarlySettleUpOrderQueryParam orderQuery) {
return !(Objects.isNull(orderQuery.getChannelId()) && StringUtils.isNotBlank(orderQuery.getChannelOrderNo())
|| Objects.nonNull(orderQuery.getChannelId()) && StringUtils.isBlank(orderQuery.getChannelOrderNo())
);
}
private boolean existAtLestOneParam(EarlySettleUpOrderQueryParam orderQuery) {
return existOrderParam(orderQuery) || existUserParam(orderQuery) || StringUtils.isNotBlank(orderQuery.getFundOrder());
}
@Override
public JsonResult<Boolean> setOrCancelSettleUpWhiteList(OperateEntryParam operateEntryParam) {
return this.xyqbService.setOrCancelSettleUpWhiteList(operateEntryParam);
}
@Override
public JsonResult<List<Map<String, Object>>> earlySettleUpTrial(Long loanId) {
String logPre = "OrderServiceImpl.earlySettleUpTrial";
JsonResult<EarlySettleUpTrial> jsonResult = this.xyqbService.earlySettleUpTrial(loanId);
if (Objects.isNull(jsonResult)) {
log.error("{} 获取试算结果失败 loanId={}", logPre, loanId);
return JsonResult.buildErrorStateResult("获取试算结果失败", null);
}
if(!jsonResult.isSuccess()){
return JsonResult.buildErrorStateResult(jsonResult.getMsg(), null);
}
List<Map<String, Object>> data = dealWithFieldAndTitle(jsonResult.getData());
log.info("{} 试算对象 data={},试算后返回 datas:{}", logPre, jsonResult.getData(), data);
return JsonResult.buildSuccessResult("处理成功", data);
}
/**
* 根据返回参数值,获取对应title
*
* @param data
* @return
*/
private List<Map<String, Object>> dealWithFieldAndTitle(EarlySettleUpTrial data) {
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) {
Map<String, Object> fieldDataMap = new HashMap<>(4);
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", "应还总额");
continue;
}
fieldDataMap.put("value", Constant.DECIMAL_FORMAT2.format(value));
dataList.add(fieldDataMap);
}
}
return dataList;
}
@Override
public JsonResult<List<OpLog>> queryOperateLog(Long loanId) {
List<OpLog> list = operateLogService.findLogsByLoanId(loanId);
return JsonResult.buildSuccessResult("处理成功", list);
}
/** /**
* 处理查询不到orderMapping的情况,可能是进件失败,也可能不存在该笔订单 * 处理查询不到orderMapping的情况,可能是进件失败,也可能不存在该笔订单
* *
...@@ -216,4 +539,6 @@ public class OrderServiceImpl implements IOrderService { ...@@ -216,4 +539,6 @@ public class OrderServiceImpl implements IOrderService {
log.info("{} 查询订单信息,返回信息 orderInfoVo={}", logPre, orderInfoVo); log.info("{} 查询订单信息,返回信息 orderInfoVo={}", logPre, orderInfoVo);
return JsonResult.buildSuccessResult("处理成功", orderInfoVo); return JsonResult.buildSuccessResult("处理成功", orderInfoVo);
} }
} }
...@@ -78,18 +78,18 @@ public class RepayServiceImpl implements IRepayService { ...@@ -78,18 +78,18 @@ public class RepayServiceImpl implements IRepayService {
Long loanId = repayOrderQuery.getLoanId(); Long loanId = repayOrderQuery.getLoanId();
RepayInfoResult repayInfoResult = new RepayInfoResult(); RepayInfoResult repayInfoResult = new RepayInfoResult();
// 处理用户信息 // // 处理用户信息
OrderQueryParam orderQueryParam = new OrderQueryParam(); // OrderQueryParam orderQueryParam = new OrderQueryParam();
orderQueryParam.setLoanId(loanId); // orderQueryParam.setLoanId(loanId);
JsonResult userJsonResult = userService.findUserInfoByOrderParam(orderQueryParam); // JsonResult userJsonResult = userService.findUserInfoByOrderParam(orderQueryParam);
if (Objects.isNull(userJsonResult) // if (Objects.isNull(userJsonResult)
|| !userJsonResult.isSuccess()) { // || !userJsonResult.isSuccess()) {
log.error("根据loanId查不到用户信息"); // log.error("根据loanId查不到用户信息");
return JsonResult.buildErrorStateResult("该笔借款申请号查询不到用户信息", ErrorCodeEnum.PARAM_ERROR.getCode()); // return JsonResult.buildErrorStateResult("该笔借款申请号查询不到用户信息", ErrorCodeEnum.PARAM_ERROR.getCode());
} // }
//
UserBasicInfo userbasicinfo = (UserBasicInfo) userJsonResult.getData(); // UserBasicInfo userbasicinfo = (UserBasicInfo) userJsonResult.getData();
repayInfoResult.setUserInfo(userbasicinfo); // repayInfoResult.setUserInfo(userbasicinfo);
//处理还款信息 //处理还款信息
...@@ -115,9 +115,9 @@ public class RepayServiceImpl implements IRepayService { ...@@ -115,9 +115,9 @@ public class RepayServiceImpl implements IRepayService {
} }
repayInfoResult.setRepaymentList(xyqbRepayInfoResult.getData()); // repayInfoResult.setRepaymentList(xyqbRepayInfoResult.getData());
log.info("[查询还款信息],返回 repayInfoResult={}", repayInfoResult); log.info("[查询还款信息],返回 repayInfoResult={}", repayInfoResult);
return JsonResult.buildSuccessResult("处理成功", repayInfoResult); return JsonResult.buildSuccessResult("处理成功", xyqbRepayInfoResult.getData());
} }
@Override @Override
......
...@@ -6,6 +6,7 @@ import cn.quantgroup.customer.enums.ErrorCodeEnum; ...@@ -6,6 +6,7 @@ import cn.quantgroup.customer.enums.ErrorCodeEnum;
import cn.quantgroup.customer.exception.BusinessException; import cn.quantgroup.customer.exception.BusinessException;
import cn.quantgroup.customer.model.Tuple; import cn.quantgroup.customer.model.Tuple;
import cn.quantgroup.customer.model.kaordermapping.LoanOrderMapping; import cn.quantgroup.customer.model.kaordermapping.LoanOrderMapping;
import cn.quantgroup.customer.model.order.ActiveApplyOrder;
import cn.quantgroup.customer.model.order.ApplyOrder; import cn.quantgroup.customer.model.order.ApplyOrder;
import cn.quantgroup.customer.model.xyqbuser.UserBasicInfo; import cn.quantgroup.customer.model.xyqbuser.UserBasicInfo;
import cn.quantgroup.customer.model.xyqbuser.UserCombination; import cn.quantgroup.customer.model.xyqbuser.UserCombination;
...@@ -385,7 +386,7 @@ public class UserServiceImpl implements IUserService { ...@@ -385,7 +386,7 @@ public class UserServiceImpl implements IUserService {
result.setValue("2"); result.setValue("2");
return result; return result;
} }
result.setValue("只能使用渠道号和渠道订单号组合查询"); result.setValue("只能通过单一条件查询");
return result; return result;
} }
...@@ -401,7 +402,7 @@ public class UserServiceImpl implements IUserService { ...@@ -401,7 +402,7 @@ public class UserServiceImpl implements IUserService {
return JsonResult.buildErrorStateResult(tuple.getValue(), null); return JsonResult.buildErrorStateResult(tuple.getValue(), null);
} }
JsonResult<UserBasicInfo> userInfo; JsonResult<UserBasicInfo> userInfo;
JsonResult<List<ApplyOrder>> applyOrders; JsonResult<ApplyOrder> applyOrder;
if ("1".equals(tuple.getValue())) { if ("1".equals(tuple.getValue())) {
//订单参数查询 //订单参数查询
OrderQueryParam orderQueryParam = new OrderQueryParam(); OrderQueryParam orderQueryParam = new OrderQueryParam();
...@@ -414,7 +415,7 @@ public class UserServiceImpl implements IUserService { ...@@ -414,7 +415,7 @@ public class UserServiceImpl implements IUserService {
log.error("{} 查询用户失败 result={}", logPre, userInfo); log.error("{} 查询用户失败 result={}", logPre, userInfo);
return userInfo; return userInfo;
} }
applyOrders = this.findApplyOrders(orderQueryParam); applyOrder = this.findApplyOrders(orderQueryParam);
} else { } else {
//用户参数查询 //用户参数查询
UserQueryParam userQueryParam = new UserQueryParam(); UserQueryParam userQueryParam = new UserQueryParam();
...@@ -428,38 +429,46 @@ public class UserServiceImpl implements IUserService { ...@@ -428,38 +429,46 @@ public class UserServiceImpl implements IUserService {
return userInfo; return userInfo;
} }
userQueryParam.setUserId(userInfo.getData().getUserId()); userQueryParam.setUserId(userInfo.getData().getUserId());
applyOrders = this.findApplyOrders(userQueryParam); applyOrder = this.findApplyOrders(userQueryParam);
} }
if (!applyOrders.isSuccess()) { if (!applyOrder.isSuccess()) {
log.error("{} 查询申请订单失败 result={}", logPre, applyOrders); log.error("{} 查询申请订单失败 result={}", logPre, applyOrder);
return applyOrders; return applyOrder;
} }
List<ApplyOrder> applyOrderList = applyOrders.getData(); List<ActiveApplyOrder> activeApplyOrders = applyOrder.getData().getActiveOrders();
if (CollectionUtils.isNotEmpty(applyOrderList)) { List<ActiveApplyOrder> invalidApplyOrders = applyOrder.getData().getInvalidOrders();
if (CollectionUtils.isNotEmpty(activeApplyOrders)) {
//通过申请订单号获得渠道订单号 //通过申请订单号获得渠道订单号
List<String> applyOrderNoList = applyOrderList.stream().map(e -> e.getApplyOrderNo()).distinct().collect(Collectors.toList()); List<String> applyOrderNoList = activeApplyOrders.stream().map(e -> e.getApplyOrderNo()).distinct().collect(Collectors.toList());
JsonResult<Map<String, String>> mapJsonResult = kaService.findChannelOrderNosByApplyOrderNos(applyOrderNoList); JsonResult<Map<String, String>> mapJsonResult = kaService.findChannelOrderNosByApplyOrderNos(applyOrderNoList);
if (!mapJsonResult.isSuccess()) { if (mapJsonResult.isSuccess()) {
return mapJsonResult;
}
Map<String, String> data = mapJsonResult.getData(); Map<String, String> data = mapJsonResult.getData();
applyOrderList.forEach(e -> e.setChannelOrderNo(data.get(e.getApplyOrderNo()))); activeApplyOrders.forEach(e -> e.setChannelOrderNo(data.get(e.getApplyOrderNo())));
}
} }
if (CollectionUtils.isNotEmpty(invalidApplyOrders)) {
//通过申请订单号获得渠道订单号
List<String> applyOrderNoList = invalidApplyOrders.stream().map(e -> e.getApplyOrderNo()).distinct().collect(Collectors.toList());
JsonResult<Map<String, String>> mapJsonResult = kaService.findChannelOrderNosByApplyOrderNos(applyOrderNoList);
if (mapJsonResult.isSuccess()) {
Map<String, String> data = mapJsonResult.getData();
invalidApplyOrders.forEach(e -> e.setChannelOrderNo(data.get(e.getApplyOrderNo())));
}
}
UserBasicInfo userBasicInfo = userInfo.getData(); UserBasicInfo userBasicInfo = userInfo.getData();
UserCombination userCombination = new UserCombination(); UserCombination userCombination = new UserCombination();
userCombination.setUserInfo(userBasicInfo); userCombination.setUserInfo(userBasicInfo);
userCombination.setApplyOrderList(applyOrderList); userCombination.setApplyOrder(applyOrder.getData());
return JsonResult.buildSuccessResult("", userCombination); return JsonResult.buildSuccessResult("", userCombination);
} }
//订单信息综合查询 //订单信息综合查询
private JsonResult findApplyOrders(OrderQueryParam orderQueryParam) { private JsonResult findApplyOrders(OrderQueryParam orderQueryParam) {
String logPre = "UserService.findApplyOrders"; String logPre = "UserService.findApplyOrders";
...@@ -481,7 +490,8 @@ public class UserServiceImpl implements IUserService { ...@@ -481,7 +490,8 @@ public class UserServiceImpl implements IUserService {
applyOrderQuery.setLoanId(loanId); applyOrderQuery.setLoanId(loanId);
applyOrderQuery.setOrderNo(applyNo); applyOrderQuery.setOrderNo(applyNo);
//申请订单查询 //申请订单查询
JsonResult<List<ApplyOrder>> applyOrders = xyqbService.findApplyOrders(applyOrderQuery); JsonResult<ApplyOrder> applyOrders = xyqbService.findApplyOrders(applyOrderQuery);
return applyOrders; return applyOrders;
} }
...@@ -492,7 +502,7 @@ public class UserServiceImpl implements IUserService { ...@@ -492,7 +502,7 @@ public class UserServiceImpl implements IUserService {
ApplyOrderQuery applyOrderQuery = new ApplyOrderQuery(); ApplyOrderQuery applyOrderQuery = new ApplyOrderQuery();
applyOrderQuery.setUserId(userQueryParam.getUserId()); applyOrderQuery.setUserId(userQueryParam.getUserId());
//申请订单查询 //申请订单查询
JsonResult<List<ApplyOrder>> applyOrders = xyqbService.findApplyOrders(applyOrderQuery); JsonResult<ApplyOrder> applyOrders = xyqbService.findApplyOrders(applyOrderQuery);
return applyOrders; return applyOrders;
} }
...@@ -527,16 +537,22 @@ public class UserServiceImpl implements IUserService { ...@@ -527,16 +537,22 @@ public class UserServiceImpl implements IUserService {
applyOrderQuery.setOrderNo(applyOrderNo); applyOrderQuery.setOrderNo(applyOrderNo);
applyOrderQuery.setLoanId(loanId); applyOrderQuery.setLoanId(loanId);
//申请订单查询 //申请订单查询
JsonResult<List<ApplyOrder>> applyOrders = xyqbService.findApplyOrders(applyOrderQuery); JsonResult<ApplyOrder> applyOrder = xyqbService.findApplyOrders(applyOrderQuery);
if (!applyOrders.isSuccess()) { if (!applyOrder.isSuccess()) {
log.error("{} 获得申请订单失败 applyOrderQuery={} result={}", logPre, applyOrderQuery, applyOrders); log.error("{} 获得申请订单失败 applyOrderQuery={} result={}", logPre, applyOrderQuery, applyOrder);
return JsonResult.buildErrorStateResult("查询失败", null); return JsonResult.buildErrorStateResult("查询失败", null);
} }
if (CollectionUtils.isEmpty(applyOrders.getData())) { if (CollectionUtils.isEmpty(applyOrder.getData().getActiveOrders())
&& CollectionUtils.isEmpty(applyOrder.getData().getInvalidOrders())) {
return JsonResult.buildErrorStateResult("请确认搜索条件后再查询", null); return JsonResult.buildErrorStateResult("请确认搜索条件后再查询", null);
} }
Long userId = applyOrders.getData().get(0).getUserId(); Long userId;
if(CollectionUtils.isNotEmpty(applyOrder.getData().getActiveOrders())){
userId = applyOrder.getData().getActiveOrders().get(0).getUserId();
}else {
userId = applyOrder.getData().getInvalidOrders().get(0).getUserId();
}
UserSysResult<XUser> userByUserId = userSdk.getService().findUserByUserId(userId); UserSysResult<XUser> userByUserId = userSdk.getService().findUserByUserId(userId);
UserSysResult<XUserDetail> userDetailByUserId = userSdk.getService().findUserDetailByUserId(userId); UserSysResult<XUserDetail> userDetailByUserId = userSdk.getService().findUserDetailByUserId(userId);
return getUserBasicInfoResult(userByUserId,userDetailByUserId); return getUserBasicInfoResult(userByUserId,userDetailByUserId);
......
...@@ -5,6 +5,8 @@ import cn.quantgroup.customer.model.order.*; ...@@ -5,6 +5,8 @@ import cn.quantgroup.customer.model.order.*;
import cn.quantgroup.customer.rest.param.applyorder.ApplyOrderQuery; import cn.quantgroup.customer.rest.param.applyorder.ApplyOrderQuery;
import cn.quantgroup.customer.rest.param.card.ModifyReservePhone; import cn.quantgroup.customer.rest.param.card.ModifyReservePhone;
import cn.quantgroup.customer.rest.param.card.UnBindCardModel; import cn.quantgroup.customer.rest.param.card.UnBindCardModel;
import cn.quantgroup.customer.rest.param.ordermapping.EarlySettleUpOrderQueryParam;
import cn.quantgroup.customer.rest.param.ordermapping.OperateEntryParam;
import cn.quantgroup.customer.rest.param.ordermapping.OrderQueryParam; 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;
...@@ -17,6 +19,7 @@ import com.fasterxml.jackson.core.type.TypeReference; ...@@ -17,6 +19,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -64,7 +67,7 @@ public class XyqbServiceImpl implements IXyqbService { ...@@ -64,7 +67,7 @@ public class XyqbServiceImpl implements IXyqbService {
@Override @Override
public JsonResult<List<ApplyOrder>> findApplyOrders(ApplyOrderQuery applyOrderQuery) { public JsonResult<ApplyOrder> findApplyOrders(ApplyOrderQuery applyOrderQuery) {
String logPre = "XyqbServiceImpl.findApplyOrders"; String logPre = "XyqbServiceImpl.findApplyOrders";
log.info("{} 申请订单查询 applyOrderQuery={}", logPre, applyOrderQuery); log.info("{} 申请订单查询 applyOrderQuery={}", logPre, applyOrderQuery);
String orderNo = applyOrderQuery.getOrderNo(); String orderNo = applyOrderQuery.getOrderNo();
...@@ -84,15 +87,15 @@ public class XyqbServiceImpl implements IXyqbService { ...@@ -84,15 +87,15 @@ public class XyqbServiceImpl implements IXyqbService {
Map<String, String> header = Maps.newHashMap(); Map<String, String> header = Maps.newHashMap();
header.put("Content-Type", "application/x-www-form-urlencoded"); header.put("Content-Type", "application/x-www-form-urlencoded");
String result = httpService.post(url, header, param); String result = httpService.post(url, header, param);
log.info("{} 用户申请订单列表 url={}, header={},param={},result={}", logPre, url, header, param, result);
if (StringUtils.isBlank(result)) { if (StringUtils.isBlank(result)) {
log.error("{} 调用信用钱包失败 url={}, header={},param={},result={}", logPre, url, header, param, result); log.error("{} 调用信用钱包失败 url={}, header={},param={},result={}", logPre, url, header, param, result);
return JsonResult.buildErrorStateResult("申请订单查询失败", null); return JsonResult.buildErrorStateResult("申请订单查询失败", null);
} }
TypeReference<JsonResult<List<ApplyOrder>>> typeToken = new TypeReference<JsonResult<List<ApplyOrder>>>() { TypeReference<JsonResult<ApplyOrder>> typeToken = new TypeReference<JsonResult<ApplyOrder>>() {
}; };
JsonResult<List<ApplyOrder>> jsonResult = JSONTools.deserialize(result, typeToken); JsonResult<ApplyOrder> jsonResult = JSONTools.deserialize(result, typeToken);
return jsonResult; return jsonResult;
} }
...@@ -354,4 +357,135 @@ public class XyqbServiceImpl implements IXyqbService { ...@@ -354,4 +357,135 @@ public class XyqbServiceImpl implements IXyqbService {
} }
} }
} }
@Override
public JsonResult<List<EarlySettleUpOrder>> findLoanOrder4EarlySettleUp(EarlySettleUpOrderQueryParam orderQuery) {
String logPre = "[XyqbServiceImpl.findLoanOrder4EarlySettleUp] 查询一次性结清订单相关信息";
String url = xyqbSysUrl + "/ex/operate/config/earlysettle/query";
Map<String, Object> queryParam = new HashMap<>(8);
if (Objects.isNull(orderQuery.getUserId()) &&
Objects.isNull(orderQuery.getLoanId()) &&
StringUtils.isBlank(orderQuery.getFundOrder())) {
log.error("{} 请求参数都为空,不允许查询 orderQuery={}", logPre, orderQuery);
return JsonResult.buildErrorStateResult("查询参数都为空,不允许查询", null);
}
if(Objects.nonNull(orderQuery.getLoanId())){
queryParam.put("loan_id", String.valueOf(orderQuery.getLoanId()));
}
if(Objects.nonNull(orderQuery.getUserId())){
queryParam.put("user_id", String.valueOf(orderQuery.getUserId()));
}
if(StringUtils.isNotBlank(orderQuery.getFundOrder())){
queryParam.put("fund_order_no", orderQuery.getFundOrder());
}
log.info("{} 请求参数 orderQuery={},queryParam={}", logPre, orderQuery, queryParam);
Map<String, String> header = new HashMap<>(2);
header.put("Accept", "application/json");
header.put("Content-Type", "application/x-www-form-urlencoded");
String result = httpService.post(url, header, queryParam);
log.info("{} 返回结果 result:{}", logPre, result);
if (StringUtils.isBlank(result)) {
log.error("{} 处理失败 queryParam={} result={}", logPre, queryParam, result);
return JsonResult.buildErrorStateResult("[查询失败,返回为空]", ErrorCodeEnum.RETURN_ERROR);
} else {
TypeReference<JsonResult<List<EarlySettleUpOrder>>> typeToken = new TypeReference<JsonResult<List<EarlySettleUpOrder>>>() {
};
JsonResult<List<EarlySettleUpOrder>> jsonResult = JSONTools.deserialize(result, typeToken);
if (Objects.isNull(jsonResult)) {
return JsonResult.buildErrorStateResult("操作失败,xyqb返回错误", null);
} else {
if(!jsonResult.isSuccess()){
return JsonResult.buildErrorStateResult(StringUtils.isNotBlank(jsonResult.getMsg())?jsonResult.getMsg():"操作失败,xyqb返回错误", null);
}
return jsonResult;
}
}
}
@Override
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()) &&
Objects.isNull(operateEntryParam.getOpState())) {
log.error("{} 请求参数都为空,不允许操作 orderQuery={}", logPre, operateEntryParam);
return JsonResult.buildErrorStateResult("查询参数都为空,不允许操作", null);
}
queryParam.put("loan_id", String.valueOf(operateEntryParam.getLoanId()));
if (operateEntryParam.getOpState() == 1) {
queryParam.put("opt", "ADD");
} else {
queryParam.put("opt", "DEL");
}
log.info("{} 请求参数 orderQuery={},queryParam={}", logPre, operateEntryParam, queryParam);
Map<String, String> header = new HashMap<>(2);
header.put("Accept", "application/json");
header.put("Content-Type", "application/x-www-form-urlencoded");
String result;
try {
result = httpService.post(url, header, queryParam);
} catch (Exception e) {
log.error("{} 系统异常 e:{}", logPre, ExceptionUtils.getStackTrace(e));
return JsonResult.buildErrorStateResult("[处理失败]", Boolean.FALSE);
}
log.info("{} 返回结果 result:{}", logPre, result);
if (StringUtils.isBlank(result)) {
log.error("{} 处理失败 queryParam={} result={}", logPre, queryParam, result);
return JsonResult.buildErrorStateResult("[处理失败]", Boolean.FALSE);
} else {
TypeReference<JsonResult> typeToken = new TypeReference<JsonResult>() {
};
JsonResult<JsonResult> jsonResult = JSONTools.deserialize(result, typeToken);
if (Objects.isNull(jsonResult)) {
return JsonResult.buildErrorStateResult("操作失败,xyqb返回错误", Boolean.FALSE);
} else {
if (!jsonResult.isSuccess()) {
return JsonResult.buildErrorStateResult(StringUtils.isNotBlank(jsonResult.getMsg()) ? jsonResult.getMsg() : "操作失败,xyqb返回错误", Boolean.FALSE);
}
return JsonResult.buildSuccessResult("[操作成功]", Boolean.TRUE);
}
}
}
@Override
public JsonResult<EarlySettleUpTrial> earlySettleUpTrial(Long loanId) {
String logPre = "[XyqbServiceImpl.earlySettleUpTrial] 提前一次性结清金额试算";
String url = xyqbSysUrl + "/ex/operate/config/earlysettle/trial_order";
Map<String, Object> queryParam = new HashMap<>(8);
if (Objects.isNull(loanId)) {
log.error("{} 请求参数为空,不允许操作 loanId={}", logPre, loanId);
return JsonResult.buildErrorStateResult("借据单号为空,不允许操作", null);
}
queryParam.put("loan_id", String.valueOf(loanId));
log.info("{} 请求参数 loanId={},queryParam={}", logPre, loanId, queryParam);
Map<String, String> header = new HashMap<>(2);
header.put("Accept", "application/json");
header.put("Content-Type", "application/x-www-form-urlencoded");
String result = httpService.post(url, header, queryParam);
log.info("{} 返回结果 result:{}", logPre, result);
if (StringUtils.isBlank(result)) {
log.error("{} 处理失败 queryParam={} result={}", logPre, queryParam, result);
return JsonResult.buildErrorStateResult("[处理失败]", null);
} else {
TypeReference<JsonResult<EarlySettleUpTrial>> typeToken = new TypeReference<JsonResult<EarlySettleUpTrial>>() {
};
JsonResult<EarlySettleUpTrial> jsonResult = JSONTools.deserialize(result, typeToken);
if (Objects.isNull(jsonResult)) {
return JsonResult.buildErrorStateResult("操作失败,xyqb返回错误", null);
} else {
if(!jsonResult.isSuccess()){
return JsonResult.buildErrorStateResult(StringUtils.isNotBlank(jsonResult.getMsg())?jsonResult.getMsg():"操作失败,xyqb返回错误", null);
}
return jsonResult;
}
}
}
} }
package cn.quantgroup.customer.util;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.math.BigDecimal;
/**
* 在字段或get上加:
* <b>@JsonSerialize(using = MoneySerializer.class)</b>
* @author Jie.Feng
* @date 2018/8/28
*/
public class MoneySerializer extends JsonSerializer<BigDecimal> {
/**
* Method that can be called to ask implementation to serialize
* values of type this serializer handles.
*
* @param value Value to serialize; can <b>not</b> be null.
* @param gen Generator used to output resulting Json content
* @param serializers Provider that can be used to get serializers for
*/
@Override
public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
if(value == null)
gen.writeString("0.00");
else
gen.writeString(value.setScale(2, BigDecimal.ROUND_HALF_UP).toString());
}
}
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