public static List<double>RedPacketDoubleMethod(double total,int count,double min=0.01)
{
List<double> list = new List<double>();
if (total <= count * min) { throw new Exception(message: "金额过小或最小金额过大!"); }
double left_money = total,avg=0.0,money=0.0;
Random ran = new Random();
for (var i = count; i>1; i--) {
avg = left_money / i *2;
money = ran.NextDouble()*avg;
money = Math.Round(money, 2);
money = money < min ? min : money;
list.Add(money);
left_money = left_money - money;
}
left_money = Math.Round(left_money, 2);
list.Add(left_money);
var sum = list.Sum();
if (Math.Abs(sum - total) > 0.00001) { throw new Exception(message: "金额分配异常!"); }
return list;
}