ソースを参照

修改分佣统计逻辑

dos 3 ヶ月 前
コミット
70ab5ee626

+ 1 - 1
game-business/src/main/java/com/game/business/service/IAppUserCountService.java

@@ -33,7 +33,7 @@ public interface IAppUserCountService extends IService<AppUserCount> {
 
     public Date selectGameLastDate(Long userId);
 
-    public void staticsUserBetting(AppGameBetting appGameBetting,List<AppGameCommission> gameRateList);
+    public void staticsUserBetting(AppGameBetting appGameBetting,List<AppUserGameRecordCount>  recordCountList);
 
     /**
      * 查询用户代理统计

+ 14 - 13
game-business/src/main/java/com/game/business/service/impl/AppUserCountServiceImpl.java

@@ -224,8 +224,8 @@ public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, App
     }
 
     @Override
-    public void staticsUserBetting(AppGameBetting appGameBetting,List<AppGameCommission> gameRateList) {
-        synchronized (CacheConstants.USER_GAME_RECORD_COUNT.concat(String.valueOf(appGameBetting.getGameId())).concat(appGameBetting.getGameDate())) {
+    public void staticsUserBetting(AppGameBetting appGameBetting,List<AppUserGameRecordCount>  recordCountList) {
+//        synchronized (CacheConstants.USER_GAME_RECORD_COUNT.concat(String.valueOf(appGameBetting.getGameId())).concat(appGameBetting.getGameDate())) {
             Date curDate = DateUtils.getNowDate();
             String dateTime = DateUtils.parseDateToStr("yyyy-MM-dd", curDate);
     /*List<Long> userIds = gameRateList.stream().map(AppGameCommission::getUserId).collect(Collectors.toList());
@@ -233,36 +233,37 @@ public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, App
                     userIds = userIds.stream().distinct().collect(Collectors.toList());*/
             //        List<AppUserGameRecordCount> gameRecordCountList = appUserGameRecordCountService.selectByDate(null, null, null,appGameBetting.getGameId(),appGameBetting.getGameDate());
 
-            if (null != gameRateList && gameRateList.size() > 0) {
+            if (null != recordCountList && recordCountList.size() > 0) {
 
                 String finalDateTime = dateTime;
                 Date finalCurDate = curDate;
                 List<Long> userIds = new ArrayList<>();
-                gameRateList.forEach(gameRate -> {
+                recordCountList.forEach(gameRate -> {
                     Long userId = gameRate.getUserId();
-                    //用户最后一次更新时间
+                    /*//用户最后一次更新时间
                     Date updateTime = this.selectGameLastDate(userId);
                     if (!DateUtil.format(updateTime, "yyyy-MM-dd").equals(DateUtil.format(finalCurDate, "yyyy-MM-dd"))) {
                         //跨天直接从当日零点开始统计
                         updateTime = DateUtil.beginOfDay(finalCurDate);
-                    }
+                    }*/
                     //查询用户返佣
-                    List<AppUserGameRecordCount> gameRecordCountList = appUserGameRecordCountService.selectByDate(userId, DateUtil.format(updateTime, "yyyy-MM-dd HH:mm:ss"), DateUtil.format(finalCurDate, "yyyy-MM-dd HH:mm:ss"), gameRate.getGameId(), appGameBetting.getGameDate());
+//                    List<AppUserGameRecordCount> gameRecordCountList = appUserGameRecordCountService.selectByDate(userId, DateUtil.format(updateTime, "yyyy-MM-dd HH:mm:ss"), DateUtil.format(finalCurDate, "yyyy-MM-dd HH:mm:ss"), gameRate.getGameId(), appGameBetting.getGameDate());
                     userIds.add(userId);
                     AppUserCount appUserCount = new AppUserCount();
                     appUserCount.setUserId(userId);
                     appUserCount.setStrDate(finalDateTime);
-                    appUserCount.setAgentUserId(gameRateList.stream().filter(e -> e.getUserId().equals(userId)).map(AppGameCommission::getPid).collect(Collectors.toList()).get(0));
+                    appUserCount.setAgentUserId(gameRate.getPid());
                     appUserCount.setUpdateTime(finalCurDate);
                     appUserCount.setGameCountTime(finalCurDate);
-                    if (null != gameRecordCountList && gameRecordCountList.size() > 0) {
+//                    if (null != gameRecordCountList && gameRecordCountList.size() > 0) {
                         //游戏佣金
-                        Map<String, Double> map = redisCache.getCacheMap(CacheConstants.USER_GAME_RECORD_COUNT.concat(String.valueOf(userId)));
+                        /*Map<String, Double> map = redisCache.getCacheMap(CacheConstants.USER_GAME_RECORD_COUNT.concat(String.valueOf(userId)));
                         appUserCount.setGameCommission(gameRecordCountList.stream().filter(e -> {
                             return null == map || null == map.get(String.valueOf(e.getId())); //过滤已统计过的id
                         }).mapToDouble(e -> e.getCommission()).sum());
-                        setGameCache(gameRecordCountList);
-                    }
+                        setGameCache(gameRecordCountList);*/
+                    appUserCount.setGameCommission(gameRate.getCommission());
+//                    }
                     //游戏下注金额 更新当前下注用户 (非金币)
                     if (userId.equals(appGameBetting.getUserId()) && appGameBetting.getBettingType().intValue() == 0) {
                         appUserCount.setGameBetting(appGameBetting.getBettingAmount());
@@ -272,7 +273,7 @@ public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, App
                 //更新周盈亏数据
                 appUserCountDividendService.reloadCache(null, userIds);
             }
-        }
+//        }
     }
 
     @Override

+ 10 - 8
game-business/src/main/java/com/game/business/task/AppAgentGameBettingTask.java

@@ -63,20 +63,22 @@ public class AppAgentGameBettingTask {
 
         getGameRate(appGameBetting.getGameId(), userAgent.getPid(), userAgent.getUserId(), gameRateList);
         if(gameRateList.isEmpty()){
-            //统计游戏下注、返佣情况
-            AppGameCommission appGameCommission = new AppGameCommission();
-            appGameCommission.setUserId(appGameBetting.getUserId());
-            appGameCommission.setPid(userAgent.getPid());
-            appGameCommission.setGameRate(0L);
-            gameRateList.add(appGameCommission);
-            appUserCountService.staticsUserBetting(appGameBetting,gameRateList);
+            List<AppUserGameRecordCount>  recordCountList = new ArrayList<>();
+            AppUserGameRecordCount recordCount = new AppUserGameRecordCount();
+            recordCount.setGameId(appGameBetting.getGameId());
+            recordCount.setUserId(appGameBetting.getUserId());
+            recordCount.setPid(userAgent.getPid());
+            recordCount.setCommission(0.00);
+            recordCount.setGameRate(0.00);
+            recordCountList.add(recordCount);
+            appUserCountService.staticsUserBetting(appGameBetting,recordCountList);
             return;
         }
 
         List<AppUserGameRecordCount>  recordCountList = commissionHandler(gameRateList, appGameBetting);
 
         //统计游戏下注、返佣情况
-        appUserCountService.staticsUserBetting(appGameBetting,gameRateList);
+        appUserCountService.staticsUserBetting(appGameBetting,recordCountList);
 
     }