Ver Fonte

Merge branch 'package-data' into package

wcc há 1 ano atrás
pai
commit
afa1f63146

+ 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) {

+ 0 - 1
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/dto/GameDataDayDTO.java

@@ -1,7 +1,6 @@
 package com.zanxiang.game.data.serve.pojo.dto;
 
 import com.zanxiang.game.data.serve.pojo.base.BasePage;
-import com.zanxiang.game.data.serve.pojo.entity.AdsGameDay;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Builder;

+ 0 - 1
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/dto/GameDataTotalDTO.java

@@ -1,7 +1,6 @@
 package com.zanxiang.game.data.serve.pojo.dto;
 
 import com.zanxiang.game.data.serve.pojo.base.BasePage;
-import com.zanxiang.game.data.serve.pojo.entity.AdsGameDay;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Builder;

+ 79 - 24
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/entity/AdsGameDay.java

@@ -10,6 +10,7 @@ import org.nutz.dao.entity.annotation.Table;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.time.LocalDate;
 
 /**
@@ -182,6 +183,12 @@ public class AdsGameDay implements Serializable {
     @Column
     private BigDecimal userAgainRate;
 
+    /**
+     * 复充人数(总)
+     */
+    @Column
+    private BigInteger regOrderUserAgain;
+
     /**
      * 新增注册ARPU(总)
      */
@@ -207,49 +214,61 @@ public class AdsGameDay implements Serializable {
     private BigDecimal amountArpu;
 
     /**
-     * 付费趋势第一天总:增/回/倍(总)
+     * 付费趋势第一天总:金额/人数/增/回/倍(总
      */
     @Column
     private String amountD1;
 
     /**
-     * 付费趋势第三天总:增/回/倍(总)
+     * 付费趋势第三天总:金额/人数/增/回/倍(总
      */
     @Column
     private String amountD3;
 
     /**
-     * 付费趋势第七天总:增/回/倍(总)
+     * 付费趋势第五天总:金额/人数/增/回/倍(总量)
+     */
+    @Column
+    private String amountD5;
+
+    /**
+     * 付费趋势第七天总:金额/人数/增/回/倍(总量)
      */
     @Column
     private String amountD7;
 
     /**
-     * 付费趋势第十五天总:增/回/倍(总)
+     * 付费趋势第十五天总:金额/人数/增/回/倍(总
      */
     @Column
     private String amountD15;
 
     /**
-     * 付费趋势第一月总:增/回/倍(总)
+     * 付费趋势第一月总:金额/人数/增/回/倍(总
      */
     @Column
     private String amountM1;
 
     /**
-     * 付费趋势第二月总:增/回/倍(总)
+     * 付费趋势第二月总:金额/人数/增/回/倍(总
      */
     @Column
     private String amountM2;
 
     /**
-     * 付费趋势第三月总:增/回/倍(总)
+     * 付费趋势第三月总:金额/人数/增/回/倍(总
      */
     @Column
     private String amountM3;
 
     /**
-     * 付费趋势总:增/回/倍(总)
+     * 付费趋势第六月总:金额/人数/增/回/倍(总量)
+     */
+    @Column
+    private String amountM6;
+
+    /**
+     * 付费趋势总:金额/人数/增/回/倍(总量)
      */
     @Column
     private String amountSum;
@@ -374,6 +393,12 @@ public class AdsGameDay implements Serializable {
     @Column
     private BigDecimal buyUserAgainRate;
 
+    /**
+     * 复充人数(买量)
+     */
+    @Column
+    private BigInteger buyRegOrderUserAgain;
+
     /**
      * 新增注册ARPU(买量)
      */
@@ -399,49 +424,61 @@ public class AdsGameDay implements Serializable {
     private BigDecimal buyAmountArpu;
 
     /**
-     * 付费趋势第一天总:增/回/倍(买量)
+     * 付费趋势第一天总:金额/人数/增/回/倍(买量)
      */
     @Column
     private String buyAmountD1;
 
     /**
-     * 付费趋势第三天总:增/回/倍(买量)
+     * 付费趋势第三天总:金额/人数/增/回/倍(买量)
      */
     @Column
     private String buyAmountD3;
 
     /**
-     * 付费趋势第七天总:增/回/倍(买量)
+     * 付费趋势第五天总:金额/人数/增/回/倍(买量)
+     */
+    @Column
+    private String buyAmountD5;
+
+    /**
+     * 付费趋势第七天总:金额/人数/增/回/倍(买量)
      */
     @Column
     private String buyAmountD7;
 
     /**
-     * 付费趋势第十五天总:增/回/倍(买量)
+     * 付费趋势第十五天总:金额/人数/增/回/倍(买量)
      */
     @Column
     private String buyAmountD15;
 
     /**
-     * 付费趋势第一月总:增/回/倍(买量)
+     * 付费趋势第一月总:金额/人数/增/回/倍(买量)
      */
     @Column
     private String buyAmountM1;
 
     /**
-     * 付费趋势第二月总:增/回/倍(买量)
+     * 付费趋势第二月总:金额/人数/增/回/倍(买量)
      */
     @Column
     private String buyAmountM2;
 
     /**
-     * 付费趋势第三月总:增/回/倍(买量)
+     * 付费趋势第三月总:金额/人数/增/回/倍(买量)
      */
     @Column
     private String buyAmountM3;
 
     /**
-     * 付费趋势总:增/回/倍(买量)
+     * 付费趋势第六月总:金额/人数/增/回/倍(买量)
+     */
+    @Column
+    private String buyAmountM6;
+
+    /**
+     * 付费趋势总:金额/人数/增/回/倍(买量)
      */
     @Column
     private String buyAmountSum;
@@ -566,6 +603,12 @@ public class AdsGameDay implements Serializable {
     @Column
     private BigDecimal natureUserAgainRate;
 
+    /**
+     * 复充人数(自然量)
+     */
+    @Column
+    private BigInteger natureRegOrderUserAgain;
+
     /**
      * 新增注册ARPU(自然量)
      */
@@ -591,49 +634,61 @@ public class AdsGameDay implements Serializable {
     private BigDecimal natureAmountArpu;
 
     /**
-     * 付费趋势第一天总:增/回/倍(自然量)
+     * 付费趋势第一天总:金额/人数/增/回/倍(自然量)
      */
     @Column
     private String natureAmountD1;
 
     /**
-     * 付费趋势第三天总:增/回/倍(自然量)
+     * 付费趋势第三天总:金额/人数/增/回/倍(自然量)
      */
     @Column
     private String natureAmountD3;
 
     /**
-     * 付费趋势第七天总:增/回/倍(自然量)
+     * 付费趋势第五天总:金额/人数/增/回/倍(自然量)
+     */
+    @Column
+    private String natureAmountD5;
+
+    /**
+     * 付费趋势第七天总:金额/人数/增/回/倍(自然量)
      */
     @Column
     private String natureAmountD7;
 
     /**
-     * 付费趋势第十五天总:增/回/倍(自然量)
+     * 付费趋势第十五天总:金额/人数/增/回/倍(自然量)
      */
     @Column
     private String natureAmountD15;
 
     /**
-     * 付费趋势第一月总:增/回/倍(自然量)
+     * 付费趋势第一月总:金额/人数/增/回/倍(自然量)
      */
     @Column
     private String natureAmountM1;
 
     /**
-     * 付费趋势第二月总:增/回/倍(自然量)
+     * 付费趋势第二月总:金额/人数/增/回/倍(自然量)
      */
     @Column
     private String natureAmountM2;
 
     /**
-     * 付费趋势第三月总:增/回/倍(自然量)
+     * 付费趋势第三月总:金额/人数/增/回/倍(自然量)
      */
     @Column
     private String natureAmountM3;
 
     /**
-     * 付费趋势总:增/回/倍(自然量)
+     * 付费趋势第六月总:金额/人数/增/回/倍(自然量)
+     */
+    @Column
+    private String natureAmountM6;
+
+    /**
+     * 付费趋势总:金额/人数/增/回/倍(自然量)
      */
     @Column
     private String natureAmountSum;

+ 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;
 
     /**
      * 首日客单价(总量)

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

@@ -19,6 +19,13 @@ import java.math.BigInteger;
 @AllArgsConstructor
 @Builder
 public class GameDataTotalVO {
+
+    /**
+     * 游戏id(前端不显示)
+     */
+    @ApiModelProperty(value = "游戏Id(前端不显示)")
+    private BigInteger gameId;
+
     /**
      * 推广游戏名称
      */
@@ -49,6 +56,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 +158,17 @@ public class GameDataTotalVO {
     @ApiModelProperty(value = "当天付费率(买量)")
     private BigDecimal buyTodayRoi;
 
+    /**
+     * 新用户付费率(买量)
+     */
+    @ApiModelProperty(value = "新用户付费率(买量)")
+    private BigDecimal buyNewUserRoi;
+
     /**
      * 新用户付费比(买量)
      */
     @ApiModelProperty(value = "新用户付费比(买量)")
-    private BigDecimal buyNewRate;
+    private BigDecimal buyNewUserRate;
 
     /**
      * 首日客单价(买量)
@@ -157,12 +188,36 @@ 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;
+
+    /**
+     * 新用户复充人数(买量)(前端不需要显示)
+     */
+    @ApiModelProperty(value = "新用户复充人数(买量)(前端不需要显示)")
+    private BigInteger buyNewUserAgainCount;
+
     /**
      * 新增注册ARPU(买量)
      */
@@ -187,6 +242,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 +350,17 @@ public class GameDataTotalVO {
     @ApiModelProperty(value = "当天付费率(自然量)")
     private BigDecimal natureTodayRoi;
 
+    /**
+     * 新用户付费率(自然量)
+     */
+    @ApiModelProperty(value = "新用户付费率(自然量)")
+    private BigDecimal natureNewUserRoi;
+
     /**
      * 新用户付费比(自然量)
      */
     @ApiModelProperty(value = "新用户付费比(自然量)")
-    private BigDecimal natureNewRate;
+    private BigDecimal natureNewUserRate;
 
     /**
      * 首日客单价(自然量)
@@ -295,12 +380,36 @@ 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;
+
+    /**
+     * 新用户复充人数(自然量)(前端不需要显示)
+     */
+    @ApiModelProperty(value = "新用户复充人数(自然量)(前端不需要显示)")
+    private BigInteger natureNewUserAgainCount;
+
     /**
      * 新增注册ARPU(自然量)
      */
@@ -325,6 +434,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 +542,17 @@ public class GameDataTotalVO {
     @ApiModelProperty(value = "当天付费率(总量)")
     private BigDecimal todayRoi;
 
+    /**
+     * 新用户付费率(总量)
+     */
+    @ApiModelProperty(value = "新用户付费率(总量)")
+    private BigDecimal newUserRoi;
+
     /**
      * 新用户付费比(总量)
      */
     @ApiModelProperty(value = "新用户付费比(总量)")
-    private BigDecimal newRate;
+    private BigDecimal newUserRate;
 
     /**
      * 首日客单价(总量)
@@ -433,12 +572,36 @@ 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;
+
+    /**
+     * 新用户复充人数(总量)(前端不需要显示)
+     */
+    @ApiModelProperty(value = "新用户复充人数(总量)(前端不需要显示)")
+    private BigInteger newUserAgainCount;
+
     /**
      * 新增注册ARPU(总量)
      */
@@ -464,146 +627,9 @@ public class GameDataTotalVO {
     private BigDecimal amountArpu;
 
     /**
-     * 付费趋势:1天(买量)
-     */
-    @ApiModelProperty(value = "付费趋势:1天(买量)")
-    private String buyAmountD1;
-
-    /**
-     * 付费趋势:3天(买量)
-     */
-    @ApiModelProperty(value = "付费趋势:3天(买量)")
-    private String buyAmountD3;
-
-    /**
-     * 付费趋势:7天(买量)
-     */
-    @ApiModelProperty(value = "付费趋势:7天(买量)")
-    private String buyAmountD7;
-
-    /**
-     * 付费趋势:15天(买量)
-     */
-    @ApiModelProperty(value = "付费趋势:15天(买量)")
-    private String buyAmountD15;
-
-    /**
-     * 付费趋势:1个月(买量)
+     * 新用户付费ARPU(总量)
      */
-    @ApiModelProperty(value = "付费趋势:1个月(买量)")
-    private String buyAmountM1;
+    @ApiModelProperty(value = "新用户付费ARPU(总量)")
+    private BigDecimal newUserAmountArpu;
 
-    /**
-     * 付费趋势: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;
 }

+ 337 - 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,337 @@ 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;
+        //如果注册时间参数为空,默认设置为当天
+        if (dto.getRegisteredBeginDate() == null || dto.getRechargeEndDate() == null) {
+            dto.setRegisteredBeginDate(LocalDate.now());
+            dto.setRegisteredEndDate(LocalDate.now());
+        }
+        //如果充值时间参数为空,默认设置为注册时间
+        if (dto.getRechargeBeginDate() == null || dto.getRechargeEndDate() == null) {
+            dto.setRechargeBeginDate(LocalDate.now());
+            dto.setRechargeEndDate(LocalDate.now());
+        }
+        //根据传入的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", "a.game_id", "a.game_classify");
+        //创建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());
+
+        /*//根据充值时间修改值
+        list.stream().map(new Function<GameDataTotalVO, Object>() {
+            //第一个参数 转换之前的参数
+            //第二个参数,转换之后的参数
+            //apply中的传入参数 就是流中的每一个数据
+            //返回值类型就是需要转换之后的类型
+            @Override
+            public Object apply(GameDataTotalVO gameDataTotalVO) {
+
+                //联表查询根据充值时间查询出相关参数
+
+
+                //设置新用户相关数据
+
+
+                //联表查询新用户复充人数
+
+
+                return null;
+            }
+        });*/
+
+        //返回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_d5,
+                buy_amount_d7,
+                buy_amount_d15,
+                buy_amount_m1,
+                buy_amount_m2,
+                buy_amount_m3,
+                buy_amount_m6,
+                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_d5,
+                nature_amount_d7,
+                nature_amount_d15,
+                nature_amount_m1,
+                nature_amount_m2,
+                nature_amount_m3,
+                nature_amount_m6,
+                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_d5,
+                amount_d7,
+                amount_d15,
+                amount_m1,
+                amount_m2,
+                amount_m3,
+                amount_m6,
+                amount_sum
+                    
+                FROM ads_game_day
+                """;
+    }
+
+    /**
+     * 游戏总数居SQL
+     *
+     * @return String
+     */
+    private String gameDataTotalSql() {
+        return """
+                SELECT
+                    a.game_id game_id,
+                    a.game_name game_name,
+                    a.game_classify game_classify,
+                    
+                    sum(a.buy_reg_num) buy_reg_num,
+                    sum(a.nature_reg_num) nature_reg_num,
+                    sum(a.reg_num) reg_num,
+                    
+                    sum(a.buy_first_new_user_amount_count) buy_first_new_user_amount_count,
+                    sum(a.buy_first_new_user_amount_num) buy_first_new_user_amount_num,
+                    sum(a.buy_first_new_user_amount) buy_first_new_user_amount,
+                    sum(a.nature_first_new_user_amount_count) nature_first_new_user_amount_count,
+                    sum(a.nature_first_new_user_amount_num) nature_first_new_user_amount_num,
+                    sum(a.nature_first_new_user_amount) nature_first_new_user_amount,
+                    sum(a.first_new_user_amount_count) first_new_user_amount_count,
+                    sum(a.first_new_user_amount_num) first_new_user_amount_num,
+                    sum(a.first_new_user_amount) first_new_user_amount,
+                    
+                    sum(b.buy_amount_count) buy_amount_count,
+                    sum(b.buy_amount_num) buy_amount_num,
+                    sum(b.buy_amount) buy_amount,
+                    sum(b.nature_amount_count) nature_amount_count,
+                    sum(b.nature_amount_num) nature_amount_num,
+                    sum(b.nature_amount) nature_amount,
+                    sum(b.amount_count) amount_count,
+                    sum(b.amount_num) amount_num,
+                    sum(b.amount) amount,
+                    
+                    sum(a.buy_new_user_total_amount_count) buy_new_user_total_amount_count,
+                    sum(a.buy_new_user_total_amount_num) buy_new_user_total_amount_num,
+                    sum(a.buy_new_user_total_amount) buy_new_user_total_amount,
+                    sum(a.nature_new_user_total_amount_count) nature_new_user_total_amount_count,
+                    sum(a.nature_new_user_total_amount_num) nature_new_user_total_amount_num,
+                    sum(a.nature_new_user_total_amount) nature_new_user_total_amount,
+                    sum(a.new_user_total_amount_count) new_user_total_amount_count,
+                    sum(a.new_user_total_amount_num) new_user_total_amount_num,
+                    sum(a.new_user_total_amount) new_user_total_amount,
+                    
+                    round(if(sum(a.buy_reg_num) > 0 ,sum(a.buy_first_new_user_amount_num) / sum(a.buy_reg_num), 0), 4) buy_first_roi,
+                    round(if(sum(a.buy_reg_num) > 0, sum(a.buy_new_user_total_amount_num) / sum(a.buy_reg_num), 0), 4) buy_today_roi,
+                    round(if(sum(a.nature_reg_num) > 0 ,sum(a.nature_first_new_user_amount_num) / sum(a.nature_reg_num), 0), 4) nature_first_roi,
+                    round(if(sum(a.nature_reg_num) > 0, sum(a.nature_new_user_total_amount_num) / sum(a.nature_reg_num), 0), 4) nature_today_roi,
+                    round(if(sum(a.reg_num) > 0 ,sum(a.first_new_user_amount_num) / sum(a.reg_num), 0), 4) first_roi,
+                    round(if(sum(a.reg_num) > 0, sum(a.new_user_total_amount_num) / sum(a.reg_num), 0), 4) today_roi,
+                    
+                    round(if(sum(a.buy_first_new_user_amount_count) > 0, sum(a.buy_first_new_user_amount) / sum(a.buy_first_new_user_amount_count), 0), 2) buy_first_avg_amount,
+                    round(if(sum(a.buy_new_user_total_amount_count) > 0, sum(a.buy_new_user_total_amount) / sum(a.buy_new_user_total_amount_count), 0), 2) buy_today_avg_amount,
+                    round(if(sum(b.buy_amount_count) > 0, sum(b.buy_amount) / sum(b.buy_amount_count), 0), 2) buy_avg_amount,
+                    round(if(sum(a.nature_first_new_user_amount_count) > 0, sum(a.nature_first_new_user_amount) / sum(a.nature_first_new_user_amount_count), 0), 2) nature_first_avg_amount,
+                    round(if(sum(a.nature_new_user_total_amount_count) > 0, sum(a.nature_new_user_total_amount) / sum(a.nature_new_user_total_amount_count), 0), 2) nature_today_avg_amount,
+                    round(if(sum(b.nature_amount_count) > 0, sum(b.nature_amount) / sum(b.nature_amount_count), 0), 2) nature_avg_amount,
+                    round(if(sum(a.first_new_user_amount_count) > 0, sum(a.first_new_user_amount) / sum(a.first_new_user_amount_count), 0), 2) first_avg_amount,
+                    round(if(sum(a.new_user_total_amount_count) > 0, sum(a.new_user_total_amount) / sum(a.new_user_total_amount_count), 0), 2) today_avg_amount,
+                    round(if(sum(b.amount_count) > 0, sum(b.amount) / sum(b.amount_count), 0), 2) avg_amount,
+                    
+                    round(if(sum(a.buy_new_user_total_amount_num) > 0 , sum(a.buy_reg_order_user_again) / sum(a.buy_new_user_total_amount_num), 0), 4) buy_today_again_rate,
+                    round(if(sum(a.nature_new_user_total_amount_num) > 0 , sum(a.nature_reg_order_user_again) / sum(a.nature_new_user_total_amount_num), 0), 4) nature_today_again_rate,
+                    round(if(sum(a.new_user_total_amount_num) > 0 , sum(a.reg_order_user_again) / sum(a.new_user_total_amount_num), 0), 4) today_again_rate,
+                    
+                    round(if(sum(a.buy_reg_num) > 0 , sum(a.buy_new_user_total_amount) / sum(a.buy_reg_num), 0), 2) buy_reg_user_arpu,
+                    round(if(sum(a.buy_first_new_user_amount_num) > 0 , sum(a.buy_first_new_user_amount) / sum(a.buy_first_new_user_amount_num), 0), 2) buy_first_amount_arpu,
+                    round(if(sum(a.buy_new_user_total_amount_num) > 0 , sum(a.buy_new_user_total_amount) / sum(a.buy_new_user_total_amount_num), 0), 2) buy_today_amount_arpu,
+                    round(if(sum(b.buy_amount_num) > 0 , sum(b.buy_amount) / sum(b.buy_amount_num), 0), 2) buy_amount_arpu,
+                    round(if(sum(a.nature_reg_num) > 0 , sum(a.nature_new_user_total_amount) / sum(a.nature_reg_num), 0), 2) nature_reg_user_arpu,
+                    round(if(sum(a.nature_first_new_user_amount_num) > 0 , sum(a.nature_first_new_user_amount) / sum(a.nature_first_new_user_amount_num), 0), 2) nature_first_amount_arpu,
+                    round(if(sum(a.nature_new_user_total_amount_num) > 0 , sum(a.nature_new_user_total_amount) / sum(a.nature_new_user_total_amount_num), 0), 2) nature_today_amount_arpu,
+                    round(if(sum(b.nature_amount_num) > 0 , sum(b.nature_amount) / sum(b.nature_amount_num), 0), 2) nature_amount_arpu,
+                    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(b.amount_num) > 0 , sum(b.amount) / sum(b.amount_num), 0), 2) amount_arpu
+                FROM
+                    ads_game_day a
+                left join
+                    ads_game_day b
+                on
+                    a.game_name = b.game_name and
+                    a.game_id = b.game_id and
+                    a.game_classify = b.game_classify and
+                    (b.dt between @rechargeBeginDate and @rechargeEndDate)
+                """;
     }
+
+
 }