|
@@ -1,18 +1,17 @@
|
|
package com.game.business.task;
|
|
package com.game.business.task;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
-import com.game.business.domain.AppGameBetting;
|
|
|
|
-import com.game.business.domain.AppUser;
|
|
|
|
-import com.game.business.domain.FinTranRecord;
|
|
|
|
-import com.game.business.service.IAppGameBettingService;
|
|
|
|
-import com.game.business.service.IAppUserService;
|
|
|
|
-import com.game.business.service.IFinTranRecordService;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
|
+import com.game.business.domain.*;
|
|
|
|
+import com.game.business.service.*;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
public class AppGameBettingTask {
|
|
public class AppGameBettingTask {
|
|
@@ -26,6 +25,194 @@ public class AppGameBettingTask {
|
|
@Autowired
|
|
@Autowired
|
|
private IFinTranRecordService finTranRecordService;
|
|
private IFinTranRecordService finTranRecordService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IAppGameLotteryService appGameLotteryService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IAppGameService appGameService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IAppGameClassifyService appGameClassifyService;
|
|
|
|
+
|
|
|
|
+ @Async("asyncExecutor")
|
|
|
|
+ public void gameDataTask(String message){
|
|
|
|
+
|
|
|
|
+ JSONArray dataArry = JSONArray.parseArray(message);
|
|
|
|
+
|
|
|
|
+ Integer type = null;
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < dataArry.size(); i++) {
|
|
|
|
+ JSONObject jsonObject = dataArry.getJSONObject(i);
|
|
|
|
+ if(jsonObject.containsKey("type")){
|
|
|
|
+ type = jsonObject.getInteger("type");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(type == null){
|
|
|
|
+ System.out.println("游戏socket推送类型为空。");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 更新倒计时
|
|
|
|
+ if(type == 1){
|
|
|
|
+
|
|
|
|
+ JSONArray gameDataArry = null;
|
|
|
|
+ String time = null;
|
|
|
|
+ String classCode = null;
|
|
|
|
+ for (int i = 0; i < dataArry.size(); i++) {
|
|
|
|
+ JSONObject jsonObject = dataArry.getJSONObject(i);
|
|
|
|
+ if(jsonObject.containsKey("data")){
|
|
|
|
+ gameDataArry = jsonObject.getJSONArray("data");
|
|
|
|
+ }
|
|
|
|
+ if(jsonObject.containsKey("time")){
|
|
|
|
+ time = jsonObject.getString("time");
|
|
|
|
+ }
|
|
|
|
+ if(jsonObject.containsKey("id")){
|
|
|
|
+ classCode = jsonObject.getString("id");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(classCode == null){
|
|
|
|
+ System.out.println("游戏socket推送倒计时,平台ID为空。");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(gameDataArry == null){
|
|
|
|
+ System.out.println("游戏socket推送倒计时,data对象为空。");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(time == null || time.trim().isEmpty()){
|
|
|
|
+ System.out.println("游戏socket推送倒计时,time为空。");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ AppGameClassify appGameClassify = appGameClassifyService.getByCode(classCode);
|
|
|
|
+ if(appGameClassify == null){
|
|
|
|
+ System.out.println("开奖游戏平台不存在:" + classCode);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<AppGame> appGameList = appGameService.selectAppGameByClassId(appGameClassify.getId());
|
|
|
|
+ if(appGameList == null || appGameList.isEmpty()){
|
|
|
|
+ System.out.println("开奖游戏平台没有游戏:" + classCode);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Map<String, List<AppGame>> codeGameMap = appGameList.stream().collect(Collectors.groupingBy(AppGame::getCode));
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < gameDataArry.size(); i++) {
|
|
|
|
+ JSONObject jsonObject = gameDataArry.getJSONObject(i);
|
|
|
|
+ String gameCode = jsonObject.getString("id");
|
|
|
|
+ if(gameCode == null){
|
|
|
|
+ System.out.println("游戏socket推送倒计时,游戏id为空。");
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if(!codeGameMap.containsKey(gameCode)){
|
|
|
|
+ System.out.println("开奖游戏不存在:" + gameCode);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ AppGame appGame = codeGameMap.get(gameCode).get(0);
|
|
|
|
+ appGame.setGameTime(time);
|
|
|
|
+ appGameService.updateAppGame(appGame);
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(type != 2 && type != 3){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONArray gameArry = null;
|
|
|
|
+ String classCode = null;
|
|
|
|
+ for (int i = 0; i < dataArry.size(); i++) {
|
|
|
|
+ JSONObject jsonObject = dataArry.getJSONObject(i);
|
|
|
|
+ if(jsonObject.containsKey("gameTypeSortArrayVOS")){
|
|
|
|
+ gameArry = jsonObject.getJSONArray("gameTypeSortArrayVOS");
|
|
|
|
+ }
|
|
|
|
+ if(jsonObject.containsKey("id")){
|
|
|
|
+ classCode = jsonObject.getString("id");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(gameArry == null){
|
|
|
|
+ System.out.println("游戏socket推送期号或开奖,gameTypeSortArrayVOS对象为空。");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(classCode == null){
|
|
|
|
+ System.out.println("游戏socket推送期号或开奖,平台ID为空。");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ AppGameClassify appGameClassify = appGameClassifyService.getByCode(classCode);
|
|
|
|
+ if(appGameClassify == null){
|
|
|
|
+ System.out.println("开奖游戏平台不存在:" + classCode);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<AppGame> appGameList = appGameService.selectAppGameByClassId(appGameClassify.getId());
|
|
|
|
+ if(appGameList == null || appGameList.isEmpty()){
|
|
|
|
+ System.out.println("开奖游戏平台没有游戏:" + classCode);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Map<String, List<AppGame>> codeGameMap = appGameList.stream().collect(Collectors.groupingBy(AppGame::getCode));
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < gameArry.size(); i++) {
|
|
|
|
+ JSONObject gameLotteryObject = gameArry.getJSONObject(i);
|
|
|
|
+ String gameCode = gameLotteryObject.getString("id");
|
|
|
|
+
|
|
|
|
+ if(gameCode == null){
|
|
|
|
+ System.out.println("游戏socket推送期号或开奖,游戏ID为空。");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!codeGameMap.containsKey(gameCode)){
|
|
|
|
+ System.out.println("开奖游戏不存在:" + gameCode);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ AppGame appGame = codeGameMap.get(gameCode).get(0);
|
|
|
|
+
|
|
|
|
+ String gameDate = gameLotteryObject.getString("gameDate");
|
|
|
|
+ if(gameDate == null){
|
|
|
|
+ System.out.println("游戏socket推送期号或开奖,期号为空。");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(type == 3){
|
|
|
|
+ appGame.setGameDate(gameDate);
|
|
|
|
+ appGameService.updateAppGame(appGame);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ long count = appGameLotteryService.selectCount(appGame.getClassifyId(), appGame.getId(), gameDate);
|
|
|
|
+
|
|
|
|
+ if(count > 0){
|
|
|
|
+ System.out.println("游戏socket推送开奖,当前期已开过将,游戏编码:" + gameCode + ",期号:" + gameDate);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Integer isLottery = gameLotteryObject.getInteger("isLottery");
|
|
|
|
+ String gameLotterySucc = gameLotteryObject.getString("gameLotterySucc");
|
|
|
|
+
|
|
|
|
+ // 保存开奖记录
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ if(isLottery != 1){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.gameBettingTask(appGameClassify.getId(), appGame.getId(), gameDate, gameLotterySucc);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
public void gameBettingTask(Long classId, Long gameId, String gameDate, String bettingItem){
|
|
public void gameBettingTask(Long classId, Long gameId, String gameDate, String bettingItem){
|
|
|
|
|
|
List<AppGameBetting> list = appGameBettingService.getIsWinning(classId, gameId, gameDate, 0);
|
|
List<AppGameBetting> list = appGameBettingService.getIsWinning(classId, gameId, gameDate, 0);
|