wcc 1 år sedan
förälder
incheckning
da4b920f16

+ 15 - 5
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/AdsAccountRechargeRankingServiceImpl.java

@@ -8,7 +8,9 @@ import com.zanxiang.game.data.serve.pojo.entity.AdsAgentRechargeRanking;
 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 com.zanxiang.module.util.NumberUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.nutz.dao.Cnd;
 import org.nutz.dao.Dao;
@@ -21,6 +23,7 @@ import org.nutz.dao.util.cri.SimpleCriteria;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.RoundingMode;
 import java.util.List;
 
 @Slf4j
@@ -49,7 +52,7 @@ public class AdsAccountRechargeRankingServiceImpl implements IAdsAccountRecharge
                 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,
+                if(sum(view_count) > 0, sum(cost)/sum(view_count) * 1000, '0') 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,
@@ -97,10 +100,17 @@ public class AdsAccountRechargeRankingServiceImpl implements IAdsAccountRecharge
         dao.execute(sql);
 
         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);
+        if (CollectionUtils.isNotEmpty(result)) {
+            result.forEach(vo -> {
+                vo.setClickRate(NumberUtil.multiply100(vo.getClickRate()).setScale(2, RoundingMode.HALF_UP));
+                vo.setAvgAmount(vo.getAvgAmount().setScale(2, RoundingMode.HALF_UP));
+                vo.setRoi(NumberUtil.multiply100(vo.getRoi()).setScale(2, RoundingMode.HALF_UP));
+            });
+            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);
     }

+ 15 - 5
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/AdsAgentRechargeRankingServiceImpl.java

@@ -7,7 +7,9 @@ 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.NumberUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.nutz.dao.Cnd;
 import org.nutz.dao.Dao;
@@ -20,6 +22,8 @@ import org.nutz.dao.util.Daos;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.List;
 
 @Slf4j
@@ -48,7 +52,7 @@ public class AdsAgentRechargeRankingServiceImpl implements IAdsAgentRechargeRank
                 max(total_recharge_count) as total_recharge_count,
                 sum(total_cost) as total_cost,
                 max(total_recharge_amount) / max(total_recharge_count) as avg_amount,
-                if (sum(total_cost) > 0, max(total_recharge_amount) / sum(total_cost), 'xx') as roi
+                if (sum(total_cost) > 0, max(total_recharge_amount) / sum(total_cost), '0') as roi
                 from ads_agent_recharge_ranking
                 """;
         Criteria cri = Cnd.cri();
@@ -80,10 +84,16 @@ public class AdsAgentRechargeRankingServiceImpl implements IAdsAgentRechargeRank
         dao.execute(sql);
 
         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);
+        if (CollectionUtils.isNotEmpty(result)) {
+            result.forEach(vo -> {
+                vo.setAvgAmount(vo.getAvgAmount().setScale(2, RoundingMode.HALF_UP));
+                vo.setRoi(NumberUtil.multiply100(vo.getRoi()).setScale(2, RoundingMode.HALF_UP));
+            });
+            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);
     }