From 235a867e15a86c3666c3e57727a7d6bb828e08de Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 07 十一月 2019 16:41:09 +0800
Subject: [PATCH] 微信支付查询是否成功修改,商城订单查询修改

---
 utils/src/main/java/org/yeshi/utils/wx/WXPayUtil.java |   43 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/utils/src/main/java/org/yeshi/utils/wx/WXPayUtil.java b/utils/src/main/java/org/yeshi/utils/wx/WXPayUtil.java
index 980853f..7617ce8 100644
--- a/utils/src/main/java/org/yeshi/utils/wx/WXPayUtil.java
+++ b/utils/src/main/java/org/yeshi/utils/wx/WXPayUtil.java
@@ -6,6 +6,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.dom4j.DocumentException;
 import org.yeshi.utils.HttpUtil;
 import org.yeshi.utils.StringUtil;
 import org.yeshi.utils.entity.wx.RedPackParams;
@@ -202,7 +203,7 @@
 
 		String result = HttpUtil.post("https://api.mch.weixin.qq.com/pay/unifiedorder", entity);
 		try {
-			System.out.println("缁熶竴涓嬪崟缁撴灉:" + new String( result.getBytes("GBK"),"UTF-8"));
+			System.out.println("缁熶竴涓嬪崟缁撴灉:" + new String(result.getBytes("GBK"), "UTF-8"));
 		} catch (UnsupportedEncodingException e) {
 			e.printStackTrace();
 		}
@@ -266,8 +267,27 @@
 		map.put("out_trade_no", orderNo);
 		map.put("sign", WXUtil.getSignMD5(map, app.getMchKey()));
 		String result = HttpUtil.post("https://api.mch.weixin.qq.com/pay/orderquery", WXUtil.loadWXMessage(map));
-		System.out.println("璁㈠崟鏌ヨ缁撴灉:" + result);
-		Map<String, String> resultMap = WXUtil.parseXML(result);
+		try {
+			try {
+				result = new String(result.getBytes("GBK"), "UTF-8");
+			} catch (UnsupportedEncodingException e1) {
+				e1.printStackTrace();
+			}
+			System.out.println("璁㈠崟鏌ヨ缁撴灉:" + new String(result.getBytes("GBK"), "UTF-8"));
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		}
+		Map<String, String> resultMap = null;
+		try {
+			resultMap = WXUtil.parseXML(result);
+		} catch (Exception e) {
+			try {
+				result = new String(result.getBytes("GBK"), "UTF-8");
+			} catch (UnsupportedEncodingException e1) {
+				e1.printStackTrace();
+			}
+			resultMap = WXUtil.parseXML(result);
+		}
 		if ("SUCCESS".equalsIgnoreCase(resultMap.get("return_code"))
 				&& "SUCCESS".equalsIgnoreCase(resultMap.get("result_code"))) {
 			if ("SUCCESS".equalsIgnoreCase(resultMap.get("trade_state")))// 鏀粯鎴愬姛
@@ -281,12 +301,13 @@
 
 	/**
 	 * 
-	 * @param refundOrderNo -閫�娆惧崟鍙�
+	 * @param refundOrderNo
+	 *            -閫�娆惧崟鍙�
 	 * @param app
 	 * @return
 	 * @throws WXOrderException
 	 */
-	public static boolean isRefundSuccess(String refundOrderNo, WXAPPInfo app)  throws WXOrderException {
+	public static boolean isRefundSuccess(String refundOrderNo, WXAPPInfo app) throws WXOrderException {
 		Map<String, String> map = new HashMap<String, String>();
 		map.put("appid", app.getAppId());
 		map.put("mch_id", app.getMchId());
@@ -295,7 +316,17 @@
 		map.put("sign", WXUtil.getSignMD5(map, app.getMchKey()));
 		String result = HttpUtil.post("https://api.mch.weixin.qq.com/pay/refundquery", WXUtil.loadWXMessage(map));
 		System.out.println("璁㈠崟鏌ヨ缁撴灉:" + result);
-		Map<String, String> resultMap = WXUtil.parseXML(result);
+		Map<String, String> resultMap = null;
+		try {
+			resultMap = WXUtil.parseXML(result);
+		} catch (Exception e) {
+			try {
+				result = new String(result.getBytes("GBK"), "UTF-8");
+			} catch (UnsupportedEncodingException e1) {
+				e1.printStackTrace();
+			}
+			resultMap = WXUtil.parseXML(result);
+		}
 		if ("SUCCESS".equalsIgnoreCase(resultMap.get("return_code"))
 				&& "SUCCESS".equalsIgnoreCase(resultMap.get("result_code"))) {
 			if ("SUCCESS".equalsIgnoreCase(resultMap.get("refund_status_0")))// 閫�娆炬垚鍔�

--
Gitblit v1.8.0