private synchronized Double getRandomMoney(int remainSize, Double remainMoney) {
// remainSize 剩余的红包数量
// remainMoney 剩余的钱
Double money = 0.0;
if (remainSize == 1) {
remainSize--;
money = (double) Math.round(remainMoney * 100) / 100;
System.out.println("=====> " + money);
return money;
}
Random r = new Random();
double min = 0.01; //
double max = remainMoney / remainSize * 2;
money = r.nextDouble() * max;
money = money <= min ? 0.01 : money;
money = Math.floor(money * 100) / 100;
System.out.println("=====> " + money);
remainSize--;
remainMoney -= money;
DecimalFormat df = new DecimalFormat("#.00");
return Double.valueOf(df.format(money));
}