Bladeren bron

fix: 风控缺陷修复

hidewnd 1 maand geleden
bovenliggende
commit
4b99b52aab
1 gewijzigde bestanden met toevoegingen van 21 en 8 verwijderingen
  1. 21 8
      yt-risk/risk-manage/src/main/java/com/ytpm/service/impl/RiskServiceImpl.java

+ 21 - 8
yt-risk/risk-manage/src/main/java/com/ytpm/service/impl/RiskServiceImpl.java

@@ -456,12 +456,15 @@ public class RiskServiceImpl implements RiskService {
                 s -> s.getLoginTime().after(yesterday) &&
                         s.getLoginTime().before(new Date())).collect(Collectors.toList());
         int intCount = 0;
-        if(!dayLoginList.isEmpty()){
-            List<String>  ipaddrList = dayLoginList.stream().map(
-                    YtDyzLoginRecord::getLoginIp).distinct().collect(Collectors.toList());
+        if(!dayLoginList.isEmpty() && configMap.get("ipPrefix") != null){
+            List<String>  ipaddrList = dayLoginList.stream()
+                    .map(YtDyzLoginRecord::getLoginIp).distinct()
+                    .filter(StrUtil::isNotEmpty)
+                    .collect(Collectors.toList());
             List<String> ipResult = new ArrayList<>();
+            int ipPrefix = Integer.parseInt(configMap.get("ipPrefix"));
             for (String ipaddr : ipaddrList) {
-                ipResult.add(ipaddr.substring(0,Integer.parseInt(configMap.get("ipPrefix"))));
+                ipResult.add(ipaddr.substring(0, ipPrefix));
             }
             intCount = Math.toIntExact(ipResult.size());
         }
@@ -678,7 +681,8 @@ public class RiskServiceImpl implements RiskService {
             //获取最先的两条
             BigDecimal reduce = revenues.stream().map(YtDyzAdRecord::getRevenue).reduce(BigDecimal.ZERO, BigDecimal::add);
             if(reduce.compareTo(income)<0){
-                log.warn(StrUtil.format("[risk 746] reduce{}  income {}", reduce, income));
+                log.warn(StrUtil.format("[risk 746] userId:{} reduce:{}  income:{}",
+                        dyzUser.getUserId(), reduce, income));
                 riskLockUser(dyzUser, "746","系统判定小于最低收益限制",getTipsMsg());
             }
         }
@@ -1016,7 +1020,8 @@ public class RiskServiceImpl implements RiskService {
                 param.setOperatorName("系统风控");
                 param.setAgentId(configMapper.getApplicationOwner(dyzUser.getAppId()));
                 addBannedRecord(Collections.singletonList(dyzUser.getUserId()),param);
-                YtPlatformUserApp appInfo = appMapper.selectParentApp(dyzUser.getAppId());
+                YtApp ytApp = appMapper.selectRiskApp(dyzUser.getAppId());
+                YtPlatformUserApp userApp =  appMapper.selectParentApp(ytApp.getSuperiorId());
                 ScheduledExecutorService scheduled  = Executors.newSingleThreadScheduledExecutor();
                 scheduled.schedule(()->{
                     YtDyzUser next = new YtDyzUser();
@@ -1024,7 +1029,7 @@ public class RiskServiceImpl implements RiskService {
                     next.setUserStatus(UserStatusEnum.VISITOR_LOCK.getCode());
                     next.setRiskCode("344");
                     next.setRiskReason("预估收益不到上限游客用户风控");
-                    feignInvoker.invoke(appInfo.getServiceName(), "updateUserInfo",next);
+                    feignInvoker.invoke(userApp.getServiceName(), "updateUserInfo",next);
                 },300, TimeUnit.MILLISECONDS);
                 //修改为解锁用户存入redis 24小时后进行解锁
                 scheduled.shutdown();
@@ -1081,11 +1086,19 @@ public class RiskServiceImpl implements RiskService {
             if (view != null && view.getEnabled() == 1) {
                 BigDecimal limitValue = getLimitValue(view, "revenueLimit");
                 checkResult = totalRevenue.compareTo(limitValue) >= 0;
+                if (!checkResult) {
+                    log.warn(StrUtil.format("[risk 344] userId:{},totalRevenue:{} revenueLimit:{}",
+                            dyzUser.getUserId(), totalRevenue, limitValue));
+                }
             }
             // 校验总ecpm
             if (view2 != null && view2.getEnabled() == 1) {
-                BigDecimal limitValue = getLimitValue(view, "ecpmLimit");
+                BigDecimal limitValue = getLimitValue(view2, "ecpmLimit");
                 checkResult = checkResult && totalEcpm.compareTo(limitValue) >= 0;
+                if (!checkResult) {
+                    log.warn(StrUtil.format("[risk 345] userId:{}, totalEcpm:{}  > ecpmLimit:{}",
+                            dyzUser.getUserId(), totalEcpm, limitValue));
+                }
             }
         }
         return checkResult;