|
|
@@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.HttpStatus;
|
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
|
+import org.checkerframework.checker.units.qual.K;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
@@ -76,7 +77,7 @@ public class BizHandlerFactory {
|
|
|
ipLogPO.setStatus("fail");
|
|
|
}
|
|
|
ipOrderPO.setUpdateTime(LocalDateTime.now());
|
|
|
- ipOrderPO.setBusinessNo(ipOrderPO.getOrderNo());
|
|
|
+ ipOrderPO.setBusinessNo(logDto.getBusinessNo());
|
|
|
ipLogPO.setUrl(logDto.getUrl());
|
|
|
ipLogPO.setRequestParam(logDto.getRequestParam());
|
|
|
ipLogPO.setUpdateTime(LocalDateTime.now());
|
|
|
@@ -113,9 +114,36 @@ public class BizHandlerFactory {
|
|
|
ipLogPO.setStatus("handle");
|
|
|
}
|
|
|
|
|
|
+ private void wrapCallBackOrder(IpOrderPO ipOrder, Boolean callbackStatus) {
|
|
|
+ IpLogPO ipLog = new IpLogPO();
|
|
|
+ IpOrderPO ipOrderPO = new IpOrderPO();
|
|
|
+
|
|
|
+ ipOrderPO.setId(SnowflakeIdWorker.nextId());
|
|
|
+ ipOrderPO.setInterfaceName(ipOrder.getInterfaceName());
|
|
|
+ ipOrderPO.setAccNo(ipOrder.getAccNo());
|
|
|
+
|
|
|
+ ipOrderPO.setCallbackUrl(ipOrder.getCallbackUrl());
|
|
|
+ ipOrderPO.setAddTime(LocalDateTime.now());
|
|
|
+ ipOrderPO.setUpdateTime(LocalDateTime.now());
|
|
|
+ ipOrderPO.setManufacturer(ipOrder.getManufacturer());
|
|
|
+ ipOrderPO.setStatus(callbackStatus ? "success" : "fail");
|
|
|
+ ipOrderPO.setCallbackStatus(callbackStatus ? "success" : "fail");
|
|
|
+
|
|
|
+ ipLog.setId(SnowflakeIdWorker.nextId());
|
|
|
+ ipLog.setOid(ipOrderPO.getId());
|
|
|
+ ipLog.setAddTime(LocalDateTime.now());
|
|
|
+ ipLog.setExecuteType("callback");
|
|
|
+ ipLog.setStatus(callbackStatus ? "success" : "fail");
|
|
|
+ ipLog.setAddTime(LocalDateTime.now());
|
|
|
+ ipLog.setUpdateTime(LocalDateTime.now());
|
|
|
+ ipOrderRepository.save(ipOrderPO);
|
|
|
+ ipLogRepository.save(ipLog);
|
|
|
+ }
|
|
|
+
|
|
|
public Boolean doCallBack(String interfaceNo, String businessNo, JSONObject json) {
|
|
|
- IpOrderPO ipOrderPO = ipOrderRepository.queryByBusinessNo(businessNo);
|
|
|
- if(ipOrderPO != null){
|
|
|
+
|
|
|
+ IpOrderPO ipOrderPO = ipOrderRepository.findByBusinessNo(businessNo);
|
|
|
+ if(ipOrderPO == null){
|
|
|
log.error("找不到对应的业务编码");
|
|
|
return false;
|
|
|
}
|
|
|
@@ -132,15 +160,15 @@ public class BizHandlerFactory {
|
|
|
BizHandler handler = getHandler(interfaceNo);
|
|
|
Boolean callbackResult = false;
|
|
|
ipOrderPO.setCallbackStatus("handle");
|
|
|
- for (Integer i = 0; i < ipOrderPO.getCallbackNum(); i++) {
|
|
|
+ for (int i = 0; i < ipOrderPO.getCallbackNum(); i++) {
|
|
|
Boolean result = handler.doCallBack(ipOrderPO, json);
|
|
|
+ // 记录调用记录
|
|
|
+ wrapCallBackOrder(ipOrderPO,result);
|
|
|
if(result){
|
|
|
callbackResult = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- ipOrderPO.setCallbackStatus(callbackResult ? "success" : "fail");
|
|
|
- ipOrderRepository.save(ipOrderPO);
|
|
|
return callbackResult;
|
|
|
}
|
|
|
-}
|
|
|
+}
|