|
@@ -13,6 +13,7 @@ import com.tzld.piaoquan.ad.engine.service.feature.Feature;
|
|
|
import com.tzld.piaoquan.ad.engine.service.feature.FeatureService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.collections4.MapUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -38,7 +39,7 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
@Autowired
|
|
|
protected AdRedisHelper adRedisHelper;
|
|
|
|
|
|
- String key = "ad:platform:guarantee:data:{date}:{adrId}";
|
|
|
+ String adPlatformGuaranteeKey = "ad:platform:guarantee:data:{date}:{adverId}";
|
|
|
|
|
|
|
|
|
protected Feature getFeature(ScoreParam param, RankRecommendRequestParam request) {
|
|
@@ -115,10 +116,10 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
try {
|
|
|
if (scoreParam.getExpCodeSet().contains(guaranteeExp)) {
|
|
|
String thatDayDateString = DateUtils.getThatDayDateString();
|
|
|
- String redisKey = key.replace("{date}", thatDayDateString);
|
|
|
+ String redisKey = adPlatformGuaranteeKey.replace("{date}", thatDayDateString);
|
|
|
List<String> adVerIds = request.getAdIdList().stream().map(AdPlatformCreativeDTO::getAdVerId).distinct()
|
|
|
.filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
- List<String> redisKeys = adVerIds.stream().map(e -> redisKey.replace("{adrId}", e)).collect(Collectors.toList());
|
|
|
+ List<String> redisKeys = adVerIds.stream().map(e -> redisKey.replace("{adverId}", e)).collect(Collectors.toList());
|
|
|
List<String> values = adRedisHelper.mget(redisKeys);
|
|
|
if (CollectionUtils.isNotEmpty(values)) {
|
|
|
for (int i = 0; i < redisKeys.size(); i++) {
|
|
@@ -137,7 +138,18 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- protected double getGuaranteeWeight(GuaranteeView guaranteeView) {
|
|
|
+ protected void setGuaranteeWeight(Map<String, GuaranteeView> map, String adVerId, Map<String, Object> ext) {
|
|
|
+ if (MapUtils.isNotEmpty(map)) {
|
|
|
+ GuaranteeView guaranteeView = map.get(adVerId);
|
|
|
+ if (guaranteeView != null) {
|
|
|
+ double guaranteeWeight = calculateGuaranteedWeight(guaranteeView);
|
|
|
+ ext.put("guaranteeView", guaranteeView.toString());
|
|
|
+ ext.put("guaranteeWeight", guaranteeWeight);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected double calculateGuaranteedWeight(GuaranteeView guaranteeView) {
|
|
|
if (guaranteeView == null) {
|
|
|
return 1.0;
|
|
|
}
|
|
@@ -166,4 +178,16 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
}
|
|
|
return guaranteeWeight;
|
|
|
}
|
|
|
+
|
|
|
+ protected double getGuaranteeScoreCoefficient(ScoreParam scoreParam, Map<String, Object> ext) {
|
|
|
+ if (scoreParam.getExpCodeSet().contains(guaranteeExp)) {
|
|
|
+ if (ext.get("guaranteeWeight") == null) {
|
|
|
+ return 1.0;
|
|
|
+ } else {
|
|
|
+ return Math.pow((double) ext.get("guaranteeWeight"), alpha);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return 1.0;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|