抽奖金额问题
This commit is contained in:
@@ -137,11 +137,13 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||||||
double resultAmount = 0;
|
double resultAmount = 0;
|
||||||
if (prize.getType() == 2) {
|
if (prize.getType() == 2) {
|
||||||
double baseRandom = getRandomDouble();
|
double baseRandom = getRandomDouble();
|
||||||
|
double baseAmount = 0;
|
||||||
for (DiscSpinningAmount amount : amounts) {
|
for (DiscSpinningAmount amount : amounts) {
|
||||||
if (baseRandom < amount.getRandom()) {
|
if (baseRandom < amount.getRandom()) {
|
||||||
resultAmount = getRandomDouble() * amount.getMaxAmount();
|
resultAmount = baseAmount + getRandomDouble() * amount.getMaxAmount();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
baseAmount = amount.getMaxAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultAmount < 0.01) {
|
if (resultAmount < 0.01) {
|
||||||
@@ -208,7 +210,7 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
for (int i = 0; i < 500; i++) {
|
for (int i = 0; i < 500; i++) {
|
||||||
random.setSeed(UUID.randomUUID().hashCode());
|
random.setSeed(UUID.randomUUID().hashCode());
|
||||||
System.out.println(random.nextInt(100)*random.nextInt(100));
|
System.out.println(random.nextInt(100) * random.nextInt(100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user