|
|
@@ -408,11 +408,56 @@ public class RiskServiceImpl implements RiskService {
|
|
|
checkDefaultRiskConfig(dyzUser, view.getConfigList());
|
|
|
}
|
|
|
checkRisk322(dyzUser);
|
|
|
+ // 风控
|
|
|
+ checkRisk334(dyzUser);
|
|
|
//查询用户所在app是否配置其他风控规则
|
|
|
// checkCustomRisk(dyzUser,EffectNodeEnum.LOGIN.getNode(),null);
|
|
|
return Result.resultOk(RepMessage.QUERY_SUCCESS);
|
|
|
}
|
|
|
|
|
|
+ private void checkRisk334(YtDyzUser dyzUser) {
|
|
|
+ RiskTemplateView riskTempView = configMapper.getByCode(dyzUser.getAppId() + "-334");
|
|
|
+ if (riskTempView == null || riskTempView.getEnabled() != 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ YtApp ytApp = appMapper.selectRiskApp(dyzUser.getAppId());
|
|
|
+ YtPlatformUserApp userApp = appMapper.selectParentApp(ytApp.getSuperiorId());
|
|
|
+ String lastLoginIp = dyzUser.getLastLoginIp();
|
|
|
+ if (ytApp.getAppType() != 2) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 白名单放行
|
|
|
+ String whiteKey = "riskPass:334:white";
|
|
|
+ if (redisService.hasKey(whiteKey)) {
|
|
|
+ List<String> list = Arrays.asList(redisService.getStr(whiteKey).split(","));
|
|
|
+ if (list.contains(lastLoginIp)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 已通过的用户放行
|
|
|
+ String passkey = StrUtil.format("riskPass:334:{}:{}", userApp.getAppId(), dyzUser.getLastLoginIp());
|
|
|
+ if (redisService.hasKey(passkey) && StrUtil.equals(dyzUser.getUserId(), redisService.getStr(passkey))) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<RiskConfigView> configList = riskTempView.getConfigList();
|
|
|
+ Map<String, String> configMap = configList.stream().collect(
|
|
|
+ Collectors.toMap(RiskConfigView::getFieldName, RiskConfigView::getConfigVal));
|
|
|
+ int limitCount = Integer.parseInt(configMap.get("limitCount"));
|
|
|
+ int limitHour = Integer.parseInt(configMap.get("limitHour"));
|
|
|
+ int userCount = 0;
|
|
|
+ Object object = feignInvoker.invoke(userApp.getServiceName(), "queryCountByIpTime", dyzUser.getAppId(), lastLoginIp, limitHour);
|
|
|
+ JSONObject jsonObject = object == null ? null : JSON.parseObject(JSON.toJSONString(object));
|
|
|
+ if (jsonObject != null && jsonObject.get("data") != null) {
|
|
|
+ userCount = Integer.parseInt(jsonObject.get("data").toString());
|
|
|
+ }
|
|
|
+ if (redisService.hasKey(passkey) && limitCount <= userCount) {
|
|
|
+ log.warn(StrUtil.format("[risk 334] superiorId:{} appId:{} userId:{} limitCount:{}",
|
|
|
+ userApp.getAppId(), dyzUser.getAppId(), dyzUser.getUserId(), limitCount));
|
|
|
+ riskLockUser(dyzUser, "334", "同IP24小时内登陆多个账号", getTipsMsg());
|
|
|
+ }
|
|
|
+ redisService.setTimeOutHoursStr(passkey, dyzUser.getUserId(), 24);
|
|
|
+ }
|
|
|
+
|
|
|
private String getTipsMsg(){
|
|
|
String[] split = tips.split(",");
|
|
|
return split[RandomUtil.randomInt(split.length)];
|
|
|
@@ -428,7 +473,7 @@ public class RiskServiceImpl implements RiskService {
|
|
|
RiskTemplateView view = configMapper.getByCode("322");
|
|
|
//根据用户所属应用查询该应用母包openid查询用户信息
|
|
|
YtApp ytApp = appMapper.selectRiskApp(dyzUser.getAppId());
|
|
|
- YtPlatformUserApp userApp = appMapper.selectParentApp(ytApp.getSuperiorId());
|
|
|
+ YtPlatformUserApp userApp = appMapper.selectParentApp(ytApp.getSuperiorId());
|
|
|
Object o;
|
|
|
if (dyzUser.getIosId() != null) {
|
|
|
o = feignInvoker.invoke(userApp.getServiceName(),"queryByIosId",dyzUser.getIosId());
|
|
|
@@ -445,7 +490,7 @@ public class RiskServiceImpl implements RiskService {
|
|
|
int days = Integer.parseInt(configMap.get("days"));
|
|
|
//过滤该用户注册时间在三天内的渠道数
|
|
|
long ditchCount = dyzUsers.stream().filter(
|
|
|
- s->(days>DateUtil.between(new Date(), s.getRegistryTime(),DateUnit.DAY))
|
|
|
+ s -> (days > DateUtil.between(new Date(), s.getRegistryTime(), DateUnit.DAY))
|
|
|
).count();
|
|
|
//三天内注册的渠道数小于预设的渠道数通过校验,否则风控锁定用户
|
|
|
if (ditchCount < uidCount) return;
|