|
@@ -1,13 +1,11 @@
|
|
|
package com.game.business.controller;
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.game.business.domain.*;
|
|
|
import com.game.business.task.AppAgentGameBettingTask;
|
|
|
-import com.game.business.vo.AppGameBettingCountVO;
|
|
|
-import com.game.business.vo.AppGameBettingDetailsCountVO;
|
|
|
+import com.game.business.vo.*;
|
|
|
import com.game.business.service.*;
|
|
|
-import com.game.business.vo.AppGameBettingVO;
|
|
|
-import com.game.business.vo.AppUserGameBettingCountVO;
|
|
|
import com.game.common.annotation.Anonymous;
|
|
|
import com.game.common.constant.finance.FinTranType1;
|
|
|
import com.game.common.constant.finance.FinTranType2;
|
|
@@ -80,6 +78,10 @@ public class AppGameBettingController extends BaseController{
|
|
|
return HttpRet.fail("用户ID为空。");
|
|
|
}
|
|
|
|
|
|
+ if(gameBetting.getBettingGameType() == null){
|
|
|
+ return HttpRet.fail("游戏投注类型为空");
|
|
|
+ }
|
|
|
+
|
|
|
AppGameClassify appGameClassify = appGameClassifyService.selectAppGameClassifyById(gameBetting.getClassId());
|
|
|
if(appGameClassify == null){
|
|
|
return HttpRet.fail("游戏平台不存在。");
|
|
@@ -102,12 +104,32 @@ public class AppGameBettingController extends BaseController{
|
|
|
return HttpRet.fail("游戏已封盘,无法下单。");
|
|
|
}
|
|
|
|
|
|
- AppGameItem appGameItem = appGameItemService.selectAppGameItemByGameIdAndItemLocation(appGame.getId(), gameBetting.getBettingItem());
|
|
|
- if(appGameItem == null){
|
|
|
- return HttpRet.fail("游戏选项不存在,无法下单。");
|
|
|
+
|
|
|
+ if(gameBetting.getBettingGameType() == 0){
|
|
|
+ AppGameItem appGameItem = appGameItemService.selectAppGameItemByGameIdAndItemLocation(appGame.getId(), gameBetting.getBettingItem());
|
|
|
+ if(appGameItem == null){
|
|
|
+ return HttpRet.fail("游戏选项不存在,无法下单。");
|
|
|
+ }
|
|
|
+
|
|
|
+ gameBetting.setBettingMultiple(Double.parseDouble(appGameItem.getItemMultiple() + ""));
|
|
|
+
|
|
|
+ }else if(gameBetting.getBettingGameType() == 1 || gameBetting.getBettingGameType() == 2){
|
|
|
+ List<AppGameItemBettingVO> itemList = JSON.parseArray(gameBetting.getBettingItem(), AppGameItemBettingVO.class);
|
|
|
+ if(itemList == null || itemList.isEmpty()){
|
|
|
+ return HttpRet.fail("游戏选项不存在,无法下单。");
|
|
|
+ }
|
|
|
+ for(AppGameItemBettingVO item : itemList){
|
|
|
+ AppGameItem appGameItem = appGameItemService.selectAppGameItemByGameIdAndItemLocation(appGame.getId(), item.getBettingItem());
|
|
|
+ if(appGameItem == null){
|
|
|
+ return HttpRet.fail("游戏选项不存在,无法下单。");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(gameBetting.getBettingGameType() == 1){
|
|
|
+ gameBetting.setBettingMultiple(getMultiple(itemList.size()));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- gameBetting.setBettingMultiple(appGameItem.getItemMultiple());
|
|
|
|
|
|
|
|
|
|
|
@@ -335,11 +357,96 @@ public class AppGameBettingController extends BaseController{
|
|
|
@Anonymous
|
|
|
@PostMapping(value = "/listHistory")
|
|
|
@ApiOperation(value = "游戏投注记录", notes = "游戏投注记录")
|
|
|
- public HttpRetPageArr<AppUserGameBettingCountVO> listHistory(@RequestParam(name = "gameId") Long gameId , @RequestParam(name = "bettingType", required = false) Integer bettingType)
|
|
|
+ public HttpRetPageArr<AppUserGameBettingCountVO> listHistory(@RequestParam(name = "gameId") Long gameId , @RequestParam(name = "bettingType", required = false) Integer bettingType
|
|
|
+ , @RequestParam(name = "bettingGameType", required = false) Integer bettingGameType)
|
|
|
{
|
|
|
startPage();
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
List<AppUserGameBettingCountVO> list = appGameBettingService.getUserCount(gameId, userId, bettingType);
|
|
|
+
|
|
|
+ if(bettingGameType == null){
|
|
|
+ bettingGameType = 0;
|
|
|
+ }
|
|
|
+ if(bettingType == null){
|
|
|
+ bettingType = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(list != null && !list.isEmpty()){
|
|
|
+
|
|
|
+ if(bettingGameType == 0){
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ AppUserGameBettingCountVO appUserGameBettingCountVO = list.get(i);
|
|
|
+ List<AppUserGameBettingDetailsCountVO> detailsCountVOList = appGameBettingService.getUserBettingItemCount(gameId, appUserGameBettingCountVO.getGameDate(), userId, bettingType);
|
|
|
+ if(detailsCountVOList == null){
|
|
|
+ detailsCountVOList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ appUserGameBettingCountVO.setDetailsCountVOList(detailsCountVOList);
|
|
|
+ }
|
|
|
+ }else if(bettingGameType == 1){
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+
|
|
|
+ AppUserGameBettingCountVO appUserGameBettingCountVO = list.get(i);
|
|
|
+ List<AppGameBetting> bettingList = appGameBettingService.getUserBettingItem(gameId, appUserGameBettingCountVO.getGameDate(), userId, bettingType);
|
|
|
+ if(bettingList == null){
|
|
|
+ bettingList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ Map<String, AppUserGameBettingDetailsCountVO> itemMap = new HashMap<>();
|
|
|
+ for (int j = 0; j < bettingList.size(); j++) {
|
|
|
+ AppGameBetting appGameBetting = bettingList.get(j);
|
|
|
+ List<AppGameItemBettingVO> itemList = JSON.parseArray(appGameBetting.getBettingItem(), AppGameItemBettingVO.class);
|
|
|
+
|
|
|
+ for(AppGameItemBettingVO item : itemList){
|
|
|
+ if(itemMap.containsKey(item.getBettingItem())){
|
|
|
+ AppUserGameBettingDetailsCountVO appUserGameBettingDetailsCountVO = itemMap.get(item.getBettingItem());
|
|
|
+ appUserGameBettingDetailsCountVO.setOrderAmount(appUserGameBettingDetailsCountVO.getOrderAmount() + item.getBettingAmount());
|
|
|
+ if(appGameBetting.getIsWinning() == 1){
|
|
|
+ appUserGameBettingDetailsCountVO.setWinAmount(appUserGameBettingDetailsCountVO.getWinAmount() + (item.getBettingAmount() * getMultiple(itemList.size())));
|
|
|
+ }else if(appGameBetting.getIsWinning() == 2){
|
|
|
+ appUserGameBettingDetailsCountVO.setLoseAmount(appUserGameBettingDetailsCountVO.getLoseAmount() + item.getBettingAmount());
|
|
|
+ }
|
|
|
+ itemMap.put(item.getBettingItem(), appUserGameBettingDetailsCountVO);
|
|
|
+ }else{
|
|
|
+ AppUserGameBettingDetailsCountVO appUserGameBettingDetailsCountVO = new AppUserGameBettingDetailsCountVO();
|
|
|
+ appUserGameBettingDetailsCountVO.setBettingTtem(item.getBettingItem());
|
|
|
+ appUserGameBettingDetailsCountVO.setOrderAmount(appUserGameBettingDetailsCountVO.getOrderAmount() + item.getBettingAmount());
|
|
|
+ if(appGameBetting.getIsWinning() == 1){
|
|
|
+ appUserGameBettingDetailsCountVO.setWinAmount(appUserGameBettingDetailsCountVO.getWinAmount() + item.getBettingAmount() * getMultiple(itemList.size()));
|
|
|
+ }else if(appGameBetting.getIsWinning() == 2){
|
|
|
+ appUserGameBettingDetailsCountVO.setLoseAmount(appUserGameBettingDetailsCountVO.getLoseAmount() + item.getBettingAmount());
|
|
|
+ }
|
|
|
+ itemMap.put(item.getBettingItem(), appUserGameBettingDetailsCountVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<AppUserGameBettingDetailsCountVO> detailsCountVOList = new ArrayList<>();
|
|
|
+ Set<String> set = itemMap.keySet();
|
|
|
+ Iterator<String> iterator = set.iterator();
|
|
|
+ while (iterator.hasNext()){
|
|
|
+ AppUserGameBettingDetailsCountVO appUserGameBettingDetailsCountVO = itemMap.get(iterator.next());
|
|
|
+ detailsCountVOList.add(appUserGameBettingDetailsCountVO);
|
|
|
+ }
|
|
|
+ appUserGameBettingCountVO.setDetailsCountVOList(detailsCountVOList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return HttpRetPageArr.success("查询成功",getDataTable(list));
|
|
|
}
|
|
|
+
|
|
|
+ private double getMultiple(int size){
|
|
|
+ double itemMultiple;
|
|
|
+ switch (size){
|
|
|
+ case 1:
|
|
|
+ itemMultiple = 8.5;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ itemMultiple = 4.0;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ itemMultiple = 2.0;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ itemMultiple = 1.0;
|
|
|
+ }
|
|
|
+ return itemMultiple;
|
|
|
+ }
|
|
|
}
|