Pārlūkot izejas kodu

Merge branch 'package' into dev

wcc 1 gadu atpakaļ
vecāks
revīzija
c0542b6f2d
24 mainītis faili ar 1088 papildinājumiem un 299 dzēšanām
  1. 16 1
      game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/controller/BackPolicyController.java
  2. 57 0
      game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/pojo/dto/GameBackPolicyDTO.java
  3. 65 16
      game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/pojo/entity/GameBackPolicy.java
  4. 35 0
      game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/pojo/enums/BackUnitEnum.java
  5. 59 0
      game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/pojo/vo/GameBackPolicyVO.java
  6. 26 0
      game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameBackPolicyServiceImpl.java
  7. 5 2
      game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameOceanengineOrderLogServiceImpl.java
  8. 6 2
      game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameTencentMiniGameOrderServiceImpl.java
  9. 5 2
      game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameTencentOrderServiceImpl.java
  10. 94 48
      game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/utils/BackPolicyUtil.java
  11. 10 2
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/controller/AdsPromotionDayController.java
  12. 3 3
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/controller/GameDataController.java
  13. 18 0
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/entity/AdsAccountAgentDay.java
  14. 18 0
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/GamePromoteDayTotalVO.java
  15. 18 0
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/GamePromoteDayVO.java
  16. 18 0
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/GamePromoteTotalSumVO.java
  17. 18 0
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/GamePromoteTotalVO.java
  18. 2 2
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/H5BuyUserVO.java
  19. 2 2
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/H5NatureUserVO.java
  20. 7 0
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/PromotionDayVO.java
  21. 7 0
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/IAdsPromotionDayService.java
  22. 64 12
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/AccountAgentDayServiceImpl.java
  23. 188 38
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/GameDataServiceImpl.java
  24. 347 169
      game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/PromotionDayServiceImpl.java

+ 16 - 1
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/controller/BackPolicyController.java

@@ -3,6 +3,7 @@ package com.zanxiang.game.back.serve.controller;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.zanxiang.erp.security.annotation.PreAuthorize;
 import com.zanxiang.game.back.serve.pojo.dto.*;
+import com.zanxiang.game.back.serve.pojo.enums.BackUnitEnum;
 import com.zanxiang.game.back.serve.pojo.vo.*;
 import com.zanxiang.game.back.serve.service.*;
 import com.zanxiang.module.util.exception.BaseException;
@@ -13,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import java.math.BigDecimal;
 import java.util.List;
 
 @RestController
@@ -62,6 +62,10 @@ public class BackPolicyController {
     }
 
     private void checkDTO(GameBackPolicyDTO dto) {
+        BackUnitEnum backUnit = BackUnitEnum.getByValue(dto.getBackUnit());
+        if (backUnit == null) {
+            dto.setBackUnit(BackUnitEnum.UNIT_ONCE.getValue());
+        }
         if (dto.getFirstMinMoney().compareTo(dto.getFirstMaxMoney()) >= 0) {
             throw new BaseException("首充的大额金额必须大于小额金额");
         }
@@ -71,5 +75,16 @@ public class BackPolicyController {
         if (dto.getRegPayIntervalTime() != null && dto.getRegPayIntervalTime() <= 0) {
             throw new BaseException("注册充值回传的最大间隔时间不能小于 1");
         }
+        if (dto.getMarkUpOrder() == null) {
+            dto.setMarkUpOrder(false);
+        }
+        if (dto.getMarkUpOrder()) {
+            if (dto.getRegPayIntervalTime() == null) {
+                throw new BaseException("开启补单后必需填充值注册回传最大间隔时间");
+            }
+            if (dto.getMarkUpOrderMinMoney().compareTo(dto.getMarkUpOrderMaxMoney()) >= 0) {
+                throw new BaseException("首充的大额金额必须大于小额金额");
+            }
+        }
     }
 }

+ 57 - 0
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/pojo/dto/GameBackPolicyDTO.java

@@ -35,6 +35,9 @@ public class GameBackPolicyDTO implements Serializable {
     @ApiModelProperty("回传策略名")
     private String backPolicyName;
 
+    @ApiModelProperty("回传类型(1:首单、次单、2:首日、次日)")
+    private Integer backUnit;
+
     /**
      * 首充-小额判定金额(小于等于)
      */
@@ -157,5 +160,59 @@ public class GameBackPolicyDTO implements Serializable {
     @ApiModelProperty("注册充值回传的最大间隔时间(超时不回传)")
     private Long regPayIntervalTime;
 
+    /**
+     * 是否补单
+     */
+    @ApiModelProperty("是否补单")
+    private Boolean markUpOrder;
+
+    /**
+     * 补单-小额判定金额(小于等于)
+     */
+    @ApiModelProperty("补单-小额判定金额(小于等于)")
+    private BigDecimal markUpOrderMinMoney;
+
+    /**
+     * 补单-小额回传方式(概率/比例)
+     */
+    @ApiModelProperty("补单-小额回传方式(概率/比例)")
+    private Integer markUpOrderMinMoneyType;
+
+    /**
+     * 补单-小额回传概率/比例
+     */
+    @ApiModelProperty("补单-小额回传概率/比例")
+    private String markUpOrderMinMoneyRate;
+
+    /**
+     * 补单-大额判定金额(大于等于)
+     */
+    @ApiModelProperty("补单-大额判定金额(大于等于)")
+    private BigDecimal markUpOrderMaxMoney;
+
+    /**
+     * 补单-大额回传方式(概率/比例)
+     */
+    @ApiModelProperty("补单-大额回传方式(概率/比例)")
+    private Integer markUpOrderMaxMoneyType;
+
+    /**
+     * 补单-大额回传概率/比例
+     */
+    @ApiModelProperty("补单-大额回传概率/比例")
+    private String markUpOrderMaxMoneyRate;
+
+    /**
+     * 补单-其它金额回传方式(概率/比例)
+     */
+    @ApiModelProperty("补单-其它金额回传方式(概率/比例)")
+    private Integer markUpOrderOtherMoneyType;
+
+    /**
+     * 补单-其它金额回传概率/比例
+     */
+    @ApiModelProperty("补单-其它金额回传概率/比例")
+    private String markUpOrderOtherMoneyRate;
+
 
 }

+ 65 - 16
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/pojo/entity/GameBackPolicy.java

@@ -38,82 +38,82 @@ public class GameBackPolicy implements Serializable {
     private String backPolicyName;
 
     /**
-     * 首充-小额判定金额(小于等于)
+     * 首充/日-小额判定金额(小于等于)
      */
     private Long firstMinMoney;
 
     /**
-     * 首充-小额回传方式(概率/比例)
+     * 首充/日-小额回传方式(概率/比例)
      */
     private Integer firstMinMoneyType;
 
     /**
-     * 首充-小额回传概率/比例
+     * 首充/日-小额回传概率/比例
      */
     private String firstMinMoneyRate;
 
     /**
-     * 首充-大额判定金额(大于等于)
+     * 首充/日-大额判定金额(大于等于)
      */
     private Long firstMaxMoney;
 
     /**
-     * 首充-大额回传方式(概率/比例)
+     * 首充/日-大额回传方式(概率/比例)
      */
     private Integer firstMaxMoneyType;
 
     /**
-     * 首充-大额回传概率/比例
+     * 首充/日-大额回传概率/比例
      */
     private String firstMaxMoneyRate;
 
     /**
-     * 首充-其它金额回传方式(概率/比例)
+     * 首充/日-其它金额回传方式(概率/比例)
      */
     private Integer firstOtherMoneyType;
 
     /**
-     * 首充-其它金额回传概率/比例
+     * 首充/日-其它金额回传概率/比例
      */
     private String firstOtherMoneyRate;
 
     /**
-     * 次单-小额判定金额(小于等于)
+     * 次单/日-小额判定金额(小于等于)
      */
     private Long rechargeMinMoney;
 
     /**
-     * 次单-小额回传方式(概率/比例)
+     * 次单/日-小额回传方式(概率/比例)
      */
     private Integer rechargeMinMoneyType;
 
     /**
-     * 次单-小额回传概率/比例
+     * 次单/日-小额回传概率/比例
      */
     private String rechargeMinMoneyRate;
 
     /**
-     * 次单-大额判定金额(大于等于)
+     * 次单/日-大额判定金额(大于等于)
      */
     private Long rechargeMaxMoney;
 
     /**
-     * 次单-大额回传方式(概率/比例)
+     * 次单/日-大额回传方式(概率/比例)
      */
     private Integer rechargeMaxMoneyType;
 
     /**
-     * 次单-大额回传概率/比例
+     * 次单/日-大额回传概率/比例
      */
     private String rechargeMaxMoneyRate;
 
     /**
-     * 次单-其它金额回传方式(概率/比例)
+     * 次单/日-其它金额回传方式(概率/比例)
      */
     private Integer rechargeOtherMoneyType;
 
     /**
-     * 次单-其它金额回传概率/比例
+     * 次单/日-其它金额回传概率/比例
      */
     private String rechargeOtherMoneyRate;
 
@@ -132,5 +132,54 @@ public class GameBackPolicy implements Serializable {
 
     private Long regPayIntervalTime;
 
+    /**
+     * 回传类型(1:首单、次单、2:首日、次日)
+     */
+    private Integer backUnit;
+
+    /**
+     * 是否补单
+     */
+    private Boolean markUpOrder;
+    /**
+     * 补单-小额判定金额(小于等于)
+     */
+    private Long markUpOrderMinMoney;
+
+    /**
+     * 补单-小额回传方式(概率/比例)
+     */
+    private Integer markUpOrderMinMoneyType;
+
+    /**
+     * 补单-小额回传概率/比例
+     */
+    private String markUpOrderMinMoneyRate;
+
+    /**
+     * 补单-大额判定金额(大于等于)
+     */
+    private Long markUpOrderMaxMoney;
+
+    /**
+     * 补单-大额回传方式(概率/比例)
+     */
+    private Integer markUpOrderMaxMoneyType;
+
+    /**
+     * 补单-大额回传概率/比例
+     */
+    private String markUpOrderMaxMoneyRate;
+
+    /**
+     * 补单-其它金额回传方式(概率/比例)
+     */
+    private Integer markUpOrderOtherMoneyType;
+
+    /**
+     * 补单-其它金额回传概率/比例
+     */
+    private String markUpOrderOtherMoneyRate;
+
 
 }

+ 35 - 0
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/pojo/enums/BackUnitEnum.java

@@ -0,0 +1,35 @@
+package com.zanxiang.game.back.serve.pojo.enums;
+
+import lombok.Getter;
+
+import java.util.Objects;
+
+@Getter
+public enum BackUnitEnum {
+    /**
+     * 未回传
+     */
+    UNIT_ONCE(1),
+    /**
+     * 回传成功
+     */
+    UNIT_DAY(2);
+
+    private final Integer value;
+
+    BackUnitEnum(Integer value) {
+        this.value = value;
+    }
+
+    public static BackUnitEnum getByValue(Integer value) {
+        if (value == null) {
+            return null;
+        }
+        for (BackUnitEnum backUnit : BackUnitEnum.values()) {
+            if (Objects.equals(backUnit.getValue(), value)) {
+                return backUnit;
+            }
+        }
+        return null;
+    }
+}

+ 59 - 0
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/pojo/vo/GameBackPolicyVO.java

@@ -31,6 +31,9 @@ public class GameBackPolicyVO implements Serializable {
     @ApiModelProperty("回传策略名")
     private String backPolicyName;
 
+    @ApiModelProperty("回传类型(1:首单、次单、2:首日、次日)")
+    private Integer backUnit;
+
     /**
      * 首充-小额判定金额(小于等于)
      */
@@ -138,7 +141,63 @@ public class GameBackPolicyVO implements Serializable {
     private Long createBy;
 
     private String createName;
+
+    @ApiModelProperty("充值注册最大间隔时间(超时不回传)")
     private Long regPayIntervalTime;
 
+    /**
+     * 是否补单
+     */
+    @ApiModelProperty("是否补单")
+    private Boolean markUpOrder;
+
+    /**
+     * 补单-小额判定金额(小于等于)
+     */
+    @ApiModelProperty("补单-小额判定金额(小于等于)")
+    private BigDecimal markUpOrderMinMoney;
+
+    /**
+     * 补单-小额回传方式(概率/比例)
+     */
+    @ApiModelProperty("补单-小额回传方式(概率/比例)")
+    private Integer markUpOrderMinMoneyType;
+
+    /**
+     * 补单-小额回传概率/比例
+     */
+    @ApiModelProperty("补单-小额回传概率/比例")
+    private String markUpOrderMinMoneyRate;
+
+    /**
+     * 补单-大额判定金额(大于等于)
+     */
+    @ApiModelProperty("补单-大额判定金额(大于等于)")
+    private BigDecimal markUpOrderMaxMoney;
+
+    /**
+     * 补单-大额回传方式(概率/比例)
+     */
+    @ApiModelProperty("补单-大额回传方式(概率/比例)")
+    private Integer markUpOrderMaxMoneyType;
+
+    /**
+     * 补单-大额回传概率/比例
+     */
+    @ApiModelProperty("补单-大额回传概率/比例")
+    private String markUpOrderMaxMoneyRate;
+
+    /**
+     * 补单-其它金额回传方式(概率/比例)
+     */
+    @ApiModelProperty("补单-其它金额回传方式(概率/比例)")
+    private Integer markUpOrderOtherMoneyType;
+
+    /**
+     * 补单-其它金额回传概率/比例
+     */
+    @ApiModelProperty("补单-其它金额回传概率/比例")
+    private String markUpOrderOtherMoneyRate;
+
 
 }

+ 26 - 0
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameBackPolicyServiceImpl.java

@@ -99,6 +99,16 @@ public class GameBackPolicyServiceImpl extends ServiceImpl<GameBackPolicyMapper,
                 .createBy(SecurityUtil.getUserId())
                 .createTime(LocalDateTime.now())
                 .regPayIntervalTime(dto.getRegPayIntervalTime())
+                .backUnit(dto.getBackUnit())
+                .markUpOrder(dto.getMarkUpOrder())
+                .markUpOrderMinMoney(dto.getMarkUpOrderMinMoney() == null ? null : NumberUtil.multiply100(dto.getMarkUpOrderMinMoney()).longValue())
+                .markUpOrderMinMoneyType(dto.getMarkUpOrderMinMoneyType())
+                .markUpOrderMinMoneyRate(dto.getMarkUpOrderMinMoneyRate())
+                .markUpOrderMaxMoney(dto.getMarkUpOrderMaxMoney() == null ? null : NumberUtil.multiply100(dto.getMarkUpOrderMaxMoney()).longValue())
+                .markUpOrderMaxMoneyType(dto.getFirstMaxMoneyType())
+                .markUpOrderMaxMoneyRate(dto.getMarkUpOrderMaxMoneyRate())
+                .markUpOrderOtherMoneyType(dto.getFirstOtherMoneyType())
+                .markUpOrderOtherMoneyRate(dto.getMarkUpOrderMaxMoneyRate())
                 .build();
         return gameBackPolicyService.save(backPolicy);
     }
@@ -134,6 +144,16 @@ public class GameBackPolicyServiceImpl extends ServiceImpl<GameBackPolicyMapper,
                 .createTime(old.getCreateTime())
                 .updateBy(SecurityUtil.getUserId())
                 .updateTime(LocalDateTime.now())
+                .backUnit(dto.getBackUnit())
+                .markUpOrder(dto.getMarkUpOrder())
+                .markUpOrderMinMoney(dto.getMarkUpOrderMinMoney() == null ? null : NumberUtil.multiply100(dto.getMarkUpOrderMinMoney()).longValue())
+                .markUpOrderMinMoneyType(dto.getMarkUpOrderMinMoneyType())
+                .markUpOrderMinMoneyRate(dto.getMarkUpOrderMinMoneyRate())
+                .markUpOrderMaxMoney(dto.getMarkUpOrderMaxMoney() == null ? null : NumberUtil.multiply100(dto.getMarkUpOrderMaxMoney()).longValue())
+                .markUpOrderMaxMoneyType(dto.getFirstMaxMoneyType())
+                .markUpOrderMaxMoneyRate(dto.getMarkUpOrderMaxMoneyRate())
+                .markUpOrderOtherMoneyType(dto.getFirstOtherMoneyType())
+                .markUpOrderOtherMoneyRate(dto.getMarkUpOrderMaxMoneyRate())
                 .build();
 
         return gameBackPolicyService.updateById(backPolicy);
@@ -161,6 +181,12 @@ public class GameBackPolicyServiceImpl extends ServiceImpl<GameBackPolicyMapper,
         vo.setFirstMaxMoney(NumberUtil.divide100(new BigDecimal(gameBackPolicy.getFirstMaxMoney())));
         vo.setRechargeMinMoney(NumberUtil.divide100(new BigDecimal(gameBackPolicy.getRechargeMinMoney())));
         vo.setRechargeMaxMoney(NumberUtil.divide100(new BigDecimal(gameBackPolicy.getRechargeMaxMoney())));
+        if (gameBackPolicy.getMarkUpOrderMinMoney() != null) {
+            vo.setMarkUpOrderMinMoney(NumberUtil.divide100(new BigDecimal(gameBackPolicy.getMarkUpOrderMinMoney())));
+        }
+        if (gameBackPolicy.getMarkUpOrderMaxMoney() != null) {
+            vo.setMarkUpOrderMaxMoney(NumberUtil.divide100(new BigDecimal(gameBackPolicy.getMarkUpOrderMaxMoney())));
+        }
         return vo;
     }
 

+ 5 - 2
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameOceanengineOrderLogServiceImpl.java

@@ -75,13 +75,16 @@ public class GameOceanengineOrderLogServiceImpl extends ServiceImpl<GameOceaneng
                 doBack = BackPolicyUtil.backOrder(orderLog.getOrderNo(), gameBackPolicy, orderLog.getAmount(),
                         orderLog.getIsFirstOrder(),
                         orderLog.getPayTime(), orderLog.getRegTime(),
-                        (backUnit, isFirstOrder) -> Long.valueOf(list(new LambdaQueryWrapper<GameOceanengineOrderLog>()
+                        (backUnit, isFirstOrder, firstDay, markUpTime) -> Long.valueOf(list(new LambdaQueryWrapper<GameOceanengineOrderLog>()
                                         .eq(GameOceanengineOrderLog::getGameId, orderLog.getGameId())
                                         .eq(GameOceanengineOrderLog::getAppId, orderLog.getAppId())
                                         .eq(GameOceanengineOrderLog::getAccountId, orderLog.getAccountId())
                                         .eq(GameOceanengineOrderLog::getBackPolicyId, gameBackPolicy.getId())
                                         .eq(GameOceanengineOrderLog::getOrderStatus, OrderStatusEnum.SUCCESS_PAY.getValue())
-                                        .eq(GameOceanengineOrderLog::getIsFirstOrder, isFirstOrder)
+                                        .eq(isFirstOrder != null, GameOceanengineOrderLog::getIsFirstOrder, isFirstOrder)
+                                        .apply(firstDay != null && firstDay, "date(reg_time) = date(pay_time)")
+                                        .apply(firstDay != null && !firstDay, "date(reg_time) != date(pay_time)")
+                                        .apply(markUpTime != null, "TIMESTAMPDIFF(MINUTE, reg_time, pay_time) > {0}", markUpTime)
                                         .ne(GameOceanengineOrderLog::getOrderNo, orderLog.getOrderNo())
                                         .orderByDesc(GameOceanengineOrderLog::getCreateTime)
                                         .last("limit " + backUnit)

+ 6 - 2
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameTencentMiniGameOrderServiceImpl.java

@@ -13,6 +13,7 @@ import com.zanxiang.game.back.base.pojo.enums.OrderStatusEnum;
 import com.zanxiang.game.back.serve.dao.mapper.GameTencentMiniGameOrderMapper;
 import com.zanxiang.game.back.serve.pojo.dto.GameTencentMiniGameOrderDTO;
 import com.zanxiang.game.back.serve.pojo.entity.GameBackPolicy;
+import com.zanxiang.game.back.serve.pojo.entity.GameOceanengineOrderLog;
 import com.zanxiang.game.back.serve.pojo.entity.GameTencentMiniGameOrder;
 import com.zanxiang.game.back.serve.pojo.enums.BackStatusEnum;
 import com.zanxiang.game.back.serve.pojo.vo.GameTencentMiniGameOrderVO;
@@ -81,13 +82,16 @@ public class GameTencentMiniGameOrderServiceImpl extends ServiceImpl<GameTencent
                 // 此处是否是首单用 limit 2。因为在执行判断之前订单已入库,所以库里只有一笔才是首单
                 doBack = BackPolicyUtil.backOrder(orderLog.getOrderId(), gameBackPolicy, orderLog.getRechargeMoney(),
                         orderLog.getIsFirstOrder(), orderLog.getPayTime(), orderLog.getRegisterTime(),
-                        (backUnit, isFirstOrder) -> Long.valueOf(list(new LambdaQueryWrapper<GameTencentMiniGameOrder>()
+                        (backUnit, isFirstOrder, firstDay, markUpTime) -> Long.valueOf(list(new LambdaQueryWrapper<GameTencentMiniGameOrder>()
                                         .eq(GameTencentMiniGameOrder::getGameId, orderLog.getGameId())
                                         .eq(GameTencentMiniGameOrder::getWechatAppId, orderLog.getWechatAppId())
                                         .eq(GameTencentMiniGameOrder::getAdAccountId, orderLog.getAdAccountId())
                                         .eq(GameTencentMiniGameOrder::getOrderStatus, OrderStatusEnum.SUCCESS_PAY.getValue())
                                         .eq(GameTencentMiniGameOrder::getBackPolicyId, gameBackPolicy.getId())
-                                        .eq(GameTencentMiniGameOrder::getIsFirstOrder, isFirstOrder)
+                                        .eq(isFirstOrder != null, GameTencentMiniGameOrder::getIsFirstOrder, isFirstOrder)
+                                        .apply(firstDay != null && firstDay, "date(register_time) = date(pay_time)")
+                                        .apply(firstDay != null && !firstDay, "date(register_time) != date(pay_time)")
+                                        .apply(markUpTime != null, "TIMESTAMPDIFF(MINUTE, register_time, pay_time) > {0}", markUpTime)
                                         .ne(GameTencentMiniGameOrder::getOrderId, orderLog.getOrderId())
                                         .orderByDesc(GameTencentMiniGameOrder::getCreateTime)
                                         .last("limit " + backUnit)

+ 5 - 2
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameTencentOrderServiceImpl.java

@@ -91,13 +91,16 @@ public class GameTencentOrderServiceImpl extends ServiceImpl<GameTencentOrderMap
                 GameBackPolicy gameBackPolicy = gameBackPolicyService.getById(orderLog.getBackPolicyId());
                 doBack = BackPolicyUtil.backOrder(orderLog.getOrderId(), gameBackPolicy, orderLog.getRechargeMoney(),
                         orderLog.getIsFirstOrder(), orderLog.getPayTime(), orderLog.getRegisterTime(),
-                        (backUnit, isFirstOrder) -> Long.valueOf(list(new LambdaQueryWrapper<GameTencentOrder>()
+                        (backUnit, isFirstOrder, firstDay, markUpTime) -> Long.valueOf(list(new LambdaQueryWrapper<GameTencentOrder>()
                                         .eq(GameTencentOrder::getGameId, orderLog.getGameId())
                                         .eq(GameTencentOrder::getWechatAppId, orderLog.getWechatAppId())
                                         .eq(GameTencentOrder::getAdAccountId, orderLog.getAdAccountId())
                                         .eq(GameTencentOrder::getBackPolicyId, gameBackPolicy.getId())
                                         .eq(GameTencentOrder::getOrderStatus, OrderStatusEnum.SUCCESS_PAY.getValue())
-                                        .eq(GameTencentOrder::getIsFirstOrder, isFirstOrder)
+                                        .eq(isFirstOrder != null, GameTencentOrder::getIsFirstOrder, isFirstOrder)
+                                        .apply(firstDay != null && firstDay, "date(register_time) = date(pay_time)")
+                                        .apply(firstDay != null && !firstDay, "date(register_time) != date(pay_time)")
+                                        .apply(markUpTime != null, "TIMESTAMPDIFF(MINUTE, register_time, pay_time) > {0}", markUpTime)
                                         .ne(GameTencentOrder::getOrderId, orderLog.getOrderId())
                                         .orderByDesc(GameTencentOrder::getCreateTime)
                                         .last("limit " + backUnit)

+ 94 - 48
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/utils/BackPolicyUtil.java

@@ -3,6 +3,7 @@ package com.zanxiang.game.back.serve.utils;
 import com.github.sd4324530.jtuple.Tuple2;
 import com.github.sd4324530.jtuple.Tuples;
 import com.zanxiang.game.back.serve.pojo.entity.GameBackPolicy;
+import com.zanxiang.game.back.serve.pojo.enums.BackUnitEnum;
 import com.zanxiang.module.util.DateUtil;
 import com.zanxiang.module.util.JsonUtil;
 import com.zanxiang.module.util.NumberUtil;
@@ -36,56 +37,101 @@ public class BackPolicyUtil {
             log.error("订单 id[{}]通过回传策略[null]判断后,是否回传:{}.", orderId, true);
             return true;
         }
-        log.error("----orderId: {}, backPolicy: {}, money: {}", orderId, JsonUtil.toString(gameBackPolicy), rechargeMoney);
-        if (payTime != null && gameBackPolicy.getRegPayIntervalTime() != null) {
-            long regPayIntervalMinute = (DateUtil.localDateTimeToSecond(payTime) - DateUtil.localDateTimeToSecond(regTime)) / 60;
-            if (regPayIntervalMinute > gameBackPolicy.getRegPayIntervalTime()) {
-                log.error("订单 id[{}]通过回传策略[{}]判断后,超过注册充值间隔时间,不回传{}.", orderId, gameBackPolicy.getId(), gameBackPolicy.getRegPayIntervalTime());
-                return false;
-            }
-        }
-        Integer firstType;
-        String firstRate;
-        Integer rechargeType;
-        String rechargeRate;
-        if (rechargeMoney <= gameBackPolicy.getFirstMinMoney()) {
-            // 小于首充金额
-            firstType = gameBackPolicy.getFirstMinMoneyType();
-            firstRate = gameBackPolicy.getFirstMinMoneyRate();
-        } else if (rechargeMoney >= gameBackPolicy.getFirstMaxMoney()) {
-            firstType = gameBackPolicy.getFirstMaxMoneyType();
-            firstRate = gameBackPolicy.getFirstMaxMoneyRate();
-        } else {
-            firstType = gameBackPolicy.getFirstOtherMoneyType();
-            firstRate = gameBackPolicy.getFirstOtherMoneyRate();
-        }
-        if (rechargeMoney <= gameBackPolicy.getRechargeMinMoney()) {
-            rechargeType = gameBackPolicy.getRechargeMinMoneyType();
-            rechargeRate = gameBackPolicy.getRechargeMinMoneyRate();
-        } else if (rechargeMoney >= gameBackPolicy.getRechargeMaxMoney()) {
-            rechargeType = gameBackPolicy.getRechargeMaxMoneyType();
-            rechargeRate = gameBackPolicy.getRechargeMaxMoneyRate();
-        } else {
-            rechargeType = gameBackPolicy.getRechargeOtherMoneyType();
-            rechargeRate = gameBackPolicy.getRechargeOtherMoneyRate();
-        }
-        boolean firstPolicy = false;
+        BackUnitEnum backUnit = gameBackPolicy.getBackUnit() == null ? BackUnitEnum.UNIT_ONCE : BackUnitEnum.getByValue(gameBackPolicy.getBackUnit());
+
+        Boolean firstPolicy = null, firstDay = null;
+        Long markUpTime = null;
         Integer backType;
         String backRate;
-        if (firstType.equals(rechargeType) && firstRate.equalsIgnoreCase(rechargeRate)) {
-            // 回传内容相同,不需要区分是不是首单
-            backType = firstType;
-            backRate = firstRate;
+        if (gameBackPolicy.getRegPayIntervalTime() != null
+                && ((DateUtil.localDateTimeToSecond(payTime) - DateUtil.localDateTimeToSecond(regTime)) / 60) > gameBackPolicy.getRegPayIntervalTime()) {
+            if (gameBackPolicy.getMarkUpOrder() != null && gameBackPolicy.getMarkUpOrder()) {
+                markUpTime = gameBackPolicy.getRegPayIntervalTime();
+                if (rechargeMoney <= gameBackPolicy.getMarkUpOrderMinMoney()) {
+                    // 小额
+                    backType = gameBackPolicy.getMarkUpOrderMinMoneyType();
+                    backRate = gameBackPolicy.getMarkUpOrderMinMoneyRate();
+                } else if (rechargeMoney >= gameBackPolicy.getMarkUpOrderMaxMoney()) {
+                    // 大额
+                    backType = gameBackPolicy.getMarkUpOrderMaxMoneyType();
+                    backRate = gameBackPolicy.getMarkUpOrderMaxMoneyRate();
+                } else {
+                    backType = gameBackPolicy.getMarkUpOrderOtherMoneyType();
+                    backRate = gameBackPolicy.getMarkUpOrderOtherMoneyRate();
+                }
+                log.error("订单 id[{}]通过回传策略[{}]判断后,超过注册充值间隔时间,走补单逻辑 {}.", orderId, gameBackPolicy.getId(), gameBackPolicy.getRegPayIntervalTime());
+            } else {
+                log.error("订单 id[{}]通过回传策略[{}]判断后,超过注册充值间隔时间,不回穿 {}.", orderId, gameBackPolicy.getId(), gameBackPolicy.getRegPayIntervalTime());
+                return false;
+            }
         } else {
-            if (isFirstOrder) {
-                log.error("订单{}是首单", orderId);
-                backType = firstType;
-                backRate = firstRate;
-                firstPolicy = true;
+            if (backUnit == BackUnitEnum.UNIT_ONCE) {
+                if (isFirstOrder) {
+                    firstPolicy = true;
+                    if (rechargeMoney <= gameBackPolicy.getFirstMinMoney()) {
+                        // 小额
+                        backType = gameBackPolicy.getFirstMinMoneyType();
+                        backRate = gameBackPolicy.getFirstMinMoneyRate();
+                    } else if (rechargeMoney >= gameBackPolicy.getFirstMaxMoney()) {
+                        // 大额
+                        backType = gameBackPolicy.getFirstMaxMoneyType();
+                        backRate = gameBackPolicy.getFirstMaxMoneyRate();
+                    } else {
+                        backType = gameBackPolicy.getFirstOtherMoneyType();
+                        backRate = gameBackPolicy.getFirstOtherMoneyRate();
+                    }
+                    log.error("订单 id[{}]通过回传策略[{}]判断后,正常回传. 首单:{}, backType: {}, backRate: {}", orderId, gameBackPolicy.getId(), true, backType, backRate);
+                } else {
+                    firstPolicy = false;
+                    if (rechargeMoney <= gameBackPolicy.getRechargeMinMoney()) {
+                        // 小额
+                        backType = gameBackPolicy.getRechargeMinMoneyType();
+                        backRate = gameBackPolicy.getRechargeMinMoneyRate();
+                    } else if (rechargeMoney >= gameBackPolicy.getRechargeMaxMoney()) {
+                        // 大额
+                        backType = gameBackPolicy.getRechargeMaxMoneyType();
+                        backRate = gameBackPolicy.getRechargeMaxMoneyRate();
+                    } else {
+                        backType = gameBackPolicy.getRechargeOtherMoneyType();
+                        backRate = gameBackPolicy.getRechargeOtherMoneyRate();
+                    }
+                    log.error("订单 id[{}]通过回传策略[{}]判断后,正常回传. 首单:{}, backType: {}, backRate: {}", orderId, gameBackPolicy.getId(), false, backType, backRate);
+                }
+            } else if (backUnit == BackUnitEnum.UNIT_DAY) {
+                long intervalDays = DateUtil.intervalOfDays(regTime.toLocalDate(), payTime.toLocalDate());
+                if (intervalDays == 0) {
+                    firstDay = true;
+                    if (rechargeMoney <= gameBackPolicy.getFirstMinMoney()) {
+                        // 小额
+                        backType = gameBackPolicy.getFirstMinMoneyType();
+                        backRate = gameBackPolicy.getFirstMinMoneyRate();
+                    } else if (rechargeMoney >= gameBackPolicy.getFirstMaxMoney()) {
+                        // 大额
+                        backType = gameBackPolicy.getFirstMaxMoneyType();
+                        backRate = gameBackPolicy.getFirstMaxMoneyRate();
+                    } else {
+                        backType = gameBackPolicy.getFirstOtherMoneyType();
+                        backRate = gameBackPolicy.getFirstOtherMoneyRate();
+                    }
+                    log.error("订单 id[{}]通过回传策略[{}]判断后,正常回传. 首日:{}, backType: {}, backRate: {}", orderId, gameBackPolicy.getId(), true, backType, backRate);
+                } else {
+                    firstDay = false;
+                    if (rechargeMoney <= gameBackPolicy.getRechargeMinMoney()) {
+                        // 小额
+                        backType = gameBackPolicy.getRechargeMinMoneyType();
+                        backRate = gameBackPolicy.getRechargeMinMoneyRate();
+                    } else if (rechargeMoney >= gameBackPolicy.getRechargeMaxMoney()) {
+                        // 大额
+                        backType = gameBackPolicy.getRechargeMaxMoneyType();
+                        backRate = gameBackPolicy.getRechargeMaxMoneyRate();
+                    } else {
+                        backType = gameBackPolicy.getRechargeOtherMoneyType();
+                        backRate = gameBackPolicy.getRechargeOtherMoneyRate();
+                    }
+                    log.error("订单 id[{}]通过回传策略[{}]判断后,正常回传. 首日:{}, backType: {}, backRate: {}", orderId, gameBackPolicy.getId(), false, backType, backRate);
+                }
             } else {
-                log.error("订单{}不是首单", orderId);
-                backType = rechargeType;
-                backRate = rechargeRate;
+                throw new RuntimeException("未知的回传单位:" + backUnit);
             }
         }
         if (Objects.equals(backType, GameBackPolicy.POLICY_TYPE_FIXED_RATE)) {
@@ -101,7 +147,7 @@ public class BackPolicyUtil {
                 log.error("订单 id[{}]通过回传策略[{}]判断后,是否回传:{}.", orderId, gameBackPolicy.getId(), true);
                 return true;
             }
-            int isBackCount = lastBackFunction.getLastBackCount(backCount + ignoreCount - 1, firstPolicy);
+            int isBackCount = lastBackFunction.getLastBackCount(backCount + ignoreCount - 1, firstPolicy, firstDay, markUpTime);
             log.error("订单 id[{}]通过回传策略[{}]判断后,是否回传:{}.", orderId, gameBackPolicy.getId(), (isBackCount < backCount));
             return isBackCount < backCount;
         } else if (Objects.equals(backType, GameBackPolicy.POLICY_TYPE_RANDOM_RATE)) {
@@ -151,6 +197,6 @@ public class BackPolicyUtil {
     }
 
     public interface LastBackFunction {
-        int getLastBackCount(int backUnit, boolean isFirstOrder);
+        int getLastBackCount(int backUnit, Boolean isFirstOrder, Boolean firstDay, Long markUpTime);
     }
 }

+ 10 - 2
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/controller/AdsPromotionDayController.java

@@ -1,5 +1,6 @@
 package com.zanxiang.game.data.serve.controller;
 
+import com.zanxiang.erp.security.annotation.PreAuthorize;
 import com.zanxiang.game.data.serve.pojo.dto.PromotionDayDTO;
 import com.zanxiang.game.data.serve.pojo.dto.PromotionDayTotalDTO;
 import com.zanxiang.game.data.serve.pojo.vo.PromotionDayTotalVO;
@@ -31,17 +32,24 @@ public class AdsPromotionDayController {
     private IAdsPromotionDayService adsPromotionDayService;
 
     @ApiOperation(value = "广告监控数据")
-    //@PreAuthorize(permissionKey = "promotionData:adsPromotionDay:day")
+    @PreAuthorize(permissionKey = "promotionData:adsPromotionDay:day")
     @PostMapping("/day")
     public ResultVO<Page<PromotionDayVO>> getPromotionDayData(@RequestBody PromotionDayDTO dto){
         return ResultVO.ok(adsPromotionDayService.getPromotionDayData(dto));
     }
 
     @ApiOperation(value = "广告监控数据总计")
-    //@PreAuthorize(permissionKey = "promotionData:adsPromotionDay:total")
+    @PreAuthorize(permissionKey = "promotionData:adsPromotionDay:total")
     @PostMapping("/total")
     public ResultVO<PromotionDayTotalVO> getPromotionDayTotalData(@RequestBody PromotionDayTotalDTO dto) {
         return ResultVO.ok(adsPromotionDayService.getPromotionDayTotalData(dto));
     }
 
+    @ApiOperation(value = "广告监控每日数据")
+    @PreAuthorize(permissionKey = "promotionData:adsPromotionDay:dayList")
+    @PostMapping("/day/list")
+    public ResultVO<Page<PromotionDayVO>> getPromotionDayListData(@RequestBody PromotionDayDTO dto){
+        return ResultVO.ok(adsPromotionDayService.getPromotionDayListData(dto));
+    }
+
 }

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

@@ -59,7 +59,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) {
@@ -67,8 +67,8 @@ public class GameDataController {
     }
 
     @ApiOperation(value = "游戏总数据总计")
-    //@PreAuthorize(permissionKey = "gameData:adsGameDay:totalTotal")
-    @PostMapping("/total/total")
+    @PreAuthorize(permissionKey = "gameData:adsGameDay:totalSum")
+    @PostMapping("/total/sum")
     public ResultVO<GameDataTotalTotalVO> getGameDataTotalTotal(@RequestBody GameDataTotalTotalDTO dto) {
         return ResultVO.ok(gameDataService.getGameDataTotalTotal(dto));
     }

+ 18 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/entity/AdsAccountAgentDay.java

@@ -909,5 +909,23 @@ public class AdsAccountAgentDay implements Serializable {
     @Column
     private Long regOrderUserAgain;
 
+    /**
+     * 首日创角人数
+     */
+    @Column
+    private Long firstRoleNum;
+
+    /**
+     * 新用户累计创角人数
+     */
+    @Column
+    private Long newUserTotalRoleNum;
+
+    /**
+     * 创角人数
+     */
+    @Column
+    private Long roleNum;
+
 
 }

+ 18 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/GamePromoteDayTotalVO.java

@@ -518,4 +518,22 @@ public class GamePromoteDayTotalVO {
 
     @ApiModelProperty(notes = "新用户累计充值次数成本 = 消耗/新用户累计充值次数")
     private BigDecimal newUserRechargeCountCost;
+
+    /**
+     * 首日创角人数
+     */
+    @ApiModelProperty(value = "首日创角人数")
+    private Long firstRoleNum;
+
+    /**
+     * 新用户累计创角人数
+     */
+    @ApiModelProperty(value = "新用户累计创角人数")
+    private Long newUserTotalRoleNum;
+
+    /**
+     * 创角人数
+     */
+    @ApiModelProperty(value = "创角人数")
+    private Long roleNum;
 }

+ 18 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/GamePromoteDayVO.java

@@ -554,4 +554,22 @@ public class GamePromoteDayVO {
 
     @ApiModelProperty(notes = "单日付费100+成本")
     private String hundredUserNumCost;
+
+    /**
+     * 首日创角人数
+     */
+    @ApiModelProperty(value = "首日创角人数")
+    private Long firstRoleNum;
+
+    /**
+     * 新用户累计创角人数
+     */
+    @ApiModelProperty(value = "新用户累计创角人数")
+    private Long newUserTotalRoleNum;
+
+    /**
+     * 创角人数
+     */
+    @ApiModelProperty(value = "创角人数")
+    private Long roleNum;
 }

+ 18 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/GamePromoteTotalSumVO.java

@@ -551,4 +551,22 @@ public class GamePromoteTotalSumVO {
 
     @ApiModelProperty(notes = "新用户累计充值次数成本 = 消耗/新用户累计充值次数")
     private BigDecimal newUserRechargeCountCost;
+
+    /**
+     * 首日创角人数
+     */
+    @ApiModelProperty(value = "首日创角人数")
+    private Long firstRoleNum;
+
+    /**
+     * 新用户累计创角人数
+     */
+    @ApiModelProperty(value = "新用户累计创角人数")
+    private Long newUserTotalRoleNum;
+
+    /**
+     * 创角人数
+     */
+    @ApiModelProperty(value = "创角人数")
+    private Long roleNum;
 }

+ 18 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/GamePromoteTotalVO.java

@@ -583,4 +583,22 @@ public class GamePromoteTotalVO {
 
     @ApiModelProperty(notes = "新用户累计充值次数成本 = 消耗/新用户累计充值次数")
     private BigDecimal newUserRechargeCountCost;
+
+    /**
+     * 首日创角人数
+     */
+    @ApiModelProperty(value = "首日创角人数")
+    private Long firstRoleNum;
+
+    /**
+     * 新用户累计创角人数
+     */
+    @ApiModelProperty(value = "新用户累计创角人数")
+    private Long newUserTotalRoleNum;
+
+    /**
+     * 创角人数
+     */
+    @ApiModelProperty(value = "创角人数")
+    private Long roleNum;
 }

+ 2 - 2
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/H5BuyUserVO.java

@@ -46,13 +46,13 @@ public class H5BuyUserVO {
     /**
      * 游戏买量导入用户数据:累计充值金额
      */
-    @ApiModelProperty("游戏买量导入用户数据:累计充值金额")
+    @ApiModelProperty("游戏买量导入用户数据:新用户累计充值金额")
     private BigDecimal h5LeadBuyNewUserTotalAmount;
 
     /**
      * 游戏买量导入用户数据:累计充值人数
      */
-    @ApiModelProperty("游戏买量导入用户数据:累计充值人数")
+    @ApiModelProperty("游戏买量导入用户数据:新用户累计充值人数")
     private Long h5LeadBuyNewUserTotalAmountNum;
 
     /**

+ 2 - 2
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/H5NatureUserVO.java

@@ -46,13 +46,13 @@ public class H5NatureUserVO {
     /**
      * 游戏官方导量用户数据:累计充值金额
      */
-    @ApiModelProperty("游戏官方导量用户数据:累计充值金额")
+    @ApiModelProperty("游戏官方导量用户数据:新用户累计充值金额")
     private BigDecimal h5LeadNatureNewUserTotalAmount;
 
     /**
      * 游戏官方导量用户数据:累计充值人数
      */
-    @ApiModelProperty("游戏官方导量用户数据:累计充值人数")
+    @ApiModelProperty("游戏官方导量用户数据:新用户累计充值人数")
     private Long h5LeadNatureNewUserTotalAmountNum;
 
     /**

+ 7 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/PromotionDayVO.java

@@ -7,6 +7,7 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import java.math.BigDecimal;
+import java.time.LocalDate;
 
 /**
  * @author tianhua
@@ -19,6 +20,12 @@ import java.math.BigDecimal;
 @Builder
 public class PromotionDayVO {
 
+    /**
+     * 时间
+     */
+    @ApiModelProperty(value = "时间")
+    private LocalDate dt;
+
     /**
      * 广告ID
      */

+ 7 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/IAdsPromotionDayService.java

@@ -22,4 +22,11 @@ public interface IAdsPromotionDayService {
      */
     PromotionDayTotalVO getPromotionDayTotalData(PromotionDayTotalDTO dto);
 
+    /**
+     * 广告监控每日数据
+     * @param dto
+     * @return
+     */
+    Page<PromotionDayVO> getPromotionDayListData(PromotionDayDTO dto);
+
 }

+ 64 - 12
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/AccountAgentDayServiceImpl.java

@@ -434,6 +434,21 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
                     group by user_id) a
                 WHERE a.repeatNum > 1
                 """);
+
+        Sql roleUserNum = Sqls.fetchLong("""
+                select
+                	count(DISTINCT role_user_id)
+                from
+                	dw_create_role_detail
+                where
+                    source_system = @sourceSystem
+                    and user_agent_id = @agentId
+                    and user_account_id = @accountId
+                    and DATE(role_create_time) >= @rechargeBeginDay
+                    and DATE(role_create_time) <= @rechargeEndDay
+                    and user_dt >= @costBeginDay
+                    and user_dt <= @costEndDay
+                """);
         //循环总数据的每条数据
         List<GamePromoteTotalVO> hasRechargeDayList = list.stream().map(item -> {
             showSql.setParam("sourceSystem", item.getSourceSystem());
@@ -472,6 +487,12 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
             List<String> dayNList = sqlDayN.getList(String.class);
             DayN dayN = null;
             //ads_dayn_amount存在充值数据
+            newUserNumMap.put("accountId", item.getAccountId());
+            newUserNumMap.put("agentId", item.getAgentId());
+            newUserNumMap.put("sourceSystem", item.getSourceSystem());
+            roleUserNum.setParams(newUserNumMap);
+            dao.execute(roleUserNum);
+            Long roleUserNumLong = roleUserNum.getLong();
             if (!CollectionUtils.isEmpty(dayNList)) {
                 Gson gson = new Gson();
                 List<Map<String, String>> jsonList = gson.fromJson(dayNList.toString(), ArrayList.class);
@@ -496,9 +517,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
                     }
                 }
 
-                newUserNumMap.put("accountId", item.getAccountId());
-                newUserNumMap.put("agentId", item.getAgentId());
-                newUserNumMap.put("sourceSystem", item.getSourceSystem());
+
                 newUserNum.setParams(newUserNumMap);
                 dao.execute(newUserNum);
                 Long newUserNumLong = newUserNum.getLong();
@@ -516,6 +535,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
                             .build();
                 }
             }
+            item.setRoleNum(roleUserNumLong);
             //充值时间范围内存在充值数据
             if (null != dayN) {
                 item.setUserRechargeMoney(dayN.getRechargeMoney());
@@ -816,7 +836,23 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
                     group by user_id) a
                 WHERE a.repeatNum > 1
                 """);
+
+        Sql roleUserNum = Sqls.fetchLong("""
+                select
+                	count(DISTINCT role_user_id)
+                from
+                	dw_create_role_detail
+                where
+                    source_system = @sourceSystem
+                    and user_agent_id = @agentId
+                    and user_account_id = @accountId
+                    and DATE(role_create_time) >= @rechargeBeginDay
+                    and DATE(role_create_time) <= @rechargeEndDay
+                    and user_dt >= @costBeginDay
+                    and user_dt <= @costEndDay
+                """);
         AtomicReference<Long> showRechargeUserNum = new AtomicReference<>(0L);
+        AtomicReference<Long> roleUserNumLong = new AtomicReference<>(0L);
         DayN dayNTotal = agentAccountList.stream().map(item -> {
             showRechargeUserSql.setParam("sourceSystem", item.getSourceSystem());
             showRechargeUserSql.setParam("agentId", item.getAgentId());
@@ -831,6 +867,14 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
             dao.execute(sqlDayN);
             List<String> dayNList = sqlDayN.getList(String.class);
             DayN dayN = null;
+
+            newUserNumMap.put("accountId", item.getAccountId());
+            newUserNumMap.put("agentId", item.getAgentId());
+            newUserNumMap.put("sourceSystem", item.getSourceSystem());
+
+            roleUserNum.setParams(newUserNumMap);
+            dao.execute(roleUserNum);
+            roleUserNumLong.set(roleUserNumLong.get() + roleUserNum.getLong());
             //ads_dayn_amount存在充值数据
             if (!CollectionUtils.isEmpty(dayNList)) {
                 Gson gson = new Gson();
@@ -856,9 +900,6 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
                     }
                 }
                 if (!resultMap.isEmpty() && !resultMap.get("dayN").isEmpty()) {
-                    newUserNumMap.put("accountId", item.getAccountId());
-                    newUserNumMap.put("agentId", item.getAgentId());
-                    newUserNumMap.put("sourceSystem", item.getSourceSystem());
                     newUserNum.setParams(newUserNumMap);
                     dao.execute(newUserNum);
                     Long newUserNumLong = newUserNum.getLong();
@@ -885,6 +926,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
             return accumulator;
         }).orElse(new DayN());
 
+        gamePromoteTotalSumVO.setRoleNum(roleUserNumLong.get());
         gamePromoteTotalSumVO.setShowRechargeUser(showRechargeUserNum.get());
         gamePromoteTotalSumVO.setShowRechargeArpu(gamePromoteTotalSumVO.getShowRechargeUser() == 0 ? BigDecimal.ZERO :
                 gamePromoteTotalSumVO.getShowRechargeMoney().divide(new BigDecimal(gamePromoteTotalSumVO.getShowRechargeUser()), 4, RoundingMode.DOWN));
@@ -1182,7 +1224,10 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
                 	round(if(amount_count > 0, cost / amount_count, 0), 4) as show_recharge_count_cost,
                 	round(if(new_user_total_amount_count > 0, cost / new_user_total_amount_count, 0), 4) as new_user_recharge_count_cost,
                 	hundred_user_num,
-                	hundred_user_num_cost
+                	hundred_user_num_cost,
+                	first_role_num,
+                	new_user_total_role_num,
+                	role_num
                 from
                 	ads_account_agent_day
                 """;
@@ -1284,9 +1329,12 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
                     round(if(sum(amount_count) > 0, sum(cost) / sum(amount_count), 0), 4) as show_recharge_count_cost,
                     round(if(sum(new_user_total_amount_count) > 0, sum(cost) / sum(new_user_total_amount_count), 0), 4) as new_user_recharge_count_cost,
                     sum(hundred_user_num) as hundred_user_num,
-                    round(if(sum(hundred_user_num) > 0, sum(cost) / sum(hundred_user_num), 0), 4) as hundred_user_num_cost
-                        from
-                        	ads_account_agent_day
+                    round(if(sum(hundred_user_num) > 0, sum(cost) / sum(hundred_user_num), 0), 4) as hundred_user_num_cost,
+                    sum(first_role_num) as first_role_num,
+                    sum(new_user_total_role_num) as new_user_total_role_num,
+                    sum(role_num) as role_num
+                    from
+                    ads_account_agent_day
                         """;
     }
 
@@ -1407,7 +1455,9 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
                 	round(if(sum(first_new_user_amount_count) > 0, sum(cost) / sum(first_new_user_amount_count), 0), 4) as first_recharge_count_cost,
                 	round(if(sum(new_user_total_amount_count) > 0, sum(cost) / sum(new_user_total_amount_count), 0), 4) as new_user_recharge_count_cost,
                 	sum(a.hundred_user_num) as hundred_user_num,
-                	round(if(sum(a.hundred_user_num) > 0, sum(a.cost) / sum(a.hundred_user_num), 0), 4) as hundred_user_num_cost
+                	round(if(sum(a.hundred_user_num) > 0, sum(a.cost) / sum(a.hundred_user_num), 0), 4) as hundred_user_num_cost,
+                	sum(first_role_num) as first_role_num,
+                    sum(new_user_total_role_num) as new_user_total_role_num
                 from
                 	ads_account_agent_day a
                 """;
@@ -1499,7 +1549,9 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
                 	round(if(sum(first_new_user_amount_count) > 0, sum(cost) / sum(first_new_user_amount_count), 0), 4) as first_recharge_count_cost,
                 	round(if(sum(new_user_total_amount_count) > 0, sum(cost) / sum(new_user_total_amount_count), 0), 4) as new_user_recharge_count_cost,
                 	sum(a.hundred_user_num) as hundred_user_num,
-                	round(if(sum(a.hundred_user_num) > 0, sum(a.cost) / sum(a.hundred_user_num), 0), 4) as hundred_user_num_cost
+                	round(if(sum(a.hundred_user_num) > 0, sum(a.cost) / sum(a.hundred_user_num), 0), 4) as hundred_user_num_cost,
+                	sum(first_role_num) as first_role_num,
+                    sum(new_user_total_role_num) as new_user_total_role_num
                 from
                 	ads_account_agent_day a
                 """;

+ 188 - 38
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/GameDataServiceImpl.java

@@ -2467,7 +2467,7 @@ public class GameDataServiceImpl implements IGameDataService {
             cri.where().andLike("a.game_name", dto.getGameName());
         }
         if (StringUtils.isNotBlank(dto.getSourceSystem())) {
-            cri.where().andLike("a.source_system", dto.getSourceSystem());
+            cri.where().andEquals("a.source_system", dto.getSourceSystem());
         }
         if (null != dto.getGameId()) {
             cri.where().andEquals("a.game_id", dto.getGameId());
@@ -2505,25 +2505,43 @@ public class GameDataServiceImpl implements IGameDataService {
         //h5账面
         String show = """
                 select
-                sum(h5_buy_amount) as h5_buy_amount,
-                sum(h5_buy_amount_num) as h5_buy_amount_num,
-                sum(h5_nature_amount) as h5_nature_amount,
-                sum(h5_nature_amount_num) as h5_nature_amount_num
-                from ads_h5_game_day
+                sum(a.h5_buy_amount) as h5_buy_amount,
+                (select count(distinct user_id) from ads_information
+                where
+                source_system = a.source_system
+                and h5_game_id = a.game_id
+                and agent_id != 0
+                and classify = 5
+                and order_time >= @rechargeBeginDay
+                and order_time <= @rechargeEndDay) as h5_buy_amount_num,
+                sum(a.h5_nature_amount) as h5_nature_amount,
+                (select count(distinct user_id) from ads_information
+                where
+                source_system = a.source_system
+                and h5_game_id = a.game_id
+                and agent_id = 0
+                and classify = 5
+                and order_time >= @rechargeBeginDay
+                and order_time <= @rechargeEndDay) as h5_nature_amount_num
+                from ads_h5_game_day a
                 """;
         Sql showSql = Sqls.queryEntity(show + "$condition");
+        showSql.setParam("rechargeBeginDay", dto.getRechargeBeginDate());
+        showSql.setParam("rechargeEndDay", dto.getRechargeEndDate());
         Entity<ShowRecharge> showEntity = dao.getEntity(ShowRecharge.class);
         List<GameDataH5VO> gameDataH5VOList = sql.getList(GameDataH5VO.class).stream().map(item -> {
             {
                 SimpleCriteria showCri = Cnd.cri();
                 if (StringUtils.isNotBlank(dto.getGameName())) {
-                    showCri.where().andLike("game_name", dto.getGameName());
+                    showCri.where().andLike("a.game_name", dto.getGameName());
                 }
-                showCri.where().and("dt", ">=", dto.getRechargeBeginDate()).and("dt", "<=", dto.getRechargeEndDate());
-                showCri.groupBy("source_system,game_id");
-                showCri.where().andEquals("game_id", item.getGameId());
-                showCri.where().andEquals("id", 1);
-                showCri.where().andEquals("source_system", item.getSourceSystem());
+                showCri.where().and("a.dt", ">=", dto.getRechargeBeginDate()).and("a.dt", "<=", dto.getRechargeEndDate());
+                showCri.groupBy("a.source_system,a.game_id");
+                Long h5GameId = item.getGameId();
+                showCri.where().andEquals("a.game_id", h5GameId);
+                showCri.where().andEquals("a.id", 1);
+                String sourceSystem = item.getSourceSystem();
+                showCri.where().andEquals("a.source_system", sourceSystem);
                 showSql.setEntity(showEntity).setCondition(showCri);
                 dao.execute(showSql);
                 ShowRecharge showRecharge = showSql.getObject(ShowRecharge.class);
@@ -2539,8 +2557,8 @@ public class GameDataServiceImpl implements IGameDataService {
                     item.setH5BuyAmountNum(0L);
                 }
 
-                dayNMap.put("sourceSystem", item.getSourceSystem());
-                dayNMap.put("h5GameId", item.getGameId());
+                dayNMap.put("sourceSystem", sourceSystem);
+                dayNMap.put("h5GameId", h5GameId);
 
                 H5DayN h5PayDayN = getH5PayDayN(dto, dayNMap);
                 //h5充值时间范围内存在买量充值数据
@@ -2604,16 +2622,25 @@ public class GameDataServiceImpl implements IGameDataService {
 
         Sql natureShowGameSql = Sqls.queryEntity("""
                 select
-                nature_source_system,
-                nature_game_id,
-                sum(h5_lead_nature_amount) as h5_lead_nature_amount,
-                sum(h5_lead_nature_amount_num) as h5_lead_nature_amount_num
-                from ads_h5_game_day
+                a.nature_source_system,
+                a.nature_game_id,
+                sum(a.h5_lead_nature_amount) as h5_lead_nature_amount,
+                (select count(distinct user_id) from ads_information
                 where
-                game_id = @gameId
+                source_system = a.nature_source_system
+                and game_id = a.nature_game_id
+                and order_h5_game_id = @gameId
+                and agent_id = 0
+                and classify != 5
+                and order_game_classify = 5
+                and order_time >= @beginDay
+                and order_time <= @endDay) as h5_lead_nature_amount_num
+                from ads_h5_game_day a
+                where
+                a.game_id = @gameId
                 and
-                dt>=@beginDay and dt<=@endDay
-                group by nature_source_system,nature_game_id
+                a.dt>=@beginDay and a.dt<=@endDay
+                group by a.nature_source_system,a.nature_game_id
                 """);
         natureShowGameSql.setParam("gameId", item.getGameId());
         natureShowGameSql.setParam("beginDay", dto.getRechargeBeginDate());
@@ -2625,12 +2652,21 @@ public class GameDataServiceImpl implements IGameDataService {
                 .filter(tt -> null != tt.getNatureGameId())
                 .collect(Collectors.groupingBy(H5NatureUserVO::getNatureGameId));
 
+        Map<String,Object> natureNewUserMap = new HashMap<>(7);
+        natureNewUserMap.put("h5GameId",item.getGameId());
+        natureNewUserMap.put("rechargeBeginDay",dto.getRechargeBeginDate());
+        natureNewUserMap.put("rechargeEndDay",dto.getRechargeEndDate());
+        natureNewUserMap.put("costBeginDay",dto.getCostBeginDate());
+        natureNewUserMap.put("costEndDay",dto.getCostEndDate());
         List<H5NatureUserVO> natureGameList = natureGameSql.getList(H5NatureUserVO.class).stream()
                 .filter(tt -> null != tt.getNatureGameId())
                 .map(natureGame -> {
+                    natureNewUserMap.put("natureSourceSystem",natureGame.getNatureSourceSystem());
+                    natureNewUserMap.put("natureGameId",natureGame.getNatureGameId());
+
                     importDayNMap.put("sourceSystem", natureGame.getNatureSourceSystem());
                     importDayNMap.put("gameId", natureGame.getNatureGameId());
-                    H5DayN importNatureH5DayN = getImportNatureH5DayN(dto, importDayNMap);
+                    H5DayN importNatureH5DayN = getImportNatureH5DayN(dto, importDayNMap, natureNewUserMap);
                     if (null != showBuyGameMap && null != showBuyGameMap.get(natureGame.getNatureGameId()) && !showBuyGameMap.get(natureGame.getNatureGameId()).isEmpty()) {
                         natureGame.setH5LeadNatureAmount(showBuyGameMap.get(natureGame.getNatureGameId()).get(0).getH5LeadNatureAmount());
                         natureGame.setH5LeadNatureAmountNum(showBuyGameMap.get(natureGame.getNatureGameId()).get(0).getH5LeadNatureAmountNum());
@@ -2678,16 +2714,25 @@ public class GameDataServiceImpl implements IGameDataService {
         //买量导入游戏账面
         Sql buyShowGameSql = Sqls.queryEntity("""
                 select
-                buy_source_system,
-                buy_game_id,
-                sum(h5_lead_buy_amount) as h5_lead_buy_amount,
-                sum(h5_lead_buy_amount_num) as h5_lead_buy_amount_num
-                from ads_h5_game_day
+                a.buy_source_system as buy_source_system,
+                a.buy_game_id as buy_game_id,
+                sum(a.h5_lead_buy_amount) as h5_lead_buy_amount,
+                (select count(distinct user_id) from ads_information
                 where
-                game_id = @gameId
+                source_system = a.buy_source_system
+                and game_id = a.buy_game_id
+                and order_h5_game_id = @gameId
+                and agent_id != 0
+                and classify != 5
+                and order_game_classify = 5
+                and order_time >= @beginDay
+                and order_time <= @endDay) as h5_lead_buy_amount_num
+                from ads_h5_game_day a
+                where
+                a.game_id = @gameId
                 and
-                dt>=@beginDay and dt<=@endDay
-                group by buy_source_system,buy_game_id
+                a.dt>=@beginDay and a.dt<=@endDay
+                group by a.buy_source_system,a.buy_game_id
                 """);
         buyShowGameSql.setParam("gameId", item.getGameId());
         buyShowGameSql.setParam("beginDay", dto.getRechargeBeginDate());
@@ -2699,12 +2744,21 @@ public class GameDataServiceImpl implements IGameDataService {
                 .filter(tt -> null != tt.getBuyGameId())
                 .collect(Collectors.groupingBy(H5BuyUserVO::getBuyGameId));
 
+        Map<String,Object> buyNewUserMap = new HashMap<>(7);
+        buyNewUserMap.put("h5GameId",item.getGameId());
+        buyNewUserMap.put("rechargeBeginDay",dto.getRechargeBeginDate());
+        buyNewUserMap.put("rechargeEndDay",dto.getRechargeEndDate());
+        buyNewUserMap.put("costBeginDay",dto.getCostBeginDate());
+        buyNewUserMap.put("costEndDay",dto.getCostEndDate());
         List<H5BuyUserVO> buyGameList = buyGameSql.getList(H5BuyUserVO.class).stream()
                 .filter(tt -> null != tt.getBuyGameId())
                 .map(buyGame -> {
                     importDayNMap.put("sourceSystem", buyGame.getBuySourceSystem());
                     importDayNMap.put("gameId", buyGame.getBuyGameId());
-                    H5DayN importBuyH5DayN = getImportBuyH5DayN(dto, importDayNMap);
+
+                    buyNewUserMap.put("buySourceSystem",buyGame.getBuySourceSystem());
+                    buyNewUserMap.put("buyGameId",buyGame.getBuyGameId());
+                    H5DayN importBuyH5DayN = getImportBuyH5DayN(dto, importDayNMap, buyNewUserMap);
                     if (null != showBuyGameMap && null != showBuyGameMap.get(buyGame.getBuyGameId()) && !showBuyGameMap.get(buyGame.getBuyGameId()).isEmpty()) {
                         buyGame.setH5LeadBuyAmount(showBuyGameMap.get(buyGame.getBuyGameId()).get(0).getH5LeadBuyAmount());
                         buyGame.setH5LeadBuyAmountNum(showBuyGameMap.get(buyGame.getBuyGameId()).get(0).getH5LeadBuyAmountNum());
@@ -2725,7 +2779,7 @@ public class GameDataServiceImpl implements IGameDataService {
         return buyGameList;
     }
 
-    private H5DayN getImportNatureH5DayN(GameDataH5DTO dto, Map<String, Object> dayNMap) {
+    private H5DayN getImportNatureH5DayN(GameDataH5DTO dto, Map<String, Object> dayNMap, Map<String, Object> natureNewUserMap) {
         Sql importNatureSqlDayN = Sqls.queryString("""
                 select dayN from ads_dayn_h5_lead_nature_game
                 where
@@ -2736,6 +2790,28 @@ public class GameDataServiceImpl implements IGameDataService {
         importNatureSqlDayN.setParams(dayNMap);
         dao.execute(importNatureSqlDayN);
         List<String> importNatureDayNList = importNatureSqlDayN.getList(String.class);
+
+        Sql newUserNum = Sqls.fetchLong("""
+                select
+                	count(DISTINCT user_id)
+                from
+                	ads_information
+                where
+                source_system = @natureSourceSystem
+                and game_id = @natureGameId
+                and order_h5_game_id = @h5GameId
+                and agent_id = 0
+                and classify != 5
+                and order_game_classify = 5
+                and order_time >= @rechargeBeginDay
+                and order_time <= @rechargeEndDay
+                and reg_time >= @costBeginDay
+                and reg_time <= @costEndDay
+                """);
+        newUserNum.setParams(natureNewUserMap);
+        dao.execute(newUserNum);
+        Long newUserNumLong = newUserNum.getLong();
+
         H5DayN importNatureDayN = null;
         //ads_dayn_h5_nature_game 存在充值数据
         if (!CollectionUtils.isEmpty(importNatureDayNList)) {
@@ -2763,14 +2839,14 @@ public class GameDataServiceImpl implements IGameDataService {
                 String[] parts = resultMap.get("dayN").split("-");
                 importNatureDayN = H5DayN.builder()
                         .rechargeMoney(new BigDecimal(parts[0]))
-                        .rechargeNum(Long.valueOf(parts[1]))
+                        .rechargeNum(newUserNumLong)
                         .build();
             }
         }
         return importNatureDayN;
     }
 
-    private H5DayN getImportBuyH5DayN(GameDataH5DTO dto, Map<String, Object> dayNMap) {
+    private H5DayN getImportBuyH5DayN(GameDataH5DTO dto, Map<String, Object> dayNMap, Map<String, Object> buyNewUserMap) {
         Sql importBuySqlDayN = Sqls.queryString("""
                 select dayN from ads_dayn_h5_lead_buy_game
                 where
@@ -2781,6 +2857,28 @@ public class GameDataServiceImpl implements IGameDataService {
         importBuySqlDayN.setParams(dayNMap);
         dao.execute(importBuySqlDayN);
         List<String> importBuyDayNList = importBuySqlDayN.getList(String.class);
+
+        Sql newUserNum = Sqls.fetchLong("""
+                select
+                	count(DISTINCT user_id)
+                from
+                	ads_information
+                where
+                source_system = @buySourceSystem
+                and game_id = @buyGameId
+                and order_h5_game_id = @h5GameId
+                and agent_id != 0
+                and classify != 5
+                and order_game_classify = 5
+                and order_time >= @rechargeBeginDay
+                and order_time <= @rechargeEndDay
+                and reg_time >= @costBeginDay
+                and reg_time <= @costEndDay
+                """);
+        newUserNum.setParams(buyNewUserMap);
+        dao.execute(newUserNum);
+        Long newUserNumLong = newUserNum.getLong();
+
         H5DayN importBuyDayN = null;
         //ads_dayn_h5_nature_game 存在充值数据
         if (!CollectionUtils.isEmpty(importBuyDayNList)) {
@@ -2808,7 +2906,7 @@ public class GameDataServiceImpl implements IGameDataService {
                 String[] parts = resultMap.get("dayN").split("-");
                 importBuyDayN = H5DayN.builder()
                         .rechargeMoney(new BigDecimal(parts[0]))
-                        .rechargeNum(Long.valueOf(parts[1]))
+                        .rechargeNum(newUserNumLong)
                         .build();
             }
         }
@@ -2826,6 +2924,28 @@ public class GameDataServiceImpl implements IGameDataService {
         natureSqlDayN.setParams(dayNMap);
         dao.execute(natureSqlDayN);
         List<String> natureDayNList = natureSqlDayN.getList(String.class);
+
+        Sql newUserNum = Sqls.fetchLong("""
+                select
+                	count(DISTINCT user_id)
+                from
+                	ads_information
+                where
+                    source_system = @sourceSystem
+                    and h5_game_id = @h5GameId
+                    and agent_id = 0
+                    and classify = 5
+                    and order_time >= @rechargeBeginDay
+                    and order_time <= @rechargeEndDay
+                    and reg_time >= @costBeginDay
+                    and reg_time <= @costEndDay
+                """);
+        Map<String, Object> newUserNumMap = new HashMap<>(6);
+        newUserNumMap.put("costBeginDay", dto.getCostBeginDate());
+        newUserNumMap.put("costEndDay", dto.getCostEndDate());
+        newUserNumMap.put("rechargeBeginDay", dto.getRechargeBeginDate());
+        newUserNumMap.put("rechargeEndDay", dto.getRechargeEndDate());
+
         H5DayN h5NatureDayN = null;
         //ads_dayn_h5_nature_game 存在充值数据
         if (!CollectionUtils.isEmpty(natureDayNList)) {
@@ -2849,11 +2969,16 @@ public class GameDataServiceImpl implements IGameDataService {
                     }
                 }
             }
+            newUserNumMap.put("sourceSystem", dayNMap.get("sourceSystem"));
+            newUserNumMap.put("h5GameId", dayNMap.get("h5GameId"));
+            newUserNum.setParams(newUserNumMap);
+            dao.execute(newUserNum);
+            Long newUserNumLong = newUserNum.getLong();
             if (!resultMap.isEmpty() && !resultMap.get("dayN").isEmpty()) {
                 String[] parts = resultMap.get("dayN").split("-");
                 h5NatureDayN = H5DayN.builder()
                         .rechargeMoney(new BigDecimal(parts[0]))
-                        .rechargeNum(Long.valueOf(parts[1]))
+                        .rechargeNum(newUserNumLong)
                         .build();
             }
         }
@@ -2873,6 +2998,26 @@ public class GameDataServiceImpl implements IGameDataService {
         dao.execute(paySqlDayN);
         List<String> payDayNList = paySqlDayN.getList(String.class);
 
+        Sql newUserNum = Sqls.fetchLong("""
+                select
+                	count(DISTINCT user_id)
+                from
+                	ads_information
+                where
+                    source_system = @sourceSystem
+                    and h5_game_id = @h5GameId
+                    and agent_id != 0
+                    and classify = 5
+                    and order_time >= @rechargeBeginDay
+                    and order_time <= @rechargeEndDay
+                    and reg_time >= @costBeginDay
+                    and reg_time <= @costEndDay
+                """);
+        Map<String, Object> newUserNumMap = new HashMap<>(6);
+        newUserNumMap.put("costBeginDay", dto.getCostBeginDate());
+        newUserNumMap.put("costEndDay", dto.getCostEndDate());
+        newUserNumMap.put("rechargeBeginDay", dto.getRechargeBeginDate());
+        newUserNumMap.put("rechargeEndDay", dto.getRechargeEndDate());
         //ads_dayn_h5_pay_game存在充值数据
         if (!CollectionUtils.isEmpty(payDayNList)) {
             Gson gson = new Gson();
@@ -2895,11 +3040,16 @@ public class GameDataServiceImpl implements IGameDataService {
                     }
                 }
             }
+            newUserNumMap.put("sourceSystem", dayNMap.get("sourceSystem"));
+            newUserNumMap.put("h5GameId", dayNMap.get("h5GameId"));
+            newUserNum.setParams(newUserNumMap);
+            dao.execute(newUserNum);
+            Long newUserNumLong = newUserNum.getLong();
             if (!resultMap.isEmpty() && !resultMap.get("dayN").isEmpty()) {
                 String[] parts = resultMap.get("dayN").split("-");
                 h5PayDayN = H5DayN.builder()
                         .rechargeMoney(new BigDecimal(parts[0]))
-                        .rechargeNum(Long.valueOf(parts[1]))
+                        .rechargeNum(newUserNumLong)
                         .build();
             }
         }

+ 347 - 169
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/PromotionDayServiceImpl.java

@@ -43,13 +43,103 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
     @Autowired
     private Dao dao;
 
+    /**
+     * 广告监控每日数据列表
+     *
+     * @param dto
+     * @return
+     */
+    public Page<PromotionDayVO> getPromotionDayListData(PromotionDayDTO dto) {
+        //不传递查询条件默认查询当天数据
+        if (dto.getCostBeginDate() == null || dto.getCostEndDate() == null) {
+            dto.setCostBeginDate(LocalDate.now());
+            dto.setCostEndDate(LocalDate.now());
+        }
+        //如果没有排序条件给默认值
+        if (StringUtils.isBlank(dto.getSortFiled())) {
+            dto.setSortFiled("dt");
+        }
+        if (StringUtils.isBlank(dto.getSortType())) {
+            dto.setSortType(OrderByEnum.DESC.getOrderType());
+        }
+        Criteria cri = myCri(dto, false);
+
+        //计算总记录条数
+        Sql sqlCount = Sqls.create("select count(*) from ads_promotion_day" + cri);
+        sqlCount.setCallback(Sqls.callback.integer());
+        //执行sql
+        dao.execute(sqlCount);
+
+        //拼接排序条件
+        cri.getOrderBy().orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
+        //创建sql语句
+        Sql sql = Sqls.create(getPromotionDayListSql() + cri);
+        //添加自定义回传对象
+        sql.setCallback(Sqls.callback.entities());
+        sql.setEntity(dao.getEntity(PromotionDayVO.class));
+        //设置pager对象
+        Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
+        sql.setPager(pager);
+        //执行sql
+        dao.execute(sql);
+        //获取到结果list
+        List<PromotionDayVO> list = sql.getList(PromotionDayVO.class);
+        //分页对象设置总记录条数
+        pager.setRecordCount(sqlCount.getInt());
+
+        //处理List中的每个vo对象缺少的数据
+        list.stream().map(vo -> {
+
+            //计算d2(次日)数据
+            vo.setD2Trend(PromotionRechargeTrendVO.builder()
+                    .roi(vo.getTodayCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
+                            vo.getD2().divide(vo.getTodayCost(), 4, RoundingMode.HALF_UP))
+                    .rechargeMoney(vo.getD2())
+                    .multiples(vo.getD1().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
+                            vo.getD2().divide(vo.getD1(), 2, RoundingMode.HALF_UP))
+                    .build());
+            //计算d3数据
+            vo.setD3Trend(PromotionRechargeTrendVO.builder()
+                    .roi(vo.getTodayCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
+                            vo.getD3().divide(vo.getTodayCost(), 4, RoundingMode.HALF_UP))
+                    .rechargeMoney(vo.getD3())
+                    .multiples(vo.getD1().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
+                            vo.getD3().divide(vo.getD1(), 2, RoundingMode.HALF_UP))
+                    .build());
+            //计算d7数据
+            vo.setD7Trend(PromotionRechargeTrendVO.builder()
+                    .roi(vo.getTodayCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
+                            vo.getD7().divide(vo.getTodayCost(), 4, RoundingMode.HALF_UP))
+                    .rechargeMoney(vo.getD7())
+                    .multiples(vo.getD1().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
+                            vo.getD7().divide(vo.getD1(), 2, RoundingMode.HALF_UP))
+                    .build());
+            //计算d15数据
+            vo.setD15Trend(PromotionRechargeTrendVO.builder()
+                    .roi(vo.getTodayCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
+                            vo.getD15().divide(vo.getTodayCost(), 4, RoundingMode.HALF_UP))
+                    .rechargeMoney(vo.getD15())
+                    .multiples(vo.getD1().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
+                            vo.getD15().divide(vo.getD1(), 2, RoundingMode.HALF_UP))
+                    .build());
+
+            //返回最终数据
+            return vo;
+        }).collect(Collectors.toList());
+
+        //返回查询得结果
+        return new Page<>(list, pager);
+    }
+
     /**
      * 广告监控数据
+     *
      * @param dto
      * @return
      */
     @Override
     public Page<PromotionDayVO> getPromotionDayData(PromotionDayDTO dto) {
+
         //不传递查询条件默认查询当天数据
         if (dto.getCostBeginDate() == null || dto.getCostEndDate() == null) {
             dto.setCostBeginDate(LocalDate.now());
@@ -62,9 +152,13 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
         if (StringUtils.isBlank(dto.getSortType())) {
             dto.setSortType(OrderByEnum.DESC.getOrderType());
         }
-        Criteria cri = myCri(dto);
+        Criteria criA = myCri(dto, true);
+        Criteria criB = myCri(dto, false);
+        Criteria criOrderBy = Cnd.cri();
+        //拼接排序条件
+        criOrderBy.getOrderBy().orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
         //创建sql语句
-        Sql sql = Sqls.create(getPromotionDayDataSql() + cri);
+        Sql sql = Sqls.create(getPromotionDayDataSql(criA,criB) + criOrderBy);
         //添加自定义回传对象
         sql.setCallback(Sqls.callback.entities());
         sql.setEntity(dao.getEntity(PromotionDayVO.class));
@@ -76,37 +170,11 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
         //获取到结果list
         List<PromotionDayVO> list = sql.getList(PromotionDayVO.class);
         //分页对象设置总条数
-        Sql sqlCount = Sqls.queryEntity("select count(*) from ads_promotion_day" + cri);
+        Sql sqlCount = Sqls.queryEntity("select count(*) from ads_promotion_day" + criA);
         pager.setRecordCount((int) Daos.queryCount(dao, sqlCount));
 
         //处理List中的每个vo对象缺少的数据
         list.stream().map(vo -> {
-            //记录最近有数据的LocalDate
-            LocalDate latestDate = dto.getCostEndDate();
-            Boolean hasDataDate = findDate(vo.getPromotionId(), latestDate);
-            while (!hasDataDate) {
-                latestDate = latestDate.minusDays(1);
-                hasDataDate = findDate(vo.getPromotionId(), latestDate);
-            }
-            //构建查询条件
-            Criteria totalCri = Cnd.cri();
-            totalCri.where().andEquals("dt", latestDate);
-            totalCri.where().andEquals("promotion_id", vo.getPromotionId());
-            //查询出最近一条包含总数据的记录
-            Sql totalDataSql = Sqls.create(getTotalDataSql() + totalCri);
-            //设置回传对象
-            totalDataSql.setCallback(Sqls.callback.entity());
-            totalDataSql.setEntity(dao.getEntity(PromotionDayVO.class));
-            //执行sql
-            dao.execute(totalDataSql);
-            //得到对象
-            PromotionDayVO tempVO = totalDataSql.getObject(PromotionDayVO.class);
-            //将两个对象内容合并
-            copyNullProperties(tempVO, vo);
-
-            //总充值次数成本
-            vo.setTotalAmountCountCost(vo.getTotalAmountCount() == 0L ? BigDecimal.ZERO :
-                    vo.getPromotionTotalCost().divide(BigDecimal.valueOf(vo.getTotalAmountCount()), 2, RoundingMode.HALF_UP));
 
             //计算d2(次日)数据
             vo.setD2Trend(PromotionRechargeTrendVO.builder()
@@ -339,10 +407,11 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
     /**
      * 广告监控用到的查询条件
      *
-     * @param dto 前端传递的查询条件
+     * @param dto         前端传递的查询条件
+     * @param needGroupBy 需要聚合分组
      * @return 查询条件
      */
-    private Criteria myCri(PromotionDayDTO dto) {
+    private Criteria myCri(PromotionDayDTO dto, Boolean needGroupBy) {
         //创建查询条件
         Criteria cri = Cnd.cri();
         if (dto.getAccountId() != null) {
@@ -393,42 +462,14 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
         if (StringUtils.isNotBlank(dto.getSourceSystem())) {
             cri.where().andEquals("source_system", dto.getSourceSystem());
         }
-        //拼接分组条件
-        cri.getGroupBy().groupBy("promotion_id");
-        //拼接排序条件
-        cri.getOrderBy().orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
+        if (needGroupBy) {
+            //拼接分组条件
+            cri.getGroupBy().groupBy("promotion_id");
+        }
 
         return cri;
     }
 
-    /**
-     * 用来判断当前日期有没有数据
-     *
-     * @param promotionId 查询的广告id
-     * @param latestDate  时间参数
-     * @return Boolean
-     */
-    private Boolean findDate(String promotionId, LocalDate latestDate) {
-        //创建查询条件
-        Criteria cri = Cnd.cri();
-        cri.where().andEquals("promotion_id", Long.valueOf(promotionId));
-        cri.where().andEquals("dt", latestDate);
-        Sql sql = Sqls.create("""
-                SELECT
-                    promotion_id
-                FROM
-                    game_ads.ads_promotion_day
-                """ + cri);
-        sql.setCallback(Sqls.callback.str());
-        dao.execute(sql);
-        String tempStr = sql.getString();
-        //查询结果判断
-        if (tempStr != null) {
-            return true;
-        }
-        return false;
-    }
-
     /**
      * 所有为空值的属性都不copy
      *
@@ -464,115 +505,14 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
     }
 
     /**
-     * 查询广告监控数据sql
+     * 广告监控每日数据sql
      *
      * @return String
      */
-    private String getPromotionDayDataSql() {
-        return """
-                SELECT
-                	promotion_id,
-                	MAX(promotion_name) as promotion_name,
-                	MAX(project_id) as project_id,
-                	MAX(project_name) as project_name,
-                	MAX(account_name) as account_name,
-                	MAX(account_id) as account_id,
-                	MAX(account_type) as account_type,
-                	MAX(pitcher_id) as pitcher_id,
-                	MAX(pitcher_name) as pitcher_name,
-                	MAX(agent_id) as agent_id,
-                	MAX(agent_name) as agent_name,
-                	MAX(agent_key) as agent_key,
-                	MAX(cp_name) as cp_name,
-                	MAX(game_id) as game_id,
-                	MAX(game_name) as game_name,
-                	MAX(classify) as classify,
-                	SUM(today_cost) as today_cost,
-                	SUM(show_count) as show_count,
-                	round(if(SUM(show_count) > 0, SUM(today_cost) / SUM(show_count), 0), 2) as thousand_display_price,
-                	SUM(click_count) as click_count,
-                	round(if(SUM(click_count) > 0, SUM(today_cost) / SUM(click_count), 0), 2) as avg_click_cost,
-                	round(if(SUM(show_count) > 0, SUM(click_count) / SUM(show_count), 0), 4) as ctr,
-                	SUM(convert_count) as convert_count,
-                	ROUND(IF(SUM(convert_count) > 0, SUM(today_cost) / SUM(convert_count), 0), 2) as convert_cost,
-                	round(if(SUM(click_count) > 0, SUM(convert_count) / SUM(click_count), 0), 4) as convert_rate,
-                	SUM(reg_num) as reg_num,
-                	SUM(first_role_num) as first_role_num,
-                	SUM(new_user_total_role_num) as new_user_total_role_num,
-                	round(if(SUM(reg_num) > 0, SUM(today_cost) / SUM(reg_num), 0), 2) as reg_cost,
-                	round(if(SUM(first_role_num) > 0, SUM(today_cost) / SUM(first_role_num), 0), 2) as first_role_cost,
-                	round(if(SUM(new_user_total_role_num) > 0, SUM(today_cost) / SUM(new_user_total_role_num), 0), 2) as new_user_total_role_cost,
-                	round(if(SUM(reg_num) > 0, SUM(first_role_num) / SUM(reg_num), 0), 4) as first_role_rate,
-                	round(if(SUM(reg_num) > 0, SUM(new_user_total_role_num) / SUM(reg_num), 0), 4) as new_user_total_role_rate,
-                	SUM(first_new_user_amount_count) as first_new_user_amount_count,
-                	SUM(first_new_user_amount_num) as first_new_user_amount_num,
-                	SUM(first_new_user_amount) as first_new_user_amount,
-                	SUM(new_user_total_amount_count) as new_user_total_amount_count,
-                	SUM(new_user_total_amount_num) as new_user_total_amount_num,
-                	SUM(new_user_total_amount) as new_user_total_amount,
-                	round(if(SUM(today_cost) > 0, SUM(first_new_user_amount) / SUM(today_cost), 0), 4) as first_roi,
-                	SUM(twenty_four_hours_amount) as twenty_four_hours_amount,
-                	round(if(SUM(today_cost) > 0, SUM(twenty_four_hours_amount) / SUM(today_cost), 0), 4) as twenty_four_hours_roi,
-                	round(if(SUM(today_cost) > 0, SUM(new_user_total_amount) / SUM(today_cost), 0), 4) as total_roi,
-                	round(if(SUM(first_new_user_amount_num) > 0, SUM(today_cost) / SUM(first_new_user_amount_num), 0), 2) as first_new_user_recharge_cost,
-                	round(if(SUM(new_user_total_amount_num) > 0, SUM(today_cost) / SUM(new_user_total_amount_num), 0), 2) as new_user_total_recharge_cost,
-                	round(if(SUM(first_new_user_amount_num) > 0, SUM(first_new_user_amount) / SUM(first_new_user_amount_num), 0), 2) as first_new_user_arppu,
-                	round(if(SUM(new_user_total_amount_num) > 0, SUM(new_user_total_amount) / SUM(new_user_total_amount_num), 0), 2) as new_user_total_amount_arppu,
-                	SUM(first_new_user_hundred_user_num) as first_new_user_hundred_user_num,
-                	round(if(SUM(first_new_user_hundred_user_num) > 0, SUM(today_cost) / SUM(first_new_user_hundred_user_num), 0), 2) as first_new_user_hundred_user_cost,
-                	SUM(first_recharge_fifty_hundred_num) as first_recharge_fifty_hundred_num,
-                	round(if(SUM(new_user_total_amount_num) > 0, SUM(first_recharge_fifty_hundred_num) / SUM(new_user_total_amount_num), 0), 4) as first_recharge_fifty_hundred_rate,
-                	SUM(first_new_user_two_hundred_user_num) as first_new_user_two_hundred_user_num,
-                	round(if(SUM(first_new_user_two_hundred_user_num) > 0, SUM(today_cost) / SUM(first_new_user_two_hundred_user_num), 0), 2) as first_new_user_two_hundred_user_cost,
-                	SUM(new_user_total_hundred_user_num) as new_user_total_hundred_user_num,
-                	round(if(SUM(new_user_total_hundred_user_num) > 0, SUM(today_cost) / SUM(new_user_total_hundred_user_num), 0), 2) as new_user_total_hundred_user_cost,
-                	SUM(first_ios_amount_num) as first_ios_amount_num,
-                	SUM(first_ios_amount_count) as first_ios_amount_count,
-                	SUM(first_ios_amount) as first_ios_amount,
-                	round(if(SUM(first_new_user_amount_num) > 0, SUM(first_ios_amount_num) / SUM(first_new_user_amount_num), 0), 4) as first_ios_amount_num_rate,
-                	round(if(SUM(first_new_user_amount) > 0, SUM(first_ios_amount) / SUM(first_new_user_amount), 0), 4) as first_ios_amount_rate,
-                	round(if(SUM(today_cost)> 0, SUM(first_ios_amount) / SUM(today_cost), 0), 4) as first_ios_amount_roi,
-                	SUM(first_android_amount_count) as first_android_amount_count,
-                	SUM(first_android_amount_num) as first_android_amount_num,
-                	SUM(first_android_amount) as first_android_amount,
-                	round(if(SUM(first_new_user_amount_num) > 0,SUM(first_android_amount_num) / SUM(first_new_user_amount_num), 0), 4) as first_android_amount_num_rate,
-                	round(if(SUM(first_new_user_amount) > 0, SUM(first_android_amount) / SUM(first_new_user_amount), 0), 4) as first_android_amount_rate,
-                	round(if(SUM(today_cost) > 0, SUM(first_android_amount) / SUM(today_cost), 0), 4) as first_android_amount_roi,
-                	round(if(SUM(reg_num) > 0, SUM(first_new_user_amount_num) / SUM(reg_num), 0), 4) as first_amount_rate,
-                	round(if(SUM(first_new_user_amount_count) > 0, SUM(first_new_user_amount) / SUM(first_new_user_amount_count), 0), 2) as first_new_user_avg_price,
-                	round(if(SUM(new_user_total_amount_count) > 0, SUM(new_user_total_amount) / SUM(new_user_total_amount_count), 0), 2) as new_user_total_avg_price,
-                	SUM(d1) as d1,
-                	SUM(d2) as d2,
-                	SUM(d3) as d3,
-                	SUM(d7) as d7,
-                	SUM(d15) as d15,
-                	IFNULL(SUM(active), 0) as active,
-                    ROUND(IF(SUM(active) > 0, SUM(today_cost) / SUM(active), 0), 2) as active_cost,
-                    IFNULL(SUM(first_convert_count), 0) as first_convert_count,
-                    ROUND(IF(SUM(first_convert_count) > 0, SUM(today_cost) / SUM(first_convert_count), 0), 2) as first_convert_cost,
-                    ROUND(IF(SUM(active) > 0, SUM(game_pay_count) / SUM(active), 0), 4) as first_active_pay_rate,
-                    SUM(first_attribution_game_in_app_ltv1day) as first_attribution_game_in_app_ltv1day,
-                    ROUND(IF(SUM(today_cost) > 0 , SUM(first_attribution_game_in_app_ltv1day) / SUM(today_cost), 0), 4) as first_attribution_game_in_app_roi1day,
-                    SUM(game_pay_count) as game_pay_count,
-                    ROUND(IF(SUM(game_pay_count) > 0, SUM(today_cost) / SUM(game_pay_count), 0), 2) as game_pay_count_cost,
-                    ROUND(IF(SUM(reg_num) > 0, SUM(first_attribution_game_in_app_ltv1day) / SUM(reg_num), 0), 2) as ltv_day1,
-                    (SUM(first_new_user_amount_count) - SUM(first_sub_amount_count)) as sub_order_num,
-                    (SUM(first_new_user_amount) - SUM(first_sub_amount)) as sub_order_amount,
-                    ROUND(IF(SUM(first_new_user_amount_count) > 0, SUM(today_cost) / SUM(first_new_user_amount_count), 0), 2) as first_new_user_amount_count_cost,
-                    ROUND(IF(SUM(new_user_total_amount_count) > 0, SUM(today_cost) / SUM(new_user_total_amount_count), 0), 2) as new_user_total_amount_count_cost
-                FROM
-                	game_ads.ads_promotion_day
-                """;
-    }
-
-    /**
-     * 查询广告每日里总数据sql
-     *
-     * @return String
-     */
-    private String getTotalDataSql() {
+    private String getPromotionDayListSql() {
         return """
                 SELECT
+                    dt,
                     status,
                     creative_preview,
                     landing_type,
@@ -595,12 +535,250 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
                     total_amount_num,
                     total_amount,
                     promotion_total_roi,
-                    total_recharge_cost
+                    total_recharge_cost,
+                	promotion_id,
+                	promotion_name,
+                	project_id,
+                	project_name,
+                	account_name,
+                	account_id,
+                	account_type,
+                	pitcher_id,
+                	pitcher_name,
+                	agent_id,
+                	agent_name,
+                	agent_key,
+                	cp_name,
+                	game_id,
+                	game_name,
+                	classify,
+                	today_cost,
+                	show_count,
+                	thousand_display_price,
+                	click_count,
+                	avg_click_cost,
+                	ctr,
+                	convert_count,
+                	convert_cost,
+                	convert_rate,
+                	reg_num,
+                	first_role_num,
+                	new_user_total_role_num,
+                	reg_cost,
+                	first_role_cost,
+                	new_user_total_role_cost,
+                	first_role_rate,
+                	new_user_total_role_rate,
+                	first_new_user_amount_count,
+                	first_new_user_amount_num,
+                	first_new_user_amount,
+                	new_user_total_amount_count,
+                	new_user_total_amount_num,
+                	new_user_total_amount,
+                	first_roi,
+                	twenty_four_hours_amount,
+                	twenty_four_hours_roi,
+                	total_roi,
+                	first_new_user_recharge_cost,
+                	new_user_total_recharge_cost,
+                	first_new_user_arppu,
+                	new_user_total_amount_arppu,
+                	first_new_user_hundred_user_num,
+                	first_new_user_hundred_user_cost,
+                	first_recharge_fifty_hundred_num,
+                	first_recharge_fifty_hundred_rate,
+                	first_new_user_two_hundred_user_num,
+                	first_new_user_two_hundred_user_cost,
+                	new_user_total_hundred_user_num,
+                	new_user_total_hundred_user_cost,
+                	first_ios_amount_num,
+                	first_ios_amount_count,
+                	first_ios_amount,
+                	first_ios_amount_num_rate,
+                	first_ios_amount_rate,
+                	first_ios_amount_roi,
+                	first_android_amount_count,
+                	first_android_amount_num,
+                	first_android_amount,
+                	first_android_amount_num_rate,
+                	first_android_amount_rate,
+                	first_android_amount_roi,
+                	first_amount_rate,
+                	first_new_user_avg_price,
+                	new_user_total_avg_price,
+                	d1,
+                	d2,
+                	d3,
+                	d7,
+                	d15,
+                	active,
+                    active_cost,
+                    first_convert_count,
+                    first_convert_cost,
+                    first_active_pay_rate,
+                    first_attribution_game_in_app_ltv1day,
+                    first_attribution_game_in_app_roi1day,
+                    game_pay_count,
+                    ROUND(IF(game_pay_count > 0, today_cost / game_pay_count, 0), 2) as game_pay_count_cost,
+                    ltv_day1,
+                    sub_order_num,
+                    sub_order_amount,
+                    ROUND(IF(first_new_user_amount_count > 0, today_cost / first_new_user_amount_count, 0), 2) as first_new_user_amount_count_cost,
+                    ROUND(IF(new_user_total_amount_count > 0, today_cost / new_user_total_amount_count, 0), 2) as new_user_total_amount_count_cost,
+                    ROUND(IF(total_amount_count > 0, promotion_total_cost / total_amount_count, 0), 2) as total_amount_count_cost
                 FROM
-                    game_ads.ads_promotion_day
+                	game_ads.ads_promotion_day
                 """;
     }
 
+    /**
+     * 获取广告监控数据的SQL
+     * @param criA
+     * @param criB
+     * @return
+     */
+    private String getPromotionDayDataSql(Criteria criA, Criteria criB) {
+        return """
+                SELECT
+                b.*,
+                c.*
+                FROM(
+                	SELECT
+                		promotion_id,
+                		MAX(promotion_name) as promotion_name,
+                		MAX(project_id) as project_id,
+                		MAX(project_name) as project_name,
+                		MAX(account_name) as account_name,
+                		MAX(account_id) as account_id,
+                		MAX(account_type) as account_type,
+                		MAX(pitcher_id) as pitcher_id,
+                		MAX(pitcher_name) as pitcher_name,
+                		MAX(agent_id) as agent_id,
+                		MAX(agent_name) as agent_name,
+                		MAX(agent_key) as agent_key,
+                		MAX(cp_name) as cp_name,
+                		MAX(game_id) as game_id,
+                		MAX(game_name) as game_name,
+                		MAX(classify) as classify,
+                		SUM(today_cost) as today_cost,
+                		SUM(show_count) as show_count,
+                		round(if(SUM(show_count) > 0, SUM(today_cost) / SUM(show_count), 0), 2) as thousand_display_price,
+                		SUM(click_count) as click_count,
+                		round(if(SUM(click_count) > 0, SUM(today_cost) / SUM(click_count), 0), 2) as avg_click_cost,
+                		round(if(SUM(show_count) > 0, SUM(click_count) / SUM(show_count), 0), 4) as ctr,
+                		SUM(convert_count) as convert_count,
+                		ROUND(IF(SUM(convert_count) > 0, SUM(today_cost) / SUM(convert_count), 0), 2) as convert_cost,
+                		round(if(SUM(click_count) > 0, SUM(convert_count) / SUM(click_count), 0), 4) as convert_rate,
+                		SUM(reg_num) as reg_num,
+                		SUM(first_role_num) as first_role_num,
+                		SUM(new_user_total_role_num) as new_user_total_role_num,
+                		round(if(SUM(reg_num) > 0, SUM(today_cost) / SUM(reg_num), 0), 2) as reg_cost,
+                		round(if(SUM(first_role_num) > 0, SUM(today_cost) / SUM(first_role_num), 0), 2) as first_role_cost,
+                		round(if(SUM(new_user_total_role_num) > 0, SUM(today_cost) / SUM(new_user_total_role_num), 0), 2) as new_user_total_role_cost,
+                		round(if(SUM(reg_num) > 0, SUM(first_role_num) / SUM(reg_num), 0), 4) as first_role_rate,
+                		round(if(SUM(reg_num) > 0, SUM(new_user_total_role_num) / SUM(reg_num), 0), 4) as new_user_total_role_rate,
+                		SUM(first_new_user_amount_count) as first_new_user_amount_count,
+                		SUM(first_new_user_amount_num) as first_new_user_amount_num,
+                		SUM(first_new_user_amount) as first_new_user_amount,
+                		SUM(new_user_total_amount_count) as new_user_total_amount_count,
+                		SUM(new_user_total_amount_num) as new_user_total_amount_num,
+                		SUM(new_user_total_amount) as new_user_total_amount,
+                		round(if(SUM(today_cost) > 0, SUM(first_new_user_amount) / SUM(today_cost), 0), 4) as first_roi,
+                		SUM(twenty_four_hours_amount) as twenty_four_hours_amount,
+                		round(if(SUM(today_cost) > 0, SUM(twenty_four_hours_amount) / SUM(today_cost), 0), 4) as twenty_four_hours_roi,
+                		round(if(SUM(today_cost) > 0, SUM(new_user_total_amount) / SUM(today_cost), 0), 4) as total_roi,
+                		round(if(SUM(first_new_user_amount_num) > 0, SUM(today_cost) / SUM(first_new_user_amount_num), 0), 2) as first_new_user_recharge_cost,
+                		round(if(SUM(new_user_total_amount_num) > 0, SUM(today_cost) / SUM(new_user_total_amount_num), 0), 2) as new_user_total_recharge_cost,
+                		round(if(SUM(first_new_user_amount_num) > 0, SUM(first_new_user_amount) / SUM(first_new_user_amount_num), 0), 2) as first_new_user_arppu,
+                		round(if(SUM(new_user_total_amount_num) > 0, SUM(new_user_total_amount) / SUM(new_user_total_amount_num), 0), 2) as new_user_total_amount_arppu,
+                		SUM(first_new_user_hundred_user_num) as first_new_user_hundred_user_num,
+                		round(if(SUM(first_new_user_hundred_user_num) > 0, SUM(today_cost) / SUM(first_new_user_hundred_user_num), 0), 2) as first_new_user_hundred_user_cost,
+                		SUM(first_recharge_fifty_hundred_num) as first_recharge_fifty_hundred_num,
+                		round(if(SUM(new_user_total_amount_num) > 0, SUM(first_recharge_fifty_hundred_num) / SUM(new_user_total_amount_num), 0), 4) as first_recharge_fifty_hundred_rate,
+                		SUM(first_new_user_two_hundred_user_num) as first_new_user_two_hundred_user_num,
+                		round(if(SUM(first_new_user_two_hundred_user_num) > 0, SUM(today_cost) / SUM(first_new_user_two_hundred_user_num), 0), 2) as first_new_user_two_hundred_user_cost,
+                		SUM(new_user_total_hundred_user_num) as new_user_total_hundred_user_num,
+                		round(if(SUM(new_user_total_hundred_user_num) > 0, SUM(today_cost) / SUM(new_user_total_hundred_user_num), 0), 2) as new_user_total_hundred_user_cost,
+                		SUM(first_ios_amount_num) as first_ios_amount_num,
+                		SUM(first_ios_amount_count) as first_ios_amount_count,
+                		SUM(first_ios_amount) as first_ios_amount,
+                		round(if(SUM(first_new_user_amount_num) > 0, SUM(first_ios_amount_num) / SUM(first_new_user_amount_num), 0), 4) as first_ios_amount_num_rate,
+                		round(if(SUM(first_new_user_amount) > 0, SUM(first_ios_amount) / SUM(first_new_user_amount), 0), 4) as first_ios_amount_rate,
+                		round(if(SUM(today_cost)> 0, SUM(first_ios_amount) / SUM(today_cost), 0), 4) as first_ios_amount_roi,
+                		SUM(first_android_amount_count) as first_android_amount_count,
+                		SUM(first_android_amount_num) as first_android_amount_num,
+                		SUM(first_android_amount) as first_android_amount,
+                		round(if(SUM(first_new_user_amount_num) > 0,SUM(first_android_amount_num) / SUM(first_new_user_amount_num), 0), 4) as first_android_amount_num_rate,
+                		round(if(SUM(first_new_user_amount) > 0, SUM(first_android_amount) / SUM(first_new_user_amount), 0), 4) as first_android_amount_rate,
+                		round(if(SUM(today_cost) > 0, SUM(first_android_amount) / SUM(today_cost), 0), 4) as first_android_amount_roi,
+                		round(if(SUM(reg_num) > 0, SUM(first_new_user_amount_num) / SUM(reg_num), 0), 4) as first_amount_rate,
+                		round(if(SUM(first_new_user_amount_count) > 0, SUM(first_new_user_amount) / SUM(first_new_user_amount_count), 0), 2) as first_new_user_avg_price,
+                		round(if(SUM(new_user_total_amount_count) > 0, SUM(new_user_total_amount) / SUM(new_user_total_amount_count), 0), 2) as new_user_total_avg_price,
+                		SUM(d1) as d1,
+                		SUM(d2) as d2,
+                		SUM(d3) as d3,
+                		SUM(d7) as d7,
+                		SUM(d15) as d15,
+                		IFNULL(SUM(active), 0) as active,
+                	    ROUND(IF(SUM(active) > 0, SUM(today_cost) / SUM(active), 0), 2) as active_cost,
+                	    IFNULL(SUM(first_convert_count), 0) as first_convert_count,
+                	    ROUND(IF(SUM(first_convert_count) > 0, SUM(today_cost) / SUM(first_convert_count), 0), 2) as first_convert_cost,
+                	    ROUND(IF(SUM(active) > 0, SUM(game_pay_count) / SUM(active), 0), 4) as first_active_pay_rate,
+                	    SUM(first_attribution_game_in_app_ltv1day) as first_attribution_game_in_app_ltv1day,
+                	    ROUND(IF(SUM(today_cost) > 0 , SUM(first_attribution_game_in_app_ltv1day) / SUM(today_cost), 0), 4) as first_attribution_game_in_app_roi1day,
+                	    SUM(game_pay_count) as game_pay_count,
+                	    ROUND(IF(SUM(game_pay_count) > 0, SUM(today_cost) / SUM(game_pay_count), 0), 2) as game_pay_count_cost,
+                	    ROUND(IF(SUM(reg_num) > 0, SUM(first_attribution_game_in_app_ltv1day) / SUM(reg_num), 0), 2) as ltv_day1,
+                	    (SUM(first_new_user_amount_count) - SUM(first_sub_amount_count)) as sub_order_num,
+                	    (SUM(first_new_user_amount) - SUM(first_sub_amount)) as sub_order_amount,
+                	    ROUND(IF(SUM(first_new_user_amount_count) > 0, SUM(today_cost) / SUM(first_new_user_amount_count), 0), 2) as first_new_user_amount_count_cost,
+                	    ROUND(IF(SUM(new_user_total_amount_count) > 0, SUM(today_cost) / SUM(new_user_total_amount_count), 0), 2) as new_user_total_amount_count_cost
+                	FROM
+                		game_ads.ads_promotion_day
+                """ + criA +
+                """
+                	 ) b
+                LEFT JOIN(
+                	SELECT
+                	*
+                	FROM(
+                	SELECT
+                	    ROW_NUMBER()over(partition by promotion_id order by dt desc) as num,
+                	    promotion_id,
+                	    status,
+                	    creative_preview,
+                	    landing_type,
+                	    pricing,
+                	    cpa_bid,
+                	    roi_goal,
+                	    budget,
+                	    concat(start_time,'/',end_time) as schedule_time,
+                	    notes,
+                	    service,
+                	    balance,
+                	    promotion_total_cost,
+                	    convert_target,
+                	    reg_total_num,
+                	    role_total_num,
+                	    reg_total_cost,
+                	    role_total_cost,
+                	    role_total_rate,
+                	    total_amount_count,
+                	    total_amount_num,
+                	    total_amount,
+                	    promotion_total_roi,
+                	    ROUND(IF(total_amount_count > 0, promotion_total_cost / total_amount_count, 0), 2) as total_amount_count_cost,
+                	    total_recharge_cost
+                	FROM
+                		game_ads.ads_promotion_day
+                	""" + criB +
+                """
+                 ) a
+                WHERE a.num = 1) c
+            ON b.promotion_id = c.promotion_id
+            """;
+    }
+
     /**
      * 查询广告监控每日总计一栏sql
      *