|
@@ -1,17 +1,27 @@
|
|
package com.zanxiang.game.data.serve.service.impl;
|
|
package com.zanxiang.game.data.serve.service.impl;
|
|
|
|
|
|
|
|
+import com.google.common.base.CaseFormat;
|
|
|
|
+import com.zanxiang.erp.security.util.SecurityUtil;
|
|
import com.zanxiang.game.data.serve.pojo.dto.AdsAgentRechargeRankingListDTO;
|
|
import com.zanxiang.game.data.serve.pojo.dto.AdsAgentRechargeRankingListDTO;
|
|
import com.zanxiang.game.data.serve.pojo.entity.AdsAgentRechargeRanking;
|
|
import com.zanxiang.game.data.serve.pojo.entity.AdsAgentRechargeRanking;
|
|
import com.zanxiang.game.data.serve.pojo.vo.AdsAgentRechargeRankingVO;
|
|
import com.zanxiang.game.data.serve.pojo.vo.AdsAgentRechargeRankingVO;
|
|
import com.zanxiang.game.data.serve.service.IAdsAgentRechargeRankingService;
|
|
import com.zanxiang.game.data.serve.service.IAdsAgentRechargeRankingService;
|
|
import com.zanxiang.game.data.serve.utils.Page;
|
|
import com.zanxiang.game.data.serve.utils.Page;
|
|
-import com.zanxiang.module.util.bean.BeanUtil;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.nutz.dao.Cnd;
|
|
import org.nutz.dao.Dao;
|
|
import org.nutz.dao.Dao;
|
|
|
|
+import org.nutz.dao.Sqls;
|
|
|
|
+import org.nutz.dao.entity.Entity;
|
|
import org.nutz.dao.pager.Pager;
|
|
import org.nutz.dao.pager.Pager;
|
|
|
|
+import org.nutz.dao.sql.Sql;
|
|
|
|
+import org.nutz.dao.util.Daos;
|
|
|
|
+import org.nutz.dao.util.cri.SimpleCriteria;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
public class AdsAgentRechargeRankingServiceImpl implements IAdsAgentRechargeRankingService {
|
|
public class AdsAgentRechargeRankingServiceImpl implements IAdsAgentRechargeRankingService {
|
|
@@ -19,19 +29,55 @@ public class AdsAgentRechargeRankingServiceImpl implements IAdsAgentRechargeRank
|
|
@Autowired
|
|
@Autowired
|
|
private Dao dao;
|
|
private Dao dao;
|
|
|
|
|
|
- private Page<AdsAgentRechargeRankingVO> list(AdsAgentRechargeRankingListDTO dto) {
|
|
|
|
|
|
+ public Page<AdsAgentRechargeRankingVO> listOfPage(AdsAgentRechargeRankingListDTO dto) {
|
|
|
|
+ if (StringUtils.isBlank(dto.getPitcherId()) && !SecurityUtil.isManager()) {
|
|
|
|
+ dto.setPitcherId(SecurityUtil.getUserId().toString());
|
|
|
|
+ }
|
|
Pager pager = dto.toPage();
|
|
Pager pager = dto.toPage();
|
|
- String sql = """
|
|
|
|
- select * from ads_agent_recharge_ranking
|
|
|
|
- group by
|
|
|
|
|
|
+ String sqlStr = """
|
|
|
|
+ select agent_id, max(agent_name) as agent_name, pitcher_id, max(pitcher) as pitcher, `type`,
|
|
|
|
+ sum(today_amount) as today_amount,
|
|
|
|
+ sum(new_user_total_recharge_amount) as new_user_total_recharge_amount,
|
|
|
|
+ sum(new_user_total_recharge_num) as new_user_total_recharge_num,
|
|
|
|
+ sum(new_user_total_recharge_count) as new_user_total_recharge_count,
|
|
|
|
+ sum(total_cost) as total_cost,
|
|
|
|
+ sum(new_user_total_recharge_amount) / sum(new_user_total_recharge_count) as avg_amount,
|
|
|
|
+ if (sum(total_cost) > 0, sum(new_user_total_recharge_amount) / sum(total_cost), 'xx') as roi
|
|
|
|
+ from ads_agent_recharge_ranking
|
|
""";
|
|
""";
|
|
- return null;
|
|
|
|
- }
|
|
|
|
|
|
+ SimpleCriteria cri = Cnd.cri();
|
|
|
|
+ if (null != dto.getBeginDay() && null != dto.getEndDay()) {
|
|
|
|
+ cri.where().and(AdsAgentRechargeRanking::getDt, ">=", dto.getBeginDay()).and(AdsAgentRechargeRanking::getDt, "<=", dto.getEndDay());
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getAgentId())) {
|
|
|
|
+ cri.where().and(AdsAgentRechargeRanking::getAgentId, "=", dto.getAgentId());
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getPitcherId())) {
|
|
|
|
+ cri.where().and(AdsAgentRechargeRanking::getPitcherId, "=", dto.getPitcherId());
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getType())) {
|
|
|
|
+ cri.where().and(AdsAgentRechargeRanking::getType, "=", dto.getType());
|
|
|
|
+ }
|
|
|
|
+ cri.groupBy(AdsAgentRechargeRanking::getAgentId, AdsAgentRechargeRanking::getPitcherId, AdsAgentRechargeRanking::getType);
|
|
|
|
+ cri.orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
|
|
|
|
+ Sql sql = Sqls.queryEntity(sqlStr + "$condition");
|
|
|
|
+ sql.setPager(pager);
|
|
|
|
+
|
|
|
|
+ Entity<AdsAgentRechargeRankingVO> entity = dao.getEntity(AdsAgentRechargeRankingVO.class);
|
|
|
|
+ sql.setEntity(entity).setCondition(cri);
|
|
|
|
+ dao.execute(sql);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Sql pagerSql = Sqls.queryEntity("select count(*) from ads_agent_recharge_ranking " + "$condition");
|
|
|
|
+ pagerSql.setCondition(cri);
|
|
|
|
+ pager.setRecordCount(((Long) Daos.queryCount(dao, pagerSql)).intValue());
|
|
|
|
|
|
- private AdsAgentRechargeRankingVO toVO(AdsAgentRechargeRanking agentRechargeRanking) {
|
|
|
|
- if (agentRechargeRanking == null) {
|
|
|
|
- return null;
|
|
|
|
|
|
+ List<AdsAgentRechargeRankingVO> result = sql.getList(AdsAgentRechargeRankingVO.class);
|
|
|
|
+ int beginIndex = (dto.getPageNum() - 1) * dto.getPageSize();
|
|
|
|
+ int size = result.size();
|
|
|
|
+ while (--size >= 0) {
|
|
|
|
+ result.get(size).setIndex(beginIndex + size);
|
|
}
|
|
}
|
|
- return BeanUtil.copy(agentRechargeRanking, AdsAgentRechargeRankingVO.class);
|
|
|
|
|
|
+ return new Page<>(result, pager);
|
|
}
|
|
}
|
|
}
|
|
}
|