|
@@ -1,23 +1,19 @@
|
|
|
package com.game.business.task;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
-import com.game.business.domain.AppGameBetting;
|
|
|
-import com.game.business.domain.AppGameLottery;
|
|
|
-import com.game.business.domain.AppUser;
|
|
|
-import com.game.business.domain.FinTranRecord;
|
|
|
-import com.game.business.service.IAppGameBettingService;
|
|
|
-import com.game.business.service.IAppGameLotteryService;
|
|
|
-import com.game.business.service.IAppUserService;
|
|
|
-import com.game.business.service.IFinTranRecordService;
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
+import com.game.business.domain.*;
|
|
|
+import com.game.business.dto.AppItemCountDTO;
|
|
|
+import com.game.business.service.*;
|
|
|
import com.game.business.vo.AppGameItemBettingVO;
|
|
|
import com.game.common.constant.finance.FinTranType1;
|
|
|
import com.game.common.constant.finance.FinTranType2;
|
|
|
import com.game.common.constant.finance.FinTranType3;
|
|
|
import com.game.common.core.redis.RedisCache;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -25,27 +21,52 @@ import java.util.stream.Collectors;
|
|
|
@Component
|
|
|
public class AppGameLotteryTask {
|
|
|
|
|
|
-
|
|
|
@Autowired
|
|
|
private IAppGameBettingService appGameBettingService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private IAppGameLotteryService appGameLotteryService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private IAppUserService appUserService;
|
|
|
|
|
|
@Autowired
|
|
|
private IFinTranRecordService finTranRecordService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IAppGameItemService appGameItemService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IAppUserCountService appUserCountService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
|
|
|
-
|
|
|
- public void updateLottery(){
|
|
|
+ public void updateLottery(AppGameLottery appGameLottery){
|
|
|
+
|
|
|
+ updateItme(appGameLottery.getGameId(), appGameLottery.getGameLotterySucc());
|
|
|
+
|
|
|
+ gameBettingTask(appGameLottery);
|
|
|
+
|
|
|
+ appUserCountService.staticsUserCount(appGameLottery.getGameId(),null);
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- List<AppGameBetting> list = appGameBettingService.getNotLottery(0);
|
|
|
+ private void updateItme(Long gameId, String gameLotterySucc){
|
|
|
+
|
|
|
+
|
|
|
+ String [] bettingItems = gameLotterySucc.split(",");
|
|
|
+
|
|
|
+ for(int j = 0; j < bettingItems.length; j++) {
|
|
|
+ String bettingItemStr = bettingItems[j];
|
|
|
+
|
|
|
+ AppGameItem appGameItem = new AppGameItem();
|
|
|
+ appGameItem.setGameId(gameId);
|
|
|
+ appGameItem.setItemLocation(bettingItemStr);
|
|
|
+
|
|
|
+ appGameItemService.updateLotteryCount(appGameItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void gameBettingTask(AppGameLottery appGameLottery){
|
|
|
+
|
|
|
+ List<AppGameBetting> list = appGameBettingService.getIsWinning(appGameLottery.getClassId(), appGameLottery.getGameId(), appGameLottery.getGameDate(), 0);
|
|
|
|
|
|
if(list == null || list.isEmpty()){
|
|
|
return;
|
|
@@ -53,137 +74,132 @@ public class AppGameLotteryTask {
|
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
AppGameBetting appGameBetting = list.get(i);
|
|
|
- AppGameLottery appGameLottery = appGameLotteryService.selectLottery(appGameBetting.getClassId(), appGameBetting.getGameId(), appGameBetting.getGameDate());
|
|
|
- if(appGameLottery != null){
|
|
|
- if((System.currentTimeMillis() - appGameLottery.getGameRecordDate().getTime()) / 1000 / 60 >= 1){
|
|
|
- appGameBetting.setUpdateTime(new Date());
|
|
|
-
|
|
|
- String [] bettingItems = appGameLottery.getGameLotterySucc().split(",");
|
|
|
- for(int j = 0; j < bettingItems.length; j++){
|
|
|
- String bettingItemStr = bettingItems[j];
|
|
|
-
|
|
|
- double bettingAmount = appGameBetting.getBettingAmount() * appGameBetting.getBettingMultiple();
|
|
|
-
|
|
|
- if(appGameBetting.getBettingGameType() == 0){
|
|
|
- if(!appGameBetting.getBettingItem().equals(bettingItemStr)){
|
|
|
- appGameBetting.setIsWinning(2);
|
|
|
- appGameBettingService.updateById(appGameBetting);
|
|
|
- continue;
|
|
|
- }
|
|
|
- }else if(appGameBetting.getBettingGameType() == 1 || appGameBetting.getBettingGameType() == 2){
|
|
|
- List<AppGameItemBettingVO> itemList = JSON.parseArray(appGameBetting.getBettingItem(), AppGameItemBettingVO.class);
|
|
|
- if(itemList == null || itemList.isEmpty()){
|
|
|
- appGameBetting.setIsWinning(2);
|
|
|
- appGameBettingService.updateById(appGameBetting);
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<String> bettingItemList = itemList.stream().map(AppGameItemBettingVO::getBettingItem).collect(Collectors.toList());
|
|
|
- if(!bettingItemList.contains(bettingItemStr)){
|
|
|
- appGameBetting.setIsWinning(2);
|
|
|
- appGameBettingService.updateById(appGameBetting);
|
|
|
- continue;
|
|
|
- }
|
|
|
+ appGameBetting.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ String [] bettingItems = appGameLottery.getGameLotterySucc().split(",");
|
|
|
+ for(int j = 0; j < bettingItems.length; j++){
|
|
|
+ String bettingItemStr = bettingItems[j];
|
|
|
|
|
|
- if(appGameBetting.getBettingGameType() == 2){
|
|
|
- for (int k = 0; k < itemList.size(); k++) {
|
|
|
- AppGameItemBettingVO appGameItemBettingVO = itemList.get(k);
|
|
|
- if(appGameItemBettingVO.getBettingItem().equals(bettingItemStr)){
|
|
|
- bettingAmount = appGameBetting.getBettingAmount() * appGameItemBettingVO.getBettingMultiple();
|
|
|
- }
|
|
|
- }
|
|
|
+ double bettingAmount = appGameBetting.getBettingAmount() * appGameBetting.getBettingMultiple();
|
|
|
+
|
|
|
+ if(appGameBetting.getBettingGameType() == 0){
|
|
|
+ if(!appGameBetting.getBettingItem().equals(bettingItemStr)){
|
|
|
+ appGameBetting.setIsWinning(2);
|
|
|
+ appGameBettingService.updateById(appGameBetting);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(appGameBetting.getBettingGameType() == 1 || appGameBetting.getBettingGameType() == 2){
|
|
|
+ List<AppGameItemBettingVO> itemList = JSON.parseArray(appGameBetting.getBettingItem(), AppGameItemBettingVO.class);
|
|
|
+ if(itemList == null || itemList.isEmpty()){
|
|
|
+ appGameBetting.setIsWinning(2);
|
|
|
+ appGameBettingService.updateById(appGameBetting);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<String> bettingItemList = itemList.stream().map(AppGameItemBettingVO::getBettingItem).collect(Collectors.toList());
|
|
|
+ if(!bettingItemList.contains(bettingItemStr)){
|
|
|
+ appGameBetting.setIsWinning(2);
|
|
|
+ appGameBettingService.updateById(appGameBetting);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(appGameBetting.getBettingGameType() == 2){
|
|
|
+ for (int k = 0; k < itemList.size(); k++) {
|
|
|
+ AppGameItemBettingVO appGameItemBettingVO = itemList.get(k);
|
|
|
+ if(appGameItemBettingVO.getBettingItem().equals(bettingItemStr)){
|
|
|
+ bettingAmount = appGameBetting.getBettingAmount() * appGameItemBettingVO.getBettingMultiple();
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- AppUser appUser = appUserService.selectAppUserByUserid(appGameBetting.getUserId());
|
|
|
- if(appUser == null){
|
|
|
- appGameBetting.setIsWinning(1);
|
|
|
- appGameBettingService.updateById(appGameBetting);
|
|
|
- continue;
|
|
|
- }
|
|
|
+ AppUser appUser = appUserService.selectAppUserByUserid(appGameBetting.getUserId());
|
|
|
+ if(appUser == null){
|
|
|
+ appGameBetting.setIsWinning(1);
|
|
|
+ appGameBettingService.updateById(appGameBetting);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- if(appGameBetting.getBettingType() == 0){
|
|
|
- appUser.setDiamondCoin(appUser.getDiamondCoin() + bettingAmount );
|
|
|
- appUser.setDiamondCoinTotal(appUser.getDiamondCoinCashTotal() + bettingAmount);
|
|
|
- appUser.setDiamondCoinCash(appUser.getDiamondCoinCash() + bettingAmount);
|
|
|
-
|
|
|
- }else{
|
|
|
- appUser.setCoin(appUser.getCoin() + bettingAmount);
|
|
|
+
|
|
|
+ if(appGameBetting.getBettingType() == 0){
|
|
|
+ appUser.setDiamondCoin(appUser.getDiamondCoin() + bettingAmount );
|
|
|
+ appUser.setDiamondCoinTotal(appUser.getDiamondCoinCashTotal() + bettingAmount);
|
|
|
+ appUser.setDiamondCoinCash(appUser.getDiamondCoinCash() + bettingAmount);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ appUser.setCoin(appUser.getCoin() + bettingAmount);
|
|
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- appUserService.updateAppUser(appUser);
|
|
|
+ appUserService.updateAppUser(appUser);
|
|
|
|
|
|
- redisCache.deleteObject("U:UserInfo:" + appUser.getUserid());
|
|
|
+ redisCache.deleteObject("U:UserInfo:" + appUser.getUserid());
|
|
|
|
|
|
- appGameBetting.setIsWinning(1);
|
|
|
- appGameBettingService.updateById(appGameBetting);
|
|
|
+ appGameBetting.setIsWinning(1);
|
|
|
+ appGameBettingService.updateById(appGameBetting);
|
|
|
|
|
|
- FinTranRecord finTranRecord = new FinTranRecord();
|
|
|
+ FinTranRecord finTranRecord = new FinTranRecord();
|
|
|
|
|
|
- finTranRecord.setAfterCoin(appUser.getCoin());
|
|
|
- finTranRecord.setAfterDiamondCoin(appUser.getDiamondCoin());
|
|
|
+ finTranRecord.setAfterCoin(appUser.getCoin());
|
|
|
+ finTranRecord.setAfterDiamondCoin(appUser.getDiamondCoin());
|
|
|
|
|
|
- if(appGameBetting.getBettingType() == 0){
|
|
|
- finTranRecord.setCurrencyType(4);
|
|
|
- finTranRecord.setDiamondCoinChange(bettingAmount);
|
|
|
- finTranRecord.setCoinChange(0.00);
|
|
|
- }else{
|
|
|
- finTranRecord.setCurrencyType(2);
|
|
|
- finTranRecord.setCoinChange(bettingAmount);
|
|
|
- finTranRecord.setDiamondCoinChange(0.00);
|
|
|
- }
|
|
|
+ if(appGameBetting.getBettingType() == 0){
|
|
|
+ finTranRecord.setCurrencyType(4);
|
|
|
+ finTranRecord.setDiamondCoinChange(bettingAmount);
|
|
|
+ finTranRecord.setCoinChange(0.00);
|
|
|
+ }else{
|
|
|
+ finTranRecord.setCurrencyType(2);
|
|
|
+ finTranRecord.setCoinChange(bettingAmount);
|
|
|
+ finTranRecord.setDiamondCoinChange(0.00);
|
|
|
+ }
|
|
|
|
|
|
- finTranRecord.setAfterMoney(0.00);
|
|
|
- finTranRecord.setMoneyChange(0.00);
|
|
|
+ finTranRecord.setAfterMoney(0.00);
|
|
|
+ finTranRecord.setMoneyChange(0.00);
|
|
|
|
|
|
- finTranRecord.setAfterTicket(0.00);
|
|
|
- finTranRecord.setTicketChange(0.00);
|
|
|
+ finTranRecord.setAfterTicket(0.00);
|
|
|
+ finTranRecord.setTicketChange(0.00);
|
|
|
|
|
|
- finTranRecord.setToUid(appUser.getUserid());
|
|
|
- finTranRecord.setUid(appUser.getUserid());
|
|
|
+ finTranRecord.setToUid(appUser.getUserid());
|
|
|
+ finTranRecord.setUid(appUser.getUserid());
|
|
|
|
|
|
- finTranRecord.setSceneId1(0L);
|
|
|
- finTranRecord.setSceneId2(null);
|
|
|
- finTranRecord.setSceneType(0L);
|
|
|
+ finTranRecord.setSceneId1(0L);
|
|
|
+ finTranRecord.setSceneId2(null);
|
|
|
+ finTranRecord.setSceneType(0L);
|
|
|
|
|
|
- finTranRecord.setTranGroupId(appGameBetting.getId());
|
|
|
+ finTranRecord.setTranGroupId(appGameBetting.getId());
|
|
|
|
|
|
- if(appGameBetting.getBettingType() == 0){
|
|
|
- finTranRecord.setTranType1(FinTranType1.U_Income_Coin_Balance.getType());
|
|
|
- }else{
|
|
|
- finTranRecord.setTranType1(FinTranType1.U_Income_Coin.getType());
|
|
|
- }
|
|
|
+ if(appGameBetting.getBettingType() == 0){
|
|
|
+ finTranRecord.setTranType1(FinTranType1.U_Income_Coin_Balance.getType());
|
|
|
+ }else{
|
|
|
+ finTranRecord.setTranType1(FinTranType1.U_Income_Coin.getType());
|
|
|
+ }
|
|
|
|
|
|
- finTranRecord.setTranType2(FinTranType2.GAME_REWARD.getType());
|
|
|
- finTranRecord.setTranType3(FinTranType3.CHARGE_WIN_GAME.getType());
|
|
|
+ finTranRecord.setTranType2(FinTranType2.GAME_REWARD.getType());
|
|
|
+ finTranRecord.setTranType3(FinTranType3.CHARGE_WIN_GAME.getType());
|
|
|
|
|
|
- finTranRecord.setRemarks("游戏中奖");
|
|
|
+ finTranRecord.setRemarks("游戏中奖");
|
|
|
|
|
|
- finTranRecord.setConsumptionCoin(appGameBetting.getBettingAmount());
|
|
|
- finTranRecord.setConsumptionMoney(0.00);
|
|
|
- finTranRecord.setCommissionRelatedUid(0L);
|
|
|
- finTranRecord.setAgentId(appUser.getAgentId());
|
|
|
+ finTranRecord.setConsumptionCoin(appGameBetting.getBettingAmount());
|
|
|
+ finTranRecord.setConsumptionMoney(0.00);
|
|
|
+ finTranRecord.setCommissionRelatedUid(0L);
|
|
|
+ finTranRecord.setAgentId(appUser.getAgentId());
|
|
|
|
|
|
- finTranRecord.setCreateTime(new Date());
|
|
|
+ finTranRecord.setCreateTime(new Date());
|
|
|
|
|
|
- finTranRecord.setFromUid(appGameBetting.getUserId());
|
|
|
- finTranRecord.setGoodsId(0L);
|
|
|
- finTranRecord.setGuildId(0L);
|
|
|
- finTranRecord.setManagerCoId(0L);
|
|
|
- finTranRecord.setManagerId(0L);
|
|
|
+ finTranRecord.setFromUid(appGameBetting.getUserId());
|
|
|
+ finTranRecord.setGoodsId(0L);
|
|
|
+ finTranRecord.setGuildId(0L);
|
|
|
+ finTranRecord.setManagerCoId(0L);
|
|
|
+ finTranRecord.setManagerId(0L);
|
|
|
|
|
|
- finTranRecord.setPerc(0.00);
|
|
|
- finTranRecord.setProId(0L);
|
|
|
- finTranRecord.setProCount(0L);
|
|
|
+ finTranRecord.setPerc(0.00);
|
|
|
+ finTranRecord.setProId(0L);
|
|
|
+ finTranRecord.setProCount(0L);
|
|
|
|
|
|
- finTranRecord.setOrderId(appGameBetting.getId());
|
|
|
- finTranRecordService.insertFinTranRecord(finTranRecord);
|
|
|
+ finTranRecord.setOrderId(appGameBetting.getId());
|
|
|
+ finTranRecordService.insertFinTranRecord(finTranRecord);
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|