|
@@ -223,51 +223,72 @@ public class AppGameBettingTask {
|
|
|
}
|
|
|
|
|
|
if(type == 3){
|
|
|
- appGame.setGameDate(gameDate);
|
|
|
- appGameService.updateAppGame(appGame);
|
|
|
|
|
|
- // 修改倍数
|
|
|
- if(gameCode.equals(Common.GAME_ONE_CODE)){
|
|
|
+ String redisKey = CacheConstants.GAME_LOTTERY_TASK_CREATE.concat(appGame.getId() + ":" + gameCode);
|
|
|
+ if(!redisCache.redisTemplate.opsForValue().setIfAbsent(redisKey, 1)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- String gameLotteryBet = gameLotteryObject.getString("gameLotteryBet");
|
|
|
- if(StringUtils.isBlank(gameLotteryBet)){
|
|
|
- continue;
|
|
|
- }
|
|
|
+ try {
|
|
|
|
|
|
- gameLotteryBet = gameLotteryBet.replace(" ", "").trim();
|
|
|
- JSONArray items = JSONArray.parseArray(gameLotteryBet);
|
|
|
- if(items == null || items.isEmpty()){
|
|
|
- continue;
|
|
|
- }
|
|
|
+ appGame.setGameDate(gameDate);
|
|
|
+ appGameService.updateAppGame(appGame);
|
|
|
|
|
|
- AppGameItem appGameItem = new AppGameItem();
|
|
|
- appGameItem.setGameId(appGame.getId());
|
|
|
- List<AppGameItem> itemList = appGameItemService.selectAppGameItemList(appGameItem);
|
|
|
+ // 修改倍数
|
|
|
+ if(gameCode.equals(Common.GAME_ONE_CODE)){
|
|
|
|
|
|
- if(itemList == null || itemList.isEmpty()){
|
|
|
- continue;
|
|
|
- }
|
|
|
+ String gameLotteryBet = gameLotteryObject.getString("gameLotteryBet");
|
|
|
+ if(StringUtils.isBlank(gameLotteryBet)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- if(itemList.size() != items.size()){
|
|
|
- continue;
|
|
|
- }
|
|
|
+ gameLotteryBet = gameLotteryBet.replace(" ", "").trim();
|
|
|
+ JSONArray items = JSONArray.parseArray(gameLotteryBet);
|
|
|
+ if(items == null || items.isEmpty()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- AppGameItemMultiple appGameItemMultiple = new AppGameItemMultiple();
|
|
|
- appGameItemMultiple.setGameId(appGame.getId());
|
|
|
- appGameItemMultiple.setGameDate(gameDate);
|
|
|
- appGameItemMultiple.setItemMultiple(gameLotteryBet.substring(1, gameLotteryBet.length() - 1));
|
|
|
- appGameItemMultipleService.save(appGameItemMultiple);
|
|
|
+ AppGameItem appGameItem = new AppGameItem();
|
|
|
+ appGameItem.setGameId(appGame.getId());
|
|
|
+ List<AppGameItem> itemList = appGameItemService.selectAppGameItemList(appGameItem);
|
|
|
|
|
|
- // 升序排序
|
|
|
- itemList.stream().sorted(Comparator.comparing(AppGameItem::getItemLocation));
|
|
|
+ if(itemList == null || itemList.isEmpty()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- for (int j = 0; j < itemList.size(); j++) {
|
|
|
- AppGameItem gameItem = itemList.get(j);
|
|
|
- gameItem.setItemMultiple(items.getDouble(j));
|
|
|
- appGameItemService.updateAppGameItem(gameItem);
|
|
|
+ if(itemList.size() != items.size()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ AppGameItemMultiple appGameItemMultiple = new AppGameItemMultiple();
|
|
|
+ appGameItemMultiple.setGameId(appGame.getId());
|
|
|
+ appGameItemMultiple.setGameDate(gameDate);
|
|
|
+ appGameItemMultiple.setItemMultiple(gameLotteryBet.substring(1, gameLotteryBet.length() - 1));
|
|
|
+ appGameItemMultipleService.save(appGameItemMultiple);
|
|
|
+
|
|
|
+ // 升序排序
|
|
|
+ itemList.stream().sorted(Comparator.comparing(AppGameItem::getItemLocation));
|
|
|
+
|
|
|
+ for (int j = 0; j < itemList.size(); j++) {
|
|
|
+ AppGameItem gameItem = itemList.get(j);
|
|
|
+ gameItem.setItemMultiple(items.getDouble(j));
|
|
|
+ appGameItemService.updateAppGameItem(gameItem);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ AppGameLottery appGameLottery = new AppGameLottery();
|
|
|
+ appGameLottery.setGameId(appGame.getId());
|
|
|
+ appGameLottery.setClassId(appGame.getClassifyId());
|
|
|
+ appGameLottery.setGameDate(gameDate);
|
|
|
+ appGameLottery.setIsLottery(0);
|
|
|
+ appGameLottery.setGameRecordDate(new Date());
|
|
|
+ appGameLotteryService.save(appGameLottery);
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }finally {
|
|
|
+ redisCache.redisTemplate.delete(redisKey);
|
|
|
+ }
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -290,24 +311,33 @@ public class AppGameBettingTask {
|
|
|
|
|
|
try {
|
|
|
|
|
|
- long count = appGameLotteryService.selectCount(appGame.getClassifyId(), appGame.getId(), gameDate);
|
|
|
+ AppGameLottery appGameLottery = appGameLotteryService.selectLottery(appGame.getClassifyId(), appGame.getId(), gameDate);
|
|
|
+
|
|
|
+ if(appGameLottery == null){
|
|
|
+ // 保存开奖记录
|
|
|
+ appGameLottery = new AppGameLottery();
|
|
|
+ appGameLottery.setGameId(appGame.getId());
|
|
|
+ appGameLottery.setClassId(appGame.getClassifyId());
|
|
|
+ appGameLottery.setGameDate(gameDate);
|
|
|
+ appGameLottery.setIsLottery(isLottery);
|
|
|
+ appGameLottery.setGameRecordDate(new Date());
|
|
|
+ appGameLottery.setGameLotterySucc(gameLotterySucc);
|
|
|
+ appGameLotteryService.save(appGameLottery);
|
|
|
+ }else{
|
|
|
+ if(appGameLottery.getIsLottery() == 1){
|
|
|
+// redisCache.redisTemplate.delete(redisKey);
|
|
|
+// System.out.println("游戏socket推送开奖,当前期已开过将,游戏编码:" + gameCode + ",期号:" + gameDate);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- if(count > 0){
|
|
|
- redisCache.redisTemplate.delete(redisKey);
|
|
|
-// System.out.println("游戏socket推送开奖,当前期已开过将,游戏编码:" + gameCode + ",期号:" + gameDate);
|
|
|
- continue;
|
|
|
+ AppGameLottery updateAppGameLottery = new AppGameLottery();
|
|
|
+ updateAppGameLottery.setId(appGameLottery.getId());
|
|
|
+ updateAppGameLottery.setIsLottery(isLottery);
|
|
|
+ updateAppGameLottery.setGameRecordDate(new Date());
|
|
|
+ updateAppGameLottery.setGameLotterySucc(gameLotterySucc);
|
|
|
+ appGameLotteryService.updateById(updateAppGameLottery);
|
|
|
}
|
|
|
|
|
|
- // 保存开奖记录
|
|
|
- AppGameLottery appGameLottery = new AppGameLottery();
|
|
|
- appGameLottery.setGameId(appGame.getId());
|
|
|
- appGameLottery.setClassId(appGame.getClassifyId());
|
|
|
- appGameLottery.setGameDate(gameDate);
|
|
|
- appGameLottery.setIsLottery(isLottery);
|
|
|
- appGameLottery.setGameRecordDate(new Date());
|
|
|
- appGameLottery.setGameLotterySucc(gameLotterySucc);
|
|
|
- appGameLotteryService.save(appGameLottery);
|
|
|
-
|
|
|
lotteryTask(appGame, appGameClassify, gameLotterySucc, gameDate);
|
|
|
|
|
|
}catch (Exception e){
|
|
@@ -324,7 +354,7 @@ public class AppGameBettingTask {
|
|
|
|
|
|
List<String> userIds = this.gameBettingTask(appGameClassify.getId(), appGame.getId(), gameDate, gameLotterySucc);
|
|
|
|
|
|
- appUserCountService.staticsUserCount(appGame.getId(),null,appGame.getGameDate());
|
|
|
+ appUserCountService.staticsUserCount(appGame.getId(),null, appGame.getGameDate());
|
|
|
|
|
|
// 给中奖人发送刷新余额通知
|
|
|
sendMsg(userIds);
|