Explorar el Código

修改内容:游戏数据

lth hace 1 año
padre
commit
dffca3d070

+ 68 - 7
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/GameDataServiceImpl.java

@@ -109,7 +109,7 @@ public class GameDataServiceImpl implements IGameDataService {
             dayNTotalFieldMapList = new ArrayList<>(dayNTotalFieldList.size());
             for(Field dayNTotalField : dayNTotalFieldList) {
                 dayNTotalField.setAccessible(true);
-                Field sourceField = fieldMap.get(dayNTotalField.getName().replace("Trend", ""));
+                Field sourceField = fieldTotalMap.get(dayNTotalField.getName().replace("Trend", ""));
                 sourceField.setAccessible(true);
                 if(sourceField != null) {
                     dayNTotalFieldMapList.add(Tuples.of(sourceField, dayNTotalField));
@@ -231,7 +231,7 @@ public class GameDataServiceImpl implements IGameDataService {
         dao.execute(gameDataDayTotalsql);
         //得到每日总计对象
         GameDataDayTotalVO vo = gameDataDayTotalsql.getObject(GameDataDayTotalVO.class);
-        //formatDayNTotal(vo);
+        formatDayNTotal(vo);
         return vo;
     }
 
@@ -364,6 +364,13 @@ public class GameDataServiceImpl implements IGameDataService {
             vo.setBuyNewUserAmountArpu(vo.getBuyNewUserAmountNum().compareTo(0L) == 0 ? BigDecimal.ZERO :
                     BigDecimal.valueOf(vo.getBuyNewUserAmount().doubleValue() / vo.getBuyNewUserAmountNum().doubleValue()).setScale(4, RoundingMode.HALF_UP));
 
+            //新用户回收率
+            vo.setBuyNewUserRechargeRate(vo.getCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
+                    vo.getBuyNewUserAmount().divide(vo.getCost(), 4, RoundingMode.HALF_UP));
+            //新用户充值成本
+            vo.setBuyNewUserRechargeCost(vo.getBuyNewUserAmountNum() == 0 ? BigDecimal.ZERO :
+                    vo.getCost().divide(BigDecimal.valueOf(vo.getBuyNewUserAmountNum()), 4, RoundingMode.HALF_UP));
+
             //设置自然量数据
             //新用户充值次数、金额、人数
             vo.setNatureNewUserAmount(natureDayN == null ? BigDecimal.ZERO : natureDayN.getRechargeMoney());
@@ -399,6 +406,13 @@ public class GameDataServiceImpl implements IGameDataService {
             vo.setNatureNewUserAmountArpu(vo.getNatureNewUserAmountNum().compareTo(0L) == 0 ? BigDecimal.ZERO :
                     BigDecimal.valueOf(vo.getNatureNewUserAmount().doubleValue() / vo.getNatureNewUserAmountNum().doubleValue()).setScale(4, RoundingMode.HALF_UP));
 
+            //新用户回收率
+            vo.setNatureNewUserRechargeRate(vo.getCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
+                    vo.getNatureNewUserAmount().divide(vo.getCost(), 4, RoundingMode.HALF_UP));
+            //新用户充值成本
+            vo.setNatureNewUserRechargeCost(vo.getNatureNewUserAmountNum() == 0 ? BigDecimal.ZERO :
+                    vo.getCost().divide(BigDecimal.valueOf(vo.getNatureNewUserAmountNum()), 4, RoundingMode.HALF_UP));
+
             //设置总量数据
             //新用户充值次数、金额、人数
             vo.setNewUserAmount(dayN == null ? BigDecimal.ZERO : dayN.getRechargeMoney());
@@ -434,6 +448,13 @@ public class GameDataServiceImpl implements IGameDataService {
             vo.setNewUserAmountArpu(vo.getNewUserAmountNum().compareTo(0L) == 0 ? BigDecimal.ZERO :
                     BigDecimal.valueOf(vo.getNewUserAmount().doubleValue() / vo.getNewUserAmountNum().doubleValue()).setScale(4, RoundingMode.HALF_UP));
 
+            //新用户回收率
+            vo.setNewUserRechargeRate(vo.getCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
+                    vo.getNewUserAmount().divide(vo.getCost(), 4, RoundingMode.HALF_UP));
+            //新用户充值成本
+            vo.setNewUserRechargeCost(vo.getNewUserAmountNum() == 0 ? BigDecimal.ZERO :
+                    vo.getCost().divide(BigDecimal.valueOf(vo.getNewUserAmountNum()), 4, RoundingMode.HALF_UP));
+
             return vo;
         }).collect(Collectors.toList());
 
@@ -1176,6 +1197,7 @@ public class GameDataServiceImpl implements IGameDataService {
                     buy_new_user_total_amount_count,
                     buy_new_user_total_amount_num,
                     buy_new_user_total_amount,
+                    buy_total_roi,
                     buy_first_roi,
                     buy_first_amount_rate,
                     buy_today_amount_rate,
@@ -1223,6 +1245,9 @@ public class GameDataServiceImpl implements IGameDataService {
                     buy_amount_m6,
                     buy_amount_y1,
                     buy_amount_sum,
+                    buy_reg_cost,
+                    buy_first_amount_cost as buy_first_new_user_recharge_cost,
+                    buy_total_amount_cost as buy_total_recharge_cost,
                         
                     nature_first_new_user_amount_count,
                     nature_first_new_user_amount_num,
@@ -1236,6 +1261,7 @@ public class GameDataServiceImpl implements IGameDataService {
                     nature_new_user_total_amount_count,
                     nature_new_user_total_amount_num,
                     nature_new_user_total_amount,
+                    nature_total_roi,
                     nature_first_roi,
                     nature_first_amount_rate,
                     nature_today_amount_rate,
@@ -1283,6 +1309,9 @@ public class GameDataServiceImpl implements IGameDataService {
                     nature_amount_m6,
                     nature_amount_y1,
                     nature_amount_sum,
+                    nature_reg_cost,
+                    nature_first_amount_cost as nature_first_new_user_recharge_cost,
+                    nature_total_amount_cost as nature_total_recharge_cost,
                         
                     first_new_user_amount_count,
                     first_new_user_amount_num,
@@ -1296,6 +1325,7 @@ public class GameDataServiceImpl implements IGameDataService {
                     new_user_total_amount_count,
                     new_user_total_amount_num,
                     new_user_total_amount,
+                    total_roi,
                     first_roi,
                     first_amount_rate,
                     today_amount_rate,
@@ -1342,7 +1372,10 @@ public class GameDataServiceImpl implements IGameDataService {
                     amount_m3,
                     amount_m6,
                     amount_y1,
-                    amount_sum
+                    amount_sum,
+                    reg_cost,
+                    first_amount_cost as first_new_user_recharge_cost,
+                    total_amount_cost as total_recharge_cost
                     
                 FROM
                     ads_game_day
@@ -1396,7 +1429,11 @@ public class GameDataServiceImpl implements IGameDataService {
                 round(if(SUM(buy_first_new_user_amount_num) > 0 , SUM(buy_first_new_user_amount) / SUM(buy_first_new_user_amount_num), 0), 2) buy_first_amount_arpu,
                 round(if(SUM(buy_new_user_total_amount_num) > 0 , SUM(buy_new_user_total_amount) / SUM(buy_new_user_total_amount_num), 0), 2) buy_today_amount_arpu,
                 round(if(SUM(buy_amount_num) > 0, SUM(buy_amount) / SUM(buy_amount_num), 0), 2) buy_amount_arpu,
-
+                round(if(SUM(buy_reg_num) > 0, SUM(cost) / SUM(buy_reg_num), 0), 2) buy_reg_cost,
+                round(if(SUM(buy_first_new_user_amount_num) > 0, SUM(cost) / SUM(buy_first_new_user_amount_num), 0), 2) buy_first_new_user_recharge_cost,
+                round(if(SUM(buy_new_user_total_amount_num) > 0, SUM(cost) / SUM(buy_new_user_total_amount_num), 0), 2) buy_total_recharge_cost,
+                round(if(SUM(cost) > 0, SUM(buy_new_user_total_amount) / SUM(cost), 0), 4) buy_total_roi,
+                
                 """
                 + amountDay("nature_") +
                 """
@@ -1430,6 +1467,10 @@ public class GameDataServiceImpl implements IGameDataService {
                 round(if(SUM(nature_first_new_user_amount_num) > 0 , SUM(nature_first_new_user_amount) / SUM(nature_first_new_user_amount_num), 0), 2) nature_first_amount_arpu,
                 round(if(SUM(nature_new_user_total_amount_num) > 0 , SUM(nature_new_user_total_amount) / SUM(nature_new_user_total_amount_num), 0), 2) nature_today_amount_arpu,
                 round(if(SUM(nature_amount_num) > 0, SUM(nature_amount) / SUM(nature_amount_num), 0), 2) nature_amount_arpu,
+                round(if(SUM(nature_reg_num) > 0, SUM(cost) / SUM(nature_reg_num), 0), 2) nature_reg_cost,
+                round(if(SUM(nature_first_new_user_amount_num) > 0, SUM(cost) / SUM(nature_first_new_user_amount_num), 0), 2) nature_first_new_user_recharge_cost,
+                round(if(SUM(nature_new_user_total_amount_num) > 0, SUM(cost) / SUM(nature_new_user_total_amount_num), 0), 2) nature_total_recharge_cost,
+                round(if(SUM(cost) > 0, SUM(nature_new_user_total_amount) / SUM(cost), 0), 4) nature_total_roi,
                 
                 """
                 + amountDay("") +
@@ -1463,7 +1504,11 @@ public class GameDataServiceImpl implements IGameDataService {
                 round(if(SUM(reg_num) > 0, SUM(new_user_total_amount) / SUM(reg_num), 0), 2) reg_user_arpu,
                 round(if(SUM(first_new_user_amount_num) > 0 , SUM(first_new_user_amount) / SUM(first_new_user_amount_num), 0), 2) first_amount_arpu,
                 round(if(SUM(new_user_total_amount_num) > 0 , SUM(new_user_total_amount) / SUM(new_user_total_amount_num), 0), 2) today_amount_arpu,
-                round(if(SUM(amount_num) > 0, SUM(amount) / SUM(amount_num), 0), 2) amount_arpu
+                round(if(SUM(amount_num) > 0, SUM(amount) / SUM(amount_num), 0), 2) amount_arpu,
+                round(if(SUM(reg_num) > 0, SUM(cost) / SUM(reg_num), 0), 2) reg_cost,
+                round(if(SUM(first_new_user_amount_num) > 0, SUM(cost) / SUM(first_new_user_amount_num), 0), 2) first_new_user_recharge_cost,
+                round(if(SUM(new_user_total_amount_num) > 0, SUM(cost) / SUM(new_user_total_amount_num), 0), 2) total_recharge_cost,
+                round(if(SUM(cost) > 0, SUM(new_user_total_amount) / SUM(cost), 0), 4) total_roi
                                 
                 FROM
                 ads_game_day
@@ -1483,7 +1528,7 @@ public class GameDataServiceImpl implements IGameDataService {
         String temp;
         if (type.equals("buy_")) {
             temp = "buy";
-        } else if (type.equals("nature")) {
+        } else if (type.equals("nature_")) {
             temp = "nature";
         } else {
             temp = "total";
@@ -1591,8 +1636,24 @@ public class GameDataServiceImpl implements IGameDataService {
                     
                     round(if(sum(a.reg_num) > 0 , sum(a.new_user_total_amount) / sum(a.reg_num), 0), 2) reg_user_arpu,
                     round(if(sum(a.first_new_user_amount_num) > 0 , sum(a.first_new_user_amount) / sum(a.first_new_user_amount_num), 0), 2) first_amount_arpu,
-                    round(if(sum(a.new_user_total_amount_num) > 0 , sum(a.new_user_total_amount) / sum(a.new_user_total_amount_num), 0), 2) today_amount_arpu
+                    round(if(sum(a.new_user_total_amount_num) > 0 , sum(a.new_user_total_amount) / sum(a.new_user_total_amount_num), 0), 2) today_amount_arpu,
+                    
+                    round(if(SUM(buy_reg_num) > 0, SUM(cost) / SUM(buy_reg_num), 0), 2) buy_reg_cost,
+                    round(if(SUM(nature_reg_num) > 0, SUM(cost) / SUM(nature_reg_num), 0), 2) nature_reg_cost,
+                    round(if(SUM(reg_num) > 0, SUM(cost) / SUM(reg_num), 0), 2) reg_cost,
+                    
+                    round(if(SUM(cost) > 0 , SUM(buy_new_user_total_amount) / SUM(cost), 0), 4) buy_total_roi,
+                    round(if(SUM(cost) > 0 , SUM(nature_new_user_total_amount) / SUM(cost), 0), 4) nature_total_roi,
+                    round(if(SUM(cost) > 0 , SUM(new_user_total_amount) / SUM(cost), 0), 4) total_roi,
+                    
+                    round(if(SUM(buy_first_new_user_amount_num) > 0, SUM(cost) / SUM(buy_first_new_user_amount_num), 0), 2) buy_first_new_user_recharge_cost,
+                    round(if(SUM(nature_first_new_user_amount_num) > 0, SUM(cost) / SUM(nature_first_new_user_amount_num), 0), 2) nature_first_new_user_recharge_cost,
+                    round(if(SUM(first_new_user_amount_num) > 0, SUM(cost) / SUM(first_new_user_amount_num), 0), 2) first_new_user_recharge_cost,
                     
+                    round(if(SUM(buy_new_user_total_amount_num) > 0, SUM(cost) / SUM(buy_new_user_total_amount_num), 0), 2) buy_total_recharge_cost,
+                    round(if(SUM(nature_new_user_total_amount_num) > 0, SUM(cost) / SUM(nature_new_user_total_amount_num), 0), 2) nature_total_recharge_cost,
+                    round(if(SUM(new_user_total_amount_num) > 0, SUM(cost) / SUM(new_user_total_amount_num), 0), 2) total_recharge_cost
+                   
                 FROM
                     ads_game_day a
                 """;