|
@@ -2,10 +2,12 @@ package com.game.business.task;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.game.business.domain.*;
|
|
|
import com.game.business.dto.AppItemCountDTO;
|
|
|
import com.game.business.service.*;
|
|
|
+import com.game.business.util.im.TencentCloudImUtil;
|
|
|
import com.game.business.vo.AppGameItemBettingVO;
|
|
|
import com.game.common.constant.finance.FinTranType1;
|
|
|
import com.game.common.constant.finance.FinTranType2;
|
|
@@ -15,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -44,9 +47,12 @@ public class AppGameLotteryTask {
|
|
|
|
|
|
updateItme(appGameLottery.getGameId(), appGameLottery.getGameLotterySucc());
|
|
|
|
|
|
- gameBettingTask(appGameLottery);
|
|
|
+ List<String> userIds = gameBettingTask(appGameLottery);
|
|
|
|
|
|
appUserCountService.staticsUserCount(appGameLottery.getGameId(),null,appGameLottery.getGameDate());
|
|
|
+
|
|
|
+
|
|
|
+ sendMsg(userIds);
|
|
|
}
|
|
|
|
|
|
private void updateItme(Long gameId, String gameLotterySucc){
|
|
@@ -66,12 +72,15 @@ public class AppGameLotteryTask {
|
|
|
}
|
|
|
|
|
|
@DSTransactional
|
|
|
- private void gameBettingTask(AppGameLottery appGameLottery) throws Exception {
|
|
|
+ private List<String> gameBettingTask(AppGameLottery appGameLottery) throws Exception {
|
|
|
+
|
|
|
|
|
|
List<AppGameBetting> list = appGameBettingService.getIsWinning(appGameLottery.getClassId(), appGameLottery.getGameId(), appGameLottery.getGameDate(), 0);
|
|
|
|
|
|
+ List<String> userIds = new ArrayList<>();
|
|
|
+
|
|
|
if(list == null || list.isEmpty()){
|
|
|
- return;
|
|
|
+ return userIds;
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
@@ -79,130 +88,173 @@ public class AppGameLotteryTask {
|
|
|
appGameBetting.setUpdateTime(new Date());
|
|
|
|
|
|
String [] bettingItems = appGameLottery.getGameLotterySucc().split(",");
|
|
|
- for(int j = 0; j < bettingItems.length; j++){
|
|
|
- String bettingItemStr = bettingItems[j];
|
|
|
+ List<String> bettingItemsList = Arrays.asList(bettingItems);
|
|
|
|
|
|
- double bettingAmount = appGameBetting.getBettingAmount() * appGameBetting.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();
|
|
|
- }
|
|
|
- }
|
|
|
+ if(appGameBetting.getBettingGameType() == 0){
|
|
|
+ if(!bettingItemsList.contains(appGameBetting.getBettingItem())){
|
|
|
+ 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());
|
|
|
+ boolean isWinning = false;
|
|
|
+ for (int j = 0; j < bettingItemList.size(); j++) {
|
|
|
+ String bettingItemStr = bettingItemList.get(j);
|
|
|
+ if(bettingItemsList.contains(bettingItemStr)){
|
|
|
+ isWinning = true;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- AppUser appUser = appUserService.selectAppUserByUserid(appGameBetting.getUserId());
|
|
|
- if(appUser == null){
|
|
|
- appGameBetting.setIsWinning(1);
|
|
|
+ if(!isWinning){
|
|
|
+ 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(bettingItemsList.contains(appGameItemBettingVO.getBettingItem())){
|
|
|
+ bettingAmount = appGameBetting.getBettingAmount() * appGameItemBettingVO.getBettingMultiple();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ AppUser appUser = appUserService.selectAppUserByUserid(appGameBetting.getUserId());
|
|
|
+ if(appUser == null){
|
|
|
appGameBetting.setIsWinning(1);
|
|
|
appGameBettingService.updateById(appGameBetting);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- FinTranRecord finTranRecord = new FinTranRecord();
|
|
|
+
|
|
|
+ String userId = appUser.getUserid() + "";
|
|
|
+ if(!userIds.contains(userId)){
|
|
|
+ userIds.add(userId);
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ appGameBetting.setIsWinning(1);
|
|
|
+ appGameBettingService.updateById(appGameBetting);
|
|
|
+
|
|
|
+ FinTranRecord finTranRecord = new FinTranRecord();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 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.setRemarks("游戏中奖");
|
|
|
|
|
|
- finTranRecord.setTranType2(FinTranType2.GAME_REWARD.getType());
|
|
|
- finTranRecord.setTranType3(FinTranType3.CHARGE_WIN_GAME.getType());
|
|
|
+ finTranRecord.setConsumptionCoin(appGameBetting.getBettingAmount());
|
|
|
+ finTranRecord.setConsumptionMoney(0.00);
|
|
|
+ finTranRecord.setCommissionRelatedUid(0L);
|
|
|
+ finTranRecord.setAgentId(appUser.getAgentId());
|
|
|
|
|
|
- finTranRecord.setRemarks("游戏中奖");
|
|
|
+ finTranRecord.setCreateTime(new Date());
|
|
|
|
|
|
- finTranRecord.setConsumptionCoin(appGameBetting.getBettingAmount());
|
|
|
- finTranRecord.setConsumptionMoney(0.00);
|
|
|
- finTranRecord.setCommissionRelatedUid(0L);
|
|
|
- finTranRecord.setAgentId(appUser.getAgentId());
|
|
|
+ finTranRecord.setFromUid(appGameBetting.getUserId());
|
|
|
+ finTranRecord.setGoodsId(0L);
|
|
|
+ finTranRecord.setGuildId(0L);
|
|
|
+ finTranRecord.setManagerCoId(0L);
|
|
|
+ finTranRecord.setManagerId(0L);
|
|
|
|
|
|
- finTranRecord.setCreateTime(new Date());
|
|
|
+ finTranRecord.setPerc(0.00);
|
|
|
+ finTranRecord.setProId(0L);
|
|
|
+ finTranRecord.setProCount(0L);
|
|
|
|
|
|
- finTranRecord.setFromUid(appGameBetting.getUserId());
|
|
|
- finTranRecord.setGoodsId(0L);
|
|
|
- finTranRecord.setGuildId(0L);
|
|
|
- finTranRecord.setManagerCoId(0L);
|
|
|
- finTranRecord.setManagerId(0L);
|
|
|
+ finTranRecord.setOrderId(appGameBetting.getId());
|
|
|
+
|
|
|
+ appUserService.updateUserAmount(finTranRecord);
|
|
|
+ }
|
|
|
+ return userIds;
|
|
|
+ }
|
|
|
|
|
|
- finTranRecord.setPerc(0.00);
|
|
|
- finTranRecord.setProId(0L);
|
|
|
- finTranRecord.setProCount(0L);
|
|
|
+ public void sendMsg(List<String> userIdList){
|
|
|
+ if(userIdList == null || userIdList.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- finTranRecord.setOrderId(appGameBetting.getId());
|
|
|
-
|
|
|
- appUserService.updateUserAmount(finTranRecord);
|
|
|
+ JSONObject paramJson = new JSONObject();
|
|
|
+ paramJson.put("type", "UserSystemNotify");
|
|
|
+ paramJson.put("subType", "UserRefreshBalance");
|
|
|
+ paramJson.put("content", JSONObject.parseObject("{'msg':'刷新余额'}"));
|
|
|
+
|
|
|
+ List<String> sendUsers = new ArrayList<>();
|
|
|
+ if(userIdList.size() > 500){
|
|
|
+ for(String userId : userIdList){
|
|
|
+ if(sendUsers.size() >= 500){
|
|
|
+ TencentCloudImUtil.imPushBatchSendMsg(sendUsers, paramJson.toString());
|
|
|
+ sendUsers.clear();
|
|
|
+ }
|
|
|
+ sendUsers.add(userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!sendUsers.isEmpty()){
|
|
|
+ TencentCloudImUtil.imPushBatchSendMsg(sendUsers, paramJson.toString());
|
|
|
}
|
|
|
+ }else{
|
|
|
+ TencentCloudImUtil.imPushBatchSendMsg(userIdList, paramJson.toString());
|
|
|
}
|
|
|
}
|
|
|
}
|