|
|
@@ -23,7 +23,6 @@ import com.ytpm.agent.model.YtPlatformUserApp;
|
|
|
import com.ytpm.agent.view.AgentAppClassView;
|
|
|
import com.ytpm.agent.view.AgentEnableAppView;
|
|
|
import com.ytpm.agent.view.AgentUserInfo;
|
|
|
-import com.ytpm.agent.view.UserAdStaticsVo;
|
|
|
import com.ytpm.app.model.YtDyzAdRecord;
|
|
|
import com.ytpm.app.model.YtDyzLoginRecord;
|
|
|
import com.ytpm.app.model.YtDyzUser;
|
|
|
@@ -1060,15 +1059,20 @@ public class RiskServiceImpl implements RiskService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Result<?> checkLoginRisk(YtDyzUser dyzUser) {
|
|
|
- RiskTemplateView view= configMapper.getByCode(dyzUser.getAppId()+"-323");
|
|
|
- checkVisitor323(dyzUser,view);
|
|
|
- return Result.resultOk(RepMessage.RISK_SUCCESS);
|
|
|
+ // 20250908 移除游客登陆校验
|
|
|
+// // 游客登陆风控校验
|
|
|
+// RiskTemplateView view = configMapper.getByCode(dyzUser.getAppId() + "-323");
|
|
|
+// checkVisitor323(dyzUser, view);
|
|
|
+ // 游客用户总收益校验
|
|
|
+ boolean checkResult = checkVisitorRisk(dyzUser);
|
|
|
+ return checkResult ? Result.resultOk(RepMessage.RISK_SUCCESS) : Result.resultErr(RepMessage.ALREADY_RISK_USER);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 校验游客登录323规则
|
|
|
*/
|
|
|
private void checkVisitor323(YtDyzUser dyzUser, RiskTemplateView view) {
|
|
|
+ if(view != null && view.getEnabled() != 1) return;
|
|
|
List<RiskConfigView> configList = view == null ? Collections.emptyList() : view.getConfigList();
|
|
|
Map<String, String> configMap = configList.stream().collect(
|
|
|
Collectors.toMap(RiskConfigView::getFieldName, RiskConfigView::getConfigVal));
|
|
|
@@ -1078,13 +1082,57 @@ public class RiskServiceImpl implements RiskService {
|
|
|
//根据用户所属应用查询该应用母包openid查询用户信息
|
|
|
YtApp ytApp = appMapper.selectRiskApp(dyzUser.getAppId());
|
|
|
YtPlatformUserApp userApp = appMapper.selectParentApp(ytApp.getSuperiorId());
|
|
|
- Object o = feignInvoker.invoke(userApp.getServiceName(),"getLoginDitchCount",dyzUser.getDeviceId(),hours);
|
|
|
+ Object o = feignInvoker.invoke(userApp.getServiceName(), "getLoginDitchCount", dyzUser.getDeviceId(), hours);
|
|
|
int ditchCount = (int)o;
|
|
|
//三天内注册的渠道数小于预设的渠道数通过校验,否则风控锁定用户
|
|
|
if(ditchCount<uidCount)return;
|
|
|
riskLockUser(dyzUser,"323",hours+"小时内登录渠道已达上限",getTipsMsg());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 344/345 游客模式登陆前三条广告收益 风控校验<br>
|
|
|
+ * 原生(信息流)+ 开屏广告 + 横幅对应 总预估收益 小于 阈值时,校验失败
|
|
|
+ * @param dyzUser 该设备同应用的最新一条注册用户信息
|
|
|
+ */
|
|
|
+ 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查询用户信息
|
|
|
+ // 查询数据
|
|
|
+ BigDecimal totalRevenue = BigDecimal.ZERO;
|
|
|
+ BigDecimal totalEcpm = BigDecimal.ZERO;
|
|
|
+ if (CollUtil.isNotEmpty(dyzUser.getPreAdRecordList())) {
|
|
|
+ for (YtDyzAdRecord adRecord : dyzUser.getPreAdRecordList()) {
|
|
|
+ totalRevenue = adRecord.getRevenue() == null ? totalRevenue : totalRevenue.add(adRecord.getRevenue());
|
|
|
+ totalEcpm = adRecord.getEcpm() == null ? totalEcpm : totalEcpm.add(adRecord.getEcpm());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 校验总预估收益
|
|
|
+ if (view != null && view.getEnabled() == 1) {
|
|
|
+ BigDecimal limitValue = getLimitValue(view, "revenueLimit");
|
|
|
+ checkResult = totalRevenue.compareTo(limitValue) >= 0;
|
|
|
+ }
|
|
|
+ // 校验总ecpm
|
|
|
+ if (view2 != null && view2.getEnabled() == 1) {
|
|
|
+ BigDecimal limitValue = getLimitValue(view, "ecpmLimit");
|
|
|
+ checkResult = checkResult && totalEcpm.compareTo(limitValue) >= 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return checkResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ private BigDecimal getLimitValue(RiskTemplateView view, String configCode){
|
|
|
+ List<RiskConfigView> configList = view == null ? Collections.emptyList() : view.getConfigList();
|
|
|
+ Map<String, String> configMap = configList.stream()
|
|
|
+ .filter(item -> item.getMulty() != null && item.getMulty() == 4)
|
|
|
+ .collect(Collectors.toMap(RiskConfigView::getFieldName, RiskConfigView::getConfigVal,
|
|
|
+ (o1,o2)-> o2));
|
|
|
+ return new BigDecimal(configMap.getOrDefault(configCode, "0"));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 333 注册风控可配置
|
|
|
* 需求要求改为小时控制
|
|
|
@@ -1112,14 +1160,6 @@ public class RiskServiceImpl implements RiskService {
|
|
|
return Result.resultErr(hours+RepMessage.DITCH_REG_LIMIT);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result<?> checkVisitorLogin(YtDyzUser dyzUser) {
|
|
|
- RiskTemplateView view = configMapper.getByCode(dyzUser.getAppId() + "-344");
|
|
|
- return checkVisitor344(dyzUser,view)
|
|
|
- ? Result.resultOk(RepMessage.RISK_SUCCESS) : Result.resultErr(RepMessage.ALREADY_RISK_USER);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public Result<?> checkAdRisk766(YtDyzUser dyzUser) {
|
|
|
YtPlatformUserApp userApp;
|
|
|
@@ -1127,7 +1167,7 @@ public class RiskServiceImpl implements RiskService {
|
|
|
userApp = appMapper.selectParentApp(dyzUser.getAppId());
|
|
|
} else {
|
|
|
YtApp ytApp = appMapper.selectRiskApp(dyzUser.getAppId());
|
|
|
- userApp = appMapper.selectParentApp(ytApp.getSuperiorId());
|
|
|
+ userApp = appMapper.selectParentApp(ytApp.getSuperiorId());
|
|
|
}
|
|
|
Object o = feignInvoker.invoke(userApp.getServiceName(), "adRecords", dyzUser.getUserId(),
|
|
|
AdSourceTypeEnum.rewarded_video.getAdSourceType());
|
|
|
@@ -1151,39 +1191,5 @@ public class RiskServiceImpl implements RiskService {
|
|
|
return Result.resultOk(RepMessage.QUERY_SUCCESS);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 344 游客模式登陆用户风控校验<br>
|
|
|
- * 原生(信息流)、开屏广告、横幅对应 ecpm 和预估收益 小于 阈值时,校验失败
|
|
|
- * @param dyzUser 该设备同应用的最新一条注册用户信息
|
|
|
- * @param view 当前校验的设备登录的应用风控配置
|
|
|
- */
|
|
|
- private boolean checkVisitor344(YtDyzUser dyzUser, RiskTemplateView view) {
|
|
|
- //根据用户所属应用查询该应用母包openid查询用户信息
|
|
|
- List<RiskConfigView> configList = view == null ? Collections.emptyList() : view.getConfigList();
|
|
|
- Map<String, String> configMap = configList.stream()
|
|
|
- .filter(item -> item.getMulty() != null && item.getMulty() == 4)
|
|
|
- .collect(Collectors.toMap(RiskConfigView::getFieldName, RiskConfigView::getConfigVal,
|
|
|
- (o1,o2)-> o2));
|
|
|
- //根据用户所属应用查询该应用母包openid查询用户信息
|
|
|
- YtApp ytApp = appMapper.selectRiskApp(dyzUser.getAppId());
|
|
|
- YtPlatformUserApp userApp = appMapper.selectParentApp(ytApp.getSuperiorId());
|
|
|
- Object result = feignInvoker.invoke(userApp.getServiceName(), "getUerAdStatics", dyzUser.getAppId(), dyzUser.getUserId());
|
|
|
- boolean checkResult = true;
|
|
|
- if (result != null) {
|
|
|
- List<UserAdStaticsVo> userAdStaticsVos = JSONArray.parseArray(JSONObject.toJSONString(result), UserAdStaticsVo.class);
|
|
|
- for (UserAdStaticsVo userAdStaticsVo : userAdStaticsVos) {
|
|
|
- String ecpmKey = StrUtil.format("ecpmLimit_{}", userAdStaticsVo.getAdSourceType());
|
|
|
- String revenueKey = StrUtil.format("revenueLimit_{}", userAdStaticsVo.getAdSourceType());
|
|
|
- checkResult = checkResult && limitCompare(userAdStaticsVo.getTotalEcpm(), ecpmKey, configMap);
|
|
|
- checkResult = checkResult && limitCompare(userAdStaticsVo.getTotalRevenue(), revenueKey, configMap);
|
|
|
- }
|
|
|
- }
|
|
|
- return checkResult;
|
|
|
- }
|
|
|
-
|
|
|
- private boolean limitCompare(BigDecimal totalValue, String limitKey, Map<String, String> configMap) {
|
|
|
- BigDecimal limitValue = new BigDecimal(configMap.getOrDefault(limitKey, "0"));
|
|
|
- return totalValue == null || totalValue.compareTo(limitValue) <= 0;
|
|
|
- }
|
|
|
|
|
|
}
|