Browse Source

[支付/退款回调][修复]:支付回调处理返回

release_toaliyun_real
Stormeye.Wu 7 years ago
parent
commit
2a03feeed9
3 changed files with 38 additions and 32 deletions
  1. +6
    -6
      mallinkAdmin/src/main/java/com/simple/controller/WxPayController.java
  2. +13
    -10
      mallinkService/src/main/java/com/simple/service/impl/WxPayOrderServiceImpl.java
  3. +19
    -16
      mallinkService/src/main/java/com/simple/service/impl/WxRefundOrderServiceImpl.java

+ 6
- 6
mallinkAdmin/src/main/java/com/simple/controller/WxPayController.java View File

@@ -99,22 +99,22 @@ public class WxPayController extends BaseController {
return response;
} catch (BizMessageException e) {
logger.error("refund wxpay, notify error, req: " + paramMap.toString() + ", e:" + e.getLocalizedMessage());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", e.getMessage());
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
} catch (MallinkException e) {
logger.error("refund wxpay, notify error, req: " + paramMap.toString() + ", e:" +e.getLocalizedMessage());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", e.getMessage());
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
} catch (Exception e) {
logger.error("refund wxpay, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", e.getMessage());
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
}
}


+ 13
- 10
mallinkService/src/main/java/com/simple/service/impl/WxPayOrderServiceImpl.java View File

@@ -220,10 +220,10 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
}
if (!"SUCCESS".equals(paramMap.get("return_code"))) {
logger.warn("notify order, wxpay status not success, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "订单状态码非SUCCESS");
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
}

String payOrderNo = paramMap.get("out_trade_no");
@@ -232,18 +232,18 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
WxPayOrder payOrder = wxPayOrderMapper.selectByPrimaryKey(payOrderId);
if (payOrder == null) {
logger.warn("notify order, wxpay check pay order not exists, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "订单不存在");
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
}
// 验证支付金额
if (!paramMap.get("total_fee").equals(payOrder.getPayAmount().toString())) {
logger.warn("notify order, wxpay check total_fee is invalid, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "订单总金额不一致");
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
}

Date timeEnd = null;
@@ -259,16 +259,19 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
// 处理支付成功
handleOrderPaySuccess(payOrder, paramMap.get("transaction_id"));
logger.info("notify order, wxpay checksign success, paramMap:{}, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "SUCCESS");
resultMap.put("return_msg", "OK");
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
}
} catch (RuntimeException e) {
logger.warn("notify order, alipay checksign error, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString() + ", e:" + e.getMessage());
throw new MallinkException(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR);
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR);
}
return "";
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "FAILED");
return XmlUtil.getRequestXml(resultMap);
}

@Override


+ 19
- 16
mallinkService/src/main/java/com/simple/service/impl/WxRefundOrderServiceImpl.java View File

@@ -396,10 +396,10 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService {
}
if (!"SUCCESS".equals(paramMap.get("return_code"))) {
logger.warn("notify order, wxpay status not success, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "订单状态码非SUCCESS");
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
}

String payOrderNo = paramMap.get("out_trade_no");
@@ -407,59 +407,62 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService {
WxPayOrder payOrder = wxPayOrderMapper.selectByPrimaryKey(payOrderId);
if (payOrder == null) {
logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "订单不存在");
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
}
// 验证支付金额
if(!paramMap.get("total_fee").equals(payOrder.getPayAmount().toString())) {
logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "订单总金额不一致");
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
}
String refundOrderNo = paramMap.get("out_refund_no");
Long refundOrderId = Long.valueOf(refundOrderNo);
WxRefundOrder refundOrder = wxRefundOrderMapper.selectByPrimaryKey(refundOrderId);
if (refundOrder == null) {
logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "退款订单不存在");
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
}
// 验证支付金额
if(!paramMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) {
logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "订单总金额不一致");
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
}
// 验证退款金额
if(!paramMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) {
logger.warn("notify order, wxpay check refund_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "退款总金额不一致");
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
}

// 处理支付成功
handleRefundSuccess(refundOrder, paramMap.get("transaction_id"), paramMap.get("refund_id"));
logger.info("notify order, wxpay checksign success, paramMap:{}, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString());
Map<String, String> resultMap = new LinkedHashMap<>();
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "SUCCESS");
resultMap.put("return_msg", "OK");
return XmlUtil.parseDto2Xml(resultMap, "");
return XmlUtil.getRequestXml(resultMap);
}
} catch (RuntimeException e) {
logger.warn("notify order, alipay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage());
throw new MallinkException(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR);
throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR);
}
return "";
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", "FAILED");
return XmlUtil.getRequestXml(resultMap);
}

@Override


Loading…
Cancel
Save