Authored by chaogeng

Merge branch 'test6.9.11' of http://git.yoho.cn/platform/platform-cms into test6.9.11

@@ -391,9 +391,10 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ @@ -391,9 +391,10 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{
391 int startSpecial = Integer.valueOf(specialStrategy[0]);//起始点(0,startSpecial) 391 int startSpecial = Integer.valueOf(specialStrategy[0]);//起始点(0,startSpecial)
392 int endSpecial = Integer.valueOf(specialStrategy[1]);//终结(timeConfig,endSpecial) 392 int endSpecial = Integer.valueOf(specialStrategy[1]);//终结(timeConfig,endSpecial)
393 //两个坐标点 --线性函数 y=kx + b 393 //两个坐标点 --线性函数 y=kx + b
394 - double k = ((end - start)*1d) / (timeConfig * 1d); 394 +// double k = ((end - start)*1d) / (timeConfig * 1d);
  395 + double k = timeConfig;
395 double b = start; 396 double b = start;
396 - double kSpecial = ((endSpecial - startSpecial)*1d) / (timeConfig * 1d); 397 + double kSpecial = timeConfig;
397 double bSpecial = startSpecial; 398 double bSpecial = startSpecial;
398 399
399 //3)基础数据--原有的点赞(正常的点赞--排除; 取消的点赞--不要发站内信) 400 //3)基础数据--原有的点赞(正常的点赞--排除; 取消的点赞--不要发站内信)
@@ -435,9 +436,9 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ @@ -435,9 +436,9 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{
435 } 436 }
436 Set<Integer> randomUidList; 437 Set<Integer> randomUidList;
437 if(authorType == GrassUserTypeEnum.COMMON.getValue() && specialAuthors.contains(authorUid)){//有货的用户,并且是重点用户,采用的线性函数有所不同 438 if(authorType == GrassUserTypeEnum.COMMON.getValue() && specialAuthors.contains(authorUid)){//有货的用户,并且是重点用户,采用的线性函数有所不同
438 - randomUidList = getPraiseUids(tempList, kSpecial, bSpecial, time); 439 + randomUidList = getPraiseUids(tempList, kSpecial, bSpecial, time, end);
439 }else{ 440 }else{
440 - randomUidList = getPraiseUids(tempList, k, b, time); 441 + randomUidList = getPraiseUids(tempList, k, b, time, end);
441 } 442 }
442 if(CollectionUtils.isEmpty(randomUidList)){ 443 if(CollectionUtils.isEmpty(randomUidList)){
443 article.setPraiseCount(0);//新增加的点赞数是0 444 article.setPraiseCount(0);//新增加的点赞数是0
@@ -489,20 +490,27 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ @@ -489,20 +490,27 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{
489 490
490 //随着时间的推移,增加的点赞数 逐步减少--》y= kx + b 491 //随着时间的推移,增加的点赞数 逐步减少--》y= kx + b
491 //x 是距离当前的时间(分钟为单位,比小时更精确) 492 //x 是距离当前的时间(分钟为单位,比小时更精确)
492 - private Set<Integer> getPraiseUids(List<Integer> virtualList,double k,double b, double x ) { 493 + private Set<Integer> getPraiseUids(List<Integer> virtualList,double timeConfig,double start, double x , int end ) {
493 if(virtualList.isEmpty()){//没有可选的马甲粉丝 494 if(virtualList.isEmpty()){//没有可选的马甲粉丝
494 return new HashSet<>(); 495 return new HashSet<>();
495 } 496 }
496 //数量--随着时间的推移,线性的 497 //数量--随着时间的推移,线性的
497 - double numDouble = k * x + b + new Random().nextInt(5);  
498 - int num = new Double(numDouble).intValue();//需要增加的点 498 +// double numDouble = k * x + b + new Random().nextInt(5);
  499 + //使用对数函数模型
  500 + double y = x==0? 1/timeConfig : x/timeConfig;
  501 + //需要随机可以加随机数
  502 + double numDouble= start + new Random().nextInt(5);
  503 + double m = log(y,1/timeConfig) * numDouble ;
  504 + double num = Math.ceil(m) > end ? Math.ceil(m) : end;
  505 +
  506 + int addnum = new Double(num).intValue();//需要增加的点
499 int totalVitual = virtualList.size(); 507 int totalVitual = virtualList.size();
500 Set<Integer> set = new HashSet<>(); 508 Set<Integer> set = new HashSet<>();
501 - if(totalVitual <= num){ 509 + if(totalVitual <= addnum){
502 set = virtualList.stream().collect(Collectors.toSet()); 510 set = virtualList.stream().collect(Collectors.toSet());
503 return set; 511 return set;
504 } 512 }
505 - for(int i = 0 ; i < num; i++){ 513 + for(int i = 0 ; i < addnum; i++){
506 int index = getRandom(0, virtualList.size() - 1); 514 int index = getRandom(0, virtualList.size() - 1);
507 Integer uid = virtualList.get(index);//随机得到的粉丝uid 515 Integer uid = virtualList.get(index);//随机得到的粉丝uid
508 virtualList.remove(uid); 516 virtualList.remove(uid);
@@ -511,6 +519,10 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ @@ -511,6 +519,10 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{
511 return set; 519 return set;
512 } 520 }
513 521
  522 + private double log(double value, double base) {
  523 + return Math.log(value) / Math.log(base);
  524 + }
  525 +
514 private void sendAddPariseMessage(List<GrassArticlePraise> pariseDetail) { 526 private void sendAddPariseMessage(List<GrassArticlePraise> pariseDetail) {
515 if(CollectionUtils.isEmpty(pariseDetail)){ 527 if(CollectionUtils.isEmpty(pariseDetail)){
516 return; 528 return;