Authored by chaogeng

马甲点赞逻辑优化

@@ -114,7 +114,7 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ @@ -114,7 +114,7 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{
114 } 114 }
115 //2)已有的点赞信息(正常的点赞,排除掉; 取消 再点赞的,不发站内信) 115 //2)已有的点赞信息(正常的点赞,排除掉; 取消 再点赞的,不发站内信)
116 List<Integer> articleIds = articleList.stream().map(GrassArticle::getId).distinct().collect(Collectors.toList()); 116 List<Integer> articleIds = articleList.stream().map(GrassArticle::getId).distinct().collect(Collectors.toList());
117 - List<GrassArticlePraise> praiseList = grassArticlePraiseDao.selectByArticles(articleIds); 117 + List<GrassArticlePraise> praiseList = grassArticlePraiseDao.selectByArticles(articleIds, allVirtualUids);
118 118
119 //3)点赞逻辑,要区分逛的作者 和 普通作者 119 //3)点赞逻辑,要区分逛的作者 和 普通作者
120 List<GrassArticle> commonArtcileList = articleList.stream().filter(obj -> obj.getAuthorType() == null || obj.getAuthorType() == GrassUserTypeEnum.COMMON.getValue() ) 120 List<GrassArticle> commonArtcileList = articleList.stream().filter(obj -> obj.getAuthorType() == null || obj.getAuthorType() == GrassUserTypeEnum.COMMON.getValue() )
@@ -165,7 +165,7 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ @@ -165,7 +165,7 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{
165 } 165 }
166 //2)已有的点赞信息(正常的点赞,排除掉; 取消 再点赞的,不发站内信) 166 //2)已有的点赞信息(正常的点赞,排除掉; 取消 再点赞的,不发站内信)
167 List<Integer> articleIds = articleList.stream().map(GrassArticle::getId).distinct().collect(Collectors.toList()); 167 List<Integer> articleIds = articleList.stream().map(GrassArticle::getId).distinct().collect(Collectors.toList());
168 - List<GrassArticlePraise> praiseList = grassArticlePraiseDao.selectByArticles(articleIds); 168 + List<GrassArticlePraise> praiseList = grassArticlePraiseDao.selectByArticles(articleIds, allVirtualUids);
169 169
170 //3)点赞逻辑,要区分逛的作者 和 普通作者 170 //3)点赞逻辑,要区分逛的作者 和 普通作者
171 List<GrassArticle> commonArtcileList = articleList.stream().filter(obj -> obj.getAuthorType() == null || obj.getAuthorType() == GrassUserTypeEnum.COMMON.getValue() ) 171 List<GrassArticle> commonArtcileList = articleList.stream().filter(obj -> obj.getAuthorType() == null || obj.getAuthorType() == GrassUserTypeEnum.COMMON.getValue() )
@@ -351,18 +351,21 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ @@ -351,18 +351,21 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{
351 String commonConfig = ""; 351 String commonConfig = "";
352 String specialConfig = ""; 352 String specialConfig = "";
353 int timeConfig = 0; 353 int timeConfig = 0;
  354 + int pubTotalThre = 0;
354 switch (praiseType){ 355 switch (praiseType){
355 case publishPraise: 356 case publishPraise:
356 //发布文章点赞策略 357 //发布文章点赞策略
357 commonConfig = configReader.getString("platform.grass.virtualpraise.pubThreshold",""); 358 commonConfig = configReader.getString("platform.grass.virtualpraise.pubThreshold","");
358 specialConfig = configReader.getString("platform.grass.virtualpraise.pubSpecialthreshold",""); 359 specialConfig = configReader.getString("platform.grass.virtualpraise.pubSpecialthreshold","");
359 timeConfig = configReader.getInt("platform.grass.virtual.time.pubInterval", 0); 360 timeConfig = configReader.getInt("platform.grass.virtual.time.pubInterval", 0);
  361 + pubTotalThre = configReader.getInt("platform.grass.virtual.time.pubTotalThre", 100);
360 break; 362 break;
361 case recPraise: 363 case recPraise:
362 //推荐文章点赞策略 364 //推荐文章点赞策略
363 commonConfig = configReader.getString("platform.grass.virtualpraise.recThreshold",""); 365 commonConfig = configReader.getString("platform.grass.virtualpraise.recThreshold","");
364 specialConfig = configReader.getString("platform.grass.virtualpraise.recSpecialThreshold",""); 366 specialConfig = configReader.getString("platform.grass.virtualpraise.recSpecialThreshold","");
365 timeConfig = configReader.getInt("platform.grass.virtual.time.recInterval", 0); 367 timeConfig = configReader.getInt("platform.grass.virtual.time.recInterval", 0);
  368 + pubTotalThre = configReader.getInt("platform.grass.virtual.time.recTotalThre", 150);
366 break; 369 break;
367 default: 370 default:
368 return; 371 return;
@@ -395,8 +398,12 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ @@ -395,8 +398,12 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{
395 for(GrassArticle article : articleList){ 398 for(GrassArticle article : articleList){
396 Integer articleId = article.getId(); 399 Integer articleId = article.getId();
397 int authorUid = article.getAuthorUid(); 400 int authorUid = article.getAuthorUid();
398 - //选择虚拟马甲 401 + //马甲点赞数超过阀值时,不再点赞
399 List<Integer> oldPraiseList = articlePraiseMap.get(articleId); 402 List<Integer> oldPraiseList = articlePraiseMap.get(articleId);
  403 + if(CollectionUtils.isNotEmpty(oldPraiseList) && oldPraiseList.size() > pubTotalThre){
  404 + continue;
  405 + }
  406 + //选择虚拟马甲
400 List<Integer> tempList = new ArrayList<>(); 407 List<Integer> tempList = new ArrayList<>();
401 tempList.addAll(allVirtualUids); 408 tempList.addAll(allVirtualUids);
402 if(CollectionUtils.isNotEmpty(oldPraiseList)){ 409 if(CollectionUtils.isNotEmpty(oldPraiseList)){
@@ -30,12 +30,16 @@ platform.grass.virtualpraise.pubThreshold = 10,3 @@ -30,12 +30,16 @@ platform.grass.virtualpraise.pubThreshold = 10,3
30 30
31 platform.grass.virtualpraise.pubSpecialthreshold = 20,5 31 platform.grass.virtualpraise.pubSpecialthreshold = 20,5
32 32
  33 +platform.grass.virtual.time.pubTotalThre = 100
  34 +
33 platform.grass.virtual.time.recInterval = 0 35 platform.grass.virtual.time.recInterval = 0
34 36
35 platform.grass.virtualpraise.recThreshold = 10,5 37 platform.grass.virtualpraise.recThreshold = 10,5
36 38
37 platform.grass.virtualpraise.recSpecialThreshold = 20,10 39 platform.grass.virtualpraise.recSpecialThreshold = 20,10
38 40
  41 +platform.grass.virtual.time.recTotalThre = 150
  42 +
39 43
40 44
41 45