浏览代码

Merge branch 'test'

zhaoxian 2 年之前
父节点
当前提交
9b4f951ea7

+ 1 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/SupplyChainMapper.java

@@ -75,7 +75,7 @@ public interface SupplyChainMapper {
 
     JSONObject selectOrderInfo(@Param("promoterIds") List<Long> promoterIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
-    JSONObject selectOrderRate(@Param("promoterIds") List<Long> promoterIds, @Param("itemIds") List<Long> itemIds, @Param("statDate") String statDate, @Param("endDate") String endDate);
+    JSONObject selectOrderRate(@Param("promoterIds") List<Long> promoterIds, @Param("itemIds") List<Long> itemIds, @Param("statDate") Long statDate, @Param("endDate") Long endDate);
 
     List<JSONObject> getMonthOrderAmount(Map<String, Object> map);
 

+ 1 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/service/ISupplyChainService.java

@@ -98,7 +98,7 @@ public interface ISupplyChainService {
 
     JSONObject selectOrderInfo(List<Long> promoterIds, String startDate, String endDate);
 
-    JSONObject selectOrderRate(List<Long> promoterIds, List<Long> itemIds, String statDate, String endDate);
+    JSONObject selectOrderRate(List<Long> promoterIds, List<Long> itemIds, Long statDate, Long endDate);
 
     List<JSONObject> getMonthOrderAmount(Map<String, Object> map);
 

+ 57 - 29
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouItemCollectSamplesServiceImpl.java

@@ -433,19 +433,25 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
         data.put("orderAmount", order.getInteger("orderAmount"));//订单金额
         data.put("regimentalPromotionAmount", order.getInteger("regimentalPromotionAmount"));//预估服务费
         data.put("baseAmount", order.getInteger("baseAmount"));//累计货贷基数
+
+        Date date = new Date();
+        //当前小时
+        Integer hour = DateUtils.getNowHour() - 1;
         //当天
         String today = DateUtils.getNowDateStr();
-        Date date = new Date();
         //昨天
         String yesterday = DateUtils.getSubtractTime(date, 1);
         //上周的同一天(上个近七天的结束日期)
         String todayOfLastWeek = DateUtils.getSubtractTime(date, 7);
+
         //当天数据
-        JSONObject toData = supplyChainService.selectOrderRate(promoterIds, null, today, today);
+        JSONObject toData = getOrderRate(today, today, hour, promoterIds, null);
+
         //昨日数据
-        JSONObject yesData = supplyChainService.selectOrderRate(promoterIds, null, yesterday, yesterday);
+        JSONObject yesData = getOrderRate(yesterday, yesterday, hour, promoterIds, null);
+
         //上周当日数据
-        JSONObject weeklyDayData = supplyChainService.selectOrderRate(promoterIds, null, todayOfLastWeek, todayOfLastWeek);
+        JSONObject weeklyDayData = getOrderRate(todayOfLastWeek, todayOfLastWeek, hour, promoterIds, null);
 
         //日环比 (今天-昨天)/昨天*100%
         data.put("dateOrderRate", getOrderRateValue(toData, yesData));
@@ -460,32 +466,43 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
         if (startDate.equals(endDate) && startDate.equals(today)) {
             //当前近七天的开始日期
             String start = DateUtils.getSubtractTime(date, 6);
-            //上个近七天的开始日期
-            String LastStart = DateUtils.getSubtractTime(date, 13);
             //当前近七天的数据
-            inDayData = supplyChainService.selectOrderRate(promoterIds, null, start, today);
+            inDayData = getOrderRate(start, today, hour, promoterIds, null);
+            //上个近七天的开始日期
+            String lastStart = DateUtils.getSubtractTime(date, 13);
             //上个近七天的数据
-            lastDayData = supplyChainService.selectOrderRate(promoterIds, null, LastStart, todayOfLastWeek);
+            lastDayData = getOrderRate(lastStart, todayOfLastWeek, hour, promoterIds, null);
         } else if (startDate.equals(endDate) && !startDate.equals(today)) {
             // startDate 环比 startDate的前一天
-            inDayData = supplyChainService.selectOrderRate(promoterIds, null, startDate, startDate);
-            String lastDay = DateUtils.getSubtractTime(DateUtils.parseDate(startDate), 1);
+            inDayData = getOrderRate(startDate, startDate, 23, promoterIds, null);
             // startDate -1
-            lastDayData = supplyChainService.selectOrderRate(promoterIds, null, lastDay, lastDay);
+            String lastDay = DateUtils.getSubtractTime(DateUtils.parseDate(startDate), 1);
+            lastDayData = getOrderRate(lastDay, lastDay, 23, promoterIds, null);
+        } else if (!startDate.equals(endDate) && !endDate.equals(today)) {
+            // startDate 环比 startDate的前一天
+            inDayData = getOrderRate(startDate, endDate, 23, promoterIds, null);
+            int days = DateUtils.differentDaysByMillisecond(DateUtils.parseDate(startDate), DateUtils.parseDate(endDate)) + 1;
+            String lastStart = DateUtils.getSubtractTime(DateUtils.parseDate(startDate), days);
+            String lastEnd = DateUtils.getSubtractTime(DateUtils.parseDate(endDate), days);
+            lastDayData = getOrderRate(lastStart, lastEnd, 23, promoterIds, null);
         } else {
-            inDayData = supplyChainService.selectOrderRate(promoterIds, null, startDate, endDate);
+            inDayData = getOrderRate(startDate, endDate, hour, promoterIds, null);
             int days = DateUtils.differentDaysByMillisecond(DateUtils.parseDate(startDate), DateUtils.parseDate(endDate)) + 1;
             String lastStart = DateUtils.getSubtractTime(DateUtils.parseDate(startDate), days);
             String lastEnd = DateUtils.getSubtractTime(DateUtils.parseDate(endDate), days);
-            lastDayData = supplyChainService.selectOrderRate(promoterIds, null, lastStart, lastEnd);
+            lastDayData = getOrderRate(lastStart, lastEnd, hour, promoterIds, null);
         }
         //数据对比
         data.put("dataOrderRate", getOrderRateValue(inDayData, lastDayData));
         data.put("dataAmountRate", getAmountRateValue(inDayData, lastDayData));
-
         return data;
     }
 
+    private JSONObject getOrderRate(String startDate, String endDate, int hour, List<Long> promoterIds, List<Long> itemIds) {
+        Long startHourTemp = DateUtils.getStartLongTime(startDate); // startDate开始时间戳
+        Long endHourTemp = DateUtils.getNowEndHourTemp(endDate, hour); // endDate结束时间戳
+        return supplyChainService.selectOrderRate(promoterIds, itemIds, startHourTemp, endHourTemp);
+    }
 
     private BigDecimal getOrderRateValue(JSONObject toData, JSONObject yesData) {
         BigDecimal allNumber = yesData.getBigDecimal("allNumber");
@@ -521,20 +538,25 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
             data.put("orderAmount", order.getInteger("orderAmount"));//订单金额
             data.put("regimentalPromotionAmount", order.getInteger("regimentalPromotionAmount"));//预估服务费
             data.put("baseAmount", order.getInteger("baseAmount"));//累计货贷基数
+
+            Date date = new Date();
+            //当前小时
+            Integer hour = DateUtils.getNowHour() - 1;
             //当天
             String today = DateUtils.getNowDateStr();
-            Date date = new Date();
             //昨天
             String yesterday = DateUtils.getSubtractTime(date, 1);
             //上周的同一天(上个近七天的结束日期)
             String todayOfLastWeek = DateUtils.getSubtractTime(date, 7);
 
             //当天数据
-            JSONObject toData = supplyChainService.selectOrderRate(null, itemIds, today, today);
+            JSONObject toData = getOrderRate(today, today, hour, null, itemIds);
+
             //昨日数据
-            JSONObject yesData = supplyChainService.selectOrderRate(null, itemIds, yesterday, yesterday);
+            JSONObject yesData = getOrderRate(yesterday, yesterday, hour, null, itemIds);
+
             //上周当日数据
-            JSONObject weeklyDayData = supplyChainService.selectOrderRate(null, itemIds, todayOfLastWeek, todayOfLastWeek);
+            JSONObject weeklyDayData = getOrderRate(todayOfLastWeek, todayOfLastWeek, hour, null, itemIds);
 
             //日环比 (今天-昨天)/昨天*100%
             data.put("dateOrderRate", getOrderRateValue(toData, yesData));
@@ -547,26 +569,32 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
             JSONObject inDayData = null;
             JSONObject lastDayData = null;
             if (startDate.equals(endDate) && startDate.equals(today)) {
-                //当前近七天的开始日期
-                String start = DateUtils.getSubtractTime(date, 6);
-                //上个近七天的开始日期
-                String LastStart = DateUtils.getSubtractTime(date, 13);
+                String start = DateUtils.getSubtractTime(date, 6); //当前近七天的开始日期
                 //当前近七天的数据
-                inDayData = supplyChainService.selectOrderRate(null, itemIds, start, today);
+                inDayData = getOrderRate(start, today, hour, null, itemIds);
+
+                String lastStart = DateUtils.getSubtractTime(date, 13); //上个近七天的开始日期
                 //上个近七天的数据
-                lastDayData = supplyChainService.selectOrderRate(null, itemIds, LastStart, todayOfLastWeek);
+                lastDayData = getOrderRate(lastStart, todayOfLastWeek, hour, null, itemIds);
             } else if (startDate.equals(endDate) && !startDate.equals(today)) {
                 // startDate 环比 startDate的前一天
-                inDayData = supplyChainService.selectOrderRate(null, itemIds, startDate, startDate);
-                String lastDay = DateUtils.getSubtractTime(DateUtils.parseDate(startDate), 1);
+                inDayData = getOrderRate(startDate, startDate, 23, null, itemIds);
                 // startDate -1
-                lastDayData = supplyChainService.selectOrderRate(null, itemIds, lastDay, lastDay);
+                String lastDay = DateUtils.getSubtractTime(DateUtils.parseDate(startDate), 1);
+                lastDayData = getOrderRate(lastDay, lastDay, 23, null, itemIds);
+            } else if (!startDate.equals(endDate) && !endDate.equals(today)) {
+                // startDate 环比 startDate的前一天
+                inDayData = getOrderRate(startDate, endDate, 23, null, itemIds);
+                int days = DateUtils.differentDaysByMillisecond(DateUtils.parseDate(startDate), DateUtils.parseDate(endDate)) + 1;
+                String lastStart = DateUtils.getSubtractTime(DateUtils.parseDate(startDate), days);
+                String lastEnd = DateUtils.getSubtractTime(DateUtils.parseDate(endDate), days);
+                lastDayData = getOrderRate(lastStart, lastEnd, 23, null, itemIds);
             } else {
-                inDayData = supplyChainService.selectOrderRate(null, itemIds, startDate, endDate);
+                inDayData = getOrderRate(startDate, endDate, hour, null, itemIds);
                 int days = DateUtils.differentDaysByMillisecond(DateUtils.parseDate(startDate), DateUtils.parseDate(endDate)) + 1;
                 String lastStart = DateUtils.getSubtractTime(DateUtils.parseDate(startDate), days);
                 String lastEnd = DateUtils.getSubtractTime(DateUtils.parseDate(endDate), days);
-                lastDayData = supplyChainService.selectOrderRate(null, itemIds, lastStart, lastEnd);
+                lastDayData = getOrderRate(lastStart, lastEnd, hour, null, itemIds);
             }
             //数据对比
             data.put("dataOrderRate", getOrderRateValue(inDayData, lastDayData));

+ 1 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/SupplyChainServiceImpl.java

@@ -187,7 +187,7 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
     }
 
     @Override
-    public JSONObject selectOrderRate(List<Long> promoterIds, List<Long> itemIds, String statDate, String endDate) {
+    public JSONObject selectOrderRate(List<Long> promoterIds, List<Long> itemIds, Long statDate, Long endDate) {
         return supplyChainMapper.selectOrderRate(promoterIds, itemIds, statDate, endDate);
     }
 

+ 2 - 2
ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml

@@ -1109,8 +1109,8 @@
         END
         ),0) AS 'orderAmount'
         FROM kuaishou_supply_chain
-        WHERE stat_date >= #{statDate}
-        AND stat_date &lt;= #{endDate}
+        WHERE order_create_time >= #{statDate}
+        AND order_create_time &lt;= #{endDate}
         <if test='promoterIds != null and promoterIds.size() > 0'>
             AND promoter_id in
             <foreach collection="promoterIds" item="item" separator=","