Ver código fonte

Merge remote-tracking branch 'origin/package-data' into package-data

shishaosong 1 ano atrás
pai
commit
12d4b20bca

+ 7 - 4
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/controller/AdsOverallSummaryController.java

@@ -1,5 +1,6 @@
 package com.zanxiang.game.data.serve.controller;
 package com.zanxiang.game.data.serve.controller;
 
 
+import com.zanxiang.erp.security.annotation.PreAuthorize;
 import com.zanxiang.game.data.serve.pojo.vo.AdsOverallSummaryLineDataVO;
 import com.zanxiang.game.data.serve.pojo.vo.AdsOverallSummaryLineDataVO;
 import com.zanxiang.game.data.serve.pojo.param.AdsOverallSummaryParam;
 import com.zanxiang.game.data.serve.pojo.param.AdsOverallSummaryParam;
 import com.zanxiang.game.data.serve.pojo.vo.AdsOverallSummaryVO;
 import com.zanxiang.game.data.serve.pojo.vo.AdsOverallSummaryVO;
@@ -33,14 +34,16 @@ public class AdsOverallSummaryController {
     private IAdsOverallSummaryService adsOverallSummaryService;
     private IAdsOverallSummaryService adsOverallSummaryService;
 
 
     @ApiOperation(value = "获取整体概况数据")
     @ApiOperation(value = "获取整体概况数据")
-    @PostMapping("/data")
+    @PreAuthorize(permissionKey = "gameData:adsOverallSummary:totalData")
+    @PostMapping("/totalData")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = AdsOverallSummaryVO.class)})
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = AdsOverallSummaryVO.class)})
-    public ResultVO<AdsOverallSummaryVO> getOverallSummaryData(@RequestBody AdsOverallSummaryParam param) {
-        return ResultVO.ok(adsOverallSummaryService.getOverallSummaryData(param));
+    public ResultVO<AdsOverallSummaryVO> getOverallSummaryTotalData(@RequestBody AdsOverallSummaryParam param) {
+        return ResultVO.ok(adsOverallSummaryService.getOverallSummaryTotalData(param));
     }
     }
 
 
     @ApiOperation(value = "获取折线图数据")
     @ApiOperation(value = "获取折线图数据")
-    @PostMapping("/linedata")
+    @PreAuthorize(permissionKey = "gameData:adsOverallSummary:lineData")
+    @PostMapping("/lineData")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = AdsOverallSummaryLineDataVO.class, responseContainer = "list")})
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = AdsOverallSummaryLineDataVO.class, responseContainer = "list")})
     public ResultVO<List<AdsOverallSummaryLineDataVO>> getOverallSummaryLineData(@RequestBody AdsOverallSummaryParam param) {
     public ResultVO<List<AdsOverallSummaryLineDataVO>> getOverallSummaryLineData(@RequestBody AdsOverallSummaryParam param) {
         return ResultVO.ok(adsOverallSummaryService.getOverallSummaryLineData(param));
         return ResultVO.ok(adsOverallSummaryService.getOverallSummaryLineData(param));

+ 1 - 1
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/IAdsOverallSummaryService.java

@@ -8,7 +8,7 @@ import java.util.List;
 
 
 public interface IAdsOverallSummaryService {
 public interface IAdsOverallSummaryService {
 
 
-    AdsOverallSummaryVO getOverallSummaryData(AdsOverallSummaryParam param);
+    AdsOverallSummaryVO getOverallSummaryTotalData(AdsOverallSummaryParam param);
 
 
     List<AdsOverallSummaryLineDataVO> getOverallSummaryLineData(AdsOverallSummaryParam param);
     List<AdsOverallSummaryLineDataVO> getOverallSummaryLineData(AdsOverallSummaryParam param);
 }
 }

+ 52 - 52
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/AdsOverallSummaryServiceImpl.java

@@ -39,21 +39,23 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
     private Dao dao;
     private Dao dao;
 
 
     @Override
     @Override
-    public AdsOverallSummaryVO getOverallSummaryData(AdsOverallSummaryParam param) {
+    public AdsOverallSummaryVO getOverallSummaryTotalData(AdsOverallSummaryParam param) {
 
 
         //获取查询条件 整体数据查询 不需要日期
         //获取查询条件 整体数据查询 不需要日期
         Condition totalDataCon = myCondition(param, false, -1);
         Condition totalDataCon = myCondition(param, false, -1);
         //查询条件转换为sql语句 设置映射 Entity为 AdsOverallSummary对象
         //查询条件转换为sql语句 设置映射 Entity为 AdsOverallSummary对象
         String totalDataConString = totalDataCon.toSql(dao.getEntity(AdsOverallSummary.class));
         String totalDataConString = totalDataCon.toSql(dao.getEntity(AdsOverallSummary.class));
         //自定义sql语句
         //自定义sql语句
-        Sql totalDataSql = Sqls.create("SELECT \n" +
-                "IFNULL(SUM(x.today_player_count),0) total_players ,\n" +
-                "IFNULL(SUM(x.today_total_cost),0) total_cost ,\n" +
-                "IFNULL(SUM(x.today_amount),0) total_amount ,\n" +
-                "IFNULL(SUM(x.today_agent_count),0) total_agent_count ,\n" +
-                "IFNULL(SUM(x.today_game_count),0) total_game_count ,\n" +
-                "IFNULL(SUM(x.today_new_player_amount)/SUM(x.today_total_cost),0) total_roi \n" +
-                "FROM ads_overall_summary x " + totalDataConString);
+        Sql totalDataSql = Sqls.create("""
+                SELECT
+                IFNULL(SUM(x.today_player_count),0) total_players ,
+                IFNULL(SUM(x.today_total_cost),0) total_cost ,
+                IFNULL(SUM(x.today_amount),0) total_amount ,
+                IFNULL(SUM(x.today_agent_count),0) total_agent_count ,
+                IFNULL(SUM(x.today_game_count),0) total_game_count ,
+                IFNULL(SUM(x.today_new_player_amount)/SUM(x.today_total_cost),0) total_roi
+                FROM ads_overall_summary x
+                """ + totalDataConString);
 
 
         //自定义回显对象 结果自动封装到给定的Entity对象中
         //自定义回显对象 结果自动封装到给定的Entity对象中
         totalDataSql.setCallback(Sqls.callback.entity());
         totalDataSql.setCallback(Sqls.callback.entity());
@@ -67,21 +69,23 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
         Condition todayDataCon = myCondition(param, false, 1);
         Condition todayDataCon = myCondition(param, false, 1);
         //查询条件转换为sql语句 设置映射 Entity为 AdsOverallSummary对象
         //查询条件转换为sql语句 设置映射 Entity为 AdsOverallSummary对象
         String todayDataConString = todayDataCon.toSql(dao.getEntity(AdsOverallSummary.class));
         String todayDataConString = todayDataCon.toSql(dao.getEntity(AdsOverallSummary.class));
-        Sql todayDataSql = Sqls.create("SELECT  \n" +
-                "IFNULL(SUM(x.today_player_count),0) today_player_count ,\n" +
-                "IFNULL(SUM(x.yesterday_player_count),0) yesterday_player_count ,\n" +
-                "IFNULL(SUM(x.today_total_cost),0) today_total_cost ,\n" +
-                "IFNULL(SUM(x.yesterday_total_cost),0) yesterday_total_cost ,\n" +
-                "IFNULL(SUM(x.today_new_player_amount),0) today_new_player_amount ,\n" +
-                "IFNULL(SUM(x.today_amount),0) today_amount ,\n" +
-                "IFNULL(SUM(x.yesterday_new_player_amount),0) yesterday_new_player_amount ,\n" +
-                "IFNULL(SUM(x.yesterday_amount),0) yesterday_amount ,\n" +
-                "IFNULL(SUM(x.today_agent_count),0) today_agent_count ,\n" +
-                "IFNULL(SUM(x.yesterday_agent_count),0) yesterday_agent_count ,\n" +
-                "IFNULL(SUM(x.today_game_count),0) today_game_count ,\n" +
-                "IFNULL(SUM(x.yesterday_game_count),0) yesterday_game_count ,\n" +
-                "IFNULL(SUM(x.first_new_user_amount)/SUM(x.today_total_cost),0) first_roi \n" +
-                "FROM ads_overall_summary x" + todayDataConString);
+        Sql todayDataSql = Sqls.create("""
+                SELECT
+                IFNULL(SUM(x.today_player_count),0) today_player_count ,
+                IFNULL(SUM(x.yesterday_player_count),0) yesterday_player_count ,
+                IFNULL(SUM(x.today_total_cost),0) today_total_cost ,
+                IFNULL(SUM(x.yesterday_total_cost),0) yesterday_total_cost ,
+                IFNULL(SUM(x.today_new_player_amount),0) today_new_player_amount ,
+                IFNULL(SUM(x.today_amount),0) today_amount ,
+                IFNULL(SUM(x.yesterday_new_player_amount),0) yesterday_new_player_amount ,
+                IFNULL(SUM(x.yesterday_amount),0) yesterday_amount ,
+                IFNULL(SUM(x.today_agent_count),0) today_agent_count ,
+                IFNULL(SUM(x.yesterday_agent_count),0) yesterday_agent_count ,
+                IFNULL(SUM(x.today_game_count),0) today_game_count ,
+                IFNULL(SUM(x.yesterday_game_count),0) yesterday_game_count ,
+                IFNULL(SUM(x.first_new_user_amount)/SUM(x.today_total_cost),0) first_roi
+                FROM ads_overall_summary x
+                """ + todayDataConString);
 
 
         //自定义回显对象 结果自动封装到给定的Entity对象中
         //自定义回显对象 结果自动封装到给定的Entity对象中
         todayDataSql.setCallback(Sqls.callback.entity());
         todayDataSql.setCallback(Sqls.callback.entity());
@@ -99,15 +103,16 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
         BigDecimal d7NewPlayerAmount = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayNewPlayerAmount", myCondition(param, false, 7));
         BigDecimal d7NewPlayerAmount = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayNewPlayerAmount", myCondition(param, false, 7));
         //7日内总消耗
         //7日内总消耗
         BigDecimal d7TotalCost = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayTotalCost", myCondition(param, false, 7));
         BigDecimal d7TotalCost = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayTotalCost", myCondition(param, false, 7));
-        //计算7日Roi
-        adsOverallSummaryVO.setD7TotalRoi(BigDecimal.ZERO.equals(d7TotalCost) ? BigDecimal.ZERO : d7NewPlayerAmount.divide(d7TotalCost, 4, RoundingMode.HALF_UP));
+        //cost 查询出的结果为null或者为0.00 设置为默认值0
+        adsOverallSummaryVO.setD7TotalRoi((d7TotalCost == null || BigDecimal.ZERO.compareTo(d7TotalCost) == 0) ? BigDecimal.ZERO : d7NewPlayerAmount.divide(d7TotalCost, 4, RoundingMode.HALF_UP));
 
 
         //30日内新用户累计充值
         //30日内新用户累计充值
         BigDecimal d30NewPlayerAmount = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayNewPlayerAmount", myCondition(param, false, 30));
         BigDecimal d30NewPlayerAmount = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayNewPlayerAmount", myCondition(param, false, 30));
         //30日内总消耗
         //30日内总消耗
-        BigDecimal d30TotalCost = (BigDecimal)dao.func2(AdsOverallSummary.class, "sum", "todayTotalCost", myCondition(param, false, 30));
+        BigDecimal d30TotalCost = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayTotalCost", myCondition(param, false, 30));
         //计算30日Roi
         //计算30日Roi
-        adsOverallSummaryVO.setD30TotalRoi(BigDecimal.ZERO.equals(d30TotalCost) ? BigDecimal.ZERO : d30NewPlayerAmount.divide(d30TotalCost, 4, RoundingMode.HALF_UP));
+        //cost 查询出的结果为null或者为0.00 设置为默认值0
+        adsOverallSummaryVO.setD30TotalRoi((d30TotalCost == null || BigDecimal.ZERO.compareTo(d30TotalCost) == 0) ? BigDecimal.ZERO : d30NewPlayerAmount.divide(d30TotalCost, 4, RoundingMode.HALF_UP));
 
 
         return adsOverallSummaryVO;
         return adsOverallSummaryVO;
     }
     }
@@ -119,16 +124,18 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
         Condition lineCon = myCondition(param, true, -1);
         Condition lineCon = myCondition(param, true, -1);
         //查询条件变为字符串
         //查询条件变为字符串
         String lineConString = lineCon.toSql(dao.getEntity(AdsOverallSummary.class));
         String lineConString = lineCon.toSql(dao.getEntity(AdsOverallSummary.class));
-
         //自定义sql语句 加上条件字符串
         //自定义sql语句 加上条件字符串
-        Sql sql = Sqls.create("Select dt," +
-                "SUM(x.today_total_cost) cost, " +
-                "SUM(x.today_amount) amount, " +
-                "SUM(x.today_buy_amount) buy_amount," +
-                "SUM(x.today_nature_amount) nature_amount, " +
-                "IFNULL(SUM(x.first_new_user_amount)/SUM(x.today_total_cost),0) first_roi," +
-                "SUM(x.today_player_count) player_account " +
-                "from ads_overall_summary x " + lineConString);
+        Sql sql = Sqls.create("""
+                Select
+                dt,
+                SUM(x.today_total_cost) cost,
+                SUM(x.today_amount) amount,
+                SUM(x.today_buy_amount) buy_amount,
+                SUM(x.today_nature_amount) nature_amount,
+                IFNULL(SUM(x.first_new_user_amount)/SUM(x.today_total_cost),0) first_roi,
+                SUM(x.today_player_count) player_account
+                from ads_overall_summary x
+                """ + lineConString);
 
 
         //自定义回显对象 结果自动添加到一个List中 List<Entity>
         //自定义回显对象 结果自动添加到一个List中 List<Entity>
         sql.setCallback(Sqls.callback.entities());
         sql.setCallback(Sqls.callback.entities());
@@ -171,6 +178,7 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
         }
         }
 
 
         /*
         /*
+         * 普通用户只能查看自己的相关信息 默认传入的param里含有投手ID
          * 如果是组长 则需要排除掉 pitcher = -2 的所有数据
          * 如果是组长 则需要排除掉 pitcher = -2 的所有数据
          * cri.where().andNotEquals("pithcerId", -2);
          * cri.where().andNotEquals("pithcerId", -2);
          * 如果是管理员账号 则不需要排除 pitcher = -2 的数据
          * 如果是管理员账号 则不需要排除 pitcher = -2 的数据
@@ -178,20 +186,11 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
 
 
         //根据参数拼接条件
         //根据参数拼接条件
         switch (queryDays) {
         switch (queryDays) {
-            case 1:
-                cri.where().andEquals("dt", LocalDate.now());
-                break;
-
-            case 7:
-                cri.where().andBetween("dt", LocalDate.now().minusDays(7), LocalDate.now());
-                break;
-
-            case 30:
-                cri.where().andBetween("dt", LocalDate.now().minusDays(30), LocalDate.now());
-                break;
-
-            default:
-                break;
+            case 1 -> cri.where().andEquals("dt", LocalDate.now());
+            case 7 -> cri.where().andBetween("dt", LocalDate.now().minusDays(7), LocalDate.now());
+            case 30 -> cri.where().andBetween("dt", LocalDate.now().minusDays(30), LocalDate.now());
+            default -> {
+            }
         }
         }
 
 
         //折线数据需要拼接时间查询条件
         //折线数据需要拼接时间查询条件
@@ -242,6 +241,7 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
             }
             }
         }
         }
         String[] notNullField = new String[notNullFieldSet.size()];
         String[] notNullField = new String[notNullFieldSet.size()];
+
         return notNullFieldSet.toArray(notNullField);
         return notNullFieldSet.toArray(notNullField);
     }
     }
 
 
@@ -249,7 +249,7 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
      * 检查前端查询日期内的数据是否在数据库中都存在
      * 检查前端查询日期内的数据是否在数据库中都存在
      * 不存在要设置默认值 0
      * 不存在要设置默认值 0
      *
      *
-     * @param list 需要判断的list
+     * @param list  需要判断的list
      * @param param 前端传递的查询参数实体
      * @param param 前端传递的查询参数实体
      * @return 返回给前端的折线图数据 list
      * @return 返回给前端的折线图数据 list
      */
      */