|
@@ -133,31 +133,26 @@ public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, App
|
|
|
lastDateStr = DateUtil.format(curDate, "yyyy-MM-dd").concat(" 00:00:00");
|
|
|
}
|
|
|
String endTimeStr = DateUtil.format(curDate,"yyyy-MM-dd HH:mm:ss");*/
|
|
|
- AppUser queryUser = new AppUser();
|
|
|
- queryUser.setAgentFlag(1);
|
|
|
- List<AppUser> list = appUserService.selectAppUserList(queryUser);//查询所有代理用户
|
|
|
- List<AppUserGameRecordCount> gameRecordCountList = appUserGameRecordCountService.selectByDate(null, null, null,gameId,gameDate);
|
|
|
List<AppGameBetting> gameBettingList = appGameBettingService.selectListByDate(null, null, null,gameId,gameDate);
|
|
|
- if (null != list && list.size() > 0) {
|
|
|
+ if (null != gameBettingList && gameBettingList.size() > 0) {
|
|
|
String finalDateTime = dateTime;
|
|
|
Date finalCurDate = curDate;
|
|
|
- list.forEach(appUser -> {
|
|
|
+ List<Long> userIds = gameBettingList.stream().map(AppGameBetting::getUserId).distinct().collect(Collectors.toList());
|
|
|
+ userIds.forEach(userId -> {
|
|
|
AppUserCount appUserCount = new AppUserCount();
|
|
|
- appUserCount.setUserId(appUser.getUserid());
|
|
|
+ appUserCount.setUserId(userId);
|
|
|
appUserCount.setStrDate(finalDateTime);
|
|
|
- appUserCount.setAgentUserId(appUser.getPid());
|
|
|
+ appUserCount.setAgentUserId(userId);
|
|
|
appUserCount.setUpdateTime(finalCurDate);
|
|
|
- //游戏佣金
|
|
|
- appUserCount.setGameCommission(gameRecordCountList.stream().filter(e -> e.getUserId().equals(appUser.getUserid())).mapToDouble(e -> e.getCommission()).sum());
|
|
|
//游戏输
|
|
|
appUserCount.setGameLoseAmount(gameBettingList.stream().filter(
|
|
|
- e -> e.getUserId().equals(appUser.getUserid()) && e.getIsWinning().intValue() == 2
|
|
|
+ e -> e.getUserId().equals(userId) && e.getIsWinning().intValue() == 2
|
|
|
).mapToDouble(e ->
|
|
|
e.getBettingAmount()
|
|
|
).sum());
|
|
|
//游戏赢
|
|
|
appUserCount.setGameWinAmount(gameBettingList.stream().filter(
|
|
|
- e -> e.getUserId().equals(appUser.getUserid()) && e.getIsWinning().intValue() == 1
|
|
|
+ e -> e.getUserId().equals(userId) && e.getIsWinning().intValue() == 1
|
|
|
).mapToDouble(e ->
|
|
|
e.getBettingAmount() * e.getBettingMultiple()
|
|
|
).sum());
|
|
@@ -193,6 +188,35 @@ public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, App
|
|
|
return DateUtil.offsetMillisecond(appUserCount.getCountTime(), 1); //往前加1毫秒用于增量更新
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void staticsUserBetting(AppGameBetting appGameBetting,List<AppGameCommission> gameRateList) {
|
|
|
+ Date curDate = DateUtils.getNowDate();
|
|
|
+ String dateTime = DateUtils.parseDateToStr("yyyy-MM-dd", curDate);
|
|
|
+
|
|
|
+ List<AppUserGameRecordCount> gameRecordCountList = appUserGameRecordCountService.selectByDate(null, null, null,appGameBetting.getGameId(),appGameBetting.getGameDate());
|
|
|
+ if (null != gameRateList && gameRateList.size() > 0) {
|
|
|
+ List<Long> userIds = gameRateList.stream().map(AppGameCommission::getUserId).collect(Collectors.toList());
|
|
|
+ userIds.add(appGameBetting.getUserId());
|
|
|
+ userIds = userIds.stream().distinct().collect(Collectors.toList());
|
|
|
+ String finalDateTime = dateTime;
|
|
|
+ Date finalCurDate = curDate;
|
|
|
+ userIds.forEach(userId -> {
|
|
|
+ AppUserCount appUserCount = new AppUserCount();
|
|
|
+ appUserCount.setUserId(userId);
|
|
|
+ appUserCount.setStrDate(finalDateTime);
|
|
|
+ appUserCount.setAgentUserId(userId);
|
|
|
+ appUserCount.setUpdateTime(finalCurDate);
|
|
|
+ //游戏佣金 更新所有用户
|
|
|
+ appUserCount.setGameCommission(gameRecordCountList.stream().filter(e -> e.getUserId().equals(userId)).mapToDouble(e -> e.getCommission()).sum());
|
|
|
+ //游戏下注金额 更新当前下注用户
|
|
|
+ if(userId.equals(appGameBetting.getUserId())) {
|
|
|
+ appUserCount.setGameBetting(appUserCount.getGameBetting() + appGameBetting.getBettingAmount());
|
|
|
+ }
|
|
|
+ this.createAppUserCount(appUserCount);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 金额为负数则转为正数
|
|
|
* */
|