|
@@ -113,6 +113,7 @@ public class WxLoginService
|
|
|
public Map<String,Object> pcLoginUrl(){
|
|
|
String scanCode = ToolsUtils.getCharAndNumr(6);
|
|
|
String key = "SCAN_LOGIN_"+scanCode;
|
|
|
+ String keyStatus = "SCAN_LOGIN_STATUS_"+scanCode; //0未扫码 1已扫码 2已登录
|
|
|
String codeUrl = scanLoginHost+"pc/login/"+scanCode;
|
|
|
String urlBase64 = null;
|
|
|
try {
|
|
@@ -128,7 +129,8 @@ public class WxLoginService
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- redisCache.setCacheObject(key, -1L,180, TimeUnit.SECONDS);//180秒锁定
|
|
|
+ redisCache.setCacheObject(key, 0L,180, TimeUnit.SECONDS);//180秒锁定
|
|
|
+ redisCache.setCacheObject(keyStatus, 0L,180, TimeUnit.SECONDS);//180秒锁定
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("scanCode",scanCode);
|
|
|
map.put("urlBase64",urlBase64);
|
|
@@ -142,11 +144,13 @@ public class WxLoginService
|
|
|
*/
|
|
|
public Map<String,Object> checkPcLogin(String scanCode) {
|
|
|
String key = "SCAN_LOGIN_"+scanCode;
|
|
|
+ String keyStatus = "SCAN_LOGIN_STATUS_"+scanCode; //0未扫码 1已扫码 2已登录
|
|
|
Long userId = redisCache.getCacheObject(key);
|
|
|
- if(Validator.isNotEmpty(userId)&&userId.equals(-2L)){
|
|
|
+ Long status = redisCache.getCacheObject(keyStatus);
|
|
|
+ if(Validator.isNotEmpty(status)&&status.equals(1L)){
|
|
|
throw new CustomException("小程序已扫码");
|
|
|
}
|
|
|
- else if(Validator.isNotEmpty(userId)&&userId.longValue()>0L){
|
|
|
+ else if(Validator.isNotEmpty(status)&&status.equals(2L)){
|
|
|
User user = iUserService.getOne(new LambdaQueryWrapper<User>().eq(User::getUserId, userId).last("limit 1"));
|
|
|
if(Validator.isEmpty(user)){
|
|
|
throw new CustomException("暂未登录");
|