ソースを参照

feat: 首页-统计新增订单和收款统计

xdd 1 ヶ月 前
コミット
24d2fff04d

+ 22 - 0
fs-admin/src/main/java/com/fs/api/controller/IndexStatisticsController.java

@@ -172,4 +172,26 @@ public class IndexStatisticsController {
 
         return R.ok().put("data", authorizationInfoDTO);
     }
+
+
+    /**
+     * 当月订单数统计
+     * @return
+     */
+    @GetMapping("/thisMonthOrderCount")
+    public R thisMonthOrderCount(){
+        R result = redisCache.getCacheObject(StatisticsRedisConstant.THIS_MONTH_ORDER_COUNT);
+        return result;
+    }
+
+    /**
+     * 当月收益统计
+     * @return
+     */
+
+    @GetMapping("/thisMonthRecvCount")
+    public R thisMonthRecvCount(){
+        R result = redisCache.getCacheObject(StatisticsRedisConstant.THIS_MONTH_RECV_COUNT);
+        return result;
+    }
 }

+ 9 - 0
fs-service-system/src/main/java/com/fs/statis/StatisticsRedisConstant.java

@@ -53,4 +53,13 @@ public class StatisticsRedisConstant {
      */
     public static final String CHARTS_REWARD_MONEY_TREND = "charts:reward:money:trend";
 
+    /**
+     * 本月订单数统计
+     */
+    public static final String THIS_MONTH_ORDER_COUNT = "charts:this:month:order:count";
+
+    /**
+     * 本月收款数统计
+     */
+    public static final String THIS_MONTH_RECV_COUNT = "charts:this:month:recv:count";
 }

+ 11 - 0
fs-service-system/src/main/java/com/fs/statis/service/IStatisticsService.java

@@ -1,5 +1,6 @@
 package com.fs.statis.service;
 
+import com.fs.common.core.domain.R;
 import com.fs.statis.dto.*;
 
 import java.util.List;
@@ -99,4 +100,14 @@ public interface IStatisticsService {
      * @return TrafficLogDTO
      */
     TrafficLogDTO getTrafficLog();
+
+    /**
+     * 本月订单数
+     */
+    void thisMonthOrderCount();
+
+    /**
+     * 本月收款数
+     */
+    void thisMonthRecvCount();
 }

+ 45 - 0
fs-service-system/src/main/java/com/fs/statis/service/impl/StatisticsServiceImpl.java

@@ -1,6 +1,9 @@
 package com.fs.statis.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
+import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
+import com.fs.common.utils.TimeUtils;
 import com.fs.company.cache.ICompanyCacheService;
 import com.fs.course.mapper.FsCourseTrafficLogMapper;
 import com.fs.statis.StatisticsRedisConstant;
@@ -25,7 +28,9 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.TemporalAdjusters;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import static com.fs.statis.StatisticsRedisConstant.*;
 
@@ -788,4 +793,44 @@ public class StatisticsServiceImpl implements IStatisticsService {
         trafficLogDTO.setThisMonth(monthTrafficLog);
         return trafficLogDTO;
     }
+
+    @Override
+    public void thisMonthOrderCount() {
+        Long[] users=new Long[0];
+        TimeUtils.TimeEntity timeEntity=TimeUtils.parseTime("5",null,null);
+        timeEntity.setUserIds(users);
+        Integer cycleNum = timeEntity.getCycleNum();
+        Integer beginTime = timeEntity.getBeginTime();
+        List<Integer> timeList = new ArrayList<>();
+        for (int i = 1; i <= cycleNum; i++) {
+            timeList.add(beginTime);
+            beginTime = TimeUtils.formatTime(beginTime);
+        }
+        List<JSONObject> jsonObjectList = storeOrderService.selectFsStoreOrderCounts(timeEntity.toMap());
+        List<String> dates = jsonObjectList.stream().map(jsonObject -> jsonObject.getString("type")).collect(Collectors.toList());
+        List<Integer> orderCount = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("orderCount")).collect(Collectors.toList());
+        List<Integer> payPrice = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("payPrice")).collect(Collectors.toList());
+        R result = R.ok().put("dates", dates).put("orderCount", orderCount).put("payPrice", payPrice);
+        redisCache.setCacheObject(THIS_MONTH_ORDER_COUNT,result);
+    }
+
+    @Override
+    public void thisMonthRecvCount() {
+        Long[] users=new Long[0];
+        TimeUtils.TimeEntity timeEntity=TimeUtils.parseTime("5",null,null);
+        timeEntity.setUserIds(users);
+        Integer cycleNum = timeEntity.getCycleNum();
+        Integer beginTime = timeEntity.getBeginTime();
+        List<Integer> timeList = new ArrayList<>();
+        for (int i = 1; i <= cycleNum; i++) {
+            timeList.add(beginTime);
+            beginTime = TimeUtils.formatTime(beginTime);
+        }
+        List<JSONObject> jsonObjectList = paymentService.selectFsStorePaymentCounts(timeEntity.toMap());
+        List<String> dates = jsonObjectList.stream().map(jsonObject -> jsonObject.getString("type")).collect(Collectors.toList());
+        List<Integer> orderCount = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("orderCount")).collect(Collectors.toList());
+        List<Float> payMoney = jsonObjectList.stream().map(jsonObject -> jsonObject.getFloatValue("payMoney")).collect(Collectors.toList());
+        R result = R.ok().put("dates", dates).put("orderCount", orderCount).put("payMoney", payMoney);
+        redisCache.setCacheObject(THIS_MONTH_RECV_COUNT,result);
+    }
 }

+ 1 - 1
fs-service-system/src/main/resources/mapper/store/FsStorePaymentMapper.xml

@@ -163,7 +163,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM
         fs_store_payment  AS o
         WHERE
-        o.status=1 and
+        o.status=1 and o.business_type=1 and
         (DATE_FORMAT(o.create_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
         <if test="userIds != null and userIds.length>0">
             AND o.company_user_id IN