浏览代码

添加中奖概率

kk 3 月之前
父节点
当前提交
8b52e29863
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      game-business/src/main/java/com/game/business/controller/AppGameItemController.java

+ 6 - 2
game-business/src/main/java/com/game/business/controller/AppGameItemController.java

@@ -79,8 +79,12 @@ public class AppGameItemController extends BaseController
                 AppGameItem gameItem = list.get(i);
                 AppGameItemVO appGameItemVO = new AppGameItemVO();
                 BeanUtils.copyProperties(gameItem, appGameItemVO);
-                BigDecimal lotteryCount = new BigDecimal(gameItem.getLotteryCount());
-                appGameItemVO.setLotteryRate(lotteryCount.divide(lotteryCountSum).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
+                if(gameItem.getLotteryCount() == null || gameItem.getLotteryCount() == 0){
+                    appGameItemVO.setLotteryRate(0.00);
+                }else{
+                    BigDecimal lotteryCount = new BigDecimal(gameItem.getLotteryCount());
+                    appGameItemVO.setLotteryRate(lotteryCount.divide(lotteryCountSum).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
+                }
             }
         }