Commit 0d60ea3a authored by 胡建龙's avatar 胡建龙

20220426 记录订单状态及日志

parent cdcd1d18
...@@ -8,7 +8,9 @@ import com.chinapay.secss.LogUtil; ...@@ -8,7 +8,9 @@ import com.chinapay.secss.LogUtil;
import com.chinapay.service.IHlsEbankCcbTransactionService; import com.chinapay.service.IHlsEbankCcbTransactionService;
import com.chinapay.util.StringUtil; import com.chinapay.util.StringUtil;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.hand.app.cmb.dto.HlsEbankCmbTransqry;
import com.hand.app.cmb.dto.Ld037; import com.hand.app.cmb.dto.Ld037;
import com.hand.app.cmb.mapper.HlsEbankCmbTransqryMapper;
import com.hand.app.cmb.mapper.Ld037Mapper; import com.hand.app.cmb.mapper.Ld037Mapper;
import com.hand.app.cmb.service.HclcCmbPolyService; import com.hand.app.cmb.service.HclcCmbPolyService;
import com.hand.app.cmb.util.MD5Utils; import com.hand.app.cmb.util.MD5Utils;
...@@ -536,6 +538,10 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService { ...@@ -536,6 +538,10 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
result.put("tradeState",hlsEbankCcbTransaction.getOrderStatus()); result.put("tradeState",hlsEbankCcbTransaction.getOrderStatus());
return result; return result;
} }
hlsEbankCmbTransqry.setOrderId(hlsEbankCcbTransaction.getCmbOrderId());
hlsEbankCmbTransqry.setTxnAmt(Math.round(hlsEbankCcbTransaction.getAmount()*100));
Map<String,String> responseMap = null; Map<String,String> responseMap = null;
ObjectMapper mapper =null; ObjectMapper mapper =null;
HlsWsRequests hlsWsRequests = null; HlsWsRequests hlsWsRequests = null;
...@@ -563,6 +569,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService { ...@@ -563,6 +569,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
apiHeader.put("timestamp", "" + currentTimeMills); apiHeader.put("timestamp", "" + currentTimeMills);
apiHeader.put("apisign", apiSignString); apiHeader.put("apisign", apiSignString);
hlsWsRequests = logInterfaceRequest(queryQrState, url, mapper.writeValueAsString(apiHeader), hlsEbankCcbTransaction.getTransactionId()); hlsWsRequests = logInterfaceRequest(queryQrState, url, mapper.writeValueAsString(apiHeader), hlsEbankCcbTransaction.getTransactionId());
//发送http请求 //发送http请求
responseMap = Utils.postForEntity(url,signResult,apiHeader); responseMap = Utils.postForEntity(url,signResult,apiHeader);
...@@ -585,23 +592,36 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService { ...@@ -585,23 +592,36 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
//数据验签成功 if (checkResponse) { //数据验签成功 if (checkResponse) {
//获取返回码,返回码不为SUCCESS表示报文内的字段不符合规范 //获取返回码,返回码不为SUCCESS表示报文内的字段不符合规范
String returnCode = responseMap.get("returnCode"); String returnCode = responseMap.get("returnCode");
hlsEbankCmbTransqry.setReturnCode(returnCode);
if ("SUCCESS".equalsIgnoreCase(returnCode)) { if ("SUCCESS".equalsIgnoreCase(returnCode)) {
//响应码 //响应码
String respCode = responseMap.get("returnCode"); String respCode = responseMap.get("returnCode");
if ("SUCCESS".equalsIgnoreCase(respCode)) { if ("SUCCESS".equalsIgnoreCase(respCode)) {
//成功拿到订单状态请求的响应 //成功拿到订单状态请求的响应
hlsEbankCmbTransqry.setCmbOrderId(responseMap.get("cmbOrderId"));
hlsEbankCmbTransqry.setTxnTime(responseMap.get("txnTime"));
hlsEbankCmbTransqry.setPayType(responseMap.get("payType"));
hlsEbankCmbTransqry.setPayBank(responseMap.get("payBank"));
hlsEbankCmbTransqry.setTradeState(responseMap.get("tradeState"));
hlsEbankCmbTransqry.setEndDate(responseMap.get("endDate"));
hlsEbankCmbTransqry.setEndTime(responseMap.get("endTime"));
resultType = "1"; resultType = "1";
} else { } else {
if ("SYSTERM_ERROR".equalsIgnoreCase(responseMap.get("errcode"))){ if ("SYSTERM_ERROR".equalsIgnoreCase(responseMap.get("errcode"))){
hlsEbankCmbTransqry.setReturnCode(respCode);
resultType = "6"; resultType = "6";
}else{ }else{
//请求成功,但是响应结果为失败,传给前端失败原因就行 //请求成功,但是响应结果为失败,传给前端失败原因就行
hlsEbankCmbTransqry.setErrCode(responseMap.get("errCode"));
hlsEbankCmbTransqry.setRespMsg(responseMap.get("respMsg"));
resultType = "2"; resultType = "2";
} }
} }
} else { } else {
//返回码都失败 //返回码都失败
hlsEbankCmbTransqry.setErrCode(responseMap.get("errCode"));
hlsEbankCmbTransqry.setRespMsg(responseMap.get("respMsg"));
resultType = "3"; resultType = "3";
} }
...@@ -621,6 +641,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService { ...@@ -621,6 +641,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
hlsWsRequests.setReturnStatus("E"); hlsWsRequests.setReturnStatus("E");
hlsWsRequests.setResponsedDate(new Date()); hlsWsRequests.setResponsedDate(new Date());
} }
hlsEbankCmbTransqryMapper.updateByPrimaryKey(hlsEbankCmbTransqry);
hlsWsRequestsMapper.updateByPrimaryKeySelective(hlsWsRequests); hlsWsRequestsMapper.updateByPrimaryKeySelective(hlsWsRequests);
hlsEbankCcbTransaction = setEbankTransactionQR(hlsEbankCcbTransaction, responseMap, resultType); hlsEbankCcbTransaction = setEbankTransactionQR(hlsEbankCcbTransaction, responseMap, resultType);
hlsEbankCcbTransactionMapper.updateByPrimaryKeySelective(hlsEbankCcbTransaction); hlsEbankCcbTransactionMapper.updateByPrimaryKeySelective(hlsEbankCcbTransaction);
...@@ -875,13 +896,10 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService { ...@@ -875,13 +896,10 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
//开始封装请求部分 //开始封装请求部分
String signResult = getOrderQueryParameter(hlsEbankCcbTransaction); String signResult = getOrderQueryParameter(hlsEbankCcbTransaction);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
Map<String,String> signResultMap = null;
Map<String, String> apiHeader = null;
try { try {
signResultMap = mapper.readValue(signResult, Map.class); Map<String,String> signResultMap = mapper.readValue(signResult, Map.class);
} catch (IOException e) {
/// resultType = "5";
e.printStackTrace();
}
long currentTimeMills = System.currentTimeMillis() / 1000; long currentTimeMills = System.currentTimeMillis() / 1000;
// 组apiSign加密Map // 组apiSign加密Map
...@@ -896,27 +914,36 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService { ...@@ -896,27 +914,36 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
String apiSignString = MD5Utils.getMD5Content(MD5Content).toLowerCase(); String apiSignString = MD5Utils.getMD5Content(MD5Content).toLowerCase();
// 组request头部Map // 组request头部Map
Map<String, String> apiHeader = new HashMap<>(); apiHeader = new HashMap<>();
apiHeader.put("appid", appId); apiHeader.put("appid", appId);
apiHeader.put("timestamp", "" + currentTimeMills); apiHeader.put("timestamp", "" + currentTimeMills);
apiHeader.put("apisign", apiSignString); apiHeader.put("apisign", apiSignString);
Map<String,String> responseMap = Utils.postForEntity(closeUrl,signResult,apiHeader); hlsEbankCmbTransqry.setOrderId(hlsEbankCcbTransaction.getCmbOrderId());
//处理响应报文 hlsEbankCmbTransqry.setTxnAmt(Math.round(hlsEbankCcbTransaction.getAmount()*100));
Boolean checkResponse = null; } catch (IOException e) {
try { /// resultType = "5";
checkResponse = checkSign(mapper.writeValueAsString(responseMap));
} catch (JsonProcessingException e) {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "数据验签失败");
e.printStackTrace(); e.printStackTrace();
} }
//数据验签成功 if (checkResponse) { HlsWsRequests hlsWsRequests = null;
try {
hlsWsRequests = logInterfaceRequest(queryQrState, url, mapper.writeValueAsString(apiHeader), hlsEbankCcbTransaction.getTransactionId());
Map<String,String> responseMap = Utils.postForEntity(closeUrl,signResult,apiHeader);
//处理响应报文
Boolean checkResponse = checkSign(mapper.writeValueAsString(responseMap));
//数据验签成功
if (checkResponse) {
hlsWsRequests.setResponseClob(mapper.writeValueAsString(responseMap));
hlsWsRequests.setReturnStatus("S");
hlsWsRequests.setResponsedDate(new Date());
//获取返回码,返回码不为SUCCESS表示报文内的字段不符合规范 //获取返回码,返回码不为SUCCESS表示报文内的字段不符合规范
String returnCode = responseMap.get("returnCode"); String returnCode = responseMap.get("returnCode");
hlsEbankCmbTransqry.setReturnCode(returnCode);
if ("SUCCESS".equalsIgnoreCase(returnCode)) { if ("SUCCESS".equalsIgnoreCase(returnCode)) {
//响应码 //响应码
String respCode = responseMap.get("returnCode"); String respCode = responseMap.get("respCode");
hlsEbankCmbTransqry.setRespCode(respCode);
hlsEbankCmbTransqry.setOrderId(responseMap.get("origOrderId"));
if ("ORDER_PAID".equalsIgnoreCase(respCode)){ if ("ORDER_PAID".equalsIgnoreCase(respCode)){
//需要调用退款接口 //需要调用退款接口
result.put(Constants.RESP_CODE, "E"); result.put(Constants.RESP_CODE, "E");
...@@ -925,6 +952,8 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService { ...@@ -925,6 +952,8 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
} }
else if ("SUCCESS".equalsIgnoreCase(respCode)) { else if ("SUCCESS".equalsIgnoreCase(respCode)) {
//订单关闭成功 //订单关闭成功
hlsEbankCmbTransqry.setTradeState(responseMap.get("closeState"));
hlsEbankCmbTransqry.setTxnTime(responseMap.get("txnTime"));
if ("C".equalsIgnoreCase(responseMap.get("closeState"))){ if ("C".equalsIgnoreCase(responseMap.get("closeState"))){
hlsEbankCcbTransaction.setStatus(transClose); hlsEbankCcbTransaction.setStatus(transClose);
hlsEbankCcbTransaction.setOrderStatus("C"); hlsEbankCcbTransaction.setOrderStatus("C");
...@@ -949,20 +978,32 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService { ...@@ -949,20 +978,32 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
result.put("respMsg", "需要重新调用查询接口!"); result.put("respMsg", "需要重新调用查询接口!");
} }
else if ("FAIL".equalsIgnoreCase(respCode)){ else if ("FAIL".equalsIgnoreCase(respCode)){
hlsEbankCmbTransqry.setErrCode(responseMap.get("errCode"));
hlsEbankCmbTransqry.setRespMsg(responseMap.get("respMsg"));
result.put("errCode", responseMap.get("errCode")); result.put("errCode", responseMap.get("errCode"));
result.put("respMsg", responseMap.get("respMsg")); result.put("respMsg", responseMap.get("respMsg"));
} }
} else { } else {
//返回码都失败 //返回码都失败
hlsEbankCmbTransqry.setErrCode(responseMap.get("errCode"));
hlsEbankCmbTransqry.setRespMsg(responseMap.get("respMsg"));
result.put("errCode", responseMap.get("errCode")); result.put("errCode", responseMap.get("errCode"));
result.put("respMsg", responseMap.get("respMsg")); result.put("respMsg", responseMap.get("respMsg"));
} }
}
} catch (JsonProcessingException e) {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "数据验签失败");
hlsWsRequests.setReturnStatus("E");
hlsWsRequests.setResponsedDate(new Date());
e.printStackTrace();
}
hlsEbankCmbTransqryMapper.updateByPrimaryKey(hlsEbankCmbTransqry);
hlsWsRequestsMapper.updateByPrimaryKey(hlsWsRequests);
hlsEbankCcbTransactionMapper.updateByPrimaryKey(hlsEbankCcbTransaction); hlsEbankCcbTransactionMapper.updateByPrimaryKey(hlsEbankCcbTransaction);
return result; return result;
} }
private Map<String, String> str2Map(String str) { private Map<String, String> str2Map(String str) {
Map<String, String> result = new HashMap<>(); Map<String, String> result = new HashMap<>();
String[] results = str.split("&"); String[] results = str.split("&");
......
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