|
@@ -1,5 +1,6 @@
|
|
package com.game.business.controller;
|
|
package com.game.business.controller;
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.game.business.domain.*;
|
|
import com.game.business.domain.*;
|
|
@@ -13,16 +14,14 @@ import com.game.common.core.domain.HttpRet;
|
|
import com.game.common.core.domain.HttpRetPageArr;
|
|
import com.game.common.core.domain.HttpRetPageArr;
|
|
import com.game.common.core.domain.R;
|
|
import com.game.common.core.domain.R;
|
|
import com.game.common.core.page.TableDataInfo;
|
|
import com.game.common.core.page.TableDataInfo;
|
|
|
|
+import com.game.common.core.redis.RedisCache;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@@ -48,13 +47,16 @@ public class AppGameBettingController extends BaseController{
|
|
@Autowired
|
|
@Autowired
|
|
private IAppGameLotteryService appGameLotteryService;
|
|
private IAppGameLotteryService appGameLotteryService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private RedisCache redisCache;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 下注
|
|
* 下注
|
|
*/
|
|
*/
|
|
@Anonymous
|
|
@Anonymous
|
|
@PostMapping(value = "/create")
|
|
@PostMapping(value = "/create")
|
|
@ApiOperation(value = "游戏下注", notes = "游戏下注")
|
|
@ApiOperation(value = "游戏下注", notes = "游戏下注")
|
|
- public HttpRet<Boolean> betting(@RequestBody AppGameBetting gameBetting)
|
|
|
|
|
|
+ public HttpRet<Double> betting(@RequestBody AppGameBetting gameBetting)
|
|
{
|
|
{
|
|
|
|
|
|
if(gameBetting.getClassId() == null){
|
|
if(gameBetting.getClassId() == null){
|
|
@@ -91,22 +93,22 @@ public class AppGameBettingController extends BaseController{
|
|
return HttpRet.fail("游戏已封盘,无法下单。");
|
|
return HttpRet.fail("游戏已封盘,无法下单。");
|
|
}
|
|
}
|
|
|
|
|
|
- String[] timeArry = appGame.getGameTime().substring(0, 4).split(":");
|
|
|
|
- int m = Integer.parseInt(timeArry[1]);
|
|
|
|
-
|
|
|
|
- if(m <= 10){
|
|
|
|
- return HttpRet.fail("游戏已封盘,无法下单。");
|
|
|
|
- }
|
|
|
|
|
|
+// String[] timeArry = appGame.getGameTime().substring(0, 5).split(":");
|
|
|
|
+// int m = Integer.parseInt(timeArry[1]);
|
|
|
|
+//
|
|
|
|
+// if(m <= 10){
|
|
|
|
+// return HttpRet.fail("游戏已封盘,无法下单。");
|
|
|
|
+// }
|
|
|
|
|
|
long count = appGameLotteryService.selectCount(appGame.getClassifyId(), appGame.getId(), appGame.getGameDate());
|
|
long count = appGameLotteryService.selectCount(appGame.getClassifyId(), appGame.getId(), appGame.getGameDate());
|
|
|
|
|
|
if(count > 0){
|
|
if(count > 0){
|
|
return HttpRet.fail("游戏已开奖,无法下单。");
|
|
return HttpRet.fail("游戏已开奖,无法下单。");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ AppUser appUser = null;
|
|
synchronized (this){
|
|
synchronized (this){
|
|
|
|
|
|
- AppUser appUser = appUserService.selectAppUserByUserid(gameBetting.getUserId());
|
|
|
|
|
|
+ appUser = appUserService.selectAppUserByUserid(gameBetting.getUserId());
|
|
|
|
|
|
if(appUser == null){
|
|
if(appUser == null){
|
|
return HttpRet.fail("用户不存在。");
|
|
return HttpRet.fail("用户不存在。");
|
|
@@ -119,10 +121,15 @@ public class AppGameBettingController extends BaseController{
|
|
|
|
|
|
// 更新用户余额
|
|
// 更新用户余额
|
|
appUser.setDiamondCoin(appUser.getDiamondCoin() - gameBetting.getBettingAmount());
|
|
appUser.setDiamondCoin(appUser.getDiamondCoin() - gameBetting.getBettingAmount());
|
|
- appUser.setDiamondCoinTotal(appUser.getDiamondCoinCashTotal() - gameBetting.getBettingAmount());
|
|
|
|
|
|
+ appUser.setDiamondCoinTotal(appUser.getDiamondCoinTotal() - gameBetting.getBettingAmount());
|
|
appUserService.updateAppUser(appUser);
|
|
appUserService.updateAppUser(appUser);
|
|
|
|
|
|
|
|
+ redisCache.deleteObject("U:UserInfo:" + appUser.getUserid());
|
|
|
|
+
|
|
gameBetting.setGameDate(appGame.getGameDate());
|
|
gameBetting.setGameDate(appGame.getGameDate());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ gameBetting.setCreateTime(new Date());
|
|
// 插入投注记录
|
|
// 插入投注记录
|
|
appGameBettingService.save(gameBetting);
|
|
appGameBettingService.save(gameBetting);
|
|
|
|
|
|
@@ -174,11 +181,11 @@ public class AppGameBettingController extends BaseController{
|
|
finTranRecord.setProCount(0L);
|
|
finTranRecord.setProCount(0L);
|
|
|
|
|
|
finTranRecord.setOrderId(gameBetting.getId());
|
|
finTranRecord.setOrderId(gameBetting.getId());
|
|
-
|
|
|
|
|
|
+ finTranRecord.setId(IdUtil.getSnowflakeNextId());
|
|
finTranRecordService.insertFinTranRecord(finTranRecord);
|
|
finTranRecordService.insertFinTranRecord(finTranRecord);
|
|
}
|
|
}
|
|
|
|
|
|
- return HttpRet.success("下注成功", true);
|
|
|
|
|
|
+ return HttpRet.success("下注成功", appUser.getDiamondCoin());
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -187,7 +194,7 @@ public class AppGameBettingController extends BaseController{
|
|
@Anonymous
|
|
@Anonymous
|
|
@PostMapping(value = "/count")
|
|
@PostMapping(value = "/count")
|
|
@ApiOperation(value = "游戏输赢统计(首页)", notes = "游戏输赢统计(首页)")
|
|
@ApiOperation(value = "游戏输赢统计(首页)", notes = "游戏输赢统计(首页)")
|
|
- public HttpRet<AppGameBettingCountDTO> getCount(@RequestParam(name = "strDate") String strDate)
|
|
|
|
|
|
+ public HttpRet<AppGameBettingCountDTO> getCount(@RequestParam(name = "strDate") String strDate, @RequestParam(name = "userId") Long userId)
|
|
{
|
|
{
|
|
AppGameBettingCountDTO appGameBettingCountDTO = new AppGameBettingCountDTO();
|
|
AppGameBettingCountDTO appGameBettingCountDTO = new AppGameBettingCountDTO();
|
|
List<AppGame> gameList = appGameService.selectAppGameList(new AppGame());
|
|
List<AppGame> gameList = appGameService.selectAppGameList(new AppGame());
|
|
@@ -196,7 +203,7 @@ public class AppGameBettingController extends BaseController{
|
|
return HttpRet.success("查询成功",appGameBettingCountDTO);
|
|
return HttpRet.success("查询成功",appGameBettingCountDTO);
|
|
}
|
|
}
|
|
|
|
|
|
- List<AppGameBettingDetailsCountDTO> countList = appGameBettingService.getCount(strDate);
|
|
|
|
|
|
+ List<AppGameBettingDetailsCountDTO> countList = appGameBettingService.getCount(strDate, userId);
|
|
if(countList == null){
|
|
if(countList == null){
|
|
countList = new ArrayList<>();
|
|
countList = new ArrayList<>();
|
|
}
|
|
}
|
|
@@ -243,10 +250,11 @@ public class AppGameBettingController extends BaseController{
|
|
@Anonymous
|
|
@Anonymous
|
|
@PostMapping(value = "/listByGameId")
|
|
@PostMapping(value = "/listByGameId")
|
|
@ApiOperation(value = "游戏输赢统计(详情)", notes = "游戏输赢统计(详情)")
|
|
@ApiOperation(value = "游戏输赢统计(详情)", notes = "游戏输赢统计(详情)")
|
|
- public HttpRetPageArr<AppGameBetting> getListByGameId(@RequestParam(name = "gameId") Long gameId)
|
|
|
|
|
|
+ public HttpRetPageArr<AppGameBetting> getListByGameId(@RequestParam(name = "gameId") Long gameId, @RequestParam(name = "userId") Long userId,
|
|
|
|
+ @RequestParam(name = "isWinning") Integer isWinning)
|
|
{
|
|
{
|
|
startPage();
|
|
startPage();
|
|
- List<AppGameBetting> list = appGameBettingService.selectListByGameId(gameId);
|
|
|
|
|
|
+ List<AppGameBetting> list = appGameBettingService.selectListByGameId(gameId, userId, isWinning);
|
|
return HttpRetPageArr.success("查询成功",getDataTable(list));
|
|
return HttpRetPageArr.success("查询成功",getDataTable(list));
|
|
}
|
|
}
|
|
}
|
|
}
|