From b024f2b627160275c650d8ab014b0a689b0341d2 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 21 Oct 2025 10:14:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/account/util/AcAccountUtil.java | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) 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 f3150f82..cd75f94e 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 @@ -85,7 +85,7 @@ public class AcAccountUtil { public String getAccessToken() { - String accessToken = redisService.get("wx:ac:AccessToken").toString(); + String accessToken = Convert.toStr(redisService.get("wx:ac:AccessToken")); if (StrUtil.isNotEmpty(accessToken)) { return accessToken; } @@ -106,28 +106,22 @@ public class AcAccountUtil { public static void main(String[] args) { // String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", "wx1fb600d0f5ea6279", "b4c0534c9b5e6c84a7fe5c2078dff876")); // System.out.println(resp); - String accessToken = "97_HZVThQrtvOiCZGrr23ZHN0cVpHBJHc18RSFHU6dvkQDMAme4GsG0NU-Dax1HP5Wx-aGa1l35KaqiMVv61TCj0Qk8DK1LC6kQ8uKLDfgRYVJjX3QjcelmIjp4PCkERBeABAUHR"; - JSONObject bodyJson = new JSONObject(); - //二维码有效时间(秒),最大2592000,仅临时二维码需要 - bodyJson.put("expire_seconds", "2592000"); - //二维码类型:QR_SCENE(临时整型)/QR_STR_SCENE(临时字符串)/QR_LIMIT_SCENE(永久整型)/QR_LIMIT_STR_SCENE(永久字符串) - bodyJson.put("action_name", "QR_STR_SCENE"); - JSONObject actionInfo = new JSONObject(); - JSONObject scene = new JSONObject(); - scene.put("scene_str", "43525423"); - actionInfo.put("scene", scene); - bodyJson.put("action_info", actionInfo); - System.out.println(bodyJson); +// String accessToken = "97_HZVThQrtvOiCZGrr23ZHN0cVpHBJHc18RSFHU6dvkQDMAme4GsG0NU-Dax1HP5Wx-aGa1l35KaqiMVv61TCj0Qk8DK1LC6kQ8uKLDfgRYVJjX3QjcelmIjp4PCkERBeABAUHR"; +// JSONObject bodyJson = new JSONObject(); +// //二维码有效时间(秒),最大2592000,仅临时二维码需要 +// bodyJson.put("expire_seconds", "2592000"); +// //二维码类型:QR_SCENE(临时整型)/QR_STR_SCENE(临时字符串)/QR_LIMIT_SCENE(永久整型)/QR_LIMIT_STR_SCENE(永久字符串) +// bodyJson.put("action_name", "QR_STR_SCENE"); +// JSONObject actionInfo = new JSONObject(); +// JSONObject scene = new JSONObject(); +// scene.put("scene_str", "43525423"); +// actionInfo.put("scene", scene); +// bodyJson.put("action_info", actionInfo); +// System.out.println(bodyJson); //创建临时二维码失败,发送参数: {"action_info":{"scene":{"scene_id":36449}},"action_name":"QR_SCENE","expire_seconds":"2592000"}, 响应内容: {"errcode":40052,"errmsg":"invalid action name rid: 68f5fa37-20fb3162-0f87b4f2"} //创建临时二维码失败,发送参数: {"action_info":{"scene":{"scene_id":36449}},"action_name":"QR_SCENE","expire_seconds":"2592000"}, 响应内容: {"errcode":40052,"errmsg":"invalid action name rid: 68f5f970-2a84749c-78e4d78f"} - 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":333}},"action_name":"QR_SCENE","expire_seconds":"2592000"} -// {"ticket":"gQEZ8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyUFVfTnM2MXhmbUoxYTM3dGhGMXIAAgSD_vVoAwQAjScA","expire_seconds":2592000,"url":"http://weixin.qq.com/q/02PU_Ns61xfmJ1a37thF1r"} +// 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); } - - //创建临时二维码失败,发送参数:url: - // https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=97_HZVThQrtvOiCZGrr23ZHN0cVpHBJHc18RSFHU6dvkQDMAme4GsG0NU-Dax1HP5Wx-aGa1l35KaqiMVv61TCj0Qk8DK1LC6kQ8uKLDfgRYVJjX3QjcelmIjp4PCkERBeABAUHR, - // {"action_info":{"scene":{"scene_str":"10839"}},"action_name":"QR_STR_SCENE","expire_seconds":"2592000"}, 响应内容: {"errcode":40052,"errmsg":"invalid action name rid: 68f60aaf-4dcdbd3c-689c5d95"} }