Przeglądaj źródła

优化 微信回调参数处理

吴学文 6 lat temu
rodzic
commit
8c38c034ff

+ 1 - 1
AppFrontService/src/main/java/com/java110/app/controller/PaymentController.java

@@ -64,7 +64,7 @@ public class PaymentController extends BaseController {
 
         logger.debug("微信支付回调报文" + postInfo);
 
-        return toNotifySMOImpl.toNotify(request);
+        return toNotifySMOImpl.toNotify(postInfo,request);
 
 
     }

+ 1 - 1
AppFrontService/src/main/java/com/java110/app/smo/payment/IToNotifySMO.java

@@ -15,5 +15,5 @@ public interface IToNotifySMO {
      * @param request
      * @return
      */
-    public ResponseEntity<String> toNotify(HttpServletRequest request);
+    public ResponseEntity<String> toNotify(String param,HttpServletRequest request);
 }

+ 3 - 14
AppFrontService/src/main/java/com/java110/app/smo/payment/impl/ToNotifySMOImpl.java

@@ -40,23 +40,12 @@ public class ToNotifySMOImpl implements IToNotifySMO {
     private WechatAuthProperties wechatAuthProperties;
 
     @Override
-    public ResponseEntity<String> toNotify(HttpServletRequest request) {
+    public ResponseEntity<String> toNotify(String param,HttpServletRequest request) {
         String resXml = "";
         ResponseEntity responseEntity = null;
         try {
-            InputStream inputStream = request.getInputStream();
-//获取请求输入流
-            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-            byte[] buffer = new byte[1024];
-            int len = 0;
-            while ((len = inputStream.read(buffer)) != -1) {
-                outputStream.write(buffer, 0, len);
-            }
-            outputStream.close();
-            inputStream.close();
-            String wxReqXml = new String(outputStream.toByteArray(), "utf-8");
-            logger.debug("微信回调报文" + wxReqXml);
-            Map<String, Object> map = PayUtil.getMapFromXML(wxReqXml);
+
+            Map<String, Object> map = PayUtil.getMapFromXML(param);
             logger.info("【小程序支付回调】 回调数据: \n" + map);
             String returnCode = (String) map.get("return_code");
             if ("SUCCESS".equalsIgnoreCase(returnCode)) {