Procházet zdrojové kódy

fix: 优化H5权重计算逻辑

jiandong.liu před 1 dnem
rodič
revize
2fdbc6265d

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

@@ -1049,13 +1049,17 @@ public abstract class RankStrategyBasic implements RankStrategy {
 
     // h5 权重
     protected double getH5SuppressWeight(AdRankItem item) {
+        if (org.springframework.util.CollectionUtils.isEmpty(h5ScoreSuppress) || Objects.isNull(item)) {
+            return 1.0;
+        }
         try {
-            if (null != h5ScoreSuppress && null != item) {
-                Integer landingPageType = item.getLandingPageType();
-                String profession = item.getProfession();
-                if (null != landingPageType && landingPageType.equals(2) && h5ScoreSuppress.containsKey(profession)) {
-                    return h5ScoreSuppress.get(profession);
-                }
+            Integer landingPageType = item.getLandingPageType();
+            String profession = item.getProfession();
+            if (StringUtils.isBlank(profession) || Objects.isNull(landingPageType)) {
+                return 1.0;
+            }
+            if (Objects.equals(2, landingPageType) && h5ScoreSuppress.containsKey(profession)) {
+                return h5ScoreSuppress.get(profession);
             }
         } catch (Exception e) {
             log.error("获取h5权重失败", e);