|
@@ -65,6 +65,12 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
@Value("${correct.cpa.view:1000}")
|
|
|
protected Integer correctCpaView;
|
|
|
|
|
|
+ @Value("${guarantee.weight:30}")
|
|
|
+ protected Integer guaranteeWeight;
|
|
|
+
|
|
|
+ @Value("${guarantee.switching.time:1753286400000}")
|
|
|
+ protected Long guaranteeSwitchingTime;
|
|
|
+
|
|
|
@Autowired
|
|
|
private FeatureService featureService;
|
|
|
@Autowired
|
|
@@ -216,10 +222,19 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
|
|
|
}
|
|
|
|
|
|
- protected Map<String, GuaranteeView> getGuaranteeViewMap(RankRecommendRequestParam request, ScoreParam scoreParam) {
|
|
|
+ protected boolean getIsGuaranteedFlow(ScoreParam scoreParam) {
|
|
|
+ if (System.currentTimeMillis() < guaranteeSwitchingTime) {
|
|
|
+ return scoreParam.getExpCodeSet().contains(guaranteeExp);
|
|
|
+ }
|
|
|
+ Random random = new Random();
|
|
|
+ int i = random.nextInt(100);
|
|
|
+ return i < guaranteeWeight;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected Map<String, GuaranteeView> getGuaranteeViewMap(RankRecommendRequestParam request, boolean isGuaranteedFlow) {
|
|
|
Map<String, GuaranteeView> map = new HashMap<>();
|
|
|
try {
|
|
|
- if (scoreParam.getExpCodeSet().contains(guaranteeExp)) {
|
|
|
+ if (isGuaranteedFlow) {
|
|
|
String thatDayDateString = DateUtils.getThatDayDateString();
|
|
|
String redisKey = adPlatformGuaranteeKey.replace("{date}", thatDayDateString);
|
|
|
List<String> adVerIds = request.getAdIdList().stream().map(AdPlatformCreativeDTO::getAdVerId).distinct()
|
|
@@ -243,8 +258,8 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- protected void setGuaranteeWeight(Map<String, GuaranteeView> map, String adVerId, Map<String, Object> ext) {
|
|
|
- if (MapUtils.isNotEmpty(map)) {
|
|
|
+ protected void setGuaranteeWeight(Map<String, GuaranteeView> map, String adVerId, Map<String, Object> ext, boolean isGuaranteedFlow) {
|
|
|
+ if (isGuaranteedFlow && MapUtils.isNotEmpty(map)) {
|
|
|
GuaranteeView guaranteeView = map.get(adVerId);
|
|
|
if (guaranteeView != null) {
|
|
|
double guaranteeWeight = calculateGuaranteedWeight(guaranteeView);
|
|
@@ -252,6 +267,7 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
ext.put("guaranteeView", guaranteeView.toString());
|
|
|
ext.put("guaranteeWeight", guaranteeWeight);
|
|
|
ext.put("isGuaranteed", isGuaranteed);
|
|
|
+ ext.put("isGuaranteedFlow", isGuaranteedFlow);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -294,8 +310,8 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
&& guaranteeView.getGuaranteeRate() != null && guaranteeView.getGuaranteeRate() != 0.0;
|
|
|
}
|
|
|
|
|
|
- protected double getGuaranteeScoreCoefficient(ScoreParam scoreParam, Map<String, Object> ext) {
|
|
|
- if (scoreParam.getExpCodeSet().contains(guaranteeExp)) {
|
|
|
+ protected double getGuaranteeScoreCoefficient(boolean isGuaranteedFlow, Map<String, Object> ext) {
|
|
|
+ if (isGuaranteedFlow) {
|
|
|
if (ext.get("guaranteeWeight") == null) {
|
|
|
return 1.0;
|
|
|
} else {
|