| | |
| | | |
| | | //当实际的收益小于预期的收益时,按照随机,否则只中奖第一方案 |
| | | int randomInt = 1; |
| | | if(profitTotal.compareTo(profitTotalNow)>0){ |
| | | randomInt = RandomUtil.randomInt(1, 4); |
| | | if(profitTotalNow.compareTo(profitTotal)>0){ |
| | | randomInt = RandomUtil.randomInt(1, 3); |
| | | } |
| | | if(1 == randomInt){ |
| | | String planKey = Integer.toString(randomInt); |
| | |
| | | } |
| | | BigDecimal amount = new BigDecimal(jsonObject.get("amount").toString()); |
| | | BigDecimal profit = amount.multiply(hangingRevenue).setScale(4, BigDecimal.ROUND_DOWN); |
| | | profitTotalNow = profitTotalNow.add(profit).setScale(4, BigDecimal.ROUND_DOWN); |
| | | if(j != randomInt){ |
| | | profitTotalNow = profitTotalNow.add(profit).subtract(amount).setScale(4, BigDecimal.ROUND_DOWN); |
| | | }else{ |
| | | profitTotalNow = profitTotalNow.add(profit).setScale(4, BigDecimal.ROUND_DOWN); |
| | | } |
| | | jsonObject.set("profit",profit); |
| | | linkedList.add(JSONUtil.toJsonStr(jsonObject)); |
| | | maxTimes --; |