diff --git a/.workbuddy/expert-history.json b/.workbuddy/expert-history.json index b022a92..0766328 100644 --- a/.workbuddy/expert-history.json +++ b/.workbuddy/expert-history.json @@ -33,7 +33,18 @@ "usedAt": 1775720823455, "industryId": "all" } + ], + "11ef16ee251d4624968d1e84c0fb1de9": [ + { + "expertId": "SeniorDeveloper", + "name": "Will", + "profession": "高级开发工程师", + "avatarUrl": "https://acc-1258344699.cos.accelerate.myqcloud.com/workbuddy/experts/avatars/02-Engineering/SeniorDeveloper/SeniorDeveloper.png", + "promptUrl": "https://acc-1258344699.cos.accelerate.myqcloud.com/workbuddy/experts/experts/02-Engineering/SeniorDeveloper/SeniorDeveloper_zh.md", + "usedAt": 1775866025894, + "industryId": "all" + } ] }, - "lastUpdated": 1775727841457 + "lastUpdated": 1775866842655 } \ No newline at end of file diff --git a/src/main/java/com/gxwebsoft/auto/service/impl/QrLoginServiceImpl.java b/src/main/java/com/gxwebsoft/auto/service/impl/QrLoginServiceImpl.java index 4fd5e1c..2abb00d 100644 --- a/src/main/java/com/gxwebsoft/auto/service/impl/QrLoginServiceImpl.java +++ b/src/main/java/com/gxwebsoft/auto/service/impl/QrLoginServiceImpl.java @@ -147,7 +147,7 @@ public class QrLoginServiceImpl implements QrLoginService { // 小程序端通过 router.params.scene 获取此 token params.put("scene", token); params.put("page", "passport/qr-confirm/index"); // 小程序确认页面路径(子包) - params.put("env_version", "release"); // 正式版小程序 release + params.put("env_version", "release"); // release/trial/develop params.put("width", 280); // 二维码宽度 params.put("auto_color", false); // 不自动配置颜色 // HashMap lineColor = new HashMap<>(); diff --git a/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java b/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java index 2e5aed2..183888b 100644 --- a/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java +++ b/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java @@ -602,16 +602,29 @@ public class WxLoginController extends BaseController { JSONObject phoneInfo = JSON.parseObject(json.getString("phone_info")); // 微信用户的手机号码 final String phoneNumber = phoneInfo.getString("phoneNumber"); - // 验证手机号码 -// if (userParam.getNotVerifyPhone() == null && !Validator.isMobile(phoneNumber)) { -// String key = ACCESS_TOKEN_KEY.concat(":").concat(getTenantId().toString()); -// redisTemplate.delete(key); -// throw new BusinessException("手机号码格式不正确"); -// } return phoneNumber; } else { String errorMsg = json.getString("errmsg"); + Integer errCodeInt = null; + if (errcode instanceof Integer) { + errCodeInt = (Integer) errcode; + } else if (errcode instanceof Long) { + errCodeInt = ((Long) errcode).intValue(); + } else if (errcode instanceof String) { + try { + errCodeInt = Integer.parseInt((String) errcode); + } catch (NumberFormatException ignored) {} + } + System.err.println("微信获取手机号失败: errcode=" + errcode + ", errmsg=" + errorMsg); + + // 判断是否是 token 相关错误,如果是则清理缓存 + if (isTokenRelatedError(errCodeInt, errorMsg)) { + String key = ACCESS_TOKEN_KEY.concat(":").concat(tenantId != null ? tenantId.toString() : getTenantId().toString()); + redisTemplate.delete(key); + System.err.println("已清理access_token缓存,key=" + key); + } + throw new BusinessException("获取手机号失败:" + errorMsg); } } catch (BusinessException be) { @@ -627,6 +640,25 @@ public class WxLoginController extends BaseController { throw new BusinessException("获取手机号失败,请检查参数"); } + /** + * 判断是否是 token 相关的错误码,需要清理缓存 + */ + private boolean isTokenRelatedError(Integer errCode, String errMsg) { + if (errCode == null) { + return false; + } + // token 相关错误码 + return errCode == 40001 // AppSecret错误 + || errCode == 40013 // appid无效 + || errCode == 40125 // appsecret无效 + || errCode == 42001 // access_token超时 + || errCode == 42002 // refresh_token超时 + || errCode == 42003 // code超时 + || errCode == 41002 // appid不正确 + || errCode == 41008 // 缺少access_token参数 + || errCode == 40014; // 不合法的access_token + } + /** * 生成随机账号 *