Explorar o código

doc: 风控打印日志补充appId, userId

hidewnd hai 1 mes
pai
achega
69f6cbc555

+ 1 - 1
yt-common/src/main/java/com/ytpm/handle/AbstractLoginService.java

@@ -140,7 +140,7 @@ public abstract class AbstractLoginService {
                     loginParam.getDeviceId(), loginParam.getDitchId()));
             beforeRegistryUser(loginParam, paramMap);
             ytDyzUser = new YtDyzUser();
-            registryUser(loginParam, ytDyzUser, paramMap);
+            ytDyzUser = registryUser(loginParam, ytDyzUser, paramMap);
         } else {
             log.warn(StrUtil.format("visitor login[ deviceId:{}, ditchId: {}]",
                     loginParam.getDeviceId(), loginParam.getDitchId()));

+ 2 - 9
yt-question/yt-question-service/src/main/java/com/ytpm/question/service/impl/AdServiceImpl.java

@@ -1,7 +1,5 @@
 package com.ytpm.question.service.impl;
 
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
@@ -39,15 +37,10 @@ import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.text.SimpleDateFormat;
-import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -77,8 +70,8 @@ public class AdServiceImpl implements AdService {
     @Transactional(rollbackFor = Exception.class)
     public Result<?> saveRecord(DyzAdRecordParam param) {
         YtDyzUser user = appUserMapper.selectPrimaryKey(param.getUserId());
-        log.warn(StrUtil.format("[saveRecord] userId:{} revenue:{} ", param.getUserId(), param.getRevenue()));
-        if(Objects.isNull(user)){
+        log.debug(StrUtil.format("[saveRecord] userId:{} revenue:{} ", param.getUserId(), param.getRevenue()));
+        if (Objects.isNull(user)) {
             return Result.resultOk(RepMessage.SAVE_SUCCESS);
         }
         if (!UserStatusEnum.NORMAL.getCode().equals(user.getUserStatus())) {

+ 1 - 0
yt-question/yt-question-service/src/main/java/com/ytpm/question/service/impl/VisitorLoginServiceImpl.java

@@ -182,6 +182,7 @@ public class VisitorLoginServiceImpl extends AbstractLoginService {
         super.saveVisitorAdRecord(ytDyzUser, loginParam, defaultConfig);
         VisitorLoginParam visitorLoginParam = (VisitorLoginParam) loginParam;
         List<DyzAdRecordParam> preAdList = visitorLoginParam.getPreAdList();
+        // 保存登陆前传递的广告记录
         List<String> adRecordIds = new ArrayList<>();
         if (CollUtil.isNotEmpty(preAdList)) {
             BigDecimal totalRevenue = BigDecimal.ZERO;

+ 17 - 13
yt-risk/risk-manage/src/main/java/com/ytpm/service/impl/RiskServiceImpl.java

@@ -529,12 +529,12 @@ public class RiskServiceImpl implements RiskService {
             adRecords = adRecords.stream().filter(s ->
                     DateUtil.isSameDay(DateUtil.parse(s.getFinishTime()), new Date())
             ).sorted(Comparator.comparing(YtDyzAdRecord::getFinishTime)).collect(Collectors.toList());
-            //校验风控742规则
+            //校验风控742规则 当日观看视频数已经达到风控条件预设的视频数
             checkRisk742(dyzUser, adRecords);
             if (!adRecords.isEmpty() && adRecords.size() > 1) {
-                //校验风控746规则
+                //校验风控746规则 判断当日获得收益的广告达到预设数值
                 checkRisk746(dyzUser, adRecords);
-                // 校验风控766规则
+                // 校验风控766规则 当日用户获得{}个获得奖励的激励视频,近期前{}个获得奖励的激励视频平均收益<{}
                 checkRisk766(dyzUser, adRecords);
             }
         } catch (CommonException e) {
@@ -566,7 +566,8 @@ public class RiskServiceImpl implements RiskService {
                     .collect(Collectors.toList());
             if (revenues.size() > hourTaskLimit) {
                 String format = StrUtil.emptyToDefault(dyzUser.getPowerLimitTip(), "当前设备完成任务次数过多,请{}后重试!");
-                log.warn(StrUtil.format("[risk 768] adRecord count[{}]  > hour limit[{}]", revenues.size(), hourTaskLimit));
+                log.warn(StrUtil.format("[risk 768]appId:{} userId:{} adRecordCount:{} hourLimit:{}",
+                        dyzUser.getAppId(),dyzUser.getUserId(), revenues.size(), hourTaskLimit));
                 throw new CommonException(StrUtil.format(format,StrUtil.format("{}小时", hourCount)));
             }
         }
@@ -602,7 +603,8 @@ public class RiskServiceImpl implements RiskService {
                 recordCount = revenues.size();
             }
             if (recordCount > monthTaskLimit) {
-                log.warn(StrUtil.format("[risk 767] adRecord count[{}]  > limit[{}]", recordCount, monthTaskLimit));
+                log.warn(StrUtil.format("[risk 767]appId:{} userId:{} adRecordCount:{} monthTaskLimit:{}",
+                        dyzUser.getAppId(),dyzUser.getUserId(), recordCount, monthTaskLimit));
                 String format = StrUtil.emptyToDefault(dyzUser.getPowerLimitTip(), "当前设备完成任务次数过多,请{}后重试!");
                 throw new CommonException(StrUtil.format(format, StrUtil.format("{}月", monthCount)));
             }
@@ -670,7 +672,8 @@ public class RiskServiceImpl implements RiskService {
                         .divide(new BigDecimal(count), RoundingMode.HALF_UP);
             }
             if (averageRevenue.compareTo(averageRevenueLimit) < 0) {
-                log.warn(StrUtil.format("[risk 766] averageRevenue{}  averageRevenueLimit {}", averageRevenue, averageRevenueLimit));
+                log.warn(StrUtil.format("[risk 766]appId:{} userId:{} averageRevenue{}  averageRevenueLimit {}",
+                        dyzUser.getAppId(), dyzUser.getUserId(), averageRevenue, averageRevenueLimit));
                 // 自定义响应
                 throw new CommonException("766");
             }
@@ -696,8 +699,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] userId:{} reduce:{}  income:{}",
-                        dyzUser.getUserId(), reduce, income));
+                log.warn(StrUtil.format("[risk 746]appId:{} userId:{} reduce:{}  income:{}",
+                        dyzUser.getAppId(), dyzUser.getUserId(), reduce, income));
                 riskLockUser(dyzUser, "746","系统判定小于最低收益限制",getTipsMsg());
             }
         }
@@ -725,7 +728,8 @@ public class RiskServiceImpl implements RiskService {
             //判断小于预设值的视频数超出预设次数
             int haveCount = Integer.parseInt(limitMap.get("haveCount"));
             if(exact>haveCount){
-                log.warn(StrUtil.format("[risk 742] exact{} > haveCount {}", exact, haveCount));
+                log.warn(StrUtil.format("[risk 742]appId:{} userId:{} exact:{} haveCount:{}",
+                        dyzUser.getAppId(), dyzUser.getUserId(), exact, haveCount));
                 riskLockUser(dyzUser,"742","系统判定激励视频ecpm值过低",getTipsMsg());
             }
         }
@@ -1121,8 +1125,8 @@ public class RiskServiceImpl implements RiskService {
                 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));
+                    log.warn(StrUtil.format("[risk 344]appId:{} userId:{} totalRevenue:{} revenueLimit:{}",
+                            dyzUser.getAppId(), dyzUser.getUserId(), totalRevenue, limitValue));
                 }
             }
             // 校验总ecpm
@@ -1130,8 +1134,8 @@ public class RiskServiceImpl implements RiskService {
                 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));
+                    log.warn(StrUtil.format("[risk 345]]appId:{} userId:{}, totalEcpm:{} ecpmLimit:{}",
+                            dyzUser.getAppId(), dyzUser.getUserId(), totalEcpm, limitValue));
                 }
             }
         }