Jelajahi Sumber

微信服务号配置

skyline 1 tahun lalu
induk
melakukan
ddb136e0ee

+ 5 - 5
car-wash-admin/src/main/resources/application.yml

@@ -79,12 +79,12 @@ wechat:
     userTitle: https://api.mch.weixin.qq.com/v3/new-tax-control-fapiao/user-title?scene=WITHOUT_WECHATPAY&fapiao_apply_id=%s
     cardTemplate: https://api.mch.weixin.qq.com/v3/new-tax-control-fapiao/card-template
 
-  # 公众号配置
+  # 服务号配置
   mp:
-    appid: wx93b0ef1be901bd19
-    secret: eea715b3058717f44e17c3e4e5cf1d2f
-    token: kym
-    aeskey: U1ZC5gRrY4DDLZeyKxwpvU5Q7lQvvnQdOV0aX0UPpn6
+    appid: wxc175b08b1b71cd5a
+    secret: 91182f3baa3bcd041837d73b0d1f1d63
+    token: Yeswash
+    aeskey: hw0pfP0aT1tOoPBfzCpeu9uDFwLceTF0ocYc98LSsQU
 
 #文件上传配置
 upload:

+ 31 - 29
car-wash-miniapp/src/main/java/com/kym/miniapp/controller/WeixinMPController.java

@@ -1,6 +1,7 @@
 package com.kym.miniapp.controller;
 
 
+import cn.dev33.satoken.annotation.SaIgnore;
 import com.kym.common.annotation.ApiLog;
 import com.kym.common.annotation.SysLog;
 import com.kym.common.utils.wx.WxPbUtil;
@@ -34,11 +35,11 @@ public class WeixinMPController {
      * @param request
      */
 
-    @PostMapping(value = "notify", produces = MediaType.TEXT_XML_VALUE)
-    @ApiLog(value = "微信公众号服务器推送消息", ignoreParams = true)
-    public void handleMessage(HttpServletRequest request, HttpServletResponse response) {
-        weixinMPService.handleWxMPNotify(request, response);
-    }
+//    @PostMapping(value = "notify", produces = MediaType.TEXT_XML_VALUE)
+//    @ApiLog(value = "微信公众号服务器推送消息", ignoreParams = true)
+//    public void handleMessage(HttpServletRequest request, HttpServletResponse response) {
+//        weixinMPService.handleWxMPNotify(request, response);
+//    }
 
 
     /*
@@ -49,30 +50,31 @@ public class WeixinMPController {
     /**
      * 微信服务器token验证
      */
-//    @GetMapping(value = "notify")
-//    @SysLog("微信服务器token验证")
-//    public void checkSign(HttpServletResponse response, String signature, String timestamp, String nonce, String echostr) {
-//        String responseVal = echostr;
-//        try {
-//
-//            boolean resp = WxPbUtil.checkSign(signature, timestamp, nonce);
-//            if (!resp) {
-//                responseVal = "failure";
-//                log.error("wxpb check sign ERR!!!!");
-//            }
-//        } catch (Exception e) {
-//            responseVal = "failure";
-//        } finally {
-//            try {
-//                PrintWriter writer = response.getWriter();
-//                writer.print(responseVal);
-//                writer.flush();
-//                writer.close();
-//            } catch (Exception e) {
-//                log.error(e.getMessage(), e);
-//            }
-//        }
-//    }
+    @GetMapping(value = "notify")
+    @SaIgnore
+    @SysLog("微信服务器token验证")
+    public void checkSign(HttpServletResponse response, String signature, String timestamp, String nonce, String echostr) {
+        String responseVal = echostr;
+        try {
+
+            boolean resp = WxPbUtil.checkSign(signature, timestamp, nonce);
+            if (!resp) {
+                responseVal = "failure";
+                log.error("wxpb check sign ERR!!!!");
+            }
+        } catch (Exception e) {
+            responseVal = "failure";
+        } finally {
+            try {
+                PrintWriter writer = response.getWriter();
+                writer.print(responseVal);
+                writer.flush();
+                writer.close();
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+            }
+        }
+    }
 
 //    @GetMapping(value = "/test")
 //    public void test() throws WxErrorException {

+ 5 - 4
car-wash-miniapp/src/main/resources/application.yml

@@ -77,11 +77,12 @@ wechat:
     userTitle: https://api.mch.weixin.qq.com/v3/new-tax-control-fapiao/user-title?scene=WITHOUT_WECHATPAY&fapiao_apply_id=%s
     cardTemplate: https://api.mch.weixin.qq.com/v3/new-tax-control-fapiao/card-template
 
+  # 服务号配置
   mp:
-    appid: wx93b0ef1be901bd19
-    secret: eea715b3058717f44e17c3e4e5cf1d2f
-    token: kym
-    aeskey: U1ZC5gRrY4DDLZeyKxwpvU5Q7lQvvnQdOV0aX0UPpn6
+    appid: wxc175b08b1b71cd5a
+    secret: 91182f3baa3bcd041837d73b0d1f1d63
+    token: Yeswash
+    aeskey: hw0pfP0aT1tOoPBfzCpeu9uDFwLceTF0ocYc98LSsQU
 
 
 #文件上传配置