Commit c26d5508 authored by 张庆's avatar 张庆

新增MQ

parent 2ce1691c
......@@ -2,6 +2,7 @@ package com.jqtx.windows.command;
import com.alibaba.fastjson.JSONObject;
import com.jqtx.windows.common.exception.BizException;
import com.jqtx.windows.common.factory.AbstractCommand;
import com.jqtx.windows.common.factory.RuntimeContextHolder;
import com.jqtx.windows.component.BackedDetailComponent;
......@@ -17,6 +18,7 @@ import com.jqtx.windows.infrastructure.feign.enums.DebtPlanStatusEnum;
import com.jqtx.windows.web.request.BackedDetail;
import com.jqtx.windows.web.request.BackedRequest;
import com.jqtx.windows.web.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -30,6 +32,7 @@ import java.util.List;
import java.util.stream.Collectors;
@Service
@Slf4j
public class BackedCommand extends AbstractCommand {
@Autowired
......@@ -49,13 +52,19 @@ public class BackedCommand extends AbstractCommand {
public JsonResult execute() {
String request = RuntimeContextHolder.currentRuntimeContext().getRequestBody();
BackedRequest backedRequest = JSONObject.parseObject(request, BackedRequest.class);
//生成 windows_repay 信息
creditRepay(backedRequest);
//生成 windows_backed_detail 信息
//修改 windows_plan backAmt 信息
//修改 windows_plan 还款状态
//修改 windows_loan 还款状态
backedDetail(backedRequest.getLoanNo(), new BigDecimal(backedRequest.getBackAmt()), backedRequest.getBackedNo(), backedRequest);
try {
//生成 windows_repay 信息
creditRepay(backedRequest);
//生成 windows_backed_detail 信息
//修改 windows_plan backAmt 信息
//修改 windows_plan 还款状态
//修改 windows_loan 还款状态
backedDetail(backedRequest.getLoanNo(), new BigDecimal(backedRequest.getBackAmt()), backedRequest.getBackedNo(), backedRequest);
} catch (Exception e) {
log.error("用户还款,授信编号:{},报错:{}", backedRequest.getLoanNo(), e.getMessage(), e);
throw new BizException("用户还款错误");
}
return JsonResult.success();
}
......
......@@ -3,17 +3,20 @@ package com.jqtx.windows.command;
import com.alibaba.fastjson.JSONObject;
import com.jqtx.infrastructure.oss.starter.config.OssUtils;
import com.jqtx.windows.common.exception.BizException;
import com.jqtx.windows.common.factory.AbstractCommand;
import com.jqtx.windows.common.factory.RuntimeContextHolder;
import com.jqtx.windows.component.model.GetSignContractModel;
import com.jqtx.windows.infrastructure.feign.IProtocalFeignService;
import com.jqtx.windows.web.response.GetSignContractResponse;
import com.jqtx.windows.web.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class GetSignContractCommand extends AbstractCommand {
@Autowired
private IProtocalFeignService iProtocalFeignService;
......@@ -25,15 +28,20 @@ public class GetSignContractCommand extends AbstractCommand {
public JsonResult execute() {
String requestBody = RuntimeContextHolder.currentRuntimeContext().getRequestBody();
GetSignContractModel getSignContractModel = JSONObject.parseObject(requestBody, GetSignContractModel.class);
GetSignContractResponse getSignContractResponse=new GetSignContractResponse();
JsonResult<String> rongdanPdfJsonResult = iProtocalFeignService.getFilePathPdf(getSignContractModel.getLoanNo(), "own-rongdan");
if (rongdanPdfJsonResult.isSuccess() && StringUtils.isNotEmpty(rongdanPdfJsonResult.getResult())){
getSignContractResponse.setSignStatus("SIGN");
String path = ossUtils.generateTempURLPrivateDomain(rongdanPdfJsonResult.getResult());
getSignContractResponse.setContractFileUrl(path);
}else {
getSignContractResponse.setSignStatus("SIGN_ING");
try {
GetSignContractResponse getSignContractResponse = new GetSignContractResponse();
JsonResult<String> rongdanPdfJsonResult = iProtocalFeignService.getFilePathPdf(getSignContractModel.getLoanNo(), "own-rongdan");
if (rongdanPdfJsonResult.isSuccess() && StringUtils.isNotEmpty(rongdanPdfJsonResult.getResult())) {
getSignContractResponse.setSignStatus("SIGN");
String path = ossUtils.generateTempURLPrivateDomain(rongdanPdfJsonResult.getResult());
getSignContractResponse.setContractFileUrl(path);
} else {
getSignContractResponse.setSignStatus("SIGN_ING");
}
return JsonResult.success(getSignContractResponse);
} catch (Exception e) {
log.error("获取融单协议,授信编号:{},报错:{}", getSignContractModel.getLoanNo(), e.getMessage(), e);
throw new BizException("获取融单协议错误");
}
return JsonResult.success(getSignContractResponse);
}
}
......@@ -76,8 +76,9 @@ public class LoanSubmitCommand extends AbstractCommand {
model.setOrderNo(loanSubmitResponse.getOrderNo());
JsonResult<Boolean> booleanJsonResult = wakandaFeignService.loanCredit(model);
JsonResult.success(booleanJsonResult.isSuccess());
} catch (BizException e) {
} catch (Exception e) {
log.error("LoanSubmitCommand借款编号:{} 报错:{}", loanSubmitResponse.getLoanNo(), e.getMessage(), e);
throw new BizException("提现授信审核错误");
}
return JsonResult.success();
}
......
......@@ -2,6 +2,7 @@ package com.jqtx.windows.command;
import com.alibaba.fastjson.JSON;
import com.jqtx.windows.common.converter.ProtocolConverter;
import com.jqtx.windows.common.exception.BizException;
import com.jqtx.windows.common.factory.AbstractCommand;
import com.jqtx.windows.common.factory.RuntimeContextHolder;
import com.jqtx.windows.component.model.UploadPdfDetailRequest;
......@@ -9,6 +10,7 @@ import com.jqtx.windows.component.model.UploadPdfRequest;
import com.jqtx.windows.infrastructure.feign.IProtocalFeignService;
import com.jqtx.windows.web.request.SyncLoanRequest;
import com.jqtx.windows.web.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -17,22 +19,29 @@ import java.util.List;
import java.util.stream.Collectors;
@Service
@Slf4j
public class SaveProtocolCommand extends AbstractCommand {
@Autowired
private IProtocalFeignService iProtocalFeignService;
@Autowired
private ProtocolConverter protocolConverter;
@Override
public JsonResult execute() {
String request = RuntimeContextHolder.currentRuntimeContext().getRequestBody();
SyncLoanRequest syncLoanRequest = JSON.parseObject(request, SyncLoanRequest.class);
UploadPdfRequest uploadPdfRequest=new UploadPdfRequest();
uploadPdfRequest.setLoanNo(syncLoanRequest.getLoanNo());
uploadPdfRequest.setOrderNo(syncLoanRequest.getOrderNo());
List<UploadPdfDetailRequest> detailRequestList= syncLoanRequest.getProtocolList().stream().map(protocolConverter::toModel).collect(Collectors.toList());
uploadPdfRequest.setDetailRequestList(detailRequestList);
iProtocalFeignService.uploadProtocolPdf(uploadPdfRequest);
try {
UploadPdfRequest uploadPdfRequest = new UploadPdfRequest();
uploadPdfRequest.setLoanNo(syncLoanRequest.getLoanNo());
uploadPdfRequest.setOrderNo(syncLoanRequest.getOrderNo());
List<UploadPdfDetailRequest> detailRequestList = syncLoanRequest.getProtocolList().stream().map(protocolConverter::toModel).collect(Collectors.toList());
uploadPdfRequest.setDetailRequestList(detailRequestList);
iProtocalFeignService.uploadProtocolPdf(uploadPdfRequest);
} catch (Exception e) {
log.error("保存用户协议,授信编号:{},报错:{}", syncLoanRequest.getLoanNo(), e.getMessage(), e);
throw new BizException("保存用户协议错误");
}
return JsonResult.success();
}
}
package com.jqtx.windows.command;
import com.alibaba.fastjson.JSONObject;
import com.jqtx.windows.common.exception.BizException;
import com.jqtx.windows.common.factory.AbstractCommand;
import com.jqtx.windows.common.factory.RuntimeContextHolder;
import com.jqtx.windows.component.CreditComponent;
......@@ -22,18 +23,24 @@ public class SignContractCommand extends AbstractCommand {
@Autowired
private CreditComponent creditComponent;
@Override
public JsonResult execute() {
String requestBody = RuntimeContextHolder.currentRuntimeContext().getRequestBody();
SignContractRequest signContractRequest = JSONObject.parseObject(requestBody, SignContractRequest.class);
CreditModel creditModel= creditComponent.getByOrderNo(signContractRequest.getOrderNo());
signContractRequest.setClientName(creditModel.getClientName());
signContractRequest.setCertNo(creditModel.getCertNo());
signContractRequest.setClientCell(creditModel.getClientCell());
log.info("融单协议提交-{}",JSONObject.toJSON(signContractRequest));
creditModel.setCreditThirdToken("INIT");
creditComponent.updateByOrderNo(creditModel.getOrderNo(),creditModel);
iProtocalFeignService.uploadRongdan(signContractRequest);
try {
CreditModel creditModel = creditComponent.getByOrderNo(signContractRequest.getOrderNo());
signContractRequest.setClientName(creditModel.getClientName());
signContractRequest.setCertNo(creditModel.getCertNo());
signContractRequest.setClientCell(creditModel.getClientCell());
log.info("融单协议提交-{}", JSONObject.toJSON(signContractRequest));
creditModel.setCreditThirdToken("INIT");
creditComponent.updateByOrderNo(creditModel.getOrderNo(), creditModel);
iProtocalFeignService.uploadRongdan(signContractRequest);
} catch (Exception e) {
log.error("签约融单协议,授信编号:{},报错:{}", signContractRequest.getOrderNo(), e.getMessage(), e);
throw new BizException("签约融单协议错误");
}
return JsonResult.success();
}
}
......@@ -2,6 +2,7 @@ package com.jqtx.windows.command;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.jqtx.windows.common.exception.BizException;
import com.jqtx.windows.common.factory.AbstractCommand;
import com.jqtx.windows.common.factory.RuntimeContextHolder;
import com.jqtx.windows.common.utils.ValidateUtil;
......@@ -9,11 +10,13 @@ import com.jqtx.windows.component.CreditResultComponent;
import com.jqtx.windows.component.model.CreditResultModel;
import com.jqtx.windows.web.request.SyncCreditResultRequest;
import com.jqtx.windows.web.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class SyncCreditCommand extends AbstractCommand {
@Autowired
private CreditResultComponent creditResultComponent;
......@@ -24,10 +27,14 @@ public class SyncCreditCommand extends AbstractCommand {
SyncCreditResultRequest syncCreditResultRequest = JSON.parseObject(request, SyncCreditResultRequest.class);
//
ValidateUtil.valid(syncCreditResultRequest);
//
CreditResultModel creditResultModel = BeanUtil.toBean(syncCreditResultRequest, CreditResultModel.class);
creditResultModel.setCreditStatus(syncCreditResultRequest.getStatus());
creditResultComponent.insert(creditResultModel);
try {
CreditResultModel creditResultModel = BeanUtil.toBean(syncCreditResultRequest, CreditResultModel.class);
creditResultModel.setCreditStatus(syncCreditResultRequest.getStatus());
creditResultComponent.insert(creditResultModel);
} catch (Exception e) {
log.error("同步授信结果授信编号:{},报错:{}", syncCreditResultRequest.getOrderNo(), e.getMessage(), e);
throw new BizException("同步授信结果错误");
}
return JsonResult.success();
}
}
......@@ -49,11 +49,11 @@ public class SyncLoanCommand extends AbstractCommand {
@Override
public JsonResult execute() {
String request = RuntimeContextHolder.currentRuntimeContext().getRequestBody();
SyncLoanRequest syncLoanRequest = JSON.parseObject(request, SyncLoanRequest.class);
//校验
ValidateUtil.valid(syncLoanRequest);
try {
String request = RuntimeContextHolder.currentRuntimeContext().getRequestBody();
SyncLoanRequest syncLoanRequest = JSON.parseObject(request, SyncLoanRequest.class);
//校验
ValidateUtil.valid(syncLoanRequest);
//修改loan
LoanModel loanModel = loanComponent.getByLoanNo(syncLoanRequest.getLoanNo());
Assert.isFalse(loanModel == null, "借款不存在");
......@@ -95,9 +95,9 @@ public class SyncLoanCommand extends AbstractCommand {
List<UploadPdfDetailRequest> detailRequestList = syncLoanRequest.getProtocolList().stream().map(protocolConverter::toModel).collect(Collectors.toList());
uploadPdfRequest.setDetailRequestList(detailRequestList);
iProtocalFeignService.uploadProtocolPdf(uploadPdfRequest);
} catch (BizException e) {
log.error("同步放款错误:{}", e.getMessage(), e);
throw new BizException("同步放款错误");
} catch (Exception e) {
log.error("同步放款借款编号:{},数据错误:{}", syncLoanRequest.getLoanNo(), e.getMessage(), e);
throw new BizException("同步放款数据错误");
}
return JsonResult.success();
......
......@@ -9,18 +9,21 @@ import org.springframework.stereotype.Service;
@Service
@Slf4j
public abstract class AbstractCommand{
public abstract class AbstractCommand {
public JsonResult doAction(){
try{
public JsonResult doAction() {
try {
return this.execute();
}catch (BizException e){
log.error("[处理业务异常:{}]",e.getMessage(),e);
} catch (BizException e) {
log.error("[处理业务异常:{}]", e.getMessage(), e);
return JsonResult.error(e.getErrorEnum());
}catch (Exception e){
log.error("[处理异常:{}]",e.getMessage(),e);
}finally {
RuntimeContextHolder.clear();
} catch (IllegalArgumentException e) {
log.error("[处理业务异常:{}]", e.getMessage(), e);
return JsonResult.error(e.getMessage());
} catch (Exception e) {
log.error("[处理异常:{}]", e.getMessage(), e);
} finally {
RuntimeContextHolder.clear();
}
return JsonResult.error(ExceptionCodeEnum.SYSTEM_ERROR);
}
......
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