| @@ -20,7 +20,7 @@ public class PressUtils { | |||||
| /** | /** | ||||
| * randomPressValue | * randomPressValue | ||||
| * @param total 砍价总钱数(分) | * @param total 砍价总钱数(分) | ||||
| * @param left_total 已砍价总钱数(分) | |||||
| * @param left_total 剩余砍价总钱数(分) | |||||
| * @param limit_num 砍价限制次数 | * @param limit_num 砍价限制次数 | ||||
| * @param limit_index 砍价index | * @param limit_index 砍价index | ||||
| * @return | * @return | ||||
| @@ -29,14 +29,14 @@ public class PressUtils { | |||||
| BigDecimal tt = BigDecimal.valueOf(total * 1.0D / 100).setScale(scale, RoundingMode.HALF_UP); | BigDecimal tt = BigDecimal.valueOf(total * 1.0D / 100).setScale(scale, RoundingMode.HALF_UP); | ||||
| BigDecimal lt = BigDecimal.valueOf(left_total* 1.0D / 100); | BigDecimal lt = BigDecimal.valueOf(left_total* 1.0D / 100); | ||||
| StatelessReduceRule rule = new DefaultStatelessReduceRule(); | StatelessReduceRule rule = new DefaultStatelessReduceRule(); | ||||
| BigDecimal current = rule.getReduce(tt, tt.subtract(lt), limit_num,limit_num - limit_index, scale); | |||||
| BigDecimal current = rule.getReduce(tt, lt, limit_num,limit_num - limit_index, scale); | |||||
| return current.intValue() * 100; | return current.intValue() * 100; | ||||
| } | } | ||||
| /** | /** | ||||
| * stateLessPressValue 优先 1/3砍掉一半 | * stateLessPressValue 优先 1/3砍掉一半 | ||||
| * @param total 砍价总钱数(分) | * @param total 砍价总钱数(分) | ||||
| * @param left_total 已砍价总钱数(分) | |||||
| * @param left_total 剩余砍价总钱数(分) | |||||
| * @param limit_num 砍价限制次数 | * @param limit_num 砍价限制次数 | ||||
| * @param limit_index 砍价index | * @param limit_index 砍价index | ||||
| * @return | * @return | ||||
| @@ -45,12 +45,14 @@ public class PressUtils { | |||||
| BigDecimal tt = BigDecimal.valueOf(total * 1.0D / 100).setScale(scale, RoundingMode.HALF_UP); | BigDecimal tt = BigDecimal.valueOf(total * 1.0D / 100).setScale(scale, RoundingMode.HALF_UP); | ||||
| BigDecimal lt = BigDecimal.valueOf(left_total* 1.0D / 100); | BigDecimal lt = BigDecimal.valueOf(left_total* 1.0D / 100); | ||||
| StatelessReduceRule rule = new StatelessPingReduceRule(); | StatelessReduceRule rule = new StatelessPingReduceRule(); | ||||
| BigDecimal current = rule.getReduce(tt, tt.subtract(lt), limit_num, limit_num - limit_index, scale); | |||||
| BigDecimal current = rule.getReduce(tt, lt, limit_num, limit_num - limit_index, scale); | |||||
| return current.intValue() * 100; | return current.intValue() * 100; | ||||
| } | } | ||||
| public static void main(String[] args) { | public static void main(String[] args) { | ||||
| int iValue = stateLessPressValue( 1800, 1800, 5, 0); | |||||
| int IValue = randomPressValue(2000, 300, 5, 4); | |||||
| System.out.println(IValue); | |||||
| int iValue = stateLessPressValue( 2000, 400, 5, 4); | |||||
| System.out.println(iValue); | System.out.println(iValue); | ||||
| } | } | ||||