|
@@ -3,20 +3,22 @@ package com.zanxiang.game.data.serve.service.impl;
|
|
|
import com.google.common.base.CaseFormat;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.zanxiang.erp.security.util.SecurityUtil;
|
|
|
+import com.zanxiang.game.data.serve.pojo.dto.AgentDayAgainDTO;
|
|
|
import com.zanxiang.game.data.serve.pojo.dto.GamePromoteDayDTO;
|
|
|
import com.zanxiang.game.data.serve.pojo.dto.GamePromoteDayTotalDTO;
|
|
|
import com.zanxiang.game.data.serve.pojo.dto.GamePromoteTotalDTO;
|
|
|
import com.zanxiang.game.data.serve.pojo.entity.AdsAccountAgentDay;
|
|
|
+import com.zanxiang.game.data.serve.pojo.entity.AdsAgentDayAgain;
|
|
|
import com.zanxiang.game.data.serve.pojo.enums.OrderByEnum;
|
|
|
-import com.zanxiang.game.data.serve.pojo.vo.GamePromoteDayTotalVO;
|
|
|
-import com.zanxiang.game.data.serve.pojo.vo.GamePromoteDayVO;
|
|
|
-import com.zanxiang.game.data.serve.pojo.vo.GamePromoteTotalVO;
|
|
|
-import com.zanxiang.game.data.serve.pojo.vo.RechargeTrendVO;
|
|
|
+import com.zanxiang.game.data.serve.pojo.vo.*;
|
|
|
import com.zanxiang.game.data.serve.service.IAccountAgentDayService;
|
|
|
import com.zanxiang.game.data.serve.utils.Page;
|
|
|
import com.zanxiang.module.util.DateUtil;
|
|
|
+import com.zanxiang.module.util.exception.BaseException;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
import lombok.Builder;
|
|
|
import lombok.Data;
|
|
|
+import lombok.NoArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.nutz.dao.Cnd;
|
|
@@ -24,6 +26,7 @@ import org.nutz.dao.Dao;
|
|
|
import org.nutz.dao.Sqls;
|
|
|
import org.nutz.dao.entity.Entity;
|
|
|
import org.nutz.dao.pager.Pager;
|
|
|
+import org.nutz.dao.sql.Criteria;
|
|
|
import org.nutz.dao.sql.Sql;
|
|
|
import org.nutz.dao.util.Daos;
|
|
|
import org.nutz.dao.util.cri.SimpleCriteria;
|
|
@@ -31,13 +34,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.lang.reflect.Method;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
@@ -80,6 +81,9 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
if (StringUtils.isNotBlank(dto.getGameName())) {
|
|
|
cri.where().andLike("game_name", dto.getGameName());
|
|
|
}
|
|
|
+ if (null != dto.getGameId()) {
|
|
|
+ cri.where().andEquals("game_id", dto.getGameId());
|
|
|
+ }
|
|
|
if (StringUtils.isNotBlank(dto.getGameType())) {
|
|
|
cri.where().andEquals("game_type", dto.getGameType());
|
|
|
}
|
|
@@ -89,6 +93,9 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
if (null != dto.getEndDay()) {
|
|
|
cri.where().and("dt", "<=", dto.getEndDay());
|
|
|
}
|
|
|
+ if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
+ cri.where().andEquals("source_system", dto.getSourceSystem());
|
|
|
+ }
|
|
|
cri.orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
|
|
|
Sql sql = Sqls.queryEntity(accountAgentDaySql() + "$condition");
|
|
|
sql.setPager(pager);
|
|
@@ -221,12 +228,18 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
if (StringUtils.isNotBlank(dto.getGameType())) {
|
|
|
cri.where().andEquals("game_type", dto.getGameType());
|
|
|
}
|
|
|
+ if (null != dto.getGameId()) {
|
|
|
+ cri.where().andEquals("game_id", dto.getGameId());
|
|
|
+ }
|
|
|
if (null != dto.getBeginDay()) {
|
|
|
cri.where().and("dt", ">=", dto.getBeginDay());
|
|
|
}
|
|
|
if (null != dto.getEndDay()) {
|
|
|
cri.where().and("dt", "<=", dto.getEndDay());
|
|
|
}
|
|
|
+ if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
+ cri.where().andEquals("source_system", dto.getSourceSystem());
|
|
|
+ }
|
|
|
Sql sql = Sqls.queryEntity(accountAgentDayTotalSql() + "$condition");
|
|
|
Entity<GamePromoteDayTotalVO> entity = dao.getEntity(GamePromoteDayTotalVO.class);
|
|
|
sql.setEntity(entity).setCondition(cri);
|
|
@@ -281,14 +294,18 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
if (null != dto.getCostEndDay()) {
|
|
|
cri.where().and("a.dt", "<=", dto.getCostEndDay());
|
|
|
}
|
|
|
- cri.groupBy("a.account_id,a.agent_id");
|
|
|
+ if (null != dto.getGameId()) {
|
|
|
+ cri.where().andEquals("a.game_id", dto.getGameId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
+ cri.where().andEquals("a.source_system", dto.getSourceSystem());
|
|
|
+ }
|
|
|
+ cri.groupBy("a.account_id,a.agent_id,a.source_system");
|
|
|
cri.orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
|
|
|
Sql sql = Sqls.queryEntity(accountAgentTotalSql() + "$condition");
|
|
|
sql.setPager(pager);
|
|
|
Entity<GamePromoteTotalVO> entity = dao.getEntity(GamePromoteTotalVO.class);
|
|
|
sql.setEntity(entity).setCondition(cri);
|
|
|
- sql.setParam("rechargeBeginDay", dto.getRechargeBeginDay());
|
|
|
- sql.setParam("rechargeEndDay", dto.getRechargeEndDay());
|
|
|
dao.execute(sql);
|
|
|
Sql sqlCount = Sqls.queryEntity("select count(*) from ads_account_agent_day a " + "$condition");
|
|
|
sqlCount.setCondition(cri);
|
|
@@ -300,14 +317,61 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
dayNMap.put("beginDay", dto.getCostBeginDay());
|
|
|
dayNMap.put("endDay", dto.getCostEndDay());
|
|
|
|
|
|
+ String show = """
|
|
|
+ select
|
|
|
+ ifnull(sum(amount_count),0) as show_recharge_count,
|
|
|
+ ifnull(sum(amount_num),0) as show_recharge_user,
|
|
|
+ ifnull(sum(amount),0) as show_recharge_money,
|
|
|
+ round(if(sum(amount_count) > 0, sum(amount) / sum(amount_count), 0), 4) as avg_show_user_recharge,
|
|
|
+ round(if(sum(amount_num) > 0, sum(amount) / sum(amount_num), 0), 4) as show_recharge_arpu
|
|
|
+ from
|
|
|
+ ads_account_agent_day
|
|
|
+ where
|
|
|
+ source_system = @sourceSystem
|
|
|
+ and agent_id = @agentId
|
|
|
+ and account_id = @accountId
|
|
|
+ and dt >= @rechargeBeginDay
|
|
|
+ and dt <= @rechargeEndDay
|
|
|
+ group by
|
|
|
+ account_id,agent_id,source_system
|
|
|
+ """;
|
|
|
+ Sql showSql = Sqls.queryEntity(show);
|
|
|
+ Entity<ShowRecharge> showEntity = dao.getEntity(ShowRecharge.class);
|
|
|
+ showSql.setEntity(showEntity);
|
|
|
+ showSql.setParam("rechargeBeginDay", dto.getRechargeBeginDay());
|
|
|
+ showSql.setParam("rechargeEndDay", dto.getRechargeEndDay());
|
|
|
//循环总数据的每条数据
|
|
|
List<GamePromoteTotalVO> hasRechargeDayList = list.stream().map(item -> {
|
|
|
- Sql sqlDayN = Sqls.queryString("select dayN from ads_dayn_amount where " +
|
|
|
- "dt>=@beginDay and dt<=@endDay " +
|
|
|
- "and account_id = @accountId " +
|
|
|
- "and agent_id = @agentId");
|
|
|
+ showSql.setParam("sourceSystem", item.getSourceSystem());
|
|
|
+ showSql.setParam("agentId", item.getAgentId());
|
|
|
+ showSql.setParam("accountId", item.getAccountId());
|
|
|
+ dao.execute(showSql);
|
|
|
+ ShowRecharge showRecharge = showSql.getObject(ShowRecharge.class);
|
|
|
+ if (null != showRecharge){
|
|
|
+ item.setShowRechargeArpu(showRecharge.showRechargeArpu);
|
|
|
+ item.setShowRechargeCount(showRecharge.getShowRechargeCount());
|
|
|
+ item.setShowRechargeMoney(showRecharge.showRechargeMoney);
|
|
|
+ item.setShowRechargeUser(showRecharge.getShowRechargeUser());
|
|
|
+ item.setAvgShowUserRecharge(showRecharge.avgShowUserRecharge);
|
|
|
+ }else {
|
|
|
+ item.setShowRechargeArpu(BigDecimal.ZERO);
|
|
|
+ item.setShowRechargeCount(0L);
|
|
|
+ item.setShowRechargeMoney(BigDecimal.ZERO);
|
|
|
+ item.setShowRechargeUser(0L);
|
|
|
+ item.setAvgShowUserRecharge(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ Sql sqlDayN = Sqls.queryString("""
|
|
|
+ select dayN
|
|
|
+ from ads_dayn_amount
|
|
|
+ where
|
|
|
+ dt>=@beginDay and dt<=@endDay
|
|
|
+ and account_id = @accountId
|
|
|
+ and agent_id = @agentId
|
|
|
+ and source_system = @sourceSystem
|
|
|
+ """);
|
|
|
dayNMap.put("accountId", item.getAccountId());
|
|
|
dayNMap.put("agentId", item.getAgentId());
|
|
|
+ dayNMap.put("sourceSystem", item.getSourceSystem());
|
|
|
sqlDayN.setParams(dayNMap);
|
|
|
dao.execute(sqlDayN);
|
|
|
List<String> dayNList = sqlDayN.getList(String.class);
|
|
@@ -384,6 +448,181 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
return new Page<>(hasRechargeDayList, pager);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<LocalDate, List<AgentDayAgainVO>> accountAgentDayAgain(AgentDayAgainDTO dto) {
|
|
|
+
|
|
|
+ //如果查询时间不传递默认从今天开始查询
|
|
|
+ if (dto.getBeginDate() == null) {
|
|
|
+ dto.setBeginDate(LocalDate.now());
|
|
|
+ }
|
|
|
+ //判断开始时间后的30天是否超过当前日期
|
|
|
+ if (dto.getBeginDate().plusDays(30).isAfter(LocalDate.now())) {
|
|
|
+ //只查询到当前的数据
|
|
|
+ dto.setEndDate(LocalDate.now());
|
|
|
+ } else {
|
|
|
+ //只考虑30天的数据
|
|
|
+ dto.setEndDate(dto.getBeginDate().plusDays(30));
|
|
|
+ }
|
|
|
+ //拼接查询条件
|
|
|
+ Criteria cri = Cnd.cri();
|
|
|
+ if (dto.getAccountId() != null){
|
|
|
+ cri.where().andEquals("account_id",dto.getAccountId());
|
|
|
+ }
|
|
|
+ if (dto.getAgentId() != null){
|
|
|
+ cri.where().andEquals("agent_id",dto.getAgentId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
+ //拼接SDK来源
|
|
|
+ cri.where().andEquals("source_system", dto.getSourceSystem());
|
|
|
+ }
|
|
|
+ if (dto.getBeginDate() != null) {
|
|
|
+ cri.where().andEquals("dt", dto.getBeginDate());
|
|
|
+ cri.where().andBetween("ddf", dto.getBeginDate(), dto.getEndDate());
|
|
|
+ }
|
|
|
+ //按 "ddf" 升序排序
|
|
|
+ cri.getOrderBy().asc("ddf");
|
|
|
+
|
|
|
+ //获取推广每日复充表的查询结果
|
|
|
+ Sql againSql = Sqls.create( agentDayAgainSql() + cri);
|
|
|
+ againSql.setCallback(Sqls.callback.entities());
|
|
|
+ againSql.setEntity(dao.getEntity(AdsAgentDayAgain.class));
|
|
|
+ //执行sql
|
|
|
+ dao.execute(againSql);
|
|
|
+ //获取到原始数据list
|
|
|
+ List<AdsAgentDayAgain> list = againSql.getList(AdsAgentDayAgain.class);
|
|
|
+
|
|
|
+ //创建Map记录数据
|
|
|
+ Map<LocalDate, List<AgentDayAgainVO>> map = new TreeMap<>(
|
|
|
+ (o1, o2) -> o1.isBefore(o2) == true ? -1 : 1);
|
|
|
+ //有序存储每个list,每个list包含当天的所有充值次数的复充数据
|
|
|
+ List<List<AgentDayAgainVO>> tempList = new ArrayList<>();
|
|
|
+ //记录查询出的记录条数
|
|
|
+ int count = list.size();
|
|
|
+ //没有数据直接返回空结果
|
|
|
+ if (count == 0){
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ //初始化list
|
|
|
+ initList(tempList, count);
|
|
|
+
|
|
|
+ //外层循环8次 表示不同复充次数的数据
|
|
|
+ for (int i = 0; i < 8; i++) {
|
|
|
+ //用来计算Ci
|
|
|
+ int ci = i + 1;
|
|
|
+ //第一天的所有充值次数都是先计算的
|
|
|
+ //充值次数
|
|
|
+ tempList.get(0).get(i).setCn("C" + ci);
|
|
|
+ AgentDayAgainVO tempVO = tempList.get(0).get(i);
|
|
|
+ //"原": Ci
|
|
|
+ tempList.get(0).get(i).setOriginal(getCnByNum(list.get(0), ci));
|
|
|
+ //"增":初始为 0
|
|
|
+ tempList.get(0).get(i).setIncrease(0L);
|
|
|
+ //"移":下一个充值次数的Ci 即C(i+1)
|
|
|
+ tempList.get(0).get(i).setDecrease(getCnByNum(list.get(0), ci + 1));
|
|
|
+ //"现":公式计算 = 原 + 增 - 移
|
|
|
+ tempList.get(0).get(i).setPresent(
|
|
|
+ tempVO.getOriginal()+(tempVO.getIncrease())-(tempVO.getDecrease())
|
|
|
+ );
|
|
|
+ //"比"
|
|
|
+ tempList.get(0).get(i).setRate(getCnByNum(list.get(0), 1).compareTo(0L) == 0 ? BigDecimal.ZERO :
|
|
|
+ BigDecimal.valueOf(tempVO.getPresent().doubleValue() / getCnByNum(list.get(0), 1).doubleValue()).setScale(4, RoundingMode.HALF_UP)
|
|
|
+ );
|
|
|
+
|
|
|
+ //计算第2-n天的数据 复充次数i的数据
|
|
|
+ for (int j = 1; j < count; j++) {
|
|
|
+ //充值次数
|
|
|
+ tempList.get(j).get(i).setCn("C" + ci);
|
|
|
+ //"原":前一天的"现"
|
|
|
+ tempList.get(j).get(i).setOriginal(tempList.get(j - 1).get(i).getPresent());
|
|
|
+ //"现":当天的Ci - 当天的C(i+1)
|
|
|
+ tempList.get(j).get(i).setPresent(
|
|
|
+ getCnByNum(list.get(j), ci)-(getCnByNum(list.get(j), ci + 1)));
|
|
|
+ //"增":当天的Ci - 前一天的Ci
|
|
|
+ tempList.get(j).get(i).setIncrease(
|
|
|
+ getCnByNum(list.get(j), ci)-(getCnByNum(list.get(j - 1), ci)));
|
|
|
+ //"移":当天的C(i+1) - 前一天的C(i+1)
|
|
|
+ tempList.get(j).get(i).setDecrease(
|
|
|
+ getCnByNum(list.get(j), ci + 1)-(getCnByNum(list.get(j - 1), ci + 1)));
|
|
|
+ //"比":当天的现 / 前一天的C1
|
|
|
+ tempList.get(j).get(i).setRate(getCnByNum(list.get(j - 1), 1).compareTo(0L) == 0 ? BigDecimal.ZERO :
|
|
|
+ BigDecimal.valueOf(tempList.get(j).get(i).getPresent().doubleValue() / getCnByNum(list.get(j - 1), 1).doubleValue()).setScale(4, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //赋值时间数据
|
|
|
+ for (int i = 0; i < tempList.size(); i++) {
|
|
|
+ map.put(list.get(i).getDdf(), tempList.get(i));
|
|
|
+ }
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化List数据
|
|
|
+ * @param list 需要初始化的数据
|
|
|
+ * @param num 多少天的数据
|
|
|
+ */
|
|
|
+ private void initList(List<List<AgentDayAgainVO>> list, Integer num) {
|
|
|
+ //外层循环 num 次 表示多少天的数据
|
|
|
+ for (int i = 0; i < num; i++) {
|
|
|
+ list.add(new ArrayList<>());
|
|
|
+ //内层循环8次 一共初始化8种复充次数数据对象
|
|
|
+ for (int j = 0; j < 8; j++) {
|
|
|
+ list.get(i).add(
|
|
|
+ AgentDayAgainVO.builder()
|
|
|
+ .decrease(0L)
|
|
|
+ .increase(0L)
|
|
|
+ .original(0L)
|
|
|
+ .present(0L)
|
|
|
+ .rate(BigDecimal.ZERO)
|
|
|
+ .build()
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过反射来获取Cn的值
|
|
|
+ * @param dto 数据库查询出来的原始数据对象实体
|
|
|
+ * @param num 1-9
|
|
|
+ * @return Cn
|
|
|
+ */
|
|
|
+ private Long getCnByNum(Object dto, int num) {
|
|
|
+ try {
|
|
|
+ Method m1 = AdsAgentDayAgain.class.getDeclaredMethod(String.format("getC%s", num));
|
|
|
+ //返回对应的Cn值
|
|
|
+ return (Long) m1.invoke(dto);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BaseException("发生错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 推广每日复充趋势sql
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String agentDayAgainSql() {
|
|
|
+ return """
|
|
|
+ SELECT
|
|
|
+ dt,
|
|
|
+ ddf,
|
|
|
+ account_id,
|
|
|
+ agent_id,
|
|
|
+ agent_name,
|
|
|
+ source_system,
|
|
|
+ c1,
|
|
|
+ c2,
|
|
|
+ c3,
|
|
|
+ c4,
|
|
|
+ c5,
|
|
|
+ c6,
|
|
|
+ c7,
|
|
|
+ c8,
|
|
|
+ c9
|
|
|
+ FROM
|
|
|
+ ads_agent_day_again
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 推广每日数据SQL
|
|
|
* @return
|
|
@@ -391,13 +630,16 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
private String accountAgentDaySql() {
|
|
|
return """
|
|
|
select
|
|
|
+ dt,
|
|
|
concat( dt, account_id, agent_id ) AS id,
|
|
|
+ source_system,
|
|
|
agent_id,
|
|
|
agent_name,
|
|
|
account_id,
|
|
|
agent_id,
|
|
|
pitcher AS sys_user_name,
|
|
|
game_cp AS cp_name,
|
|
|
+ game_id,
|
|
|
game_name,
|
|
|
game_type,
|
|
|
dt AS cost_day,
|
|
@@ -569,12 +811,14 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
return """
|
|
|
select
|
|
|
concat(a.account_id, a.agent_id) as id,
|
|
|
+ a.source_system,
|
|
|
a.account_id,
|
|
|
a.agent_id,
|
|
|
max(a.agent_name) as agent_name,
|
|
|
max(a.account_type) as account_type,
|
|
|
max(a.pitcher) as sys_user_name,
|
|
|
max(a.game_cp) as cp_name,
|
|
|
+ max(a.game_id) as game_id,
|
|
|
max(a.game_name) as game_name,
|
|
|
max(a.game_type) as game_type,
|
|
|
max(a.pitcher_id) as sys_user_id,
|
|
@@ -611,9 +855,6 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
sum(a.first_new_user_amount_count) as user_recharge_count,
|
|
|
sum(a.first_new_user_amount_num) as user_recharge_user,
|
|
|
sum(a.first_new_user_amount) as user_recharge_money,
|
|
|
- ifnull(sum(b.amount_count),0) as show_recharge_count,
|
|
|
- ifnull(sum(b.amount_num),0) as show_recharge_user,
|
|
|
- ifnull(sum(b.amount),0) as show_recharge_money,
|
|
|
sum(a.old_amount_count) as old_user_recharge_count,
|
|
|
sum(a.old_amount_num) as old_user_recharge_user,
|
|
|
sum(a.old_amount) as old_user_recharge_money,
|
|
@@ -635,24 +876,16 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
round(if(sum(a.register_num) > 0, sum(a.new_user_total_amount_num) / sum(a.register_num), 0), 4) as today_recharge_rate,
|
|
|
round(if(sum(a.first_new_user_amount_count) > 0, sum(a.first_new_user_amount) / sum(a.first_new_user_amount_count), 0), 4) as avg_first_user_recharge,
|
|
|
round(if(sum(a.new_user_total_amount_count) > 0, sum(a.new_user_total_amount) / sum(a.new_user_total_amount_count), 0), 4) as avg_today_recharge,
|
|
|
- round(if(sum(b.amount_count) > 0, sum(b.amount) / sum(b.amount_count), 0), 4) as avg_show_user_recharge,
|
|
|
round(if(sum(a.first_new_user_amount_num) > 0, sum(a.cost) / sum(a.first_new_user_amount_num), 0), 4) as first_recharge_cost,
|
|
|
round(if(sum(a.new_user_total_amount_num) > 0, sum(a.cost) / sum(a.new_user_total_amount_num), 0), 4) as today_recharge_cost,
|
|
|
round(if(sum(a.new_user_total_amount_num) > 0, sum(a.reg_order_user_again) / sum(a.new_user_total_amount_num), 0), 4) as today_repeat_recharge_rate,
|
|
|
round(if(sum(a.register_num) > 0, sum(a.new_user_total_amount) / sum(a.register_num), 0), 4) as new_reg_arpu,
|
|
|
round(if(sum(a.first_new_user_amount_num) > 0, sum(a.first_new_user_amount) / sum(a.first_new_user_amount_num), 0), 4) as first_recharge_arpu,
|
|
|
round(if(sum(a.new_user_total_amount_num) > 0, sum(a.new_user_total_amount) / sum(a.new_user_total_amount_num), 0), 4) as today_recharge_arpu,
|
|
|
- round(if(sum(a.amount_num) > 0, sum(a.amount) / sum(a.amount_num), 0), 4) as show_recharge_arpu,
|
|
|
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
|
|
|
from
|
|
|
ads_account_agent_day a
|
|
|
- left join game_ads.ads_account_agent_day b on
|
|
|
- b.pitcher_id = a.pitcher_id
|
|
|
- and b.agent_id = a.agent_id
|
|
|
- and b.account_id = a.account_id
|
|
|
- and b.dt >= @rechargeBeginDay
|
|
|
- and b.dt <= @rechargeEndDay
|
|
|
""";
|
|
|
}
|
|
|
|
|
@@ -664,4 +897,20 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
private Long rechargeNum;
|
|
|
private Long repeatNum;
|
|
|
}
|
|
|
+
|
|
|
+ @Data
|
|
|
+ @NoArgsConstructor
|
|
|
+ @AllArgsConstructor
|
|
|
+ @Builder
|
|
|
+ public static class ShowRecharge{
|
|
|
+ private Long showRechargeCount;
|
|
|
+
|
|
|
+ private Long showRechargeUser;
|
|
|
+
|
|
|
+ private BigDecimal showRechargeMoney;
|
|
|
+
|
|
|
+ private BigDecimal avgShowUserRecharge;
|
|
|
+
|
|
|
+ private BigDecimal showRechargeArpu;
|
|
|
+ }
|
|
|
}
|