Browse Source

doc:风控处理打印用时统计

hidewnd 1 month ago
parent
commit
9c9860fed2

+ 23 - 0
yt-risk/risk-manage/src/main/java/com/ytpm/service/impl/RiskServiceImpl.java

@@ -501,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());
@@ -512,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 {
@@ -532,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);
     }
 
@@ -1004,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");
@@ -1019,6 +1029,8 @@ public class RiskServiceImpl implements RiskService {
             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);
@@ -1053,11 +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);
     }
 
@@ -1164,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());
@@ -1176,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);
         }
         //过滤出当日的激励视频数据 按照时间正序排以便筛选每日前几条激励视频
@@ -1187,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);
     }