Sfoglia il codice sorgente

feat : 微信支付删除没有用的辣鸡代码, 整理格式

bilingfeng 2 anni fa
parent
commit
4e53f04e87

+ 0 - 59
game-module/game-sdk/src/main/java/com/zanxiang/sdk/common/constant/WXPayConstants.java

@@ -1,59 +0,0 @@
-package com.zanxiang.sdk.common.constant;
-
-import org.apache.http.client.HttpClient;
-
-/**
- * 常量
- */
-public class WXPayConstants {
-
-    public enum SignType {
-        MD5, HMACSHA256
-    }
-
-    public static final String DOMAIN_API = "api.mch.weixin.qq.com";
-    public static final String DOMAIN_API2 = "api2.mch.weixin.qq.com";
-    public static final String DOMAIN_APIHK = "apihk.mch.weixin.qq.com";
-    public static final String DOMAIN_APIUS = "apius.mch.weixin.qq.com";
-
-
-    public static final String FAIL     = "FAIL";
-    public static final String SUCCESS  = "SUCCESS";
-    public static final String HMACSHA256 = "HMAC-SHA256";
-    public static final String MD5 = "MD5";
-
-    public static final String FIELD_SIGN = "sign";
-    public static final String FIELD_SIGN_TYPE = "sign_type";
-
-    public static final String WXPAYSDK_VERSION = "WXPaySDK/3.0.9";
-    public static final String USER_AGENT = WXPAYSDK_VERSION +
-            " (" + System.getProperty("os.arch") + " " + System.getProperty("os.name") + " " + System.getProperty("os.version") +
-            ") Java/" + System.getProperty("java.version") + " HttpClient/" + HttpClient.class.getPackage().getImplementationVersion();
-
-    public static final String MICROPAY_URL_SUFFIX     = "/pay/micropay";
-    public static final String UNIFIEDORDER_URL_SUFFIX = "/pay/unifiedorder";
-    public static final String ORDERQUERY_URL_SUFFIX   = "/pay/orderquery";
-    public static final String REVERSE_URL_SUFFIX      = "/secapi/pay/reverse";
-    public static final String CLOSEORDER_URL_SUFFIX   = "/pay/closeorder";
-    public static final String REFUND_URL_SUFFIX       = "/secapi/pay/refund";
-    public static final String REFUNDQUERY_URL_SUFFIX  = "/pay/refundquery";
-    public static final String DOWNLOADBILL_URL_SUFFIX = "/pay/downloadbill";
-    public static final String REPORT_URL_SUFFIX       = "/payitil/report";
-    public static final String SHORTURL_URL_SUFFIX     = "/tools/shorturl";
-    public static final String AUTHCODETOOPENID_URL_SUFFIX = "/tools/authcodetoopenid";
-
-    // sandbox
-    public static final String SANDBOX_MICROPAY_URL_SUFFIX     = "/sandboxnew/pay/micropay";
-    public static final String SANDBOX_UNIFIEDORDER_URL_SUFFIX = "/sandboxnew/pay/unifiedorder";
-    public static final String SANDBOX_ORDERQUERY_URL_SUFFIX   = "/sandboxnew/pay/orderquery";
-    public static final String SANDBOX_REVERSE_URL_SUFFIX      = "/sandboxnew/secapi/pay/reverse";
-    public static final String SANDBOX_CLOSEORDER_URL_SUFFIX   = "/sandboxnew/pay/closeorder";
-    public static final String SANDBOX_REFUND_URL_SUFFIX       = "/sandboxnew/secapi/pay/refund";
-    public static final String SANDBOX_REFUNDQUERY_URL_SUFFIX  = "/sandboxnew/pay/refundquery";
-    public static final String SANDBOX_DOWNLOADBILL_URL_SUFFIX = "/sandboxnew/pay/downloadbill";
-    public static final String SANDBOX_REPORT_URL_SUFFIX       = "/sandboxnew/payitil/report";
-    public static final String SANDBOX_SHORTURL_URL_SUFFIX     = "/sandboxnew/tools/shorturl";
-    public static final String SANDBOX_AUTHCODETOOPENID_URL_SUFFIX = "/sandboxnew/tools/authcodetoopenid";
-
-}
-

+ 51 - 49
game-module/game-sdk/src/main/java/com/zanxiang/sdk/common/util/WxPayUrl.java → game-module/game-sdk/src/main/java/com/zanxiang/sdk/common/constant/WxPayConstants.java

@@ -1,49 +1,51 @@
-package com.zanxiang.sdk.common.util;
-
-/**
- * @author : lingfeng
- * @time : 2021-11-23
- * @description : 微信支付接口地址
- */
-public class WxPayUrl {
-
-    /**
-     * 微信支付统一接口(POST)
-     */
-    public final static String UNIFIED_ORDER_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder";
-
-    /**
-     * 微信退款接口(POST)
-     */
-    public final static String REFUND_URL = "https://api.mch.weixin.qq.com/secapi/pay/refund";
-
-    /**
-     * 订单查询接口(POST)
-     */
-    public final static String CHECK_ORDER_URL = "https://api.mch.weixin.qq.com/pay/orderquery";
-
-    /**
-     * 关闭订单接口(POST)
-     */
-    public final static String CLOSE_ORDER_URL = "https://api.mch.weixin.qq.com/pay/closeorder";
-
-    /**
-     * 退款查询接口(POST)
-     */
-    public final static String CHECK_REFUND_URL = "https://api.mch.weixin.qq.com/pay/refundquery";
-
-    /**
-     * 对账单接口(POST)
-     */
-    public final static String DOWNLOAD_BILL_URL = "https://api.mch.weixin.qq.com/pay/downloadbill";
-
-    /**
-     * 短链接转换接口(POST)
-     */
-    public final static String SHORT_URL = "https://api.mch.weixin.qq.com/tools/shorturl";
-
-    /**
-     * 接口调用上报接口(POST)
-     */
-    public final static String REPORT_URL = "https://api.mch.weixin.qq.com/payitil/report";
-}
+package com.zanxiang.sdk.common.constant;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-06-21
+ * @description : 微信支付常量
+ */
+public class WxPayConstants {
+
+    /**
+     * 微信支付统一接口(POST)
+     */
+    public final static String UNIFIED_ORDER_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder";
+
+    /**
+     * 微信退款接口(POST)
+     */
+    public final static String REFUND_URL = "https://api.mch.weixin.qq.com/secapi/pay/refund";
+
+    /**
+     * 订单查询接口(POST)
+     */
+    public final static String CHECK_ORDER_URL = "https://api.mch.weixin.qq.com/pay/orderquery";
+
+    /**
+     * 关闭订单接口(POST)
+     */
+    public final static String CLOSE_ORDER_URL = "https://api.mch.weixin.qq.com/pay/closeorder";
+
+    /**
+     * 退款查询接口(POST)
+     */
+    public final static String CHECK_REFUND_URL = "https://api.mch.weixin.qq.com/pay/refundquery";
+
+    /**
+     * 对账单接口(POST)
+     */
+    public final static String DOWNLOAD_BILL_URL = "https://api.mch.weixin.qq.com/pay/downloadbill";
+
+    /**
+     * 短链接转换接口(POST)
+     */
+    public final static String SHORT_URL = "https://api.mch.weixin.qq.com/tools/shorturl";
+
+    /**
+     * 接口调用上报接口(POST)
+     */
+    public final static String REPORT_URL = "https://api.mch.weixin.qq.com/payitil/report";
+
+}
+

+ 41 - 56
game-module/game-sdk/src/main/java/com/zanxiang/sdk/common/util/WxPayUtil.java

@@ -1,9 +1,5 @@
 package com.zanxiang.sdk.common.util;
 
-import com.zanxiang.sdk.common.constant.WXPayConstants;
-import com.zanxiang.sdk.common.constant.WXPayConstants.SignType;
-import com.zanxiang.sdk.domain.bo.WxPayConfigBO;
-
 import javax.crypto.Mac;
 import javax.crypto.spec.SecretKeySpec;
 import java.io.BufferedReader;
@@ -23,37 +19,24 @@ import java.util.regex.Pattern;
  */
 public class WxPayUtil {
 
-    private WxPayConfigBO wxPay;
-
-    public WxPayUtil(WxPayConfigBO wxPay) {
-        this.wxPay = wxPay;
-    }
+    /**
+     * MD5加密
+     */
+    private static final String SIGN_MD5 = "MD5";
 
     /**
-     * 基础参数
-     *
-     * @param packageParams
+     * HMACSHA256加密
      */
-    public void commonParams(SortedMap<Object, Object> packageParams) {
-        String appId = wxPay.getAppId();
-        String mch_id = wxPay.getMchId();
-        String currTime = PayCommonUtil.getCurrTime();
-        String strTime = currTime.substring(8);
-        String strRandom = PayCommonUtil.buildRandom(4) + "";
-        String nonce_str = strTime + strRandom;
-        packageParams.put("appid", appId);
-        packageParams.put("mch_id", mch_id);
-        packageParams.put("nonce_str", nonce_str);
-    }
+    private static final String SIGN_HMACSHA256 = "HMACSHA256";
 
     /**
-     * 转换deepLink
+     * webUrl转换deepLink
      *
-     * @param url
-     * @return
-     * @throws Exception
+     * @param url : webUrl
+     * @return : 返回deepLink
+     * @throws Exception : 异常
      */
-    public String readUrl(String url, String serverUrl) throws Exception {
+    public static String readUrl(String url, String serverUrl) throws Exception {
         // 定义好匹配规则
         String regex = "weixin://wap/pay?.[^\\x{4e00}-\\x{9fa5}-\"]+";
         Pattern pattern = Pattern.compile(regex);
@@ -75,6 +58,12 @@ public class WxPayUtil {
         return result;
     }
 
+    /**
+     * 金额处理
+     *
+     * @param s : 金额字符串
+     * @return : 返回处理完的字符串
+     */
     public static String subZeroAndDot(String s) {
         if (s.indexOf(".") > 0) {
             // 去掉多余的0
@@ -85,38 +74,32 @@ public class WxPayUtil {
         return s;
     }
 
-    //------------------- 腾讯的工具类 -------------------
-
-    private static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
-    private static final Random RANDOM = new SecureRandom();
-
     /**
-     * 生成签名
+     * 生成签名(MD5加密)
      *
      * @param data 待签名数据
      * @param key  API密钥
      * @return 签名
      */
     public static String generateSignature(final Map<String, String> data, String key) throws Exception {
-        return generateSignature(data, key, SignType.MD5);
+        return generateSignature(data, key, SIGN_MD5);
     }
 
     /**
-     * 生成签名. 注意,若含有sign_type字段,必须和signType参数保持一致。
+     * 生成签名, 指定加密方式
      *
      * @param data     待签名数据
      * @param key      API密钥
-     * @param signType 签名方式
+     * @param signType 签名加密方式
      * @return 签名
      */
-    public static String generateSignature(final Map<String, String> data, String key, SignType signType) throws Exception {
+    public static String generateSignature(final Map<String, String> data, String key, String signType) throws Exception {
         Set<String> keySet = data.keySet();
-        String[] keyArray = keySet.toArray(new String[keySet.size()]);
+        String[] keyArray = keySet.toArray(new String[0]);
         Arrays.sort(keyArray);
         StringBuilder sb = new StringBuilder();
         for (String k : keyArray) {
-            if (k.equals(WXPayConstants.FIELD_SIGN)) {
+            if (Objects.equals("sign", k)) {
                 continue;
             }
             // 参数值为空,则不参与签名
@@ -125,9 +108,9 @@ public class WxPayUtil {
             }
         }
         sb.append("key=").append(key);
-        if (SignType.MD5.equals(signType)) {
+        if (Objects.equals(SIGN_MD5, signType)) {
             return MD5(sb.toString()).toUpperCase();
-        } else if (SignType.HMACSHA256.equals(signType)) {
+        } else if (Objects.equals(SIGN_HMACSHA256, signType)) {
             return HMACSHA256(sb.toString(), key);
         } else {
             throw new Exception(String.format("Invalid sign_type: %s", signType));
@@ -141,46 +124,48 @@ public class WxPayUtil {
      * @return String 随机字符串
      */
     public static String generateNonceStr() {
+        Random random = new SecureRandom();
+        String symBls = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
         char[] nonceChars = new char[32];
         for (int index = 0; index < nonceChars.length; ++index) {
-            nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length()));
+            nonceChars[index] = symBls.charAt(random.nextInt(symBls.length()));
         }
         return new String(nonceChars);
     }
 
 
     /**
-     * 生成 MD5
+     * MD5加密
      *
      * @param data 待处理数据
      * @return MD5结果
      */
-    public static String MD5(String data) throws Exception {
+    private static String MD5(String data) throws Exception {
         java.security.MessageDigest md = MessageDigest.getInstance("MD5");
-        byte[] array = md.digest(data.getBytes("UTF-8"));
+        byte[] array = md.digest(data.getBytes(StandardCharsets.UTF_8));
         StringBuilder sb = new StringBuilder();
         for (byte item : array) {
-            sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
+            sb.append(Integer.toHexString((item & 0xFF) | 0x100), 1, 3);
         }
         return sb.toString().toUpperCase();
     }
 
     /**
-     * 生成 HMACSHA256
+     * HMACSHA256加密
      *
      * @param data 待处理数据
      * @param key  密钥
      * @return 加密结果
-     * @throws Exception
+     * @throws Exception : 异常
      */
-    public static String HMACSHA256(String data, String key) throws Exception {
-        Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
-        SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256");
-        sha256_HMAC.init(secret_key);
-        byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8"));
+    private static String HMACSHA256(String data, String key) throws Exception {
+        Mac sha256HMAC = Mac.getInstance("HmacSHA256");
+        SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
+        sha256HMAC.init(secretKey);
+        byte[] array = sha256HMAC.doFinal(data.getBytes(StandardCharsets.UTF_8));
         StringBuilder sb = new StringBuilder();
         for (byte item : array) {
-            sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
+            sb.append(Integer.toHexString((item & 0xFF) | 0x100), 1, 3);
         }
         return sb.toString().toUpperCase();
     }

+ 4 - 91
game-module/game-sdk/src/main/java/com/zanxiang/sdk/common/util/XMLUtil.java → game-module/game-sdk/src/main/java/com/zanxiang/sdk/common/util/XmlUtil.java

@@ -1,11 +1,6 @@
 package com.zanxiang.sdk.common.util;
 
 import com.zanxiang.common.exception.BaseException;
-import com.zanxiang.common.utils.StringUtils;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -19,13 +14,10 @@ import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
 import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -33,9 +25,9 @@ import java.util.Map;
  * @time : 2022-09-16
  * @description : xml 转换工具类
  */
-public class XMLUtil {
+public class XmlUtil {
 
-    public static org.w3c.dom.Document newDocument() throws ParserConfigurationException {
+    private static org.w3c.dom.Document newDocument() throws ParserConfigurationException {
         return newDocumentBuilder().newDocument();
     }
 
@@ -55,7 +47,7 @@ public class XMLUtil {
     public static Map<String, String> xmlToMap(String strXml) {
         try {
             Map<String, String> data = new HashMap<>();
-            DocumentBuilder documentBuilder = XMLUtil.newDocumentBuilder();
+            DocumentBuilder documentBuilder = XmlUtil.newDocumentBuilder();
             InputStream stream = new ByteArrayInputStream(strXml.getBytes(StandardCharsets.UTF_8));
             org.w3c.dom.Document doc = documentBuilder.parse(stream);
             doc.getDocumentElement().normalize();
@@ -76,12 +68,11 @@ public class XMLUtil {
         } catch (Exception ex) {
             throw new BaseException("xml转map异常");
         }
-
     }
 
     public static String mapToXml(Map<String, String> data) {
         try {
-            org.w3c.dom.Document document = XMLUtil.newDocument();
+            org.w3c.dom.Document document = XmlUtil.newDocument();
             org.w3c.dom.Element root = document.createElement("xml");
             document.appendChild(root);
             for (String key : data.keySet()) {
@@ -113,82 +104,4 @@ public class XMLUtil {
             throw new BaseException("map转xml异常");
         }
     }
-
-
-    /**
-     * 解析xml,返回第一级元素键值对。如果第一级元素有子节点,则此节点的值是子节点的xml数据。
-     *
-     * @param strXml
-     * @return
-     * @throws JDOMException
-     * @throws IOException
-     */
-    public static Map doXmlParse(String strXml) throws JDOMException, IOException {
-        strXml = filterXXE(strXml);
-        strXml = strXml.replaceFirst("encoding=\".*\"", "encoding=\"UTF-8\"");
-        if (StringUtils.isBlank(strXml)) {
-            return null;
-        }
-        Map m = new HashMap();
-        InputStream in = new ByteArrayInputStream(strXml.getBytes("UTF-8"));
-        SAXBuilder builder = new SAXBuilder();
-        Document doc = builder.build(in);
-        Element root = doc.getRootElement();
-        List list = root.getChildren();
-        for (Object object : list) {
-            Element e = (Element) object;
-            String k = e.getName();
-            String v;
-            List children = e.getChildren();
-            if (children.isEmpty()) {
-                v = e.getTextNormalize();
-            } else {
-                v = XMLUtil.getChildrenText(children);
-            }
-
-            m.put(k, v);
-        }
-        in.close();
-        return m;
-    }
-
-    /**
-     * 获取子结点的xml
-     *
-     * @param children
-     * @return String
-     */
-    public static String getChildrenText(List children) {
-        StringBuffer sb = new StringBuffer();
-        if (!children.isEmpty()) {
-            Iterator it = children.iterator();
-            while (it.hasNext()) {
-                Element e = (Element) it.next();
-                String name = e.getName();
-                String value = e.getTextNormalize();
-                List list = e.getChildren();
-                sb.append("<" + name + ">");
-                if (!list.isEmpty()) {
-                    sb.append(XMLUtil.getChildrenText(list));
-                }
-                sb.append(value);
-                sb.append("</" + name + ">");
-            }
-        }
-
-        return sb.toString();
-    }
-
-    /**
-     * 通过DOCTYPE和ENTITY来加载本地受保护的文件、替换掉即可
-     * 漏洞原理:https://my.oschina.net/u/574353/blog/1841103
-     * 防止 XXE漏洞 注入实体攻击
-     * 过滤 过滤用户提交的XML数据
-     * 过滤关键词:<!DOCTYPE和<!ENTITY,或者SYSTEM和PUBLIC。
-     *    
-     */
-    public static String filterXXE(String xmlStr) {
-        xmlStr = xmlStr.replace("DOCTYPE", "").replace("SYSTEM", "").replace("ENTITY", "").replace("PUBLIC", "");
-        return xmlStr;
-    }
 }

+ 9 - 83
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/pay/WxPayServiceImpl.java

@@ -1,6 +1,5 @@
 package com.zanxiang.sdk.service.Impl.pay;
 
-import com.alibaba.fastjson.JSONObject;
 import com.zanxiang.common.constant.Constants;
 import com.zanxiang.common.domain.ResultMap;
 import com.zanxiang.common.enums.ResEnum;
@@ -8,7 +7,10 @@ import com.zanxiang.common.exception.BaseException;
 import com.zanxiang.common.utils.JsonUtil;
 import com.zanxiang.common.utils.RandomStringUtil;
 import com.zanxiang.common.utils.URIUtil;
-import com.zanxiang.sdk.common.util.*;
+import com.zanxiang.sdk.common.constant.WxPayConstants;
+import com.zanxiang.sdk.common.util.PayCommonUtil;
+import com.zanxiang.sdk.common.util.WxPayUtil;
+import com.zanxiang.sdk.common.util.XmlUtil;
 import com.zanxiang.sdk.domain.bo.ProductPayAttachParamBO;
 import com.zanxiang.sdk.domain.bo.ProductPayParamBO;
 import com.zanxiang.sdk.domain.bo.WxPayConfigBO;
@@ -72,8 +74,6 @@ public class WxPayServiceImpl extends PayService implements OrderPayService {
      */
     private WxPayConfigBO config;
 
-    private WxPayUtil wxPayUtil;
-
     private String body;
 
     private String totalFee;
@@ -83,13 +83,6 @@ public class WxPayServiceImpl extends PayService implements OrderPayService {
     @Autowired
     private RestTemplate restTemplate;
 
-
-    /**
-     * 支付调起
-     *
-     * @param product
-     * @return
-     */
     @Override
     public ResultMap create(ProductPayParamBO product) {
         this.body = product.getSubject();
@@ -128,7 +121,7 @@ public class WxPayServiceImpl extends PayService implements OrderPayService {
         inputStream.close();
         log.info("微信支付回调 body:{}", sb);
         // 解析xml成map
-        Map m = XMLUtil.xmlToMap(sb.toString());
+        Map m = XmlUtil.xmlToMap(sb.toString());
         // 过滤空 设置 TreeMap
         SortedMap<Object, Object> packageParams = new TreeMap<>();
         for (Object parameter : m.keySet()) {
@@ -205,7 +198,7 @@ public class WxPayServiceImpl extends PayService implements OrderPayService {
         //转换deepLink
         String deepLink;
         try {
-            deepLink = wxPayUtil.readUrl(urlCode, serverUrl);
+            deepLink = WxPayUtil.readUrl(urlCode, serverUrl);
         } catch (Exception e) {
             log.error("微信h5支付urlCode转deepLink异常, urlCode:{}", urlCode);
             throw new BaseException("微信h5支付urlCode转deepLink异常");
@@ -261,72 +254,6 @@ public class WxPayServiceImpl extends PayService implements OrderPayService {
         }
     }
 
-    /**
-     * H5手机支付(jspapi)
-     *
-     * @param product
-     * @return
-     */
-    private ResultMap mobile(ProductPayParamBO product, String tradeType) {
-        //商户支付回调URL设置指引:进入公众平台-->微信支付-->开发配置-->扫码支付-->修改 加入回调URL
-        log.info("订单号:{}生成微信支付码", product.getOutTradeNo());
-        try {
-            // 账号信息
-            String key = config.getApiKey();
-            SortedMap<Object, Object> packageParams = new TreeMap<>();
-            wxPayUtil.commonParams(packageParams);
-            // 商品描述
-            packageParams.put("body", this.body);
-            // 商户订单号
-            packageParams.put("out_trade_no", this.outTradeNo);
-            totalFee = WxPayUtil.subZeroAndDot(this.totalFee);
-            // 总金额
-            packageParams.put("total_fee", totalFee);
-            // 发起人IP地址
-            packageParams.put("spbill_create_ip", product.getSpbillCreateIp());
-            // 回调地址 notifyUrl
-            packageParams.put("notify_url", notifyUrl);
-            // 交易类型
-            packageParams.put("trade_type", tradeType);
-            packageParams.put("attach", JSONObject.toJSONString(this.attach));
-            String sign = PayCommonUtil.createSign(Constants.UTF8, packageParams, key);
-            packageParams.put("sign", sign);
-            String requestXml = PayCommonUtil.getRequestXml(packageParams);
-            String resXml = HttpUtil.postData(WxPayUrl.UNIFIED_ORDER_URL, requestXml);
-            Map map = XMLUtil.xmlToMap(resXml);
-            if (map == null) {
-                log.error("微信支付通信异常, 订单号:{}", product.getOutTradeNo());
-                return ResultMap.error();
-            }
-            String returnCode = (String) map.get("return_code");
-            //返回失败
-            if (!Constants.SUCCESS.equalsIgnoreCase(returnCode)) {
-                String returnMsg = (String) map.get("return_msg");
-                log.error("微信支付通信失败, 订单号:{}, msg :{}", product.getOutTradeNo(), returnMsg);
-                return ResultMap.error(returnMsg);
-            }
-            //结果失败
-            String resultCode = (String) map.get("result_code");
-            if (!Constants.SUCCESS.equalsIgnoreCase(resultCode)) {
-                String errCodeDes = (String) map.get("err_code_des");
-                log.error("微信支付通信失败, 订单号:{}, errCodeDes :{}", product.getOutTradeNo(), errCodeDes);
-                return ResultMap.error(errCodeDes);
-            }
-            if (tradeType.equals(WX_PAY_MWEB)) {
-                String urlCode = wxPayUtil.readUrl((String) map.get("mweb_url"), serverUrl);
-                return ResultMap.ok(product.getPayDevice(), urlCode);
-            }
-            if (tradeType.equals(WX_PAY_NATIVE)) {
-                String urlCode = (String) map.get("code_url");
-                return ResultMap.ok(product.getPayDevice(), urlCode);
-            }
-            return ResultMap.ok(product.getPayDevice(), null);
-        } catch (Exception e) {
-            log.error("微信支付通信异常, 订单号:{}, e : {}", product.getOutTradeNo(), e.getMessage());
-            return ResultMap.error();
-        }
-    }
-
     private Map<String, String> unifiedOrder(ProductPayParamBO product, String tradeType, String openId) {
         try {
             Map<String, String> paramData = new HashMap<>(13);
@@ -350,8 +277,8 @@ public class WxPayServiceImpl extends PayService implements OrderPayService {
             String sign = WxPayUtil.generateSignature(paramData, config.getApiKey());
             paramData.put("sign", sign);
             // 下单, 获取结果
-            String result = restTemplate.postForObject(WxPayUrl.UNIFIED_ORDER_URL, XMLUtil.mapToXml(paramData), String.class);
-            Map<String, String> successMap = XMLUtil.xmlToMap(result);
+            String result = restTemplate.postForObject(WxPayConstants.UNIFIED_ORDER_URL, XmlUtil.mapToXml(paramData), String.class);
+            Map<String, String> successMap = XmlUtil.xmlToMap(result);
             // 返回状态码
             String returnCode = successMap.get("return_code");
             // 结果状态码
@@ -374,7 +301,6 @@ public class WxPayServiceImpl extends PayService implements OrderPayService {
      */
     @Override
     public void configInit(String obj) {
-        this.config = JSONObject.parseObject(obj, WxPayConfigBO.class);
-        this.wxPayUtil = new WxPayUtil(this.config);
+        this.config = JsonUtil.toObj(obj, WxPayConfigBO.class);
     }
 }