Browse Source

添加渠道接口

tianyun 3 years ago
parent
commit
5bb1f2ea29

+ 10 - 0
book-server/src/main/java/com/book/server/controller/SunDataController.java

@@ -446,6 +446,16 @@ public class SunDataController extends BaseController {
         return Result.success(sunDataService.updateChannelName(channelId,bookName,staticDate));
     }
 
+    /**
+     * 回收统计-更新渠道推广书籍
+     *
+     * @return {@link Result}
+     */
+    @GetMapping("/getAllChannel")
+    public Result getAllChannel() {
+        return Result.success(sunDataService.getAllChannel());
+    }
+
     public static void main(String[] args) {
         System.out.println(UUID.randomUUID().toString());
     }

+ 2 - 0
book-server/src/main/java/com/book/server/service/SunDataService.java

@@ -96,4 +96,6 @@ public interface SunDataService {
     Map getIncomeByDayChannel(int page, int size, String channelId);
 
     Boolean updateChannelName(String channelId, String bookName, String staticDate);
+
+    List<SunChannel> getAllChannel();
 }

+ 12 - 1
book-server/src/main/java/com/book/server/service/impl/SunDataServiceImpl.java

@@ -1,5 +1,6 @@
 package com.book.server.service.impl;
 
+import java.text.DecimalFormat;
 import java.util.Date;
 
 import com.book.dao.VO.SunVO;
@@ -760,13 +761,18 @@ public class SunDataServiceImpl implements SunDataService {
     public Map getIncomeByDay(int page, int size) {
         HashMap<String, Object> resMap = new HashMap<>();
         SunStaticIncomeExample example = SunStaticIncomeExample.newAndCreateCriteria().example();
-        //总共多少条
+        // 总共多少条
         long l = sunStaticIncomeMapper.countByExample(example);
         resMap.put("total", l);
         // 排序查询指定页
         example.orderBy(SunStaticIncome.Column.staticDate.desc());
         example.page(page, size);
         List<SunStaticIncome> sunStaticIncomes = sunStaticIncomeMapper.selectByExample(example);
+        //保留小数点
+        //for (SunStaticIncome sunStaticIncome : sunStaticIncomes) {
+        //    DecimalFormat df = new DecimalFormat("#.00");//此为保留2位小数
+        //    sunStaticIncome.setAllRecharge(df.format(sunStaticIncome.getAllRecharge()));
+        //}
 
         //查询另一张表对应的前 60 天的数据
         List<String> collect = sunStaticIncomes.stream().map(SunStaticIncome::getStaticDate).collect(Collectors.toList());
@@ -828,6 +834,11 @@ public class SunDataServiceImpl implements SunDataService {
         return i > 0;
     }
 
+    @Override
+    public List<SunChannel> getAllChannel() {
+        return sunChannelMapper.selectByExample(SunChannelExample.newAndCreateCriteria().example());
+    }
+
     private SunStaticUserDay getSunUserByDate(String startDate, String endDate) {
         int i = sun2Mapper.selectCountUserByDay(startDate, endDate);
         if (i <= 0) {