// 概率抽奖:prizeList为奖品列表,,每一个奖品有一个概率值
PrizeDO prize = null;
if(!CollectionUtils.isEmpty(prizeList)){
double value = new Random().nextDouble() * 100 ;
log.info("概率值,value={}",value);
double compareValue = 0d;
for (ActivityPrizeDO prizeDO : prizeList) {
compareValue += prizeDO.getProbability();
if(value <= compareValue){
prize = prizeDO;
break;
}
};
}
return prize;