wangming il y a 1 mois
Parent
commit
2ff64648fe

+ 14 - 5
yami-shop-wx/src/main/java/com/yami/shop/wx/service/impl/WxProviderServiceImpl.java

@@ -492,14 +492,14 @@ public class WxProviderServiceImpl implements WxProviderService {
                 JSONObject resourceJson = WechatPayValidator.decryptFromResource(resource, WxConstants.API_V3_KEY);
                 log.info("  =================== 服务商小程序支付回调解密resource中的通知数据 ===================\n" + resourceJson);
                 Integer trans = statusTrans(resourceJson.getString("trade_state"));
-                JSONObject attach = resourceJson.getJSONObject("attach");
-                if (trans == 1 && attach != null) {
+                if (trans == 1) {
                     JSONObject successJson = trueMsg(response);
-                    successJson.put("attach", attach);
+                    successJson.put("wxData", resourceJson);
                     return successJson;
                 } else {
-                    System.err.println("支付失败...");
-                    return bodyJson;
+                    JSONObject failMsg = failMsg(response);
+                    failMsg.put("wxData", resourceJson);
+                    return failMsg;
                 }
             } finally {
                 lock.unlock();
@@ -531,6 +531,15 @@ public class WxProviderServiceImpl implements WxProviderService {
         return resMap;
     }
 
+    private JSONObject failMsg(HttpServletResponse response) {
+        JSONObject resMap = new JSONObject();
+        response.setStatus(500);
+        resMap.put("code", "ERROR");
+        resMap.put("message", "失败");
+        return resMap;
+    }
+
+
     /**
      * 支付状态( 1-支付成功 )
      *