jch před 1 dnem
rodič
revize
932b74482a

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

@@ -42,6 +42,9 @@ public abstract class RankStrategyBasic implements RankStrategy {
     @ApolloJsonValue("${creative.model.score.coefficient:{}}")
     private Map<Long, Double> creativeScoreCoefficient;
 
+    @ApolloJsonValue("${h5.score.suppress:{}}")
+    private Map<String, Double> h5ScoreSuppress;
+
     @Value("${guarantee.exp:742}")
     protected String guaranteeExp;
 
@@ -1044,6 +1047,22 @@ public abstract class RankStrategyBasic implements RankStrategy {
         }
     }
 
+    // h5 权重
+    protected double getH5SuppressWeight(AdRankItem item) {
+        try {
+            if (null != h5ScoreSuppress && null != item) {
+                int landingPageType = item.getLandingPageType();
+                String profession = item.getProfession();
+                if (2 == landingPageType && h5ScoreSuppress.containsKey(profession)) {
+                    return h5ScoreSuppress.get(profession);
+                }
+            }
+        } catch (Exception e) {
+            log.error("获取h5权重失败", e);
+        }
+        return 1.0;
+    }
+
     // 安全的数值转换
     private double safeDouble(Double value, Double min) {
         return (value == null || value == 0) ? min : value;

+ 5 - 1
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBy688.java

@@ -350,18 +350,22 @@ public class RankStrategyBy688 extends RankStrategyBasic {
                 isGuaranteeType = true;
             }
 
+            // h5 降权
+            double h5Weight = this.getH5SuppressWeight(item);
+
             String layerAndCreativeWeightMapKey = getLayerAndCreativeWeightMapKey(peopleLayer, String.valueOf(item.getAdId()));
             // 人群分层&创意的权重
             double layerAndCreativeWeight = getLayerAndCreativeWeight(layerAndCreativeWeightMapKey);
             double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
             double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
-            double score = item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
+            double score = h5Weight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
             item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
             item.getScoreMap().put("cpa", item.getCpa());
             item.getScoreMap().put("cpm", item.getCpm());
             item.getScoreMap().put("bid", bid);
             item.getScoreMap().put("cpmCoefficient", cpmCoefficient);
             item.getScoreMap().put("scoreCoefficient", scoreCoefficient);
+            item.getScoreMap().put("h5", h5Weight);
             item.getFeatureMap().putAll(userFeatureMap);
             item.getFeatureMap().putAll(sceneFeatureMap);
 

+ 6 - 1
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBy833.java

@@ -182,6 +182,7 @@ public class RankStrategyBy833 extends RankStrategyBasic {
                     adRankItem.setSkuId(dto.getSkuId());
                     adRankItem.setCustomerId(dto.getCustomerId());
                     adRankItem.setProfession(dto.getProfession());
+                    adRankItem.setLandingPageType(dto.getLandingPageType());
                     adRankItem.setRandom(random.nextInt(1000));
                     if (noApiAdVerIds.contains(dto.getAdVerId())) {
                         adRankItem.getExt().put("isApi", "0");
@@ -365,6 +366,9 @@ public class RankStrategyBy833 extends RankStrategyBasic {
                 isGuaranteeType = true;
             }
 
+            // h5 降权
+            double h5Weight = this.getH5SuppressWeight(item);
+
             // 控制曝光权重
             Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(String.valueOf(item.getAdId()), EMPTY_NESTED_MAP);
             Map<String, String> b3Feature = cidFeature.getOrDefault("alg_cid_feature_cid_action", EMPTY_STRING_MAP);
@@ -378,13 +382,14 @@ public class RankStrategyBy833 extends RankStrategyBasic {
             double layerAndCreativeWeight = getLayerAndCreativeWeight(layerAndCreativeWeightMapKey);
             double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
             double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
-            double score = expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
+            double score = h5Weight * expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
             item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
             item.getScoreMap().put("cpa", item.getCpa());
             item.getScoreMap().put("cpm", item.getCpm());
             item.getScoreMap().put("bid", bid);
             item.getScoreMap().put("cpmCoefficient", cpmCoefficient);
             item.getScoreMap().put("scoreCoefficient", scoreCoefficient);
+            item.getScoreMap().put("h5", h5Weight);
             item.getFeatureMap().putAll(userFeatureMap);
             item.getFeatureMap().putAll(sceneFeatureMap);
 

+ 6 - 1
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBy840.java

@@ -182,6 +182,7 @@ public class RankStrategyBy840 extends RankStrategyBasic {
                     adRankItem.setSkuId(dto.getSkuId());
                     adRankItem.setCustomerId(dto.getCustomerId());
                     adRankItem.setProfession(dto.getProfession());
+                    adRankItem.setLandingPageType(dto.getLandingPageType());
                     adRankItem.setRandom(random.nextInt(1000));
                     if (noApiAdVerIds.contains(dto.getAdVerId())) {
                         adRankItem.getExt().put("isApi", "0");
@@ -365,6 +366,9 @@ public class RankStrategyBy840 extends RankStrategyBasic {
                 isGuaranteeType = true;
             }
 
+            // h5 降权
+            double h5Weight = this.getH5SuppressWeight(item);
+
             // 控制曝光权重
             Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(String.valueOf(item.getAdId()), EMPTY_NESTED_MAP);
             Map<String, String> b3Feature = cidFeature.getOrDefault("alg_cid_feature_cid_action", EMPTY_STRING_MAP);
@@ -378,13 +382,14 @@ public class RankStrategyBy840 extends RankStrategyBasic {
             double layerAndCreativeWeight = getLayerAndCreativeWeight(layerAndCreativeWeightMapKey);
             double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
             double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
-            double score = expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
+            double score = h5Weight * expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
             item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
             item.getScoreMap().put("cpa", item.getCpa());
             item.getScoreMap().put("cpm", item.getCpm());
             item.getScoreMap().put("bid", bid);
             item.getScoreMap().put("cpmCoefficient", cpmCoefficient);
             item.getScoreMap().put("scoreCoefficient", scoreCoefficient);
+            item.getScoreMap().put("h5", h5Weight);
             item.getFeatureMap().putAll(userFeatureMap);
             item.getFeatureMap().putAll(sceneFeatureMap);