Commit 9bb15646 authored by suntao's avatar suntao

Merge branch 'master' into v1

* master:
  操作的重复 在切面中判断
parents a7a3715a 03b29c42
...@@ -309,12 +309,6 @@ public class OrderServiceImpl implements OrderService{ ...@@ -309,12 +309,6 @@ public class OrderServiceImpl implements OrderService{
return new Tuple<>(false, "orderMapping为空或者loanId为空"); return new Tuple<>(false, "orderMapping为空或者loanId为空");
} }
OptHistoryLog optHistoryLogExsit = optHistoryLogService.findByChannelOrderNumberAndOptNameAndSuccess(channelOrderNumber, secondAudit);
if (optHistoryLogExsit != null) {
log.info("secondAudit,已经操作成功,channelOrderNumber=".concat(channelOrderNumber));
return new Tuple<>(true, "已经操作成功. 重复操作");
}
// 更新合同状态 // 更新合同状态
Contract conscont= xyqbCenterService.findContractByUserId(orderMapping.getQgUserId()); Contract conscont= xyqbCenterService.findContractByUserId(orderMapping.getQgUserId());
if (conscont != null) { if (conscont != null) {
...@@ -403,14 +397,21 @@ public class OrderServiceImpl implements OrderService{ ...@@ -403,14 +397,21 @@ public class OrderServiceImpl implements OrderService{
} else { } else {
// p2p // p2p
Map data = this.xyqbCenterService.queryLendingRecordCount(Long.valueOf(orderApprove.getFundId())); Map data = null;
try {
data = this.xyqbCenterService.queryLendingRecordCount(Long.valueOf(orderApprove.getFundId()));
} catch (Exception e) {
log.error("[order_lending][queryLendingRecordCount]查询待打款数量 失败,channelOrderNumber={}, data={}", lendingFormModel.getChannelOrderNumber(), data);
}
log.info("[order_lending][queryLendingRecordCount]查询待打款数量,channelOrderNumber={}, data={}", lendingFormModel.getChannelOrderNumber(), data); log.info("[order_lending][queryLendingRecordCount]查询待打款数量,channelOrderNumber={}, data={}", lendingFormModel.getChannelOrderNumber(), data);
if (data.size() > 0) { if (data !=null && data.size() > 0) {
if (Objects.nonNull(data.get("totalAmount")) && Objects.nonNull(data.get("totalCount"))) { if (Objects.nonNull(data.get("totalAmount")) && Objects.nonNull(data.get("totalCount"))) {
result = this.clothoCenterService.lending(orderApprove.getFundId(), new BigDecimal(String.valueOf(data.get("totalAmount"))), Integer.valueOf(String.valueOf(data.get("totalCount")))); result = this.clothoCenterService.lending(orderApprove.getFundId(), new BigDecimal(String.valueOf(data.get("totalAmount"))), Integer.valueOf(String.valueOf(data.get("totalCount"))));
log.info("[order_lending]直投打款,channelOrderNumber={}, result={}", lendingFormModel.getChannelOrderNumber(), result); log.info("[order_lending]直投打款,channelOrderNumber={}, result={}", lendingFormModel.getChannelOrderNumber(), result);
} }
} }
result = true;
} }
if (result) { if (result) {
......
...@@ -10,6 +10,7 @@ import cn.quantgroup.cashloanflowboss.spi.clf.entity.ClfOrderMapping; ...@@ -10,6 +10,7 @@ import cn.quantgroup.cashloanflowboss.spi.clf.entity.ClfOrderMapping;
import cn.quantgroup.cashloanflowboss.spi.clf.service.CLFCenterService; import cn.quantgroup.cashloanflowboss.spi.clf.service.CLFCenterService;
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.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
...@@ -51,6 +52,8 @@ public class OperationAspect { ...@@ -51,6 +52,8 @@ public class OperationAspect {
*/ */
@Around("operationAnno()") @Around("operationAnno()")
private Object operationAnnoAndSave(ProceedingJoinPoint pjp) throws Throwable { private Object operationAnnoAndSave(ProceedingJoinPoint pjp) throws Throwable {
try {
MethodSignature methodSignature = (MethodSignature) pjp.getSignature(); MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
Method method = methodSignature.getMethod(); Method method = methodSignature.getMethod();
OperationAnno annotation = method.getAnnotation(OperationAnno.class); OperationAnno annotation = method.getAnnotation(OperationAnno.class);
...@@ -98,14 +101,13 @@ public class OperationAspect { ...@@ -98,14 +101,13 @@ public class OperationAspect {
log.warn("[operationAnnoAnnSave]channelOrderNumber is empty, channelOrderNumber={}" , channelOrderNumber ); log.warn("[operationAnnoAnnSave]channelOrderNumber is empty, channelOrderNumber={}" , channelOrderNumber );
return pjp.proceed(); return pjp.proceed();
} }
Object proceed = pjp.proceed();
// 是否成功SPEL 表达式解析
Expression expressionsuccSPEL = null;
if (StringUtils.isNotEmpty(succSPEL)) { if (StringUtils.isNotEmpty(succSPEL)) {
try { try {
if (succSPEL.startsWith("#this")) {//判断是否是spel表达式 if (succSPEL.startsWith("#this")) {//判断是否是spel表达式
Expression expression = new SpelExpressionParser().parseExpression(succSPEL); expressionsuccSPEL = new SpelExpressionParser().parseExpression(succSPEL);
Boolean isSuccess = expression.getValue(proceed, Boolean.class);
optHistoryLog.setOptResult(isSuccess);
} else { } else {
log.warn("[operationAnnoAnnSave]optResult获取失败"); log.warn("[operationAnnoAnnSave]optResult获取失败");
} }
...@@ -115,12 +117,11 @@ public class OperationAspect { ...@@ -115,12 +117,11 @@ public class OperationAspect {
} }
} }
Expression expressionMsgSPEL = null;
if (StringUtils.isNotEmpty(optDetailSPEL)) { if (StringUtils.isNotEmpty(optDetailSPEL)) {
try { try {
if (optDetailSPEL.startsWith("#this")) {//判断是否是spel表达式 if (optDetailSPEL.startsWith("#this")) {//判断是否是spel表达式
Expression expression = new SpelExpressionParser().parseExpression(optDetailSPEL); expressionMsgSPEL = new SpelExpressionParser().parseExpression(optDetailSPEL);
String optDetail = expression.getValue(proceed, String.class);
optHistoryLog.setOptLogDetail(optDetail);
} else { } else {
log.warn("[operationAnnoAnnSave]optDetail获取失败"); log.warn("[operationAnnoAnnSave]optDetail获取失败");
} }
...@@ -130,8 +131,45 @@ public class OperationAspect { ...@@ -130,8 +131,45 @@ public class OperationAspect {
} }
} }
optHistoryLogService.save(optHistoryLog); if (StringUtils.isNotEmpty(channelOrderNumber)) {
// 判断是否 已经请求成功过
OptHistoryLog optHistoryLogSuccess = optHistoryLogService.findByChannelOrderNumberAndOptNameAndSuccess(channelOrderNumber, opt);
if (optHistoryLogSuccess != null) {
Class returnType = ((MethodSignature) pjp.getSignature()).getReturnType();
if (returnType != null) {
Object ret = returnType.newInstance();
if (expressionsuccSPEL != null) {
expressionsuccSPEL.setValue(ret, true);
}
if (expressionMsgSPEL != null) {
expressionMsgSPEL.setValue(ret, "该操作已经操作成功,无须重复操作!");
}
// 直接返回 重复操作结果
log.info("[operationAnnoAnnSave]该操作已经操作成功,无须重复操作,切面返回");
return ret;
}
}
}
// 代理执行方法
Object proceed = pjp.proceed();
// 获取方法返回 是否成功
if (expressionsuccSPEL != null) {
optHistoryLog.setOptResult(expressionsuccSPEL.getValue(proceed, Boolean.class));
}
// 获取方法详细信息
if (expressionMsgSPEL != null) {
optHistoryLog.setOptLogDetail(expressionMsgSPEL.getValue(proceed, String.class));
}
optHistoryLogService.save(optHistoryLog);
return proceed; return proceed;
} catch (Throwable throwable) {
log.error("[operationAnnoAnnSave]异常,直接跳过,e={}", ExceptionUtils.getStackTrace(throwable));
return pjp.proceed();
}
} }
} }
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