|
@@ -3,6 +3,7 @@ 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.component.DataPowerComponent;
|
|
|
import com.zanxiang.game.data.serve.pojo.dto.*;
|
|
|
import com.zanxiang.game.data.serve.pojo.entity.AdsAccountAgentDay;
|
|
|
import com.zanxiang.game.data.serve.pojo.entity.AdsAgentDayAgain;
|
|
@@ -42,21 +43,27 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataPowerComponent dataPowerComponent;
|
|
|
@Autowired
|
|
|
private Dao dao;
|
|
|
|
|
|
@Override
|
|
|
public Page<GamePromoteDayVO> accountAgentDay(GamePromoteDayDTO dto) {
|
|
|
- Long sysUserId = SecurityUtil.isAdmin() ? null : SecurityUtil.getUserId();
|
|
|
+ long[] userIds = dto.getSysUserId() == null ? dataPowerComponent.getSubUserIdList() : new long[]{dto.getSysUserId()};
|
|
|
+ long[] gameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
+
|
|
|
+ /*Long sysUserId = SecurityUtil.isAdmin() ? null : SecurityUtil.getUserId();
|
|
|
sysUserId = null == dto.getSysUserId() ? sysUserId : dto.getSysUserId();
|
|
|
- dto.setSysUserId(sysUserId);
|
|
|
- if (StringUtils.isBlank(dto.getSortFiled())){
|
|
|
+ dto.setSysUserId(sysUserId);*/
|
|
|
+ if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
dto.setSortFiled("dt");
|
|
|
}
|
|
|
- if (StringUtils.isBlank(dto.getSortType())){
|
|
|
+ if (StringUtils.isBlank(dto.getSortType())) {
|
|
|
dto.setSortType(OrderByEnum.DESC.getOrderType());
|
|
|
}
|
|
|
- if (null == dto.getBeginDay() || null == dto.getEndDay()){
|
|
|
+ if (null == dto.getBeginDay() || null == dto.getEndDay()) {
|
|
|
dto.setBeginDay(LocalDate.now());
|
|
|
dto.setEndDay(LocalDate.now());
|
|
|
}
|
|
@@ -64,8 +71,8 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
// 创建一个 Criteria 接口实例
|
|
|
SimpleCriteria cri = Cnd.cri();
|
|
|
// 组装条件
|
|
|
- if (null != dto.getSysUserId()) {
|
|
|
- cri.where().andEquals("pitcher_id", dto.getSysUserId());
|
|
|
+ if (userIds != null) {
|
|
|
+ cri.where().andIn("pitcher_id", userIds);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getAccountId())) {
|
|
|
cri.where().andEquals("account_id", dto.getAccountId());
|
|
@@ -82,8 +89,8 @@ 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 (gameIds != null) {
|
|
|
+ cri.where().andEquals("game_id", gameIds);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getGameType())) {
|
|
|
cri.where().andEquals("game_type", dto.getGameType());
|
|
@@ -236,18 +243,21 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
|
|
|
@Override
|
|
|
public GamePromoteDayTotalVO accountAgentDayTotal(GamePromoteDayTotalDTO dto) {
|
|
|
- Long sysUserId = SecurityUtil.isAdmin() ? null : SecurityUtil.getUserId();
|
|
|
+ long[] userIds = dto.getSysUserId() == null ? dataPowerComponent.getSubUserIdList() : new long[]{dto.getSysUserId()};
|
|
|
+ long[] gameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
+
|
|
|
+ /*Long sysUserId = SecurityUtil.isAdmin() ? null : SecurityUtil.getUserId();
|
|
|
sysUserId = null == dto.getSysUserId() ? sysUserId : dto.getSysUserId();
|
|
|
- dto.setSysUserId(sysUserId);
|
|
|
- if (null == dto.getBeginDay() || null == dto.getEndDay()){
|
|
|
+ dto.setSysUserId(sysUserId);*/
|
|
|
+ if (null == dto.getBeginDay() || null == dto.getEndDay()) {
|
|
|
dto.setBeginDay(LocalDate.now());
|
|
|
dto.setEndDay(LocalDate.now());
|
|
|
}
|
|
|
// 创建一个 Criteria 接口实例
|
|
|
SimpleCriteria cri = Cnd.cri();
|
|
|
// 组装条件
|
|
|
- if (null != dto.getSysUserId()) {
|
|
|
- cri.where().andEquals("pitcher_id", dto.getSysUserId());
|
|
|
+ if (null != userIds) {
|
|
|
+ cri.where().andIn("pitcher_id", userIds);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getAccountId())) {
|
|
|
cri.where().andEquals("account_id", dto.getAccountId());
|
|
@@ -267,8 +277,8 @@ 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 (gameIds != null) {
|
|
|
+ cri.where().andIn("game_id", gameIds);
|
|
|
}
|
|
|
if (null != dto.getBeginDay()) {
|
|
|
cri.where().and("dt", ">=", dto.getBeginDay());
|
|
@@ -284,7 +294,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
sql.setEntity(entity).setCondition(cri);
|
|
|
dao.execute(sql);
|
|
|
GamePromoteDayTotalVO gamePromoteDayTotalVO = sql.getObject(GamePromoteDayTotalVO.class);
|
|
|
- if (null == gamePromoteDayTotalVO.getCost()){
|
|
|
+ if (null == gamePromoteDayTotalVO.getCost()) {
|
|
|
return gamePromoteDayTotalVO;
|
|
|
}
|
|
|
setDayTotalRechargeTrend(gamePromoteDayTotalVO);
|
|
@@ -430,23 +440,25 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
.rechargeUserCount(Long.valueOf(trendDayResult[2]))
|
|
|
.rechargeMoneyTotal(dayTotalRecharge)
|
|
|
.increase(currCost.compareTo(BigDecimal.ZERO) == 0 ?
|
|
|
- BigDecimal.ZERO:dayRecharge.divide(currCost,4, RoundingMode.DOWN))
|
|
|
+ BigDecimal.ZERO : dayRecharge.divide(currCost, 4, RoundingMode.DOWN))
|
|
|
.back(currCost.compareTo(BigDecimal.ZERO) == 0 ?
|
|
|
- BigDecimal.ZERO:dayTotalRecharge.divide(currCost,4, RoundingMode.DOWN))
|
|
|
+ BigDecimal.ZERO : dayTotalRecharge.divide(currCost, 4, RoundingMode.DOWN))
|
|
|
.multiples(currDay1.compareTo(BigDecimal.ZERO) == 0 ?
|
|
|
- BigDecimal.ZERO:dayTotalRecharge.divide(currDay1,4, RoundingMode.DOWN))
|
|
|
+ BigDecimal.ZERO : dayTotalRecharge.divide(currDay1, 4, RoundingMode.DOWN))
|
|
|
.build();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Page<GamePromoteTotalVO> accountAgentTotal(GamePromoteTotalDTO dto) {
|
|
|
- Long sysUserId = SecurityUtil.isAdmin() ? null : SecurityUtil.getUserId();
|
|
|
+ long[] userIds = dto.getSysUserId() == null ? dataPowerComponent.getSubUserIdList() : new long[]{dto.getSysUserId()};
|
|
|
+ long[] gameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
+ /*Long sysUserId = SecurityUtil.isAdmin() ? null : SecurityUtil.getUserId();
|
|
|
sysUserId = null == dto.getSysUserId() ? sysUserId : dto.getSysUserId();
|
|
|
- dto.setSysUserId(sysUserId);
|
|
|
- if (StringUtils.isBlank(dto.getSortFiled())){
|
|
|
+ dto.setSysUserId(sysUserId);*/
|
|
|
+ if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
dto.setSortFiled("cost");
|
|
|
}
|
|
|
- if (StringUtils.isBlank(dto.getSortType())){
|
|
|
+ if (StringUtils.isBlank(dto.getSortType())) {
|
|
|
dto.setSortType(OrderByEnum.DESC.getOrderType());
|
|
|
}
|
|
|
if (null == dto.getCostEndDay() || null == dto.getCostBeginDay()) {
|
|
@@ -461,8 +473,8 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
// 创建一个 Criteria 接口实例
|
|
|
SimpleCriteria cri = Cnd.cri();
|
|
|
// 组装条件
|
|
|
- if (null != dto.getSysUserId()) {
|
|
|
- cri.where().andEquals("a.pitcher_id", dto.getSysUserId());
|
|
|
+ if (userIds != null) {
|
|
|
+ cri.where().andIn("a.pitcher_id", userIds);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getAccountId())) {
|
|
|
cri.where().andEquals("a.account_id", dto.getAccountId());
|
|
@@ -488,8 +500,8 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
if (null != dto.getCostEndDay()) {
|
|
|
cri.where().and("a.dt", "<=", dto.getCostEndDay());
|
|
|
}
|
|
|
- if (null != dto.getGameId()) {
|
|
|
- cri.where().andEquals("a.game_id", dto.getGameId());
|
|
|
+ if (null != gameIds) {
|
|
|
+ cri.where().andIn("a.game_id", gameIds);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
cri.where().andEquals("a.source_system", dto.getSourceSystem());
|
|
@@ -602,14 +614,14 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
showSql.setParam("accountId", item.getAccountId());
|
|
|
dao.execute(showSql);
|
|
|
ShowRecharge showRecharge = showSql.getObject(ShowRecharge.class);
|
|
|
- if (null != showRecharge){
|
|
|
+ if (null != showRecharge) {
|
|
|
item.setShowRechargeArpu(showRecharge.getShowRechargeUser() == 0 ? BigDecimal.ZERO :
|
|
|
showRecharge.getShowRechargeMoney().divide(new BigDecimal(showRecharge.getShowRechargeUser()), 4, RoundingMode.DOWN));
|
|
|
item.setShowRechargeCount(showRecharge.getShowRechargeCount());
|
|
|
item.setShowRechargeMoney(showRecharge.getShowRechargeMoney());
|
|
|
item.setShowRechargeUser(showRecharge.getShowRechargeUser());
|
|
|
item.setAvgShowUserRecharge(showRecharge.getAvgShowUserRecharge());
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
item.setShowRechargeArpu(BigDecimal.ZERO);
|
|
|
item.setShowRechargeCount(0L);
|
|
|
item.setShowRechargeMoney(BigDecimal.ZERO);
|
|
@@ -689,31 +701,31 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
item.setUserRechargeUser(dayN.getRechargeNum());
|
|
|
item.setRepeatRechargeUser(dayN.getRepeatNum());
|
|
|
item.setUserRechargeArpu(item.getUserRechargeUser() == 0 ?
|
|
|
- BigDecimal.ZERO:item.getUserRechargeMoney().divide(BigDecimal.valueOf(item.getUserRechargeUser()),4, RoundingMode.DOWN));
|
|
|
+ BigDecimal.ZERO : item.getUserRechargeMoney().divide(BigDecimal.valueOf(item.getUserRechargeUser()), 4, RoundingMode.DOWN));
|
|
|
|
|
|
item.setOldUserRechargeMoney(item.getShowRechargeMoney().subtract(item.getUserRechargeMoney()));
|
|
|
item.setOldUserRechargeCount(item.getShowRechargeCount() - item.getUserRechargeCount());
|
|
|
item.setOldUserRechargeUser(item.getShowRechargeUser() - item.getUserRechargeUser());
|
|
|
|
|
|
item.setRecoveryRate(item.getCost().compareTo(BigDecimal.ZERO) == 0 ?
|
|
|
- BigDecimal.ZERO:item.getUserRechargeMoney().divide(item.getCost(),4, RoundingMode.DOWN));
|
|
|
+ BigDecimal.ZERO : item.getUserRechargeMoney().divide(item.getCost(), 4, RoundingMode.DOWN));
|
|
|
|
|
|
item.setUserRechargeRate(item.getRegUserCount() == 0 ?
|
|
|
- BigDecimal.ZERO:BigDecimal.valueOf(item.getUserRechargeUser()).divide(BigDecimal.valueOf(item.getRegUserCount()),4, RoundingMode.DOWN));
|
|
|
+ BigDecimal.ZERO : BigDecimal.valueOf(item.getUserRechargeUser()).divide(BigDecimal.valueOf(item.getRegUserCount()), 4, RoundingMode.DOWN));
|
|
|
|
|
|
item.setNewUserRechargeRatio(item.getShowRechargeUser() == 0 ?
|
|
|
- BigDecimal.ZERO:BigDecimal.valueOf(item.getUserRechargeUser()).divide(BigDecimal.valueOf(item.getShowRechargeUser()),4, RoundingMode.DOWN));
|
|
|
+ BigDecimal.ZERO : BigDecimal.valueOf(item.getUserRechargeUser()).divide(BigDecimal.valueOf(item.getShowRechargeUser()), 4, RoundingMode.DOWN));
|
|
|
|
|
|
item.setAvgUserRecharge(item.getUserRechargeCount() == 0 ?
|
|
|
- BigDecimal.ZERO:item.getUserRechargeMoney().divide(BigDecimal.valueOf(item.getUserRechargeCount()),4, RoundingMode.DOWN));
|
|
|
+ BigDecimal.ZERO : item.getUserRechargeMoney().divide(BigDecimal.valueOf(item.getUserRechargeCount()), 4, RoundingMode.DOWN));
|
|
|
|
|
|
item.setUserRechargeCost(item.getUserRechargeUser() == 0 ?
|
|
|
- BigDecimal.ZERO:item.getCost().divide(BigDecimal.valueOf(item.getUserRechargeUser()),2, RoundingMode.DOWN));
|
|
|
+ BigDecimal.ZERO : item.getCost().divide(BigDecimal.valueOf(item.getUserRechargeUser()), 2, RoundingMode.DOWN));
|
|
|
|
|
|
item.setRepeatRechargeRate(item.getUserRechargeUser() == 0 ?
|
|
|
- BigDecimal.ZERO:BigDecimal.valueOf(item.getRepeatRechargeUser()).divide(BigDecimal.valueOf(item.getUserRechargeUser()),4, RoundingMode.DOWN));
|
|
|
+ BigDecimal.ZERO : BigDecimal.valueOf(item.getRepeatRechargeUser()).divide(BigDecimal.valueOf(item.getUserRechargeUser()), 4, RoundingMode.DOWN));
|
|
|
item.setUserRepeatRechargeRate(item.getNewUserRechargeUser() == 0 ?
|
|
|
- BigDecimal.ZERO:BigDecimal.valueOf(item.getRepeatRechargeUser()).divide(BigDecimal.valueOf(item.getNewUserRechargeUser()),4, RoundingMode.DOWN));
|
|
|
+ BigDecimal.ZERO : BigDecimal.valueOf(item.getRepeatRechargeUser()).divide(BigDecimal.valueOf(item.getNewUserRechargeUser()), 4, RoundingMode.DOWN));
|
|
|
|
|
|
item.setUserRechargeCountCost(item.getUserRechargeCount() == 0 ?
|
|
|
BigDecimal.ZERO : item.getCost().divide(BigDecimal.valueOf(item.getUserRechargeCount()), 4, RoundingMode.DOWN));
|
|
@@ -744,11 +756,11 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
}
|
|
|
//拼接查询条件
|
|
|
Criteria cri = Cnd.cri();
|
|
|
- if (dto.getAccountId() != null){
|
|
|
- cri.where().andEquals("account_id",dto.getAccountId());
|
|
|
+ if (dto.getAccountId() != null) {
|
|
|
+ cri.where().andEquals("account_id", dto.getAccountId());
|
|
|
}
|
|
|
- if (dto.getAgentId() != null){
|
|
|
- cri.where().andEquals("agent_id",dto.getAgentId());
|
|
|
+ if (dto.getAgentId() != null) {
|
|
|
+ cri.where().andEquals("agent_id", dto.getAgentId());
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
//拼接SDK来源
|
|
@@ -762,7 +774,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
cri.getOrderBy().asc("ddf");
|
|
|
|
|
|
//获取推广每日复充表的查询结果
|
|
|
- Sql againSql = Sqls.create( agentDayAgainSql() + cri);
|
|
|
+ Sql againSql = Sqls.create(agentDayAgainSql() + cri);
|
|
|
againSql.setCallback(Sqls.callback.entities());
|
|
|
againSql.setEntity(dao.getEntity(AdsAgentDayAgain.class));
|
|
|
//执行sql
|
|
@@ -778,7 +790,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
//记录查询出的记录条数
|
|
|
int count = list.size();
|
|
|
//没有数据直接返回空结果
|
|
|
- if (count == 0){
|
|
|
+ if (count == 0) {
|
|
|
return map;
|
|
|
}
|
|
|
//初始化list
|
|
@@ -800,7 +812,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
tempList.get(0).get(i).setDecrease(getCnByNum(list.get(0), ci + 1));
|
|
|
//"现":公式计算 = 原 + 增 - 移
|
|
|
tempList.get(0).get(i).setPresent(
|
|
|
- tempVO.getOriginal()+(tempVO.getIncrease())-(tempVO.getDecrease())
|
|
|
+ tempVO.getOriginal() + (tempVO.getIncrease()) - (tempVO.getDecrease())
|
|
|
);
|
|
|
//"比"
|
|
|
tempList.get(0).get(i).setRate(getCnByNum(list.get(0), 1).compareTo(0L) == 0 ? BigDecimal.ZERO :
|
|
@@ -815,13 +827,13 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
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)));
|
|
|
+ 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)));
|
|
|
+ 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)));
|
|
|
+ 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));
|
|
@@ -837,9 +849,11 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
|
|
|
@Override
|
|
|
public GamePromoteTotalSumVO accountAgentTotalSum(GamePromoteTotalSumDTO dto) {
|
|
|
- Long sysUserId = SecurityUtil.isAdmin() ? null : SecurityUtil.getUserId();
|
|
|
+ long[] userIds = dto.getSysUserId() == null ? dataPowerComponent.getSubUserIdList() : new long[]{dto.getSysUserId()};
|
|
|
+ long[] gameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
+ /*Long sysUserId = SecurityUtil.isAdmin() ? null : SecurityUtil.getUserId();
|
|
|
sysUserId = null == dto.getSysUserId() ? sysUserId : dto.getSysUserId();
|
|
|
- dto.setSysUserId(sysUserId);
|
|
|
+ dto.setSysUserId(sysUserId);*/
|
|
|
if (null == dto.getCostEndDay() || null == dto.getCostBeginDay()) {
|
|
|
dto.setCostBeginDay(LocalDate.now());
|
|
|
dto.setCostEndDay(LocalDate.now());
|
|
@@ -849,7 +863,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
dto.setRechargeBeginDay(LocalDate.now());
|
|
|
}
|
|
|
// 推广总计
|
|
|
- SimpleCriteria cri = getSimpleCriteria(dto);
|
|
|
+ SimpleCriteria cri = getSimpleCriteria(userIds, gameIds, dto);
|
|
|
if (null != dto.getCostBeginDay()) {
|
|
|
cri.where().and("a.dt", ">=", dto.getCostBeginDay());
|
|
|
}
|
|
@@ -861,12 +875,12 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
sql.setEntity(entity).setCondition(cri);
|
|
|
dao.execute(sql);
|
|
|
GamePromoteTotalSumVO gamePromoteTotalSumVO = sql.getObject(GamePromoteTotalSumVO.class);
|
|
|
- if (null == gamePromoteTotalSumVO.getCost()){
|
|
|
+ if (null == gamePromoteTotalSumVO.getCost()) {
|
|
|
return gamePromoteTotalSumVO;
|
|
|
}
|
|
|
|
|
|
//账面总计
|
|
|
- SimpleCriteria showCri = getSimpleCriteria(dto);
|
|
|
+ SimpleCriteria showCri = getSimpleCriteria(userIds, gameIds, dto);
|
|
|
if (null != dto.getRechargeBeginDay()) {
|
|
|
showCri.where().and("a.dt", ">=", dto.getRechargeBeginDay());
|
|
|
}
|
|
@@ -916,7 +930,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
}
|
|
|
|
|
|
// dayN总计
|
|
|
- SimpleCriteria agentAccountCri = getSimpleCriteria(dto);
|
|
|
+ SimpleCriteria agentAccountCri = getSimpleCriteria(userIds, gameIds, dto);
|
|
|
if (null != dto.getCostBeginDay()) {
|
|
|
agentAccountCri.where().and("a.dt", ">=", dto.getCostBeginDay());
|
|
|
}
|
|
@@ -1117,11 +1131,11 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
return gamePromoteTotalSumVO;
|
|
|
}
|
|
|
|
|
|
- private SimpleCriteria getSimpleCriteria(GamePromoteTotalSumDTO dto) {
|
|
|
+ private SimpleCriteria getSimpleCriteria(long[] userIds, long[] gameIds, GamePromoteTotalSumDTO dto) {
|
|
|
SimpleCriteria cri = Cnd.cri();
|
|
|
// 组装条件
|
|
|
- if (null != dto.getSysUserId()) {
|
|
|
- cri.where().andEquals("a.pitcher_id", dto.getSysUserId());
|
|
|
+ if (null != userIds) {
|
|
|
+ cri.where().andIn("a.pitcher_id", userIds);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getAccountId())) {
|
|
|
cri.where().andEquals("a.account_id", dto.getAccountId());
|
|
@@ -1141,8 +1155,8 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
if (StringUtils.isNotBlank(dto.getGameType())) {
|
|
|
cri.where().andEquals("a.game_type", dto.getGameType());
|
|
|
}
|
|
|
- if (null != dto.getGameId()) {
|
|
|
- cri.where().andEquals("a.game_id", dto.getGameId());
|
|
|
+ if (null != gameIds) {
|
|
|
+ cri.where().andIn("a.game_id", gameIds);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
cri.where().andEquals("a.source_system", dto.getSourceSystem());
|
|
@@ -1152,8 +1166,9 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
|
|
|
/**
|
|
|
* 初始化List数据
|
|
|
+ *
|
|
|
* @param list 需要初始化的数据
|
|
|
- * @param num 多少天的数据
|
|
|
+ * @param num 多少天的数据
|
|
|
*/
|
|
|
private void initList(List<List<AgentDayAgainVO>> list, Integer num) {
|
|
|
//外层循环 num 次 表示多少天的数据
|
|
@@ -1176,6 +1191,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
|
|
|
/**
|
|
|
* 通过反射来获取Cn的值
|
|
|
+ *
|
|
|
* @param dto 数据库查询出来的原始数据对象实体
|
|
|
* @param num 1-9
|
|
|
* @return Cn
|
|
@@ -1192,6 +1208,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
|
|
|
/**
|
|
|
* 推广每日复充趋势sql
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
private String agentDayAgainSql() {
|
|
@@ -1219,6 +1236,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
|
|
|
/**
|
|
|
* 推广每日数据SQL
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
private String accountAgentDaySql() {
|
|
@@ -1446,6 +1464,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
|
|
|
/**
|
|
|
* 推广每日数据总计SQL
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
private String accountAgentDayTotalSql() {
|
|
@@ -1495,43 +1514,43 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
round(if(sum(cost) > 0, sum(buy_new_user_total_amount) / sum(cost), 0), 4) as buy_recovery_rate,
|
|
|
sum(gross_profit) as gross_margin,
|
|
|
"""
|
|
|
- +roiDay()+
|
|
|
+ + roiDay() +
|
|
|
"""
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 29 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d30, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 29 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day30,
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 59 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d60, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 59 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day60,
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 89 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d90, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 89 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day90,
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 179 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_m6, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 179 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day180,
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 359 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_m12, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 359 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_year1,
|
|
|
- round(if(SUM(cost) > 0, sum(SPLIT_PART(amount_sum, '/', 6)) / SUM(cost), 0), 4) as roi_total,
|
|
|
- """
|
|
|
- +trendDay()+
|
|
|
- """
|
|
|
- CONCAT(SUM(CAST(SPLIT_PART(amount_sum , '/', 1) AS DECIMAL(10, 2))),'/',SUM(CAST(SPLIT_PART(amount_sum, '/', 6) AS DECIMAL(10, 2))),'/',SUM(CAST(SPLIT_PART(amount_sum, '/', 2) AS BIGINT))) AS trend_total,
|
|
|
- round(if(sum(register_num) > 0, sum(first_new_user_amount_num) / sum(register_num), 0), 4) as first_recharge_rate,
|
|
|
- round(if(sum(register_num) > 0, sum(buy_new_user_total_amount_num) / sum(register_num), 0), 4) as buy_user_recharge_rate,
|
|
|
- round(if(sum(amount_num) > 0, sum(first_new_user_amount_num) / sum(amount_num), 0), 4) as new_user_recharge_rate,
|
|
|
- round(if(sum(first_new_user_amount_count) > 0, sum(first_new_user_amount) / sum(first_new_user_amount_count), 0), 4) as avg_first_user_recharge,
|
|
|
- round(if(sum(buy_new_user_total_amount_count) > 0, sum(buy_new_user_total_amount) / sum(buy_new_user_total_amount_count), 0), 4) as avg_buy_user_recharge,
|
|
|
- round(if(sum(amount_count) > 0, sum(amount) / sum(amount_count), 0), 4) as avg_show_user_recharge,
|
|
|
- round(if(sum(first_new_user_amount_num) > 0, sum(cost) / sum(first_new_user_amount_num), 0), 4) as first_recharge_cost,
|
|
|
- round(if(sum(buy_new_user_total_amount_num) > 0, sum(cost) / sum(buy_new_user_total_amount_num), 0), 4) as buy_user_recharge_cost,
|
|
|
- round(if(sum(new_user_total_amount_num) > 0, sum(reg_order_user_again) / sum(new_user_total_amount_num), 0), 4) as repeat_recharge_rate,
|
|
|
- round(if(sum(register_num) > 0, sum(new_user_total_amount) / sum(register_num), 0), 4) as new_reg_arpu,
|
|
|
- round(if(sum(first_new_user_amount_num) > 0, sum(first_new_user_amount) / sum(first_new_user_amount_num), 0), 4) as first_recharge_arpu,
|
|
|
- round(if(sum(new_user_total_amount_num) > 0, sum(new_user_total_amount) / sum(new_user_total_amount_num), 0), 4) as today_recharge_arpu,
|
|
|
- round(if(sum(amount_num) > 0, sum(amount) / sum(amount_num), 0), 4) as show_recharge_arpu,
|
|
|
- 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(old_amount_count) > 0, sum(cost) / sum(old_amount_count), 0), 4) as old_user_recharge_count_cost,
|
|
|
- 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,
|
|
|
- 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
|
|
|
- """;
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 29 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d30, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 29 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day30,
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 59 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d60, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 59 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day60,
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 89 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d90, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 89 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day90,
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 179 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_m6, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 179 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day180,
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 359 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_m12, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 359 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_year1,
|
|
|
+ round(if(SUM(cost) > 0, sum(SPLIT_PART(amount_sum, '/', 6)) / SUM(cost), 0), 4) as roi_total,
|
|
|
+ """
|
|
|
+ + trendDay() +
|
|
|
+ """
|
|
|
+ CONCAT(SUM(CAST(SPLIT_PART(amount_sum , '/', 1) AS DECIMAL(10, 2))),'/',SUM(CAST(SPLIT_PART(amount_sum, '/', 6) AS DECIMAL(10, 2))),'/',SUM(CAST(SPLIT_PART(amount_sum, '/', 2) AS BIGINT))) AS trend_total,
|
|
|
+ round(if(sum(register_num) > 0, sum(first_new_user_amount_num) / sum(register_num), 0), 4) as first_recharge_rate,
|
|
|
+ round(if(sum(register_num) > 0, sum(buy_new_user_total_amount_num) / sum(register_num), 0), 4) as buy_user_recharge_rate,
|
|
|
+ round(if(sum(amount_num) > 0, sum(first_new_user_amount_num) / sum(amount_num), 0), 4) as new_user_recharge_rate,
|
|
|
+ round(if(sum(first_new_user_amount_count) > 0, sum(first_new_user_amount) / sum(first_new_user_amount_count), 0), 4) as avg_first_user_recharge,
|
|
|
+ round(if(sum(buy_new_user_total_amount_count) > 0, sum(buy_new_user_total_amount) / sum(buy_new_user_total_amount_count), 0), 4) as avg_buy_user_recharge,
|
|
|
+ round(if(sum(amount_count) > 0, sum(amount) / sum(amount_count), 0), 4) as avg_show_user_recharge,
|
|
|
+ round(if(sum(first_new_user_amount_num) > 0, sum(cost) / sum(first_new_user_amount_num), 0), 4) as first_recharge_cost,
|
|
|
+ round(if(sum(buy_new_user_total_amount_num) > 0, sum(cost) / sum(buy_new_user_total_amount_num), 0), 4) as buy_user_recharge_cost,
|
|
|
+ round(if(sum(new_user_total_amount_num) > 0, sum(reg_order_user_again) / sum(new_user_total_amount_num), 0), 4) as repeat_recharge_rate,
|
|
|
+ round(if(sum(register_num) > 0, sum(new_user_total_amount) / sum(register_num), 0), 4) as new_reg_arpu,
|
|
|
+ round(if(sum(first_new_user_amount_num) > 0, sum(first_new_user_amount) / sum(first_new_user_amount_num), 0), 4) as first_recharge_arpu,
|
|
|
+ round(if(sum(new_user_total_amount_num) > 0, sum(new_user_total_amount) / sum(new_user_total_amount_num), 0), 4) as today_recharge_arpu,
|
|
|
+ round(if(sum(amount_num) > 0, sum(amount) / sum(amount_num), 0), 4) as show_recharge_arpu,
|
|
|
+ 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(old_amount_count) > 0, sum(cost) / sum(old_amount_count), 0), 4) as old_user_recharge_count_cost,
|
|
|
+ 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,
|
|
|
+ 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
|
|
|
+ """;
|
|
|
}
|
|
|
|
|
|
private String trendDay() {
|
|
@@ -1545,7 +1564,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
SUM(CAST(SPLIT_PART(amount_d%s, '/', 2) AS BIGINT)), '/',
|
|
|
SUM(IF(DATE_ADD(dt, INTERVAL %s DAY) > '%s', 0, cost)), '/',
|
|
|
SUM(IF(DATE_ADD(dt, INTERVAL %s DAY) > '%s', 0, CAST(SPLIT_PART(amount_d1 , '/', 1) AS DECIMAL(10, 2))))
|
|
|
- ) AS trend_day%s,""".formatted(day, day, day, day - 1, now,day-1,now,day));
|
|
|
+ ) AS trend_day%s,""".formatted(day, day, day, day - 1, now, day - 1, now, day));
|
|
|
}
|
|
|
for (int month = 4; month <= 12; month++) {
|
|
|
trendDay.append("""
|
|
@@ -1555,7 +1574,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
SUM(CAST(SPLIT_PART(amount_m%s, '/', 2) AS BIGINT)), '/',
|
|
|
SUM(IF(DATE_ADD(dt, INTERVAL %s month) > '%s', 0, cost)), '/',
|
|
|
SUM(IF(DATE_ADD(dt, INTERVAL %s month) > '%s', 0, CAST(SPLIT_PART(amount_d1 , '/', 1) AS DECIMAL(10, 2))))
|
|
|
- ) AS trend_month%s,""".formatted(month, month, month, month, now,month,now,month));
|
|
|
+ ) AS trend_month%s,""".formatted(month, month, month, month, now, month, now, month));
|
|
|
}
|
|
|
return trendDay.toString();
|
|
|
}
|
|
@@ -1567,13 +1586,14 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
roiDay.append("""
|
|
|
round(if(SUM(IF(DATE_ADD(dt, INTERVAL %s DAY) > '%s', 0, cost)) > 0, sum(SPLIT_PART(amount_d%s, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL %s DAY) > '%s', 0, cost)), 0), 4) as roi_day%s,
|
|
|
"""
|
|
|
- .formatted(day - 1, now,day,day-1,now,day));
|
|
|
+ .formatted(day - 1, now, day, day - 1, now, day));
|
|
|
}
|
|
|
return roiDay.toString();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 推广总数据SQL
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
private String accountAgentTotalSumDayNSql() {
|
|
@@ -1589,6 +1609,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
|
|
|
/**
|
|
|
* 推广总数据SQL
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
private String accountAgentTotalSumSql() {
|
|
@@ -1637,40 +1658,41 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
round(if(sum(a.cost) > 0, sum(a.new_user_total_amount) / sum(a.cost), 0), 4) as today_recovery_rate,
|
|
|
sum(a.gross_profit) as gross_margin,
|
|
|
"""
|
|
|
- +roiDay()+
|
|
|
- """
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 29 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d30, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 29 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day30,
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 59 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d60, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 59 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day60,
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 89 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d90, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 89 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day90,
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 179 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_m6, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 179 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day180,
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 359 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_m12, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 359 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_year1,
|
|
|
- round(if(SUM(cost) > 0, sum(SPLIT_PART(amount_sum, '/', 6)) / SUM(cost), 0), 4) as roi_total,
|
|
|
- """
|
|
|
+ + roiDay() +
|
|
|
+ """
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 29 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d30, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 29 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day30,
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 59 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d60, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 59 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day60,
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 89 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d90, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 89 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day90,
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 179 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_m6, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 179 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day180,
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 359 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_m12, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 359 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_year1,
|
|
|
+ round(if(SUM(cost) > 0, sum(SPLIT_PART(amount_sum, '/', 6)) / SUM(cost), 0), 4) as roi_total,
|
|
|
+ """
|
|
|
+
|
|
|
- """
|
|
|
- round(if(sum(a.register_num) > 0, sum(a.first_new_user_amount_num) / sum(a.register_num), 0), 4) as first_recharge_rate,
|
|
|
- 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(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(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,
|
|
|
- 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
|
|
|
- """;
|
|
|
+ """
|
|
|
+ round(if(sum(a.register_num) > 0, sum(a.first_new_user_amount_num) / sum(a.register_num), 0), 4) as first_recharge_rate,
|
|
|
+ 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(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(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,
|
|
|
+ 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
|
|
|
+ """;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 推广总数据SQL
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
private String accountAgentTotalSql() {
|
|
@@ -1731,43 +1753,43 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
round(if(sum(a.cost) > 0, sum(a.new_user_total_amount) / sum(a.cost), 0), 4) as today_recovery_rate,
|
|
|
sum(a.gross_profit) as gross_margin,
|
|
|
"""
|
|
|
- +roiDay()+
|
|
|
+ + roiDay() +
|
|
|
"""
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 29 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d30, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 29 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day30,
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 59 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d60, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 59 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day60,
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 89 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d90, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 89 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day90,
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 179 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_m6, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 179 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day180,
|
|
|
- round(if(SUM(IF(DATE_ADD(dt, INTERVAL 359 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_m12, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 359 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_year1,
|
|
|
- round(if(SUM(cost) > 0, sum(SPLIT_PART(amount_sum, '/', 6)) / SUM(cost), 0), 4) as roi_total,
|
|
|
- """
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 29 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d30, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 29 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day30,
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 59 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d60, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 59 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day60,
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 89 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_d90, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 89 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day90,
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 179 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_m6, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 179 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_day180,
|
|
|
+ round(if(SUM(IF(DATE_ADD(dt, INTERVAL 359 DAY) > CURRENT_DATE(), 0, cost)) > 0, sum(SPLIT_PART(amount_m12, '/', 6)) / SUM(IF(DATE_ADD(dt, INTERVAL 359 DAY) > CURRENT_DATE(), 0, cost)), 0), 4) as roi_year1,
|
|
|
+ round(if(SUM(cost) > 0, sum(SPLIT_PART(amount_sum, '/', 6)) / SUM(cost), 0), 4) as roi_total,
|
|
|
+ """
|
|
|
+
|
|
|
"""
|
|
|
- round(if(sum(a.register_num) > 0, sum(a.first_new_user_amount_num) / sum(a.register_num), 0), 4) as first_recharge_rate,
|
|
|
- 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(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(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,
|
|
|
- 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
|
|
|
- """;
|
|
|
+ round(if(sum(a.register_num) > 0, sum(a.first_new_user_amount_num) / sum(a.register_num), 0), 4) as first_recharge_rate,
|
|
|
+ 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(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(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,
|
|
|
+ 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
|
|
|
+ """;
|
|
|
}
|
|
|
|
|
|
@Data
|
|
|
@NoArgsConstructor
|
|
|
@AllArgsConstructor
|
|
|
@Builder
|
|
|
- public static class DayN{
|
|
|
+ public static class DayN {
|
|
|
private BigDecimal rechargeMoney = BigDecimal.ZERO;
|
|
|
private Long rechargeCount = 0L;
|
|
|
private Long rechargeNum = 0L;
|
|
@@ -1778,7 +1800,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
@NoArgsConstructor
|
|
|
@AllArgsConstructor
|
|
|
@Builder
|
|
|
- public static class ShowRecharge{
|
|
|
+ public static class ShowRecharge {
|
|
|
private Long showRechargeCount;
|
|
|
|
|
|
private Long showRechargeUser;
|
|
@@ -1794,7 +1816,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
|
|
|
@NoArgsConstructor
|
|
|
@AllArgsConstructor
|
|
|
@Builder
|
|
|
- public static class AgentAccount{
|
|
|
+ public static class AgentAccount {
|
|
|
private String sourceSystem;
|
|
|
|
|
|
private Long accountId;
|