wcc hai 1 ano
pai
achega
2674381d6e

+ 33 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/controller/AdsAgentRechargeRankingController.java

@@ -1,4 +1,37 @@
 package com.zanxiang.game.data.serve.controller;
 
+import com.zanxiang.erp.security.annotation.PreAuthorize;
+import com.zanxiang.game.data.serve.pojo.dto.AdsAgentRechargeRankingListDTO;
+import com.zanxiang.game.data.serve.pojo.vo.AdsAgentRechargeRankingVO;
+import com.zanxiang.game.data.serve.service.IAdsAgentRechargeRankingService;
+import com.zanxiang.game.data.serve.utils.Page;
+import com.zanxiang.module.util.pojo.ResultVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@Api(tags = {"渠道充值排行榜"})
+@RestController
+@RequestMapping("/agentRechargeRanking")
 public class AdsAgentRechargeRankingController {
+
+    @Autowired
+    private IAdsAgentRechargeRankingService adsAgentRechargeRankingService;
+
+    @PreAuthorize(permissionKey = "gameData:agentRechargeRanking:list")
+    @ApiOperation(value = "推广渠道充值排行榜")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = AdsAgentRechargeRankingVO.class)})
+    @PostMapping("/list")
+    public ResultVO<Page<AdsAgentRechargeRankingVO>> list(@Validated @RequestBody AdsAgentRechargeRankingListDTO dto) {
+        return ResultVO.ok(adsAgentRechargeRankingService.listOfPage(dto));
+    }
 }

+ 26 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/dto/AdsAccountRechargeRankingListDTO.java

@@ -0,0 +1,26 @@
+package com.zanxiang.game.data.serve.pojo.dto;
+
+import com.zanxiang.game.data.serve.pojo.base.BasePage;
+import lombok.Data;
+
+import java.time.LocalDate;
+
+@Data
+public class AdsAccountRechargeRankingListDTO  extends BasePage {
+
+    private LocalDate beginDay;
+
+    private LocalDate endDay;
+
+    private String accountId;
+
+    private String pitcherId;
+
+    private String type;
+
+    private String gameId;
+
+    private String sortFiled;
+
+    private String sortType;
+}

+ 8 - 2
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/dto/AdsAgentRechargeRankingListDTO.java

@@ -8,11 +8,17 @@ import java.time.LocalDate;
 @Data
 public class AdsAgentRechargeRankingListDTO extends BasePage {
 
-    private LocalDate beginTime;
+    private LocalDate beginDay;
 
-    private LocalDate endTime;
+    private LocalDate endDay;
 
     private String agentId;
 
     private String pitcherId;
+
+    private String type;
+
+    private String sortFiled;
+
+    private String sortType;
 }

+ 6 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/entity/AdsAccountRechargeRanking.java

@@ -52,6 +52,12 @@ public class AdsAccountRechargeRanking implements Serializable {
     @Column
     private String pitcher;
 
+    @Column
+    private String pitcherId;
+
+    @Column
+    private String gameId;
+
     /**
      * 推广游戏名称
      */

+ 91 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/AdsAccountRechargeRankingVO.java

@@ -0,0 +1,91 @@
+package com.zanxiang.game.data.serve.pojo.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class AdsAccountRechargeRankingVO {
+
+    @ApiModelProperty(notes = "序号")
+    private Integer index;
+
+    @ApiModelProperty(notes = "推广账号")
+    private Long accountId;
+
+    @ApiModelProperty(notes = "推广账号媒体")
+    private String type;
+
+    @ApiModelProperty(notes = "投手名称")
+    private String pitcher;
+
+    @ApiModelProperty(notes = "游戏 id")
+    private String gameId;
+
+    @ApiModelProperty(notes = "推广游戏名称")
+    private String gameName;
+
+    @ApiModelProperty(notes = "推广游戏类型")
+    private String gameClassify;
+
+    @ApiModelProperty(notes = "推广游戏CP名称")
+    private String gameCp;
+
+    @ApiModelProperty(notes = "消耗")
+    private BigDecimal cost;
+
+    @ApiModelProperty(notes = "推广广告数量")
+    private Long adCount;
+
+    @ApiModelProperty(notes = "曝光数量")
+    private Long viewCount;
+
+    @ApiModelProperty(notes = "点击数量")
+    private Long clickCount;
+
+    @ApiModelProperty(notes = "点击率")
+    private BigDecimal clickRate;
+
+    @ApiModelProperty(notes = "千次曝光成本")
+    private BigDecimal thousandDisplayPrice;
+
+    @ApiModelProperty(notes = "注册人数")
+    private Long regUserCnt;
+
+    @ApiModelProperty(notes = "注册成本")
+    private BigDecimal regCost;
+
+    @ApiModelProperty(notes = "首日创角人数")
+    private Long firstRole;
+
+    @ApiModelProperty(notes = "累计创角人数")
+    private Long totalRole;
+
+    @ApiModelProperty(notes = "首日充值金额")
+    private BigDecimal firstAmount;
+
+    @ApiModelProperty(notes = "首日充值人数")
+    private Long firstAmountUser;
+
+    @ApiModelProperty(notes = "首日充值次数")
+    private Long firstAmountCount;
+
+    @ApiModelProperty(notes = "累计充值金额")
+    private BigDecimal totalAmount;
+
+    @ApiModelProperty(notes = "累计充值人数")
+    private Long totalAmountUser;
+
+    @ApiModelProperty(notes = "累计充值次数")
+    private Long totalAmountCount;
+
+    @ApiModelProperty(notes = "首日ROI")
+    private BigDecimal firstRoi;
+
+    @ApiModelProperty(notes = "平均单价")
+    private BigDecimal avgAmount;
+
+    @ApiModelProperty(notes = "回本率")
+    private BigDecimal roi;
+}

+ 14 - 54
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/AdsAgentRechargeRankingVO.java

@@ -2,88 +2,48 @@ package com.zanxiang.game.data.serve.pojo.vo;
 
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
-import org.nutz.dao.entity.annotation.Column;
 
 import java.math.BigDecimal;
-import java.time.LocalDate;
 
 @Data
 public class AdsAgentRechargeRankingVO {
 
-    /**
-     * 日期(充值时间)
-     */
-    @ApiModelProperty(notes = "日期(充值时间)")
-    private LocalDate dt;
+    @ApiModelProperty(notes = "序号")
+    private Integer index;
 
-    /**
-     * 推广渠道账号
-     */
+    @ApiModelProperty(notes = "推广渠道账号")
     private Long agentId;
 
-    /**
-     * 推广渠道名称
-     */
-    @Column
+    @ApiModelProperty(notes = "推广渠道名称")
     private String agentName;
 
-    /**
-     * 投手
-     */
-    @Column
+    @ApiModelProperty(notes = "投手")
     private String pitcher;
 
-    /**
-     * 推广媒体
-     */
-    @Column
+    @ApiModelProperty(notes = "推广媒体")
     private String type;
 
-    /**
-     * 当天充值金额
-     */
-    @Column
+    @ApiModelProperty(notes = "当天充值金额")
     private BigDecimal todayAmount;
 
-    /**
-     * 累计充值今额
-     */
-    @Column
+    @ApiModelProperty(notes = "累计充值今额")
     private BigDecimal totalAmount;
 
-    /**
-     * 累计充值人数
-     */
-    @Column
+    @ApiModelProperty(notes = "累计充值人数")
     private Long totalRechargeUserCount;
 
-    /**
-     * 累计充值次数
-     */
-    @Column
+    @ApiModelProperty(notes = "累计充值次数")
     private Long totalRechargeCount;
 
-    /**
-     * 平均单价
-     */
-    @Column
+    @ApiModelProperty(notes = "平均单价")
     private BigDecimal avgAmount;
 
-    /**
-     * 注册人数
-     */
-    @Column
+    @ApiModelProperty(notes = "注册人数")
     private Long regUserCount;
 
-    /**
-     * 累计消耗
-     */
-    @Column
+    @ApiModelProperty(notes = "累计消耗")
     private BigDecimal totalCost;
 
-    /**
-     * 回本率
-     */
-    @Column
+    @ApiModelProperty(notes = "回本率")
     private BigDecimal roi;
 }

+ 4 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/IAdsAccountRechargeRankingService.java

@@ -0,0 +1,4 @@
+package com.zanxiang.game.data.serve.service;
+
+public interface IAdsAccountRechargeRankingService {
+}

+ 6 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/IAdsAgentRechargeRankingService.java

@@ -1,4 +1,10 @@
 package com.zanxiang.game.data.serve.service;
 
+import com.zanxiang.game.data.serve.pojo.dto.AdsAgentRechargeRankingListDTO;
+import com.zanxiang.game.data.serve.pojo.vo.AdsAgentRechargeRankingVO;
+import com.zanxiang.game.data.serve.utils.Page;
+
 public interface IAdsAgentRechargeRankingService {
+
+    Page<AdsAgentRechargeRankingVO> listOfPage(AdsAgentRechargeRankingListDTO dto);
 }

+ 98 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/AdsAccountRechargeRankingServiceImpl.java

@@ -0,0 +1,98 @@
+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.AdsAccountRechargeRankingListDTO;
+import com.zanxiang.game.data.serve.pojo.entity.AdsAccountRechargeRanking;
+import com.zanxiang.game.data.serve.pojo.vo.AdsAccountRechargeRankingVO;
+import com.zanxiang.game.data.serve.service.IAdsAccountRechargeRankingService;
+import com.zanxiang.game.data.serve.utils.Page;
+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.Sqls;
+import org.nutz.dao.entity.Entity;
+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.stereotype.Service;
+
+import java.util.List;
+
+@Slf4j
+@Service
+public class AdsAccountRechargeRankingServiceImpl implements IAdsAccountRechargeRankingService {
+
+    @Autowired
+    private Dao dao;
+
+    public Page<AdsAccountRechargeRankingVO> listOfPage(AdsAccountRechargeRankingListDTO dto) {
+        if (StringUtils.isBlank(dto.getPitcherId()) && !SecurityUtil.isManager()) {
+            dto.setPitcherId(SecurityUtil.getUserId().toString());
+        }
+        Pager pager = dto.toPage();
+        String sqlStr = """
+                select account_id, pitcher_id, max(pitcher) as pitcher, `type`, game_id, max(game_name), max(game_classify) as game_classify , max(game_cp) as game_cp,
+                sum(cost) as cost,
+                sum(ad_count) as ad_count,
+                sum(view_count) as view_count,
+                sum(click_count) as click_count,
+                sum(click_count) / sum(view_count) as click_rate,
+                if(sum(view_count) > 0, sum(cost)/sum(view_count) * 1000, '--') as thousand_display_price,
+                sum(reg_user_cnt) as reg_user_cnt,
+                sum(cost) / sum(reg_user_cnt) as reg_cost,
+                sum(first_role) as first_role,
+                sum(total_role) as total_role,
+                sum(first_amount) as first_amount,
+                sum(first_amount_user) as first_amount_user,
+                sum(first_amount_count) as first_amount_count,
+                sum(total_amount) as total_amount,
+                sum(total_amount_user) as total_amount_user,
+                sum(total_amount_count) as total_amount_count,
+                sum(cost) / sum(first_amount) as first_roi,
+                sum(total_amount) / sum(total_amount_count) as avg_amount,
+                sum(total_amount) / sum(cost) as roi
+                from ads_account_recharge_ranking
+                """;
+        SimpleCriteria cri = Cnd.cri();
+        if (null != dto.getBeginDay() && null != dto.getEndDay()) {
+            cri.where().and(AdsAccountRechargeRanking::getDt, ">=", dto.getBeginDay()).and(AdsAccountRechargeRanking::getDt, "<=", dto.getEndDay());
+        }
+        if (StringUtils.isNotBlank(dto.getPitcherId())) {
+            cri.where().and(AdsAccountRechargeRanking::getPitcherId, "=", dto.getPitcherId());
+        }
+        if(StringUtils.isNotBlank(dto.getAccountId())) {
+            cri.where().and(AdsAccountRechargeRanking::getAccountId, "=", dto.getAccountId());
+        }
+        if(StringUtils.isNotBlank(dto.getGameId())) {
+            cri.where().and(AdsAccountRechargeRanking::getGameId, "=", dto.getGameId());
+        }
+        if (StringUtils.isNotBlank(dto.getType())) {
+            cri.where().and(AdsAccountRechargeRanking::getType, "=", dto.getType());
+        }
+        cri.groupBy(AdsAccountRechargeRanking::getAccountId, AdsAccountRechargeRanking::getPitcherId, AdsAccountRechargeRanking::getType, AdsAccountRechargeRanking::getGameId);
+        cri.orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
+        Sql sql = Sqls.queryEntity(sqlStr + "$condition");
+        sql.setPager(pager);
+
+        Entity<AdsAccountRechargeRankingVO> entity = dao.getEntity(AdsAccountRechargeRankingVO.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());
+
+        List<AdsAccountRechargeRankingVO> result = sql.getList(AdsAccountRechargeRankingVO.class);
+        int beginIndex = (dto.getPageNum() - 1) * dto.getPageSize();
+        int size = result.size();
+        while (--size >= 0) {
+            result.get(size).setIndex(beginIndex + size);
+        }
+        return new Page<>(result, pager);
+    }
+}

+ 57 - 11
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/AdsAgentRechargeRankingServiceImpl.java

@@ -1,17 +1,27 @@
 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.entity.AdsAgentRechargeRanking;
 import com.zanxiang.game.data.serve.pojo.vo.AdsAgentRechargeRankingVO;
 import com.zanxiang.game.data.serve.service.IAdsAgentRechargeRankingService;
 import com.zanxiang.game.data.serve.utils.Page;
-import com.zanxiang.module.util.bean.BeanUtil;
 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.Sqls;
+import org.nutz.dao.entity.Entity;
 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.stereotype.Service;
 
+import java.util.List;
+
 @Slf4j
 @Service
 public class AdsAgentRechargeRankingServiceImpl implements IAdsAgentRechargeRankingService {
@@ -19,19 +29,55 @@ public class AdsAgentRechargeRankingServiceImpl implements IAdsAgentRechargeRank
     @Autowired
     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();
-        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);
     }
 }