瀏覽代碼

快手賬戶报表-线形图bug修复

zhaoxian 2 年之前
父節點
當前提交
0c78164ff9

+ 27 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaiShouAccountReportServiceImpl.java

@@ -73,6 +73,7 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
             }
             List<JSONObject> afterDis = this.countDiscountCost(mediaId, discount, after);
             List<JSONObject> beforeDis = this.countDiscountCost(mediaId, discount, before);
+            completionTime(beforeDis);
             result = LinkUtils.getCompareDate(beforeDis, afterDis, "statHour");
         } else {
             List<JSONObject> after;
@@ -181,6 +182,32 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
         return result;
     }
 
+    /**
+     * 补全时辰
+     */
+    private void completionTime(List<JSONObject> dataList) {
+        List<Integer> newDayList = new ArrayList<>();
+        for (JSONObject data : dataList) {
+            newDayList.add(data.getInteger("statHour"));
+        }
+        List<Integer> dayList = new ArrayList<>();
+        for (int i = 0; i < 23; i++) {
+            dayList.add(i);
+        }
+        for (Integer hour : dayList) {
+            if (!newDayList.contains(hour)) {
+                JSONObject obj = new JSONObject();
+                obj.put("statHour", hour);
+                obj.put("cost", 0);
+                obj.put("photoShow", 0);
+                obj.put("photoClick", 0);
+                obj.put("aClick", 0);
+                obj.put("discountCost", 0);
+                dataList.add(obj);
+            }
+        }
+    }
+
     //计算折后消耗
     private List<JSONObject> countDiscountCost(String mediaId, BigDecimal discount, List<JSONObject> data) {
         if (data.isEmpty()) {