Przeglądaj źródła

添加中奖概率

kk 3 miesięcy temu
rodzic
commit
1fe0b07b61

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

@@ -1,10 +1,16 @@
 package com.game.business.controller;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
+import com.game.business.domain.AppGameBetting;
+import com.game.business.vo.AppGameBettingVO;
+import com.game.business.vo.AppGameItemVO;
 import com.game.common.core.domain.HttpRetArr;
 import com.game.common.core.domain.R;
+import org.springframework.beans.BeanUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -59,10 +65,26 @@ public class AppGameItemController extends BaseController
      */
     @GetMapping("/listAll")
     @ApiOperation(value = "查询游戏所有选项", notes = "查询游戏所有选项")
-    public HttpRetArr<AppGameItem> listAll(AppGameItem appGameItem)
+    public HttpRetArr<AppGameItemVO> listAll(AppGameItem appGameItem)
     {
+        List<AppGameItemVO> resultList = new ArrayList<>();
         List<AppGameItem> list = appGameItemService.selectAppGameItemList(appGameItem);
-        return HttpRetArr.success("查询成功", list);
+
+        if(list != null && !list.isEmpty()){
+
+            int lotterySum = list.stream().mapToInt(AppGameItem::getLotteryCount).sum();
+            BigDecimal lotteryCountSum = new BigDecimal(lotterySum);
+
+            for (int i = 0; i < list.size(); i++) {
+                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_DOWN).doubleValue());
+            }
+        }
+
+        return HttpRetArr.success("查询成功", resultList);
     }
 
     /**

+ 14 - 0
game-business/src/main/java/com/game/business/vo/AppGameItemVO.java

@@ -0,0 +1,14 @@
+package com.game.business.vo;
+
+import com.game.business.domain.AppGameItem;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "游戏选项", description = "游戏选项")
+public class AppGameItemVO extends AppGameItem {
+
+    @ApiModelProperty(value = "中奖汇率")
+    private Double lotteryRate;
+}

+ 1 - 1
game-business/src/main/java/com/game/business/vo/AppUserGameBettingCountVO.java

@@ -7,7 +7,7 @@ import lombok.Data;
 import java.util.Date;
 
 @Data
-@ApiModel(value = "游戏选项连中次数", description = "游戏选项连中次数")
+@ApiModel(value = "游戏投注记录", description = "游戏投注记录")
 public class AppUserGameBettingCountVO {
 
     @ApiModelProperty(value = "当前期号")