瀏覽代碼

修改内容:游戏数据

lth 1 年之前
父節點
當前提交
b0e845cc5a

+ 2 - 3
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/controller/GameDataController.java

@@ -1,6 +1,5 @@
 package com.zanxiang.game.data.serve.controller;
 
-import com.zanxiang.erp.security.annotation.PreAuthorize;
 import com.zanxiang.game.data.serve.pojo.dto.GameDataDayDTO;
 import com.zanxiang.game.data.serve.pojo.dto.GameDataTotalDTO;
 import com.zanxiang.game.data.serve.pojo.vo.GameDataDayVO;
@@ -34,7 +33,7 @@ public class GameDataController {
     private IGameDataService gameDataService;
 
     @ApiOperation(value = "游戏每日数据")
-    @PreAuthorize(permissionKey = "gameData:adsGameDay:day")
+    //@PreAuthorize(permissionKey = "gameData:adsGameDay:day")
     @PostMapping("/day")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameDataDayVO.class)})
     public ResultVO<Page<GameDataDayVO>> getGameDataDay(@RequestBody GameDataDayDTO dto) {
@@ -43,7 +42,7 @@ public class GameDataController {
 
 
     @ApiOperation(value = "游戏总数据")
-    @PreAuthorize(permissionKey = "gameData:adsGameDay:total")
+    //@PreAuthorize(permissionKey = "gameData:adsGameDay:total")
     @PostMapping("/total")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameDataTotalVO.class)})
     public ResultVO<Page<GameDataTotalVO>> getGameDataTotal(@RequestBody GameDataTotalDTO dto) {

+ 3 - 3
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/GameDataDayVO.java

@@ -145,7 +145,7 @@ public class GameDataDayVO {
      * 新用户付费比(买量)
      */
     @ApiModelProperty(value = "新用户付费比(买量)")
-    private BigDecimal buyNewRate;
+    private BigDecimal buyNewUserRate;
 
     /**
      * 首日客单价(买量)
@@ -283,7 +283,7 @@ public class GameDataDayVO {
      * 新用户付费比(自然量)
      */
     @ApiModelProperty(value = "新用户付费比(自然量)")
-    private BigDecimal natureNewRate;
+    private BigDecimal natureNewUserRate;
 
     /**
      * 首日客单价(自然量)
@@ -421,7 +421,7 @@ public class GameDataDayVO {
      * 新用户付费比(总量)
      */
     @ApiModelProperty(value = "新用户付费比(总量)")
-    private BigDecimal newRate;
+    private BigDecimal newUserRate;
 
     /**
      * 首日客单价(总量)

+ 144 - 143
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/GameDataTotalVO.java

@@ -49,6 +49,24 @@ public class GameDataTotalVO {
     @ApiModelProperty(value = "注册人数(总量)")
     private BigInteger regNum;
 
+    /**
+     * 新用户充值次数(买量)
+     */
+    @ApiModelProperty(value = "新用户充值次数(买量)")
+    private BigInteger buyNewUserAmountCount;
+
+    /**
+     * 新用户充值人数(买量)
+     */
+    @ApiModelProperty(value = "新用户充值人数(买量)")
+    private BigInteger buyNewUserAmountNum;
+
+    /**
+     * 新用户充值金额(买量)
+     */
+    @ApiModelProperty(value = "新用户充值金额(买量)")
+    private BigDecimal buyNewUserAmount;
+
     /**
      * 首日新用户充值次数(买量)
      */
@@ -133,11 +151,17 @@ public class GameDataTotalVO {
     @ApiModelProperty(value = "当天付费率(买量)")
     private BigDecimal buyTodayRoi;
 
+    /**
+     * 新用户付费率(买量)
+     */
+    @ApiModelProperty(value = "新用户付费率(买量)")
+    private BigDecimal buyNewUserRoi;
+
     /**
      * 新用户付费比(买量)
      */
     @ApiModelProperty(value = "新用户付费比(买量)")
-    private BigDecimal buyNewRate;
+    private BigDecimal buyNewUserRate;
 
     /**
      * 首日客单价(买量)
@@ -157,12 +181,30 @@ public class GameDataTotalVO {
     @ApiModelProperty(value = "账面客单价(买量)")
     private BigDecimal buyAvgAmount;
 
+    /**
+     * 新用户客单价(买量)
+     */
+    @ApiModelProperty(value = "新用户客单价(买量)")
+    private BigDecimal buyNewUserAvgAmount;
+
     /**
      * 复充率(买量)
      */
     @ApiModelProperty(value = "复充率(买量)")
     private BigDecimal buyUserAgainRate;
 
+    /**
+     * 新用户复充率(买量)
+     */
+    @ApiModelProperty(value = "新用户复充率(买量)")
+    private BigDecimal buyNewUserAgainRate;
+
+    /**
+     * 当天复充率(买量)
+     */
+    @ApiModelProperty(value = "当天复充率(买量)")
+    private BigDecimal buyTodayAgainRate;
+
     /**
      * 新增注册ARPU(买量)
      */
@@ -187,6 +229,30 @@ public class GameDataTotalVO {
     @ApiModelProperty(value = "账面ARPU(买量)")
     private BigDecimal buyAmountArpu;
 
+    /**
+     * 新用户付费ARPU(买量)
+     */
+    @ApiModelProperty(value = "新用户付费ARPU(买量)")
+    private BigDecimal buyNewUserAmountArpu;
+
+    /**
+     * 新用户充值次数(自然量)
+     */
+    @ApiModelProperty(value = "新用户充值次数(自然量)")
+    private BigInteger natureNewUserAmountCount;
+
+    /**
+     * 新用户充值人数(自然量)
+     */
+    @ApiModelProperty(value = "新用户充值人数(自然量)")
+    private BigInteger natureNewUserAmountNum;
+
+    /**
+     * 新用户充值金额(自然量)
+     */
+    @ApiModelProperty(value = "新用户充值金额(自然量)")
+    private BigDecimal natureNewUserAmount;
+
     /**
      * 首日新用户充值次数(自然量)
      */
@@ -271,11 +337,17 @@ public class GameDataTotalVO {
     @ApiModelProperty(value = "当天付费率(自然量)")
     private BigDecimal natureTodayRoi;
 
+    /**
+     * 新用户付费率(自然量)
+     */
+    @ApiModelProperty(value = "新用户付费率(自然量)")
+    private BigDecimal natureNewUserRoi;
+
     /**
      * 新用户付费比(自然量)
      */
     @ApiModelProperty(value = "新用户付费比(自然量)")
-    private BigDecimal natureNewRate;
+    private BigDecimal natureNewUserRate;
 
     /**
      * 首日客单价(自然量)
@@ -295,12 +367,30 @@ public class GameDataTotalVO {
     @ApiModelProperty(value = "账面客单价(自然量)")
     private BigDecimal natureAvgAmount;
 
+    /**
+     * 新用户客单价(自然量)
+     */
+    @ApiModelProperty(value = "新用户客单价(自然量)")
+    private BigDecimal natureNewUserAvgAmount;
+
     /**
      * 复充率(自然量)
      */
     @ApiModelProperty(value = "复充率(自然量)")
     private BigDecimal natureUserAgainRate;
 
+    /**
+     * 新用户复充率(自然量)
+     */
+    @ApiModelProperty(value = "新用户复充率(自然量)")
+    private BigDecimal natureNewUserAgainRate;
+
+    /**
+     * 当天复充率(自然量)
+     */
+    @ApiModelProperty(value = "当天复充率(自然量)")
+    private BigDecimal natureTodayAgainRate;
+
     /**
      * 新增注册ARPU(自然量)
      */
@@ -325,6 +415,30 @@ public class GameDataTotalVO {
     @ApiModelProperty(value = "账面ARPU(自然量)")
     private BigDecimal natureAmountArpu;
 
+    /**
+     * 新用户付费ARPU(自然量)
+     */
+    @ApiModelProperty(value = "新用户付费ARPU(自然量)")
+    private BigDecimal natureNewUserAmountArpu;
+
+    /**
+     * 新用户充值次数(总量)
+     */
+    @ApiModelProperty(value = "新用户充值次数(总量)")
+    private BigInteger newUserAmountCount;
+
+    /**
+     * 新用户充值人数(总量)
+     */
+    @ApiModelProperty(value = "新用户充值人数(总量)")
+    private BigInteger newUserAmountNum;
+
+    /**
+     * 新用户充值金额(总量)
+     */
+    @ApiModelProperty(value = "新用户充值金额(总量)")
+    private BigDecimal newUserAmount;
+
     /**
      * 首日新用户充值次数(总量)
      */
@@ -409,11 +523,17 @@ public class GameDataTotalVO {
     @ApiModelProperty(value = "当天付费率(总量)")
     private BigDecimal todayRoi;
 
+    /**
+     * 新用户付费率(总量)
+     */
+    @ApiModelProperty(value = "新用户付费率(总量)")
+    private BigDecimal newUserRoi;
+
     /**
      * 新用户付费比(总量)
      */
     @ApiModelProperty(value = "新用户付费比(总量)")
-    private BigDecimal newRate;
+    private BigDecimal newUserRate;
 
     /**
      * 首日客单价(总量)
@@ -433,12 +553,30 @@ public class GameDataTotalVO {
     @ApiModelProperty(value = "账面客单价(总量)")
     private BigDecimal avgAmount;
 
+    /**
+     * 新用户客单价(总量)
+     */
+    @ApiModelProperty(value = "新用户客单价(总量)")
+    private BigDecimal newUserAvgAmount;
+
     /**
      * 复充率(总量)
      */
     @ApiModelProperty(value = "复充率(总量)")
     private BigDecimal userAgainRate;
 
+    /**
+     * 新用户复充率(总量)
+     */
+    @ApiModelProperty(value = "新用户复充率(总量)")
+    private BigDecimal newUserAgainRate;
+
+    /**
+     * 当天复充率(总量)
+     */
+    @ApiModelProperty(value = "当天复充率(总量)")
+    private BigDecimal todayAgainRate;
+
     /**
      * 新增注册ARPU(总量)
      */
@@ -464,146 +602,9 @@ public class GameDataTotalVO {
     private BigDecimal amountArpu;
 
     /**
-     * 付费趋势:1天(买量)
+     * 新用户付费ARPU(总量)
      */
-    @ApiModelProperty(value = "付费趋势:1天(买量)")
-    private String buyAmountD1;
+    @ApiModelProperty(value = "新用户付费ARPU(总量)")
+    private BigDecimal newUserAmountArpu;
 
-    /**
-     * 付费趋势:3天(买量)
-     */
-    @ApiModelProperty(value = "付费趋势:3天(买量)")
-    private String buyAmountD3;
-
-    /**
-     * 付费趋势:7天(买量)
-     */
-    @ApiModelProperty(value = "付费趋势:7天(买量)")
-    private String buyAmountD7;
-
-    /**
-     * 付费趋势:15天(买量)
-     */
-    @ApiModelProperty(value = "付费趋势:15天(买量)")
-    private String buyAmountD15;
-
-    /**
-     * 付费趋势:1个月(买量)
-     */
-    @ApiModelProperty(value = "付费趋势:1个月(买量)")
-    private String buyAmountM1;
-
-    /**
-     * 付费趋势:2个月(买量)
-     */
-    @ApiModelProperty(value = "付费趋势:2个月(买量)")
-    private String buyAmountM2;
-
-    /**
-     * 付费趋势:3个月(买量)
-     */
-    @ApiModelProperty(value = "付费趋势:3个月(买量)")
-    private String buyAmountM3;
-
-    /**
-     * 付费趋势:总(买量)
-     */
-    @ApiModelProperty(value = "付费趋势:总(买量)")
-    private String buyAmountSum;
-
-    /**
-     * 付费趋势:1天(自然量)
-     */
-    @ApiModelProperty(value = "付费趋势:1天(自然量)")
-    private String natureAmountD1;
-
-    /**
-     * 付费趋势:3天(自然量)
-     */
-    @ApiModelProperty(value = "付费趋势:3天(自然量)")
-    private String natureAmountD3;
-
-    /**
-     * 付费趋势:7天(自然量)
-     */
-    @ApiModelProperty(value = "付费趋势:7天(自然量)")
-    private String natureAmountD7;
-
-    /**
-     * 付费趋势:15天(自然量)
-     */
-    @ApiModelProperty(value = "付费趋势:15天(自然量)")
-    private String natureAmountD15;
-
-    /**
-     * 付费趋势:1个月(自然量)
-     */
-    @ApiModelProperty(value = "付费趋势:1个月(自然量)")
-    private String natureAmountM1;
-
-    /**
-     * 付费趋势:2个月(自然量)
-     */
-    @ApiModelProperty(value = "付费趋势:2个月(自然量)")
-    private String natureAmountM2;
-
-    /**
-     * 付费趋势:3个月(自然量)
-     */
-    @ApiModelProperty(value = "付费趋势:3个月(自然量)")
-    private String natureAmountM3;
-
-    /**
-     * 付费趋势:总(自然量)
-     */
-    @ApiModelProperty(value = "付费趋势:总(自然量)")
-    private String natureAmountSum;
-
-    /**
-     * 付费趋势:1天(总量)
-     */
-    @ApiModelProperty(value = "付费趋势:1天(总量)")
-    private String amountD1;
-
-    /**
-     * 付费趋势:3天(总量)
-     */
-    @ApiModelProperty(value = "付费趋势:3天(总量)")
-    private String amountD3;
-
-    /**
-     * 付费趋势:7天(总量)
-     */
-    @ApiModelProperty(value = "付费趋势:7天(总量)")
-    private String amountD7;
-
-    /**
-     * 付费趋势:15天(总量)
-     */
-    @ApiModelProperty(value = "付费趋势:15天(总量)")
-    private String amountD15;
-
-    /**
-     * 付费趋势:1个月(总量)
-     */
-    @ApiModelProperty(value = "付费趋势:1个月(总量)")
-    private String amountM1;
-
-    /**
-     * 付费趋势:2个月(总量)
-     */
-    @ApiModelProperty(value = "付费趋势:2个月(总量)")
-    private String amountM2;
-
-    /**
-     * 付费趋势:3个月(总量)
-     */
-    @ApiModelProperty(value = "付费趋势:3个月(总量)")
-    private String amountM3;
-
-    /**
-     * 付费趋势:总(总量)
-     */
-    @ApiModelProperty(value = "付费趋势:总(总量)")
-    private String amountSum;
 }

+ 245 - 2
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/GameDataServiceImpl.java

@@ -7,8 +7,19 @@ import com.zanxiang.game.data.serve.pojo.vo.GameDataTotalVO;
 import com.zanxiang.game.data.serve.service.IGameDataService;
 import com.zanxiang.game.data.serve.utils.Page;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.nutz.dao.Cnd;
+import org.nutz.dao.Dao;
+import org.nutz.dao.Sqls;
+import org.nutz.dao.pager.Pager;
+import org.nutz.dao.sql.Criteria;
+import org.nutz.dao.sql.Sql;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDate;
+import java.util.List;
+
 /**
  * @author tianhua
  * @time 2023/7/12
@@ -18,13 +29,245 @@ import org.springframework.stereotype.Service;
 @Slf4j
 public class GameDataServiceImpl implements IGameDataService {
 
+    @Autowired
+    private Dao dao;
+
     @Override
     public Page<GameDataDayVO> getGameDataDay(GameDataDayDTO dto) {
-        return null;
+
+        //传入的注册时间为空时,给一个默认值 当天数据
+        if (dto.getRegisteredBeginDate() == null || dto.getRegisteredEndDate() == null) {
+            dto.setRegisteredBeginDate(LocalDate.now());
+            dto.setRegisteredEndDate(LocalDate.now());
+        }
+        //根据dto拼接查询条件
+        Criteria cri = Cnd.cri();
+        if (StringUtils.isNotBlank(dto.getGameName())) {
+            //拼接游戏名称查询条件
+            cri.where().andEquals("game_name", dto.getGameName());
+        }
+        if (dto.getGameClassify() != null) {
+            //拼接游戏类型查询条件
+            cri.where().andEquals("game_classify", dto.getGameClassify());
+        }
+        if (dto.getRegisteredBeginDate() != null && dto.getRegisteredEndDate() != null) {
+            cri.where().andBetween("dt", dto.getRegisteredBeginDate(), dto.getRegisteredEndDate());
+        }
+        //结果按日期排序
+        cri.getOrderBy().desc("dt");
+
+        //编写sql语句 拼接查询条件
+        Sql sql = Sqls.create(gameDataDaySql() + cri);
+        //设置自定义回显对象
+        sql.setCallback(Sqls.callback.entities());
+        sql.setEntity(dao.getEntity(GameDataDayVO.class));
+        //设置pager对象
+        Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
+        sql.setPager(pager);
+        //执行sql
+        dao.execute(sql);
+        //得到结果集list
+        List<GameDataDayVO> list = sql.getList(GameDataDayVO.class);
+        //设置查询总数
+        pager.setRecordCount(list.size());
+
+        //返回list结果 封装到page对象里
+        return new Page<>(list, pager);
     }
 
     @Override
     public Page<GameDataTotalVO> getGameDataTotal(GameDataTotalDTO dto) {
-        return null;
+        //设置是否含有充值时间查询参数 默认含有
+        Boolean hasRechargeDate = true;
+        //如果注册时间参数为空,默认设置为当天
+        if (dto.getRegisteredBeginDate() == null || dto.getRechargeEndDate() == null) {
+            dto.setRegisteredBeginDate(LocalDate.now());
+            dto.setRegisteredEndDate(LocalDate.now());
+        }
+        //如果充值时间参数为空,默认设置为注册时间
+        if (dto.getRechargeBeginDate() == null || dto.getRechargeEndDate() == null) {
+            //修改布尔值
+            hasRechargeDate = false;
+            dto.setRechargeBeginDate(dto.getRegisteredBeginDate());
+            dto.setRechargeEndDate(dto.getRegisteredEndDate());
+        }
+        //根据传入的dto拼接查询参数
+        Criteria cri = Cnd.cri();
+        if (StringUtils.isNotBlank(dto.getGameName())) {
+            //拼接游戏名称查询条件
+            cri.where().andEquals("a.game_name", dto.getGameName());
+        }
+        if (dto.getGameClassify() != null) {
+            //拼接游戏类型查询条件
+            cri.where().andEquals("a.game_classify", dto.getGameClassify());
+        }
+        if (dto.getRegisteredBeginDate() != null && dto.getRegisteredEndDate() != null) {
+            //拼接注册日期查询条件
+            cri.where().andBetween("a.dt", dto.getRegisteredBeginDate(), dto.getRegisteredEndDate());
+        }
+        //拼接分组条件
+        cri.getGroupBy().groupBy("a.game_name");
+        //创建sql语句 执行sql
+        Sql sql = Sqls.create(gameDataTotalSql() + cri);
+        //设置自定义参数
+        sql.setParam("rechargeBeginDate", dto.getRechargeBeginDate());
+        sql.setParam("rechargeEndDate", dto.getRechargeEndDate());
+        //设置自定义回显对象
+        sql.setCallback(Sqls.callback.entities());
+        sql.setEntity(dao.getEntity(GameDataTotalVO.class));
+        //设置pager对象
+        Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
+        sql.setPager(pager);
+        //执行sql
+        dao.execute(sql);
+        //得到结果集list
+        List<GameDataTotalVO> list = sql.getList(GameDataTotalVO.class);
+        //设置查询总数
+        pager.setRecordCount(list.size());
+        //如果带有充值时间查询条件 需要联表查询修改结果
+        if (hasRechargeDate) {
+            //充值时间查询 逻辑处理
+        }
+
+        //返回list结果封装到page对象里
+        return new Page<>(list, pager);
     }
+
+
+    /**
+     * 游戏每日数据SQL
+     *
+     * @return String
+     */
+    private String gameDataDaySql() {
+        return """
+                SELECT
+                dt cost_date,
+                game_name,
+                game_classify,
+                buy_reg_num,
+                nature_reg_num,
+                reg_num,
+                    
+                buy_first_new_user_amount_count,
+                buy_first_new_user_amount_num,
+                buy_first_new_user_amount,
+                buy_old_user_count,
+                buy_old_user_num,
+                buy_old_user_amount,
+                buy_amount_count,
+                buy_amount_num,
+                buy_amount,
+                buy_new_user_total_amount_count,
+                buy_new_user_total_amount_num,
+                buy_new_user_total_amount,
+                buy_first_roi,
+                buy_today_roi,
+                buy_new_user_rate,
+                buy_first_avg_amount,
+                buy_today_avg_amount,
+                buy_avg_amount,
+                buy_user_again_rate,
+                buy_reg_user_arpu,
+                buy_first_amount_arpu,
+                buy_today_amount_arpu,
+                buy_amount_arpu,
+                buy_amount_d1,
+                buy_amount_d3,
+                buy_amount_d7,
+                buy_amount_d15,
+                buy_amount_m1,
+                buy_amount_m2,
+                buy_amount_m3,
+                buy_amount_sum,
+                    
+                nature_first_new_user_amount_count,
+                nature_first_new_user_amount_num,
+                nature_first_new_user_amount,
+                nature_old_user_count,
+                nature_old_user_num,
+                nature_old_user_amount,
+                nature_amount_count,
+                nature_amount_num,
+                nature_amount,
+                nature_new_user_total_amount_count,
+                nature_new_user_total_amount_num,
+                nature_new_user_total_amount,
+                nature_first_roi,
+                nature_today_roi,
+                nature_new_user_rate,
+                nature_first_avg_amount,
+                nature_today_avg_amount,
+                nature_avg_amount,
+                nature_user_again_rate,
+                nature_reg_user_arpu,
+                nature_first_amount_arpu,
+                nature_today_amount_arpu,
+                nature_amount_arpu,
+                nature_amount_d1,
+                nature_amount_d3,
+                nature_amount_d7,
+                nature_amount_d15,
+                nature_amount_m1,
+                nature_amount_m2,
+                nature_amount_m3,
+                nature_amount_sum,
+                    
+                first_new_user_amount_count,
+                first_new_user_amount_num,
+                first_new_user_amount,
+                old_user_count,
+                old_user_num,
+                old_user_amount,
+                amount_count,
+                amount_num,
+                amount,
+                new_user_total_amount_count,
+                new_user_total_amount_num,
+                new_user_total_amount,
+                first_roi,
+                today_roi,
+                new_user_rate,
+                first_avg_amount,
+                today_avg_amount,
+                avg_amount,
+                user_again_rate,
+                reg_user_arpu,
+                first_amount_arpu,
+                today_amount_arpu,
+                amount_arpu,
+                amount_d1,
+                amount_d3,
+                amount_d7,
+                amount_d15,
+                amount_m1,
+                amount_m2,
+                amount_m3,
+                amount_sum
+                    
+                FROM ads_game_day
+                """;
+    }
+
+    /**
+     * 游戏总数居SQL
+     *
+     * @return String
+     */
+    private String gameDataTotalSql() {
+        return """
+                SELECT
+                    a.game_name game_name
+                FROM
+                    ads_game_day a
+                left join
+                    game_ads.ads_game_day b
+                on
+                    a.game_name = b.game_name
+                    and
+                    (b.dt between @rechargeBeginDate and @rechargeEndDate)
+                """;
+    }
+
+
 }