Browse Source

834随机实验

yaodaoseng 1 tháng trước cách đây
mục cha
commit
0c4800b703

+ 14 - 0
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBy834.java

@@ -376,6 +376,20 @@ public class RankStrategyBy834 extends RankStrategyBasic {
 
         if (CollectionUtils.isNotEmpty(result)) {
             AdRankItem top1Item = result.get(0);
+
+            // 判断第一名是否是保量广告
+            boolean top1IsGuaranteed = top1Item.getExt().get("isGuaranteed") != null
+                    && (boolean) top1Item.getExt().get("isGuaranteed");
+
+            // 如果第一名不是保量广告,则随机取一条,并取消保量标记
+            if (!top1IsGuaranteed && result.size() > 1) {
+                int randomIndex = random.nextInt(result.size());
+                top1Item = result.get(randomIndex);
+                // 随机取出的广告取消保量标记
+                top1Item.getExt().put("isGuaranteed", false);
+                top1Item.getExt().put("guaranteeWeight", 1.0);
+            }
+
             List<String> participateCompetitionType = new ArrayList<>();
             participateCompetitionType.add("engine");
             top1Item.getExt().put("isGuaranteeType", isGuaranteeType);