From 105162aa899b21550b9eec21d802f5b0e2d0c894 Mon Sep 17 00:00:00 2001 From: Chopper711 Date: Fri, 25 Aug 2023 11:48:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9F=90=E7=A7=8D=E4=B8=8D=E7=9F=A5?= =?UTF-8?q?=E5=90=8D=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E8=81=94=E5=90=88=E7=99=BB=E9=99=86=E4=BC=9A=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/ConnectServiceImpl.java | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java index 095bb826..eac79b15 100644 --- a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java @@ -5,7 +5,6 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; -import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ClientTypeEnum; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; @@ -125,24 +124,18 @@ public class ConnectServiceImpl extends ServiceImpl impl @Transactional public Token miniProgramAutoLogin(WechatMPLoginParams params) { - Object cacheData = cache.get(CachePrefix.WECHAT_SESSION_PARAMS.getPrefix() + params.getUuid()); Map map = new HashMap<>(3); - if (cacheData == null) { - //得到微信小程序联合登陆信息 - JSONObject json = this.getConnect(params.getCode()); - //存储session key 后续登录用得到 - String sessionKey = json.getStr("session_key"); - String unionId = json.getStr("unionid"); - String openId = json.getStr("openid"); - map.put("sessionKey", sessionKey); - map.put("unionId", unionId); - map.put("openId", openId); - cache.put(CachePrefix.WECHAT_SESSION_PARAMS.getPrefix() + params.getUuid(), map, 900L); - } else { - map = (Map) cacheData; - } - //微信联合登陆参数 + //得到微信小程序联合登陆信息 + JSONObject json = this.getConnect(params.getCode()); + //存储session key 后续登录用得到 + String sessionKey = json.getStr("session_key"); + String unionId = json.getStr("unionid"); + String openId = json.getStr("openid"); + map.put("sessionKey", sessionKey); + map.put("unionId", unionId); + map.put("openId", openId); + //微信联合登陆参数 return phoneMpBindAndLogin(map.get("sessionKey"), params, map.get("openId"), map.get("unionId")); } @@ -217,7 +210,7 @@ public class ConnectServiceImpl extends ServiceImpl impl connectQueryDTO.getUnionType()) .eq(CharSequenceUtil.isNotEmpty(connectQueryDTO.getUnionId()), Connect::getUnionId, connectQueryDTO.getUnionId()); - return this.getOne(queryWrapper,false); + return this.getOne(queryWrapper, false); } @Override @@ -267,13 +260,13 @@ public class ConnectServiceImpl extends ServiceImpl impl private Token unionLoginCallback(ConnectAuthUser authUser, boolean longTerm) { try { - Member member =null; + Member member = null; //判断是否传递手机号,如果传递手机号则使用手机号登录 - if(StrUtil.isNotBlank(authUser.getPhone())){ + if (StrUtil.isNotBlank(authUser.getPhone())) { member = memberService.findByMobile(authUser.getPhone()); } //如果未查到手机号的会员则使用第三方登录 - if(member==null){ + if (member == null) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); //使用UnionId登录 if (authUser.getToken() != null && StrUtil.isNotBlank(authUser.getToken().getUnionId())) {