|
@@ -142,7 +142,8 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
Map<String, String> sceneFeatureMap = this.handleSceneFeature(ts);
|
|
|
long time1 = System.currentTimeMillis();
|
|
|
|
|
|
- Map<String, GuaranteeView> map = getGuaranteeViewMap(request, scoreParam);
|
|
|
+ boolean isGuaranteedFlow = getIsGuaranteedFlow(scoreParam);
|
|
|
+ Map<String, GuaranteeView> map = getGuaranteeViewMap(request, isGuaranteedFlow);
|
|
|
Map<Long, CorrectCpaParam> correctCpaMap = getCorrectCpaParamMap(request, scoreParam);
|
|
|
List<AdRankItem> adRankItems = new ArrayList<>();
|
|
|
Random random = new Random();
|
|
@@ -171,7 +172,7 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
adRankItem.getExt().put("recallsources", dto.getRecallSources());
|
|
|
adRankItem.getExt().put("correctCpaMap", JSONObject.toJSONString(correctCpaMap.get(dto.getCreativeId())));
|
|
|
adRankItem.getExt().put("correctionFactor", correctCpaMap.get(dto.getCreativeId()).getCorrectionFactor());
|
|
|
- setGuaranteeWeight(map, dto.getAdVerId(), adRankItem.getExt());
|
|
|
+ setGuaranteeWeight(map, dto.getAdVerId(), adRankItem.getExt(), isGuaranteedFlow);
|
|
|
String cidStr = dto.getCreativeId().toString();
|
|
|
Map<String, String> cidFeatureMap = adRankItem.getFeatureMap();
|
|
|
Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(cidStr, new HashMap<>());
|
|
@@ -296,7 +297,7 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
calculateCtcvrScore(result, request, scoreParam);
|
|
|
// loop
|
|
|
double cpmCoefficient = weightParam.getOrDefault("cpmCoefficient", 0.9);
|
|
|
-
|
|
|
+ boolean isGuaranteeType = false;
|
|
|
for (AdRankItem item : result) {
|
|
|
double bid = item.getCpa();
|
|
|
if (scoreParam.getExpCodeSet().contains(correctCpaExp1) || scoreParam.getExpCodeSet().contains(correctCpaExp2)) {
|
|
@@ -305,21 +306,29 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
bid = bid * correctionFactor;
|
|
|
}
|
|
|
item.getScoreMap().put("ecpm", item.getLrScore() * bid * 1000);
|
|
|
+ if (isGuaranteedFlow && item.getExt().get("isGuaranteed") != null && (boolean) item.getExt().get("isGuaranteed")) {
|
|
|
+ isGuaranteeType = true;
|
|
|
+ }
|
|
|
double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
|
|
|
- double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(scoreParam, item.getExt());
|
|
|
+ double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
|
|
|
double score = item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient;
|
|
|
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.getFeatureMap().putAll(userFeatureMap);
|
|
|
item.getFeatureMap().putAll(sceneFeatureMap);
|
|
|
+
|
|
|
// 没有转化回传的广告主,使用后台配置的CPM
|
|
|
if (noApiAdVerIds.contains(item.getAdVerId())) {
|
|
|
score = item.getCpm() * cpmCoefficient / 1000;
|
|
|
}
|
|
|
+ if (scoreParam.getExpCodeSet().contains(correctCpaExp1) || scoreParam.getExpCodeSet().contains(correctCpaExp2)) {
|
|
|
+ Double correctionFactor = (Double) item.getExt().get("correctionFactor");
|
|
|
+ item.getScoreMap().put("correctionFactor", correctionFactor);
|
|
|
+ score = score * correctionFactor;
|
|
|
+ }
|
|
|
item.setScore(score);
|
|
|
}
|
|
|
|
|
@@ -328,6 +337,7 @@ public class RankStrategyBy688 extends RankStrategyBasic {
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result)) {
|
|
|
AdRankItem top1Item = result.get(0);
|
|
|
+ top1Item.getExt().put("isGuaranteeType", isGuaranteeType);
|
|
|
putMetaFeature(top1Item, feature, reqFeature, sceneFeatureMap, request);
|
|
|
}
|
|
|
long time6 = System.currentTimeMillis();
|