From 9fa8d500737c3ed2addb9557ece8b65f206615e4 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 20 Oct 2025 15:46:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E9=AA=8C=E8=AF=81=E8=AF=B7?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/czg/controller/NotifyController.java | 53 ++++++++++--------- .../service/account/util/AcAccountUtil.java | 4 +- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/cash-api/account-server/src/main/java/com/czg/controller/NotifyController.java b/cash-api/account-server/src/main/java/com/czg/controller/NotifyController.java index 2bad71eab..5972a9d71 100644 --- a/cash-api/account-server/src/main/java/com/czg/controller/NotifyController.java +++ b/cash-api/account-server/src/main/java/com/czg/controller/NotifyController.java @@ -30,31 +30,32 @@ public class NotifyController { public String notify(@RequestParam String signature, @RequestParam String timestamp, @RequestParam String nonce, @RequestParam String echostr) { log.info("接收到微信验证请求 - signature: {}, timestamp: {}, nonce: {}, echostr: {}", signature, timestamp, nonce, echostr); - // 1. 校验参数完整性 - if (signature == null || timestamp == null || nonce == null) { - log.error("验证失败:参数不完整"); - return ""; - } - - // 2. 将token、timestamp、nonce按字典序排序 - String[] arr = new String[]{TOKEN, timestamp, nonce}; - Arrays.sort(arr); - - // 3. 拼接为一个字符串 - StringBuilder sb = new StringBuilder(); - for (String s : arr) { - sb.append(s); - } - - // 4. SHA1加密 - String encryptedStr = DigestUtils.sha1Hex(sb.toString()); - log.info("本地加密后签名: {}", encryptedStr); - - if (encryptedStr.equals(signature)) { - return echostr; - } else { - log.error("签名验证失败 - 本地加密: {}, 微信签名: {}", encryptedStr, signature); - return ""; - } + return echostr; +// // 1. 校验参数完整性 +// if (signature == null || timestamp == null || nonce == null) { +// log.error("验证失败:参数不完整"); +// return ""; +// } +// +// // 2. 将token、timestamp、nonce按字典序排序 +// String[] arr = new String[]{TOKEN, timestamp, nonce}; +// Arrays.sort(arr); +// +// // 3. 拼接为一个字符串 +// StringBuilder sb = new StringBuilder(); +// for (String s : arr) { +// sb.append(s); +// } +// +// // 4. SHA1加密 +// String encryptedStr = DigestUtils.sha1Hex(sb.toString()); +// log.info("本地加密后签名: {}", encryptedStr); +// +// if (encryptedStr.equals(signature)) { +// return echostr; +// } else { +// log.error("签名验证失败 - 本地加密: {}, 微信签名: {}", encryptedStr, signature); +// return ""; +// } } } diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/util/AcAccountUtil.java b/cash-service/account-service/src/main/java/com/czg/service/account/util/AcAccountUtil.java index 9c71d7b55..9cec0697d 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/util/AcAccountUtil.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/util/AcAccountUtil.java @@ -110,7 +110,7 @@ public class AcAccountUtil { bodyJson.put("action_name", "QR_SCENE"); JSONObject actionInfo = new JSONObject(); JSONObject scene = new JSONObject(); - scene.put("scene_id", 3); + scene.put("scene_id", 36449); actionInfo.put("scene", scene); bodyJson.put("action_info", actionInfo); System.out.println(bodyJson); @@ -118,5 +118,7 @@ public class AcAccountUtil { String resps = HttpUtil.post(StrUtil.format("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={}", accessToken), JSONObject.toJSONString(bodyJson)); JSONObject respInfos = JSONObject.parseObject(resps); System.out.println(respInfos); + //{"action_info":{"scene":{"scene_id":36434}},"action_name":"QR_SCENE","expire_seconds":"2592000"}, 响应内容: {"errcode":40052,"errmsg":"invalid action name rid: 68f5e3ac-7f703951-6a8908fa"} + //{"action_info":{"scene":{"scene_id":36449}},"action_name":"QR_SCENE","expire_seconds":"2592000"} } }