|
@@ -438,7 +438,7 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
|
|
|
}
|
|
}
|
|
|
int ipSameCount = Integer.parseInt(configMap.get("ipSameCount"));
|
|
int ipSameCount = Integer.parseInt(configMap.get("ipSameCount"));
|
|
|
if(intCount > ipSameCount){//校验同IP登录次数大于预设值,锁定用户
|
|
if(intCount > ipSameCount){//校验同IP登录次数大于预设值,锁定用户
|
|
|
- riskLockUser(dyzUser.getUserId(), dyzUser.getAppId(),"313","系统判定登录IP限制","当前用户已被风控!");
|
|
|
|
|
|
|
+ riskLockUser(dyzUser,"313","系统判定登录IP限制","当前用户已被风控!");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -462,8 +462,8 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
|
|
|
* 校验广告的默认风控配置
|
|
* 校验广告的默认风控配置
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public Result<?> checkAdRisk(String userId,String appId) {
|
|
|
|
|
- ResultTable<YtDyzAdRecord> table = appFeign.adRecords(userId);
|
|
|
|
|
|
|
+ public Result<?> checkAdRisk(YtDyzUser dyzUser) {
|
|
|
|
|
+ ResultTable<YtDyzAdRecord> table = appFeign.adRecords(dyzUser.getUserId());
|
|
|
List<YtDyzAdRecord> records = table.getData();
|
|
List<YtDyzAdRecord> records = table.getData();
|
|
|
if(records.isEmpty()){
|
|
if(records.isEmpty()){
|
|
|
return Result.resultOk(RepMessage.QUERY_SUCCESS);
|
|
return Result.resultOk(RepMessage.QUERY_SUCCESS);
|
|
@@ -476,10 +476,10 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
|
|
|
).sorted(Comparator.comparing(YtDyzAdRecord::getFinishTime)).collect(Collectors.toList());
|
|
).sorted(Comparator.comparing(YtDyzAdRecord::getFinishTime)).collect(Collectors.toList());
|
|
|
//校验风控742规则
|
|
//校验风控742规则
|
|
|
RiskTemplateView ecpmLimit= configMapper.getByCode("742");
|
|
RiskTemplateView ecpmLimit= configMapper.getByCode("742");
|
|
|
- checkRisk742(ecpmLimit,userId,appId,records);
|
|
|
|
|
|
|
+ checkRisk742(ecpmLimit,dyzUser,records);
|
|
|
//校验风控746规则
|
|
//校验风控746规则
|
|
|
if(!records.isEmpty() && records.size()>1){
|
|
if(!records.isEmpty() && records.size()>1){
|
|
|
- checkRisk746(userId,appId,records);
|
|
|
|
|
|
|
+ checkRisk746(dyzUser,records);
|
|
|
}
|
|
}
|
|
|
return Result.resultOk(RepMessage.QUERY_SUCCESS);
|
|
return Result.resultOk(RepMessage.QUERY_SUCCESS);
|
|
|
}
|
|
}
|
|
@@ -487,7 +487,7 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
|
|
|
/**
|
|
/**
|
|
|
* 校验默认风控规则746
|
|
* 校验默认风控规则746
|
|
|
*/
|
|
*/
|
|
|
- private void checkRisk746(String userId,String appId, List<YtDyzAdRecord> records) {
|
|
|
|
|
|
|
+ private void checkRisk746(YtDyzUser dyzUser, List<YtDyzAdRecord> records) {
|
|
|
RiskTemplateView revenue = configMapper.getByCode("746");
|
|
RiskTemplateView revenue = configMapper.getByCode("746");
|
|
|
Map<String, String> revenueMap = revenue.getConfigList().stream().collect(
|
|
Map<String, String> revenueMap = revenue.getConfigList().stream().collect(
|
|
|
Collectors.toMap(RiskConfigView::getFieldName, RiskConfigView::getConfigVal));
|
|
Collectors.toMap(RiskConfigView::getFieldName, RiskConfigView::getConfigVal));
|
|
@@ -502,7 +502,7 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
|
|
|
//获取最先的两条
|
|
//获取最先的两条
|
|
|
BigDecimal reduce = revenues.stream().map(YtDyzAdRecord::getRevenue).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
BigDecimal reduce = revenues.stream().map(YtDyzAdRecord::getRevenue).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
if(reduce.compareTo(income)<0){
|
|
if(reduce.compareTo(income)<0){
|
|
|
- riskLockUser(userId,appId, "746","系统判定小于最低收益限制","用户已被风控,风控编码:746");
|
|
|
|
|
|
|
+ riskLockUser(dyzUser, "746","系统判定小于最低收益限制","用户已被风控,风控编码:746");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -510,7 +510,7 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
|
|
|
/**
|
|
/**
|
|
|
* 校验默认风控规则742
|
|
* 校验默认风控规则742
|
|
|
*/
|
|
*/
|
|
|
- private void checkRisk742(RiskTemplateView ecpmLimit,String userId,String appId,List<YtDyzAdRecord> records) {
|
|
|
|
|
|
|
+ private void checkRisk742(RiskTemplateView ecpmLimit,YtDyzUser dyzUser,List<YtDyzAdRecord> records) {
|
|
|
Map<String, String> limitMap = ecpmLimit.getConfigList().stream().collect(
|
|
Map<String, String> limitMap = ecpmLimit.getConfigList().stream().collect(
|
|
|
Collectors.toMap(RiskConfigView::getFieldName, RiskConfigView::getConfigVal));
|
|
Collectors.toMap(RiskConfigView::getFieldName, RiskConfigView::getConfigVal));
|
|
|
int adCount = 0;
|
|
int adCount = 0;
|
|
@@ -527,7 +527,7 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
|
|
|
//判断小于预设值的视频数超出预设次数
|
|
//判断小于预设值的视频数超出预设次数
|
|
|
int haveCount = Integer.parseInt(limitMap.get("haveCount"));
|
|
int haveCount = Integer.parseInt(limitMap.get("haveCount"));
|
|
|
if(exact>haveCount){
|
|
if(exact>haveCount){
|
|
|
- riskLockUser(userId, appId,"742","系统判定激励视频ecpm值过低","用户已被风控,风控编码:742");
|
|
|
|
|
|
|
+ riskLockUser(dyzUser,"742","系统判定激励视频ecpm值过低","用户已被风控,风控编码:742");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -535,21 +535,22 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
|
|
|
/**
|
|
/**
|
|
|
* 风控锁定用户
|
|
* 风控锁定用户
|
|
|
*/
|
|
*/
|
|
|
- private void riskLockUser(String userId,String appId, String riskCode, String tempName, String errMsg) {
|
|
|
|
|
|
|
+ private void riskLockUser(YtDyzUser dyzUser, String riskCode, String tempName, String errMsg) {
|
|
|
//增加用户风控记录
|
|
//增加用户风控记录
|
|
|
RiskBannedParam param = new RiskBannedParam();
|
|
RiskBannedParam param = new RiskBannedParam();
|
|
|
- param.setUserId(userId);
|
|
|
|
|
- param.setAppId(appId);
|
|
|
|
|
|
|
+ param.setUserId(dyzUser.getUserId());
|
|
|
|
|
+ param.setAppId(dyzUser.getAppId());
|
|
|
|
|
+ param.setDitChId(dyzUser.getDitchId());
|
|
|
param.setBannedLimit(24);
|
|
param.setBannedLimit(24);
|
|
|
param.setOperator("系统风控");
|
|
param.setOperator("系统风控");
|
|
|
param.setBannedReason(tempName);
|
|
param.setBannedReason(tempName);
|
|
|
param.setOperatorName("系统风控");
|
|
param.setOperatorName("系统风控");
|
|
|
- addBannedRecord(Collections.singletonList(userId),param);
|
|
|
|
|
|
|
+ addBannedRecord(Collections.singletonList(dyzUser.getUserId()),param);
|
|
|
//懒得引入mq,因而利用线程池创建延迟定时任务修改用户状态,主线程继续执行,避免循环调用产生的死锁
|
|
//懒得引入mq,因而利用线程池创建延迟定时任务修改用户状态,主线程继续执行,避免循环调用产生的死锁
|
|
|
ScheduledExecutorService scheduled = Executors.newSingleThreadScheduledExecutor();
|
|
ScheduledExecutorService scheduled = Executors.newSingleThreadScheduledExecutor();
|
|
|
scheduled.schedule(()->{
|
|
scheduled.schedule(()->{
|
|
|
YtDyzUser next = new YtDyzUser();
|
|
YtDyzUser next = new YtDyzUser();
|
|
|
- next.setUserId(userId);
|
|
|
|
|
|
|
+ next.setUserId(dyzUser.getUserId());
|
|
|
next.setUserStatus(UserStatusEnum.LOCK.getCode());
|
|
next.setUserStatus(UserStatusEnum.LOCK.getCode());
|
|
|
next.setRiskCode(riskCode);
|
|
next.setRiskCode(riskCode);
|
|
|
next.setRiskReason(tempName);
|
|
next.setRiskReason(tempName);
|
|
@@ -558,7 +559,7 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
|
|
|
//创建一次性定时任务用于24小时后解锁用户
|
|
//创建一次性定时任务用于24小时后解锁用户
|
|
|
scheduled.schedule(()->{
|
|
scheduled.schedule(()->{
|
|
|
YtDyzUser user = new YtDyzUser();
|
|
YtDyzUser user = new YtDyzUser();
|
|
|
- user.setUserId(userId);
|
|
|
|
|
|
|
+ user.setUserId(dyzUser.getUserId());
|
|
|
user.setUserStatus(UserStatusEnum.NORMAL.getCode());
|
|
user.setUserStatus(UserStatusEnum.NORMAL.getCode());
|
|
|
appFeign.updateUserInfo(user);
|
|
appFeign.updateUserInfo(user);
|
|
|
scheduled.shutdown();
|
|
scheduled.shutdown();
|
|
@@ -621,7 +622,7 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
|
|
|
banned.setBannedId(IdUtil.fastSimpleUUID());
|
|
banned.setBannedId(IdUtil.fastSimpleUUID());
|
|
|
banned.setUserId(userId);
|
|
banned.setUserId(userId);
|
|
|
banned.setAppId(param.getAppId());
|
|
banned.setAppId(param.getAppId());
|
|
|
- banned.setChannelId(param.getOperator());
|
|
|
|
|
|
|
+ banned.setChannelId(param.getDitChId().toString());
|
|
|
banned.setBannedLimit(Objects.isNull(param.getBannedLimit())?defaultLimit:param.getBannedLimit());
|
|
banned.setBannedLimit(Objects.isNull(param.getBannedLimit())?defaultLimit:param.getBannedLimit());
|
|
|
banned.setBannedReason(StrUtil.isBlank(param.getBannedReason())?defaultReason:param.getBannedReason());
|
|
banned.setBannedReason(StrUtil.isBlank(param.getBannedReason())?defaultReason:param.getBannedReason());
|
|
|
banned.setBannedType(BannedTypeEnum.CHANNEL.getCode());
|
|
banned.setBannedType(BannedTypeEnum.CHANNEL.getCode());
|