|
|
@@ -113,6 +113,11 @@ public class RiskServiceImpl implements RiskService {
|
|
|
private RedisService redisService;
|
|
|
@Resource
|
|
|
private AppMapper appMapper;
|
|
|
+
|
|
|
+ @Value("${risk.visitor.validity-period:48}")
|
|
|
+ private Integer loginCheckValidityPeriod;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 查询配置字段选项
|
|
|
*/
|
|
|
@@ -496,8 +501,11 @@ public class RiskServiceImpl implements RiskService {
|
|
|
@Override
|
|
|
public Result<?> checkAdRisk(YtDyzUser dyzUser) {
|
|
|
//查询当前用户今日有被解封则直接放行
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
List<RiskDeblockingListView> vo = riskManageMapper.queryTodayDeblock(dyzUser.getUserId());
|
|
|
if(CollUtil.isNotEmpty(vo)){
|
|
|
+ log.debug(StrUtil.format("[checkAdRisk] appId:{} (end - start):{}",
|
|
|
+ dyzUser.getAppId(), System.currentTimeMillis() - start));
|
|
|
return Result.resultOk(RepMessage.QUERY_SUCCESS);
|
|
|
}
|
|
|
YtApp ytApp = appMapper.selectRiskApp(dyzUser.getAppId());
|
|
|
@@ -507,6 +515,8 @@ public class RiskServiceImpl implements RiskService {
|
|
|
JSONObject object = JSON.parseObject(JSON.toJSONString(o));
|
|
|
List<YtDyzAdRecord> adRecords = JSONArray.parseArray(object.getString("data"), YtDyzAdRecord.class);
|
|
|
if(CollUtil.isEmpty(adRecords)){
|
|
|
+ log.debug(StrUtil.format("[checkAdRisk] appId:{} (end - start):{}",
|
|
|
+ dyzUser.getAppId(), System.currentTimeMillis() - start));
|
|
|
return Result.resultOk(RepMessage.QUERY_SUCCESS);
|
|
|
}
|
|
|
try {
|
|
|
@@ -527,8 +537,12 @@ public class RiskServiceImpl implements RiskService {
|
|
|
checkRisk766(dyzUser, adRecords);
|
|
|
}
|
|
|
} catch (CommonException e) {
|
|
|
+ log.debug(StrUtil.format("[checkAdRisk] appId:{} (end - start):{}",
|
|
|
+ dyzUser.getAppId(), System.currentTimeMillis() - start));
|
|
|
return Result.resultFail(StatusCode.ACCESS_RISK_ERROR, e.getMessage());
|
|
|
}
|
|
|
+ log.debug(StrUtil.format("[checkAdRisk] appId:{} (end - start):{}",
|
|
|
+ dyzUser.getAppId(), System.currentTimeMillis() - start));
|
|
|
return Result.resultOk(RepMessage.QUERY_SUCCESS);
|
|
|
}
|
|
|
|
|
|
@@ -999,6 +1013,7 @@ public class RiskServiceImpl implements RiskService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Result<?> checkLoginRisk(YtDyzUser dyzUser) {
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
// 20250908 移除游客登陆校验
|
|
|
// // 游客登陆风控校验
|
|
|
// RiskTemplateView view = configMapper.getByCode(dyzUser.getAppId() + "-323");
|
|
|
@@ -1010,6 +1025,14 @@ public class RiskServiceImpl implements RiskService {
|
|
|
}
|
|
|
// 游客用户总收益校验
|
|
|
if(dyzUser.getLoginType() != null && LoginType.VISITOR == dyzUser.getLoginType()){
|
|
|
+ // 已通过用户 不再进行校验
|
|
|
+ String cacheKey = StrUtil.format("visitor:login_validity_{}_{}", dyzUser.getAppId(), dyzUser.getUserId());
|
|
|
+ if (redisService.hasKey(cacheKey)) {
|
|
|
+ log.info("visitor[{}] last check success time < {} h", dyzUser.getUserId(), loginCheckValidityPeriod);
|
|
|
+ log.debug(StrUtil.format("[checkLoginRisk] appId:{} (end - start):{}",
|
|
|
+ dyzUser.getAppId(), System.currentTimeMillis() - start));
|
|
|
+ return Result.resultOk(RepMessage.RISK_SUCCESS);
|
|
|
+ }
|
|
|
boolean checkResult = checkVisitorRisk(dyzUser);
|
|
|
if (!checkResult) {
|
|
|
// 20250911 需求调整 锁定用户
|
|
|
@@ -1024,8 +1047,13 @@ public class RiskServiceImpl implements RiskService {
|
|
|
param.setOperatorName("系统风控");
|
|
|
param.setAgentId(configMapper.getApplicationOwner(dyzUser.getAppId()));
|
|
|
addBannedRecord(Collections.singletonList(dyzUser.getUserId()),param);
|
|
|
- YtApp ytApp = appMapper.selectRiskApp(dyzUser.getAppId());
|
|
|
- YtPlatformUserApp userApp = appMapper.selectParentApp(ytApp.getSuperiorId());
|
|
|
+ YtPlatformUserApp userApp;
|
|
|
+ if (dyzUser.getIosId() != null) {
|
|
|
+ userApp = appMapper.selectParentApp(dyzUser.getAppId());
|
|
|
+ } else {
|
|
|
+ YtApp ytApp = appMapper.selectRiskApp(dyzUser.getAppId());
|
|
|
+ userApp = appMapper.selectParentApp(ytApp.getSuperiorId());
|
|
|
+ }
|
|
|
ScheduledExecutorService scheduled = Executors.newSingleThreadScheduledExecutor();
|
|
|
scheduled.schedule(()->{
|
|
|
YtDyzUser next = new YtDyzUser();
|
|
|
@@ -1037,10 +1065,15 @@ public class RiskServiceImpl implements RiskService {
|
|
|
},300, TimeUnit.MILLISECONDS);
|
|
|
//修改为解锁用户存入redis 24小时后进行解锁
|
|
|
scheduled.shutdown();
|
|
|
+ log.debug(StrUtil.format("[checkLoginRisk] appId:{} (end - start):{}",
|
|
|
+ dyzUser.getAppId(), System.currentTimeMillis() - start));
|
|
|
return Result.resultErr(RepMessage.RISK_VISITOR_LOWER_VALUE);
|
|
|
}
|
|
|
// return checkResult ? Result.resultOk(RepMessage.RISK_SUCCESS) : Result.resultErr(RepMessage.RISK_VISITOR_LOWER_VALUE);
|
|
|
+ redisService.setTimeOutHoursStr(cacheKey, "ok", loginCheckValidityPeriod);
|
|
|
}
|
|
|
+ log.debug(StrUtil.format("[checkLoginRisk] appId:{} (end - start):{}",
|
|
|
+ dyzUser.getAppId(), System.currentTimeMillis() - start));
|
|
|
return Result.resultOk(RepMessage.RISK_SUCCESS);
|
|
|
}
|
|
|
|
|
|
@@ -1074,6 +1107,7 @@ public class RiskServiceImpl implements RiskService {
|
|
|
private boolean checkVisitorRisk(YtDyzUser dyzUser) {
|
|
|
RiskTemplateView view = configMapper.getByCode(dyzUser.getAppId() + "-344");
|
|
|
RiskTemplateView view2 = configMapper.getByCode(dyzUser.getAppId() + "-345");
|
|
|
+
|
|
|
boolean checkResult = true;
|
|
|
if((view != null && view.getEnabled() == 1) || (view2 != null && view2.getEnabled() == 1)) {
|
|
|
//根据用户所属应用查询该应用母包openid查询用户信息
|
|
|
@@ -1146,6 +1180,7 @@ public class RiskServiceImpl implements RiskService {
|
|
|
|
|
|
@Override
|
|
|
public Result<?> checkAdRisk766(YtDyzUser dyzUser) {
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
YtPlatformUserApp userApp;
|
|
|
if (dyzUser.getIosId()!=null) {
|
|
|
userApp = appMapper.selectParentApp(dyzUser.getAppId());
|
|
|
@@ -1158,6 +1193,8 @@ public class RiskServiceImpl implements RiskService {
|
|
|
JSONObject object = JSON.parseObject(JSON.toJSONString(o));
|
|
|
List<YtDyzAdRecord> adRecords = JSONArray.parseArray(object.getString("data"), YtDyzAdRecord.class);
|
|
|
if(CollUtil.isEmpty(adRecords)){
|
|
|
+ log.debug(StrUtil.format("[checkAdRisk766] appId:{} (end - start):{}",
|
|
|
+ dyzUser.getAppId(), System.currentTimeMillis() - start));
|
|
|
return Result.resultOk(RepMessage.QUERY_SUCCESS);
|
|
|
}
|
|
|
//过滤出当日的激励视频数据 按照时间正序排以便筛选每日前几条激励视频
|
|
|
@@ -1169,9 +1206,13 @@ public class RiskServiceImpl implements RiskService {
|
|
|
// 校验风控766规则
|
|
|
checkRisk766(dyzUser, adRecords);
|
|
|
} catch (CommonException e) {
|
|
|
+ log.debug(StrUtil.format("[checkAdRisk766] appId:{} (end - start):{}",
|
|
|
+ dyzUser.getAppId(), System.currentTimeMillis() - start));
|
|
|
return Result.resultFail(StatusCode.ACCESS_ERR, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+ log.debug(StrUtil.format("[checkAdRisk766] appId:{} (end - start):{}",
|
|
|
+ dyzUser.getAppId(), System.currentTimeMillis() - start));
|
|
|
return Result.resultOk(RepMessage.QUERY_SUCCESS);
|
|
|
}
|
|
|
|