ソースを参照

修改内容:游戏复充趋势

lth 1 年間 前
コミット
bf1a82f105

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

@@ -1,8 +1,11 @@
 package com.zanxiang.game.data.serve.controller;
 
+import com.zanxiang.erp.security.annotation.PreAuthorize;
+import com.zanxiang.game.data.serve.pojo.dto.GameDataAgainDayDTO;
 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.dto.GameDataWaterDTO;
+import com.zanxiang.game.data.serve.pojo.vo.GameDataAgainDayVO;
 import com.zanxiang.game.data.serve.pojo.vo.GameDataDayVO;
 import com.zanxiang.game.data.serve.pojo.vo.GameDataTotalVO;
 import com.zanxiang.game.data.serve.pojo.vo.GameDataWaterVO;
@@ -20,6 +23,10 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.time.LocalDate;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author tianhua
  * @time 2023/7/12
@@ -35,7 +42,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) {
@@ -44,7 +51,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) {
@@ -52,11 +59,17 @@ public class GameDataController {
     }
 
     @ApiOperation(value = "每日流水贡献")
-    //@PreAuthorize(permissionKey = "gameData:adsGameDay:water")
+    @PreAuthorize(permissionKey = "gameData:adsGameDay:water")
     @PostMapping("/water")
     public ResultVO<Page<GameDataWaterVO>> getGameDataWater(@RequestBody GameDataWaterDTO dto) {
         return ResultVO.ok(gameDataService.getGameDataWater(dto));
     }
 
+    @ApiOperation(value = "游戏每日复充数据")
+    @PreAuthorize(permissionKey = "gameData:adsGameDay:again")
+    @PostMapping("/again")
+    public ResultVO<Map<LocalDate, List<GameDataAgainDayVO>>> getGameDataAgainDay(@RequestBody GameDataAgainDayDTO dto) throws Exception {
+        return ResultVO.ok(gameDataService.getGameDataAgainDay(dto));
+    }
 
 }

+ 40 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/dto/GameDataAgainDayDTO.java

@@ -0,0 +1,40 @@
+package com.zanxiang.game.data.serve.pojo.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDate;
+
+/**
+ * @author tianhua
+ * @time 2023/7/18
+ * @Description 前端传递的游戏每日复充查询实体
+ **/
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class GameDataAgainDayDTO {
+
+    /**
+     * 游戏名称
+     */
+    @ApiModelProperty(value = "游戏名称")
+    private String gameName;
+
+    /**
+     * 查询开始时间
+     */
+    @ApiModelProperty(value = "查询开始时间")
+    private LocalDate beginDate;
+
+    /**
+     * 查询结束时间
+     */
+    @ApiModelProperty(value = "查询结束时间(前端不需要传递)")
+    private LocalDate endDate;
+
+}

+ 109 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/entity/AdsGameDayAgain.java

@@ -0,0 +1,109 @@
+package com.zanxiang.game.data.serve.pojo.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.nutz.dao.entity.annotation.Column;
+import org.nutz.dao.entity.annotation.PK;
+import org.nutz.dao.entity.annotation.Table;
+
+import java.math.BigInteger;
+import java.time.LocalDate;
+
+/**
+ * <p>
+ * 游戏每日复充数据表(总量)
+ * </p>
+ *
+ * @author tianhua
+ * @time 2023/7/11
+ * @Description
+ **/
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+@Table(AdsGameDayAgain.TABLE_NAME)
+@PK({"dt","ddf","gameId","gameName"})
+public class AdsGameDayAgain {
+    private static final long serialVersionUID = 1L;
+    public static final String TABLE_NAME = "ads_game_day_again";
+
+    /**
+     * 日期
+     */
+    private LocalDate dt;
+
+    /**
+     * 复充日期
+     */
+    private LocalDate ddf;
+
+    /**
+     * 游戏ID
+     */
+    private BigInteger gameId;
+
+    /**
+     * 游戏名称
+     */
+    private String gameName;
+
+    /**
+     * 充值一次
+     */
+    @Column
+    private BigInteger c1;
+
+    /**
+     * 充值大于一次
+     */
+    @Column
+    private BigInteger c2;
+
+    /**
+     * 充值大于两次
+     */
+    @Column
+    private BigInteger c3;
+
+    /**
+     * 充值大于三次
+     */
+    @Column
+    private BigInteger c4;
+
+    /**
+     * 充值大于四次
+     */
+    @Column
+    private BigInteger c5;
+
+    /**
+     * 充值大于五次
+     */
+    @Column
+    private BigInteger c6;
+
+    /**
+     * 充值大于十次
+     */
+    @Column
+    private BigInteger c7;
+
+    /**
+     * 充值大于二十次
+     */
+    @Column
+    private BigInteger c8;
+
+    /**
+     * 充值大于一百次
+     */
+    @Column
+    private BigInteger c9;
+
+
+
+}

+ 109 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/entity/AdsGameDayAgainBuy.java

@@ -0,0 +1,109 @@
+package com.zanxiang.game.data.serve.pojo.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.nutz.dao.entity.annotation.Column;
+import org.nutz.dao.entity.annotation.PK;
+import org.nutz.dao.entity.annotation.Table;
+
+import java.math.BigInteger;
+import java.time.LocalDate;
+
+/**
+ * <p>
+ * 游戏每日复充数据表(买量)
+ * </p>
+ *
+ * @author tianhua
+ * @time 2023/7/11
+ * @Description
+ **/
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+@Table(AdsGameDayAgainBuy.TABLE_NAME)
+@PK({"dt","ddf","gameId","gameName"})
+public class AdsGameDayAgainBuy {
+    private static final long serialVersionUID = 1L;
+    public static final String TABLE_NAME = "ads_game_day_again_buy";
+
+    /**
+     * 日期
+     */
+    private LocalDate dt;
+
+    /**
+     * 复充日期
+     */
+    private LocalDate ddf;
+
+    /**
+     * 游戏ID
+     */
+    private BigInteger gameId;
+
+    /**
+     * 游戏名称
+     */
+    private String gameName;
+
+    /**
+     * 充值一次
+     */
+    @Column
+    private BigInteger buyC1;
+
+    /**
+     * 充值大于一次
+     */
+    @Column
+    private BigInteger buyC2;
+
+    /**
+     * 充值大于两次
+     */
+    @Column
+    private BigInteger buyC3;
+
+    /**
+     * 充值大于三次
+     */
+    @Column
+    private BigInteger buyC4;
+
+    /**
+     * 充值大于四次
+     */
+    @Column
+    private BigInteger buyC5;
+
+    /**
+     * 充值大于五次
+     */
+    @Column
+    private BigInteger buyC6;
+
+    /**
+     * 充值大于十次
+     */
+    @Column
+    private BigInteger buyC7;
+
+    /**
+     * 充值大于二十次
+     */
+    @Column
+    private BigInteger buyC8;
+
+    /**
+     * 充值大于一百次
+     */
+    @Column
+    private BigInteger buyC9;
+
+
+
+}

+ 109 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/entity/AdsGameDayAgainNature.java

@@ -0,0 +1,109 @@
+package com.zanxiang.game.data.serve.pojo.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.nutz.dao.entity.annotation.Column;
+import org.nutz.dao.entity.annotation.PK;
+import org.nutz.dao.entity.annotation.Table;
+
+import java.math.BigInteger;
+import java.time.LocalDate;
+
+/**
+ * <p>
+ * 游戏每日复充数据表(自然量)
+ * </p>
+ *
+ * @author tianhua
+ * @time 2023/7/11
+ * @Description
+ **/
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+@Table(AdsGameDayAgainNature.TABLE_NAME)
+@PK({"dt","ddf","gameId","gameName"})
+public class AdsGameDayAgainNature {
+    private static final long serialVersionUID = 1L;
+    public static final String TABLE_NAME = "ads_game_day_again_nature";
+
+    /**
+     * 日期
+     */
+    private LocalDate dt;
+
+    /**
+     * 复充日期
+     */
+    private LocalDate ddf;
+
+    /**
+     * 游戏ID
+     */
+    private BigInteger gameId;
+
+    /**
+     * 游戏名称
+     */
+    private String gameName;
+
+    /**
+     * 充值一次
+     */
+    @Column
+    private BigInteger natureC1;
+
+    /**
+     * 充值大于一次
+     */
+    @Column
+    private BigInteger natureC2;
+
+    /**
+     * 充值大于两次
+     */
+    @Column
+    private BigInteger natureC3;
+
+    /**
+     * 充值大于三次
+     */
+    @Column
+    private BigInteger natureC4;
+
+    /**
+     * 充值大于四次
+     */
+    @Column
+    private BigInteger natureC5;
+
+    /**
+     * 充值大于五次
+     */
+    @Column
+    private BigInteger natureC6;
+
+    /**
+     * 充值大于十次
+     */
+    @Column
+    private BigInteger natureC7;
+
+    /**
+     * 充值大于二十次
+     */
+    @Column
+    private BigInteger natureC8;
+
+    /**
+     * 充值大于一百次
+     */
+    @Column
+    private BigInteger natureC9;
+
+
+
+}

+ 113 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/GameDataAgainDayVO.java

@@ -0,0 +1,113 @@
+package com.zanxiang.game.data.serve.pojo.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+/**
+ * @author tianhua
+ * @time 2023/7/18
+ * @Description 返回给前端的游戏每日复充数据对象实体
+ **/
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class GameDataAgainDayVO {
+
+    /**
+     * 原(总量)
+     */
+    @ApiModelProperty(value = "原(总量)")
+    private BigInteger original;
+
+    /**
+     * 现(总量)
+     */
+    @ApiModelProperty(value = "现(总量)")
+    private BigInteger present;
+
+    /**
+     * 增(总量)
+     */
+    @ApiModelProperty(value = "增(总量)")
+    private BigInteger increase;
+
+    /**
+     * 移(总量)
+     */
+    @ApiModelProperty(value = "移(总量)")
+    private BigInteger decrease;
+
+    /**
+     * 比(总量)
+     */
+    @ApiModelProperty(value = "比(总量)")
+    private BigDecimal rate;
+
+    /**
+     * 原(买量)
+     */
+    @ApiModelProperty(value = "原(买量)")
+    private BigInteger buyOriginal;
+
+    /**
+     * 现(买量)
+     */
+    @ApiModelProperty(value = "现(买量)")
+    private BigInteger buyPresent;
+
+    /**
+     * 增(买量)
+     */
+    @ApiModelProperty(value = "增(买量)")
+    private BigInteger buyIncrease;
+
+    /**
+     * 移(买量)
+     */
+    @ApiModelProperty(value = "移(买量)")
+    private BigInteger buyDecrease;
+
+    /**
+     * 比(买量)
+     */
+    @ApiModelProperty(value = "比(买量)")
+    private BigDecimal buyRate;
+
+    /**
+     * 原(自然量)
+     */
+    @ApiModelProperty(value = "原(自然量)")
+    private BigInteger natureOriginal;
+
+    /**
+     * 现(自然量)
+     */
+    @ApiModelProperty(value = "现(自然量)")
+    private BigInteger naturePresent;
+
+    /**
+     * 增(自然量)
+     */
+    @ApiModelProperty(value = "增(自然量)")
+    private BigInteger natureIncrease;
+
+    /**
+     * 移(自然量)
+     */
+    @ApiModelProperty(value = "移(自然量)")
+    private BigInteger natureDecrease;
+
+    /**
+     * 比(自然量)
+     */
+    @ApiModelProperty(value = "比(自然量)")
+    private BigDecimal natureRate;
+
+}

+ 19 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/IGameDataService.java

@@ -1,13 +1,19 @@
 package com.zanxiang.game.data.serve.service;
 
+import com.zanxiang.game.data.serve.pojo.dto.GameDataAgainDayDTO;
 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.dto.GameDataWaterDTO;
+import com.zanxiang.game.data.serve.pojo.vo.GameDataAgainDayVO;
 import com.zanxiang.game.data.serve.pojo.vo.GameDataDayVO;
 import com.zanxiang.game.data.serve.pojo.vo.GameDataTotalVO;
 import com.zanxiang.game.data.serve.pojo.vo.GameDataWaterVO;
 import com.zanxiang.game.data.serve.utils.Page;
 
+import java.time.LocalDate;
+import java.util.List;
+import java.util.Map;
+
 public interface IGameDataService {
 
     /**
@@ -24,5 +30,18 @@ public interface IGameDataService {
      */
     Page<GameDataTotalVO> getGameDataTotal(GameDataTotalDTO dto);
 
+    /**
+     * 游戏流水数据
+     * @param dto
+     * @return
+     */
     Page<GameDataWaterVO> getGameDataWater(GameDataWaterDTO dto);
+
+    /**
+     * 游戏每日复充数据
+     * @param dto
+     * @return
+     */
+    Map<LocalDate, List<GameDataAgainDayVO>> getGameDataAgainDay(GameDataAgainDayDTO dto) throws Exception;
+
 }

+ 322 - 1
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/GameDataServiceImpl.java

@@ -2,15 +2,20 @@ package com.zanxiang.game.data.serve.service.impl;
 
 import com.google.common.base.CaseFormat;
 import com.google.gson.Gson;
+import com.zanxiang.game.data.serve.pojo.dto.GameDataAgainDayDTO;
 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.dto.GameDataWaterDTO;
 import com.zanxiang.game.data.serve.pojo.entity.AdsEverydayWater;
+import com.zanxiang.game.data.serve.pojo.entity.AdsGameDayAgain;
+import com.zanxiang.game.data.serve.pojo.entity.AdsGameDayAgainBuy;
+import com.zanxiang.game.data.serve.pojo.entity.AdsGameDayAgainNature;
 import com.zanxiang.game.data.serve.pojo.enums.OrderByEnum;
 import com.zanxiang.game.data.serve.pojo.vo.*;
 import com.zanxiang.game.data.serve.service.IGameDataService;
 import com.zanxiang.game.data.serve.utils.Page;
 import com.zanxiang.module.util.DateUtil;
+import com.zanxiang.module.util.exception.BaseException;
 import lombok.Builder;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
@@ -28,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.math.RoundingMode;
@@ -52,6 +58,7 @@ public class GameDataServiceImpl implements IGameDataService {
 
     /**
      * 游戏每日数据
+     *
      * @param dto 前端传递查询参数
      * @return 返回给前端的数据
      */
@@ -377,6 +384,7 @@ public class GameDataServiceImpl implements IGameDataService {
 
     /**
      * 游戏总数据
+     *
      * @param dto 前端传递的查询参数
      * @return 返回给前端的数据
      */
@@ -769,7 +777,8 @@ public class GameDataServiceImpl implements IGameDataService {
                 """;
     }
 
-    /** 三张表共用的方法
+    /**
+     * 三张表共用的方法
      * @param dayNMap 参数Map
      * @param tableName 查询的表名
      * @return DayN数据
@@ -994,4 +1003,316 @@ public class GameDataServiceImpl implements IGameDataService {
                 from ads_everyday_water
                 """;
     }
+
+    /**
+     * 游戏每日复充数据
+     *
+     * @param dto 前端传递查询参数实体
+     * @return 返回给前端的数据
+     */
+    @Override
+    public Map<LocalDate, List<GameDataAgainDayVO>> getGameDataAgainDay(GameDataAgainDayDTO dto) {
+
+        //如果查询时间不传递默认从今天开始查询
+        if (dto.getBeginDate() == null) {
+            dto.setBeginDate(LocalDate.now());
+        }
+        //判断开始时间后的30天是否超过当前日期
+        if (dto.getBeginDate().plusDays(30).isAfter(LocalDate.now())) {
+            //只查询到当前的数据
+            dto.setEndDate(LocalDate.now());
+        } else {
+            //只考虑30天的数据
+            dto.setEndDate(dto.getBeginDate().plusDays(30));
+        }
+        //拼接查询条件
+        Criteria cri = Cnd.cri();
+        if (StringUtils.isNotBlank(dto.getGameName())) {
+            cri.where().andEquals("game_name", dto.getGameName());
+        }
+        if (dto.getBeginDate() != null) {
+            cri.where().andEquals("dt", dto.getBeginDate());
+            cri.where().andBetween("ddf", dto.getBeginDate(), dto.getEndDate());
+        }
+        //按 "ddf" 升序排序
+        cri.getOrderBy().asc("ddf");
+
+        //获取三张表的查询结果
+        List<AdsGameDayAgain> list = getListByTableType("total", cri);
+        List<AdsGameDayAgainBuy> listBuy = getListByTableType("buy", cri);
+        List<AdsGameDayAgainNature> listNature = getListByTableType("nature", cri);
+
+        //创建Map记录数据
+        Map<LocalDate, List<GameDataAgainDayVO>> map = new HashMap<>();
+        //有序存储每个list,每个list包含当天的所有充值次数的复充数据
+        List<List<GameDataAgainDayVO>> tempList = new ArrayList<>();
+        //记录查询出的记录条数
+        Integer count = list.size();
+        //初始化list
+        initList(tempList, count);
+
+        //外层循环8次 表示不同复充次数的数据
+        for (int i = 0; i < 8; i++) {
+            //用来计算Ci
+            int ci = i + 1;
+            //第一天的所有充值次数都是先计算的
+            GameDataAgainDayVO tempVO = tempList.get(0).get(i);
+            //"原": Ci
+            tempList.get(0).get(i).setOriginal(getCnByNum(list.get(0), ci));
+            tempList.get(0).get(i).setBuyOriginal(getCnByNum(listBuy.get(0), ci));
+            tempList.get(0).get(i).setNatureOriginal(getCnByNum(listNature.get(0), ci));
+            //"增":初始为 0
+            tempList.get(0).get(i).setIncrease(BigInteger.ZERO);
+            tempList.get(0).get(i).setBuyIncrease(BigInteger.ZERO);
+            tempList.get(0).get(i).setNatureIncrease(BigInteger.ZERO);
+            //"移":下一个充值次数的Ci 即C(i+1)
+            tempList.get(0).get(i).setDecrease(getCnByNum(list.get(0), ci + 1));
+            tempList.get(0).get(i).setBuyDecrease(getCnByNum(listBuy.get(0), ci + 1));
+            tempList.get(0).get(i).setNatureDecrease(getCnByNum(listNature.get(0), ci + 1));
+            //"现":公式计算 = 原 + 增 - 移
+            tempList.get(0).get(i).setPresent(
+                    tempVO.getOriginal().add(tempVO.getIncrease()).subtract(tempVO.getDecrease())
+            );
+            tempList.get(0).get(i).setBuyPresent(
+                    tempVO.getBuyOriginal().add(tempVO.getBuyIncrease()).subtract(tempVO.getBuyDecrease())
+            );
+            tempList.get(0).get(i).setNaturePresent(
+                    tempVO.getNatureOriginal().add(tempVO.getNatureIncrease()).subtract(tempVO.getNatureDecrease())
+            );
+            //"比"
+            tempList.get(0).get(i).setRate(getCnByNum(list.get(0), 1).compareTo(BigInteger.ZERO) == 0 ? BigDecimal.ZERO :
+                    BigDecimal.valueOf(tempVO.getPresent().doubleValue() / getCnByNum(list.get(0), 1).doubleValue()).setScale(4, RoundingMode.HALF_UP)
+            );
+            tempList.get(0).get(i).setBuyRate(getCnByNum(listBuy.get(0), 1).compareTo(BigInteger.ZERO) == 0 ? BigDecimal.ZERO :
+                    BigDecimal.valueOf(tempVO.getBuyPresent().doubleValue() / getCnByNum(listBuy.get(0), 1).doubleValue()).setScale(4, RoundingMode.HALF_UP)
+            );
+            tempList.get(0).get(i).setNatureRate(getCnByNum(listNature.get(0), 1).compareTo(BigInteger.ZERO) == 0 ? BigDecimal.ZERO :
+                    BigDecimal.valueOf(tempVO.getNaturePresent().doubleValue() / getCnByNum(listNature.get(0), 1).doubleValue()).setScale(4, RoundingMode.HALF_UP)
+            );
+
+            //计算第2-n天的数据 复充次数i的数据
+            for (int j = 1; j < count; j++) {
+                //"原":前一天的"现"
+                tempList.get(j).get(i).setOriginal(tempList.get(j - 1).get(i).getPresent());
+                tempList.get(j).get(i).setBuyOriginal(tempList.get(j - 1).get(i).getBuyPresent());
+                tempList.get(j).get(i).setNatureOriginal(tempList.get(j - 1).get(i).getNaturePresent());
+                //"现":当天的Ci - 当天的C(i+1)
+                tempList.get(j).get(i).setPresent(
+                        getCnByNum(list.get(j), ci).subtract(getCnByNum(list.get(j), ci + 1)));
+                tempList.get(j).get(i).setBuyPresent(
+                        getCnByNum(listBuy.get(j), ci).subtract(getCnByNum(listBuy.get(j), ci + 1)));
+                tempList.get(j).get(i).setNaturePresent(
+                        getCnByNum(listNature.get(j), ci).subtract(getCnByNum(listNature.get(j), ci + 1)));
+                //"增":当天的Ci - 前一天的Ci
+                tempList.get(j).get(i).setIncrease(
+                        getCnByNum(list.get(j), ci).subtract(getCnByNum(list.get(j - 1), ci)));
+                tempList.get(j).get(i).setBuyIncrease(
+                        getCnByNum(listBuy.get(j), ci).subtract(getCnByNum(listBuy.get(j - 1), ci)));
+                tempList.get(j).get(i).setNatureIncrease(
+                        getCnByNum(listNature.get(j), ci).subtract(getCnByNum(listNature.get(j - 1), ci)));
+                //"移":当天的C(i+1) - 前一天的C(i+1)
+                tempList.get(j).get(i).setDecrease(
+                        getCnByNum(list.get(j), ci + 1).subtract(getCnByNum(list.get(j - 1), ci + 1)));
+                tempList.get(j).get(i).setBuyDecrease(
+                        getCnByNum(listBuy.get(j), ci + 1).subtract(getCnByNum(listBuy.get(j - 1), ci + 1)));
+                tempList.get(j).get(i).setNatureDecrease(
+                        getCnByNum(listNature.get(j), ci + 1).subtract(getCnByNum(listNature.get(j - 1), ci + 1)));
+                //"比":当天的现 / 前一天的C1
+                tempList.get(j).get(i).setRate(getCnByNum(list.get(j - 1), 1).compareTo(BigInteger.ZERO) == 0 ? BigDecimal.ZERO :
+                        BigDecimal.valueOf(tempList.get(j).get(i).getPresent().doubleValue() / getCnByNum(list.get(j - 1), 1).doubleValue()).setScale(4, RoundingMode.HALF_UP));
+                tempList.get(j).get(i).setBuyRate(getCnByNum(listBuy.get(j - 1), 1).compareTo(BigInteger.ZERO) == 0 ? BigDecimal.ZERO :
+                        BigDecimal.valueOf(tempList.get(j).get(i).getBuyPresent().doubleValue() / getCnByNum(listBuy.get(j - 1), 1).doubleValue()).setScale(4, RoundingMode.HALF_UP));
+                tempList.get(j).get(i).setNatureRate(getCnByNum(listNature.get(j - 1), 1).compareTo(BigInteger.ZERO) == 0 ? BigDecimal.ZERO :
+                        BigDecimal.valueOf(tempList.get(j).get(i).getNaturePresent().doubleValue() / getCnByNum(listNature.get(j - 1), 1).doubleValue()).setScale(4, RoundingMode.HALF_UP));
+            }
+        }
+        //赋值时间数据
+        for (int i = 0; i < tempList.size(); i++) {
+            map.put(list.get(i).getDdf(), tempList.get(i));
+        }
+
+        //返回数据
+        return map;
+    }
+
+    /**
+     * 通过反射来获取Cn的值
+     * @param dto 数据库查询出来的原始数据对象实体
+     * @param num 1-9
+     * @return Cn
+     */
+    private BigInteger getCnByNum(Object dto, int num) {
+        try {
+            Method m1 = null;
+            //不同对象获取的方法不同
+            if (dto instanceof AdsGameDayAgain) {
+                m1 = AdsGameDayAgain.class.getDeclaredMethod(String.format("getC%s", num));
+            } else if (dto instanceof AdsGameDayAgainBuy) {
+                m1 = AdsGameDayAgainBuy.class.getDeclaredMethod(String.format("getBuyC%s", num));
+            } else if (dto instanceof AdsGameDayAgainNature) {
+                m1 = AdsGameDayAgainNature.class.getDeclaredMethod(String.format("getNatureC%s", num));
+            }
+            //返回对应的Cn值
+            return (BigInteger) m1.invoke(dto);
+        } catch (Exception e) {
+            throw new BaseException("发生错误");
+        }
+    }
+
+    /**
+     * 初始化List数据
+     * @param list 需要初始化的数据
+     * @param num 多少天的数据
+     */
+    private void initList(List<List<GameDataAgainDayVO>> list, Integer num) {
+        //外层循环 num 次 表示多少天的数据
+        for (int i = 0; i < num; i++) {
+            list.add(new ArrayList<>());
+            //内层循环8次 一共初始化8中复充次数数据对象
+            for (int j = 0; j < 8; j++) {
+                list.get(i).add(
+                        GameDataAgainDayVO.builder()
+                                .buyOriginal(BigInteger.ZERO)
+                                .buyPresent(BigInteger.ZERO)
+                                .buyIncrease(BigInteger.ZERO)
+                                .buyDecrease(BigInteger.ZERO)
+                                .buyRate(BigDecimal.ZERO)
+                                .natureOriginal(BigInteger.ZERO)
+                                .naturePresent(BigInteger.ZERO)
+                                .natureIncrease(BigInteger.ZERO)
+                                .natureDecrease(BigInteger.ZERO)
+                                .natureRate(BigDecimal.ZERO)
+                                .original(BigInteger.ZERO)
+                                .present(BigInteger.ZERO)
+                                .increase(BigInteger.ZERO)
+                                .decrease(BigInteger.ZERO)
+                                .rate(BigDecimal.ZERO)
+                                .build()
+                );
+            }
+        }
+    }
+
+    /**
+     * 不同表获取不同的list结果
+     * @param tableName 表明
+     * @param cri 查询条件
+     * @return 查询结果
+     */
+    private List getListByTableType(String tableName, Criteria cri) {
+        //创建sql语句
+        Sql againSql;
+        //查询的结果封装到list中
+        List list = null;
+        //判断具体查询哪张表
+        if (tableName.equals("total")) {
+            againSql = Sqls.create(adsGameDataAgain() + cri);
+            //自定义回传对象
+            againSql.setCallback(Sqls.callback.entities());
+            againSql.setEntity(dao.getEntity(AdsGameDayAgain.class));
+            //执行sql
+            dao.execute(againSql);
+            //得到查询的原始结果
+            list = againSql.getList(AdsGameDayAgain.class);
+        } else if (tableName.equals("buy")) {
+            againSql = Sqls.create(adsGameDataAgainBuy() + cri);
+            //自定义回传对象
+            againSql.setCallback(Sqls.callback.entities());
+            againSql.setEntity(dao.getEntity(AdsGameDayAgainBuy.class));
+            //执行sql
+            dao.execute(againSql);
+            //得到查询的原始结果
+            list = againSql.getList(AdsGameDayAgainBuy.class);
+        } else if (tableName.equals("nature")) {
+            againSql = Sqls.create(adsGameDataAgainNature() + cri);
+            //自定义回传对象
+            againSql.setCallback(Sqls.callback.entities());
+            againSql.setEntity(dao.getEntity(AdsGameDayAgainNature.class));
+            //执行sql
+            dao.execute(againSql);
+            //得到查询的原始结果
+            list = againSql.getList(AdsGameDayAgainNature.class);
+        }
+        //返回结果
+        return list;
+    }
+
+    /**
+     * 复充表sql(总量)
+     * @return sql
+     */
+    private String adsGameDataAgain() {
+        return
+                """  
+                    SELECT
+                        dt,
+                        ddf,
+                        game_id,
+                        game_name,
+                        c1,
+                        c2,
+                        c3,
+                        c4,
+                        c5,
+                        c6,
+                        c7,
+                        c8,
+                        c9
+                    FROM
+                        ads_game_day_again
+                """;
+    }
+
+    /**
+     * 复充表sql(买量)
+     * @return sql
+     */
+    private String adsGameDataAgainBuy() {
+        return
+                """  
+                    SELECT
+                        dt,
+                        ddf,
+                        game_id,
+                        game_name,
+                        buy_c1,
+                        buy_c2,
+                        buy_c3,
+                        buy_c4,
+                        buy_c5,
+                        buy_c6,
+                        buy_c7,
+                        buy_c8,
+                        buy_c9
+                    FROM
+                        ads_game_day_again_buy
+                """;
+    }
+
+    /**
+     * 复充表sql(自然量)
+     * @return sql
+     */
+    private String adsGameDataAgainNature() {
+        return
+                """  
+                    SELECT
+                        dt,
+                        ddf,
+                        game_id,
+                        game_name,
+                        nature_c1,
+                        nature_c2,
+                        nature_c3,
+                        nature_c4,
+                        nature_c5,
+                        nature_c6,
+                        nature_c7,
+                        nature_c8,
+                        nature_c9
+                    FROM
+                        ads_game_day_again_nature
+                """;
+    }
+
 }