保存日志
This commit is contained in:
parent
9fd9436d94
commit
25696996d7
|
@ -1,5 +1,12 @@
|
|||
package com.hzya.frame.cbs8.dto.res;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description 经办支付接口返回参数中的data节点
|
||||
* @Author xiangerlin
|
||||
|
@ -70,4 +77,22 @@ public class PayResponseDTO {
|
|||
public void setSuccessed(Boolean successed) {
|
||||
this.successed = successed;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从银行响应报文解析
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
public static PayResponseDTO payResValueOf(String result){
|
||||
if (StrUtil.isNotEmpty(result)){
|
||||
CbsResponseDTO cbsResponseDTO = JSONObject.parseObject(result, CbsResponseDTO.class);
|
||||
List<JSONObject> dataList = cbsResponseDTO.getData();
|
||||
if (CollectionUtils.isNotEmpty(dataList)){
|
||||
JSONObject o = dataList.get(0);
|
||||
PayResponseDTO payResponseDTO = JSON.toJavaObject(o, PayResponseDTO.class);
|
||||
return payResponseDTO;
|
||||
}
|
||||
}
|
||||
return new PayResponseDTO();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.cbs8.dto.req.*;
|
||||
import com.hzya.frame.cbs8.dto.res.PayResponseDTO;
|
||||
import com.hzya.frame.cbs8.service.ICbs8ExtService;
|
||||
import com.hzya.frame.cbs8.util.CBSUtil;
|
||||
import com.hzya.frame.cbs8.util.CbsAccessToken;
|
||||
|
@ -11,12 +12,14 @@ import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity;
|
|||
import com.hzya.frame.stringutil.StringUtil;
|
||||
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
|
||||
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
|
||||
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
|
||||
import com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity;
|
||||
import com.hzya.frame.web.exception.BaseSystemException;
|
||||
import org.apache.http.protocol.HTTP;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -29,6 +32,8 @@ import java.util.*;
|
|||
public class Cbs8ExtServiceImpl implements ICbs8ExtService {
|
||||
|
||||
Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
|
||||
|
||||
/**
|
||||
* 支付经办
|
||||
*
|
||||
|
@ -65,7 +70,7 @@ public class Cbs8ExtServiceImpl implements ICbs8ExtService {
|
|||
String requestData = JSONObject.toJSONString(list);
|
||||
//加密 签名
|
||||
encrypAndsign(entity, requestData);
|
||||
entity.setBodys(JSONObject.toJSONString(payRequestDTO));
|
||||
entity.setBodys(requestData);
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
|
@ -78,18 +83,40 @@ public class Cbs8ExtServiceImpl implements ICbs8ExtService {
|
|||
*/
|
||||
@Override
|
||||
public void payApplyCallBack(SysMessageManageLogEntity logEntity) {
|
||||
try {
|
||||
//todo 这里要验证一下bodys里有没有数据
|
||||
logger.info("回调方法里的参数:{}", JSONObject.toJSONString(logEntity));
|
||||
JSONObject targetData = JSONObject.parseObject(logEntity.getTargetData());//目标数据
|
||||
JSONObject sourceData = JSONObject.parseObject(logEntity.getSourceData());//源数据
|
||||
JSONObject sourceHeaders = sourceData.getJSONObject("header");//源header
|
||||
JSONObject targetHeaders = targetData.getJSONObject("header");//目标header
|
||||
JSONObject sourceBody = sourceData.getJSONObject("body");//源数据body
|
||||
//自定义参数,存放的是请求报文明文
|
||||
String hzyaExtData = targetHeaders.getString("hzyaExtData");
|
||||
String returnDataBase64 = logEntity.getReturnData();
|
||||
byte[] secretResByte = Base64.getDecoder().decode(returnDataBase64);
|
||||
//解密报文
|
||||
String decryptRes = CBSUtil.decrypt(secretResByte);
|
||||
//6、记录系统日志
|
||||
IntegrationTaskLivingDetailsEntity logTask = new IntegrationTaskLivingDetailsEntity();
|
||||
//logTask.setRootAppPk(pay.getFormsonId());
|
||||
//logTask.setRootAppBill(pay.getReferenceNum());
|
||||
logTask.setRootAppPk(sourceBody.getString("formsonId"));
|
||||
logTask.setRootAppBill(sourceBody.getString("referenceNum"));
|
||||
logTask.setPluginId("CBS8PayApplyPlugin");
|
||||
//对方接口返回信息
|
||||
//logTask.setNewTransmitInfo(JSONObject.toJSONString(payResponseDTO));
|
||||
logTask.setNewTransmitInfo(decryptRes);
|
||||
logTask.setNewPushDate(new Date());
|
||||
//调用接口请求参数
|
||||
logTask.setRootAppNewData("");
|
||||
//saveTaskLog();
|
||||
logTask.setRootAppNewData(hzyaExtData);
|
||||
PayResponseDTO payResponseDTO = PayResponseDTO.payResValueOf(decryptRes);
|
||||
//为true是成功
|
||||
if (payResponseDTO.getSuccessed()) {
|
||||
taskLivingDetailsService.saveLogToSuccess(logTask);
|
||||
}else {
|
||||
taskLivingDetailsService.saveLogToFail(logTask);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.info("payApplyCallBack方法执行出错:{}",e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,7 +196,6 @@ public class Cbs8ExtServiceImpl implements ICbs8ExtService {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 代发代扣结果查询
|
||||
*
|
||||
|
@ -208,6 +234,7 @@ public class Cbs8ExtServiceImpl implements ICbs8ExtService {
|
|||
|
||||
/**
|
||||
* 请求头
|
||||
*
|
||||
* @param sign
|
||||
* @param timestamp
|
||||
* @return
|
||||
|
@ -223,6 +250,7 @@ public class Cbs8ExtServiceImpl implements ICbs8ExtService {
|
|||
|
||||
/**
|
||||
* 加密 签名
|
||||
*
|
||||
* @param entity 接口转发参数对象
|
||||
* @param requestData 请求参数json字符串
|
||||
*/
|
||||
|
@ -234,6 +262,7 @@ public class Cbs8ExtServiceImpl implements ICbs8ExtService {
|
|||
//加密
|
||||
byte[] encryptedData = CBSUtil.encrypt(requestData);
|
||||
Map<String, String> header = headersValueOf(sign, timestamp);
|
||||
header.put("hzyaExtData", requestData);
|
||||
entity.setByteBodys(encryptedData);
|
||||
entity.setHeaders(header);
|
||||
}
|
||||
|
|
|
@ -47,17 +47,18 @@ public class Cbs8ServiceImpl implements ICbs8Service {
|
|||
String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterfaceToESB").addHeaders(headerMap).body(JSONObject.toJSONString(paymentEntity)).timeout(60000).execute().body();
|
||||
//解密响应报文
|
||||
String result = decryptResBody(body);
|
||||
if (StrUtil.isNotEmpty(result)){
|
||||
CbsResponseDTO cbsResponseDTO = JSONObject.parseObject(result, CbsResponseDTO.class);
|
||||
List<JSONObject> dataList = cbsResponseDTO.getData();
|
||||
if (CollectionUtils.isNotEmpty(dataList)){
|
||||
JSONObject o = dataList.get(0);
|
||||
PayResponseDTO payResponseDTO = JSON.toJavaObject(o, PayResponseDTO.class);
|
||||
PayResponseDTO payResponseDTO = PayResponseDTO.payResValueOf(result);
|
||||
// if (StrUtil.isNotEmpty(result)){
|
||||
// CbsResponseDTO cbsResponseDTO = JSONObject.parseObject(result, CbsResponseDTO.class);
|
||||
// List<JSONObject> dataList = cbsResponseDTO.getData();
|
||||
// if (CollectionUtils.isNotEmpty(dataList)){
|
||||
// JSONObject o = dataList.get(0);
|
||||
// PayResponseDTO payResponseDTO = JSON.toJavaObject(o, PayResponseDTO.class);
|
||||
// return payResponseDTO;
|
||||
// }
|
||||
// }
|
||||
return payResponseDTO;
|
||||
}
|
||||
}
|
||||
return new PayResponseDTO();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过业务参考号查询交易结果 3.2.6
|
||||
|
@ -205,17 +206,18 @@ public class Cbs8ServiceImpl implements ICbs8Service {
|
|||
.build();
|
||||
String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterfaceToESB").addHeaders(headerMap).body(params).timeout(60000).execute().body();
|
||||
String result = decryptResBody(body);
|
||||
if (StrUtil.isNotEmpty(result)){
|
||||
CbsResponseDTO cbsResponseDTO = JSONObject.parseObject(result, CbsResponseDTO.class);
|
||||
List<JSONObject> dataList = cbsResponseDTO.getData();
|
||||
if (CollectionUtils.isNotEmpty(dataList)){
|
||||
JSONObject o = dataList.get(0);
|
||||
PayResponseDTO payResponseDTO = JSON.toJavaObject(o, PayResponseDTO.class);
|
||||
PayResponseDTO payResponseDTO = PayResponseDTO.payResValueOf(result);
|
||||
// if (StrUtil.isNotEmpty(result)){
|
||||
// CbsResponseDTO cbsResponseDTO = JSONObject.parseObject(result, CbsResponseDTO.class);
|
||||
// List<JSONObject> dataList = cbsResponseDTO.getData();
|
||||
// if (CollectionUtils.isNotEmpty(dataList)){
|
||||
// JSONObject o = dataList.get(0);
|
||||
// PayResponseDTO payResponseDTO = JSON.toJavaObject(o, PayResponseDTO.class);
|
||||
// return payResponseDTO;
|
||||
// }
|
||||
// }
|
||||
return payResponseDTO;
|
||||
}
|
||||
}
|
||||
return new PayResponseDTO();
|
||||
}
|
||||
|
||||
/**
|
||||
* 代发代扣 详情查询
|
||||
|
|
Loading…
Reference in New Issue