|
|
@@ -87,7 +87,8 @@ public class RiskServiceImpl implements RiskService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Result<?> lockUser(AgentUserInfo curUser, String userId, String appId) {
|
|
|
- redisService.setTimeOutStr("lock_"+userId,appId,1000);
|
|
|
+ String key = StrUtil.format("{}_lock_{}", appId, userId);
|
|
|
+ redisService.setTimeOutStr(key, appId, 1000);
|
|
|
addBannedRecord(userId,curUser,appId,24,BannedTypeEnum.CHANNEL.getDesc()+"禁止登录");
|
|
|
return Result.resultOk(RepMessage.LOCK_USER_SUCCESS);
|
|
|
}
|
|
|
@@ -97,10 +98,12 @@ public class RiskServiceImpl implements RiskService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Result<?> banned(RiskBannedParam param,AgentUserInfo curUser) {
|
|
|
- redisService.setTimeOutStr("lock_"+param.getUserId(),param.getAppId(),1000);
|
|
|
- addBannedRecord(param.getUserId(),curUser,param.getAppId(),param.getBannedLimit()*24,param.getBannedReason());
|
|
|
+ String key = StrUtil.format("{}_lock_{}", param.getAppId(), param.getUserId());
|
|
|
+ redisService.setTimeOutStr(key, param.getAppId(), 1000);
|
|
|
+ addBannedRecord(param.getUserId(), curUser, param.getAppId(), param.getBannedLimit() * 24, param.getBannedReason());
|
|
|
//预设24小时过期key 用于解锁用户
|
|
|
- redisService.setTimeOutHoursStr("unlock_"+param.getUserId(),param.getAppId(),param.getBannedLimit() * 24L);
|
|
|
+ key = StrUtil.format("{}_unlock__{}", param.getAppId(), param.getUserId());
|
|
|
+ redisService.setTimeOutHoursStr(key, param.getAppId(), param.getBannedLimit() * 24L);
|
|
|
return Result.resultOk(RepMessage.ALREADY_RISK_USER);
|
|
|
}
|
|
|
|
|
|
@@ -114,11 +117,15 @@ public class RiskServiceImpl implements RiskService {
|
|
|
return Result.resultErr("请选择封禁用户");
|
|
|
}
|
|
|
String[] split = param.getUserIds().split(",");
|
|
|
+ String lockFormat = "{}_lock_{}";
|
|
|
+ String unlockFormat = "{}_unlock_{}";
|
|
|
for (String userId : split) { // 为避免大量解锁的key再同一时间过期, 这里采用随机数
|
|
|
- redisService.setTimeOutStr("lock_"+userId,param.getAppId(),RandomUtil.randomInt(500, 2000));
|
|
|
- addBannedRecord(userId,curUser,param.getAppId(),param.getBannedLimit()*24, param.getBannedReason());
|
|
|
+ redisService.setTimeOutStr(StrUtil.format(lockFormat, param.getAppId(), userId),
|
|
|
+ param.getAppId(), RandomUtil.randomInt(500, 2000));
|
|
|
+ addBannedRecord(userId, curUser, param.getAppId(), param.getBannedLimit() * 24, param.getBannedReason());
|
|
|
//预设20-24小时过期key 用于解锁用户
|
|
|
- redisService.setTimeOutHoursStr("unlock_"+userId,param.getAppId(),param.getBannedLimit() * RandomUtil.randomLong(20, 24));
|
|
|
+ redisService.setTimeOutHoursStr(StrUtil.format(unlockFormat, param.getAppId(), userId),
|
|
|
+ param.getAppId(), param.getBannedLimit() * RandomUtil.randomLong(20, 24));
|
|
|
}
|
|
|
return Result.resultOk(RepMessage.ALREADY_RISK_USER);
|
|
|
}
|
|
|
@@ -133,9 +140,12 @@ public class RiskServiceImpl implements RiskService {
|
|
|
}
|
|
|
String[] split = param.getUserIds().split(",");
|
|
|
RiskUserStatusParam riskUserStatusParam;
|
|
|
+ String unlockFormat = "{}_unlock_{}";
|
|
|
+ String lockFormat = "{}_lock_{}";
|
|
|
for (String userId : split) {
|
|
|
//批量解封用户并增加解封记录
|
|
|
- redisService.setTimeOutStr("unlock_"+userId,param.getAppId(),RandomUtil.randomInt(500, 2000));
|
|
|
+ redisService.setTimeOutStr(StrUtil.format(unlockFormat, param.getAppId(), userId),
|
|
|
+ param.getAppId(),RandomUtil.randomInt(500, 2000));
|
|
|
YtPlatformBanned lastBanned = riskMapper.getLastBanned(userId);
|
|
|
riskUserStatusParam = new RiskUserStatusParam();
|
|
|
riskUserStatusParam.setAgentId(curUser.getUserId());
|
|
|
@@ -144,7 +154,8 @@ public class RiskServiceImpl implements RiskService {
|
|
|
riskUserStatusParam.setReason(param.getDeblockingReason());
|
|
|
addDeblockingRecord(lastBanned,riskUserStatusParam);
|
|
|
//查询用户id 在redis中是否存在未处理的 lock_ 清除掉
|
|
|
- redisService.del("lock_"+userId);
|
|
|
+ redisService.del("lock_" + userId);
|
|
|
+ redisService.del(StrUtil.format(lockFormat, param.getAppId(), userId));
|
|
|
}
|
|
|
return Result.resultOk(RepMessage.PROCESS_SUCCESS);
|
|
|
}
|
|
|
@@ -178,7 +189,7 @@ public class RiskServiceImpl implements RiskService {
|
|
|
List<YtDyzUser> data = dealWithFeignData(issuedAppList,appUserParam);
|
|
|
setBannedLoginInfo(bannedList,data);
|
|
|
}
|
|
|
- return ResultTable.resultTableOk(new PageInfo<RiskBannedListView>(bannedList));
|
|
|
+ return ResultTable.resultTableOk(new PageInfo<>(bannedList));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -290,7 +301,7 @@ public class RiskServiceImpl implements RiskService {
|
|
|
}
|
|
|
String oldValue = valueMap.get(listParam.getConfigId());
|
|
|
if (!StrUtil.emptyIfNull(oldValue).equals(StrUtil.emptyIfNull(listParam.getConfigVal()))) {
|
|
|
- YtRiskTemplateLog log = new YtRiskTemplateLog();;
|
|
|
+ YtRiskTemplateLog log = new YtRiskTemplateLog();
|
|
|
log.setTemplateId(old.getTemplateId());
|
|
|
log.setTemplateCode(old.getTemplateCode());
|
|
|
log.setConfigId(listParam.getConfigId());
|
|
|
@@ -327,7 +338,7 @@ public class RiskServiceImpl implements RiskService {
|
|
|
log.error(e.getMessage());
|
|
|
throw new CustomerException(e.getMessage());
|
|
|
}
|
|
|
- return ResultTable.resultTableOk(new PageInfo<RiskConfigView>(configList));
|
|
|
+ return ResultTable.resultTableOk(new PageInfo<>(configList));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -385,7 +396,7 @@ public class RiskServiceImpl implements RiskService {
|
|
|
log.error(e.getMessage());
|
|
|
throw new CustomerException(e.getMessage());
|
|
|
}
|
|
|
- return ResultTable.resultTableOk(new PageInfo<RiskConfigView>(configList));
|
|
|
+ return ResultTable.resultTableOk(new PageInfo<>(configList));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -432,26 +443,28 @@ public class RiskServiceImpl implements RiskService {
|
|
|
YtDyzUser appUser = new YtDyzUser();
|
|
|
appUser.setUserId(param.getUserId());
|
|
|
appUser.setUserStatus(param.getUserStatus());
|
|
|
+ String lockKey = StrUtil.format("{}_lock_{}", param.getAppId(), param.getUserId());
|
|
|
+ String unlockKey = StrUtil.format("{}_unlock_{}", param.getAppId(), param.getUserId());
|
|
|
switch (param.getUserStatus()){
|
|
|
case 2:
|
|
|
appUser.setRiskReason(param.getReason());
|
|
|
//1s锁定用户,并设置 24小时后进行解锁
|
|
|
- redisService.setTimeOutStr("lock_"+userId,param.getAppId(),1000);
|
|
|
- redisService.setTimeOutHoursStr("unlock_"+userId,param.getAppId(),24);
|
|
|
+ redisService.setTimeOutStr(lockKey, param.getAppId(), 1000);
|
|
|
+ redisService.setTimeOutHoursStr(unlockKey, param.getAppId(), 24);
|
|
|
break;
|
|
|
case 3: //增加封禁记录
|
|
|
appUser.setRiskReason(param.getReason());
|
|
|
addBannedRecord(userId,curUser,param.getAppId(),param.getBannedLimit()*24, param.getReason());
|
|
|
//1s锁定用户,并设置 24小时后进行解锁
|
|
|
- redisService.setTimeOutStr("lock_"+userId,param.getAppId(),1000);
|
|
|
- redisService.setTimeOutHoursStr("unlock_"+userId,param.getAppId(),param.getBannedLimit()*24L);
|
|
|
+ redisService.setTimeOutStr(lockKey, param.getAppId(), 1000);
|
|
|
+ redisService.setTimeOutHoursStr(unlockKey, param.getAppId(), param.getBannedLimit() * 24L);
|
|
|
break;
|
|
|
default: //解禁
|
|
|
YtPlatformBanned banned = riskMapper.getLastBanned(userId);
|
|
|
if(Objects.nonNull(banned)){
|
|
|
addDeblockingRecord(banned,param);
|
|
|
}
|
|
|
- redisService.setTimeOutStr("unlock_"+userId,param.getAppId(),1000);
|
|
|
+ redisService.setTimeOutStr(unlockKey, param.getAppId(), 1000);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
@@ -506,14 +519,17 @@ public class RiskServiceImpl implements RiskService {
|
|
|
view.setUserStatus(dyzUser.getUserStatus());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 设置封禁用户信息
|
|
|
*/
|
|
|
- private void setBannedLoginInfo(List<RiskBannedListView> bannedList,List<YtDyzUser> data) {
|
|
|
- Map<String, YtDyzUser> collect = data.stream().collect(Collectors.toMap(YtDyzUser::getUserId, o->o));
|
|
|
+ private void setBannedLoginInfo(List<RiskBannedListView> bannedList, List<YtDyzUser> data) {
|
|
|
+ Map<String, YtDyzUser> collectMap = data.stream().collect(Collectors.toMap(
|
|
|
+ item-> StrUtil.format("{}_{}", item.getAppId(), item.getUserId()), o -> o));
|
|
|
for (RiskBannedListView view : bannedList) {
|
|
|
- if(!collect.containsKey(view.getUserId()))continue;
|
|
|
- YtDyzUser dyzUser = collect.get(view.getUserId());
|
|
|
+ String key = StrUtil.format("{}_{}", view.getAppId(), view.getUserId());
|
|
|
+ if(!collectMap.containsKey(key))continue;
|
|
|
+ YtDyzUser dyzUser = collectMap.get(key);
|
|
|
List<YtDyzLoginRecord> recordList = dyzUser.getLoginRecordList();
|
|
|
if(CollUtil.isNotEmpty(recordList)){
|
|
|
view.setPhoneModel(recordList.get(0).getDeviceModel());
|