浏览代码

今日数据百分比调整

yumeng 5 年之前
父节点
当前提交
3c458b367c

+ 11 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/BytedanceReportMapper.java

@@ -52,6 +52,16 @@ public interface BytedanceReportMapper {
     JSONObject selectDayHourlyByHourAndDate(@Param("date") String date, @Param("statHour") String statHour);
 
     /**
+     * 根据日期 最大小时小时 查询信息
+     *
+     * @param date
+     * @param statHour
+     * @return
+     */
+    JSONObject selectSumDayHourlyByHourAndDate(@Param("date") String date, @Param("statHour") String statHour);
+
+
+    /**
      * 查询 七天汇总数据
      *
      * @param anotherDay
@@ -113,6 +123,7 @@ public interface BytedanceReportMapper {
 
     /**
      * 根据日期获取 分时详情数据
+     *
      * @param date
      * @return
      */

+ 19 - 6
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/BytedanceReportMapper.xml

@@ -8,7 +8,8 @@
          sum(charge) cost,
          sum(photo_show) photoShow,
          sum(photo_click) photoClick,
-         sum(aclick) aclick
+         sum(aclick) aclick,
+         max(stat_hour) maxHour
        from
         ctop_kuaishou_report_hourly_account
         where stat_date = #{date}
@@ -66,6 +67,18 @@
       and stat_hour = #{statHour}
     </select>
 
+    <select id="selectSumDayHourlyByHourAndDate" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick
+     from
+      ctop_kuaishou_report_hourly_account
+      where stat_date = #{date}
+      and stat_hour &lt;= #{statHour}
+    </select>
+
 
     <select id="selectDayDetailByDate" resultType="com.alibaba.fastjson.JSONObject">
       select
@@ -79,7 +92,7 @@
       where stat_date &lt;= #{startDate}
       and  stat_date &gt;= #{endDate}
       group by stat_date
-      order by stat_date desc
+      order by stat_date asc
     </select>
 
 
@@ -95,7 +108,7 @@
       where stat_date &lt;= #{startDate}
       and  stat_date &gt;= #{endDate}
       group by DATE_FORMAT(stat_date,'%Y-%m')
-      order by stat_date desc
+      order by stat_date asc
     </select>
 
     <select id="selectAllDayDetailByMonth" resultType="com.alibaba.fastjson.JSONObject">
@@ -108,7 +121,7 @@
      from
       ctop_kuaishou_report_daily_account
       group by DATE_FORMAT(stat_date,'%Y-%m')
-      order by stat_date desc
+      order by stat_date asc
     </select>
 
 
@@ -136,7 +149,7 @@
       ctop_kuaishou_report_daily_account
       where DATE_FORMAT(stat_date,'%Y-%m') = #{date}
       group by stat_date
-      order by stat_date desc
+      order by stat_date asc
     </select>
 
 
@@ -180,7 +193,7 @@
       ctop_kuaishou_report_hourly_account
       where stat_date = #{date}
       group by stat_hour
-      order by stat_hour desc
+      order by stat_hour asc
     </select>
 
 

+ 1 - 1
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportServiceImpl.java

@@ -205,7 +205,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             if (type == 1) { // 今日总消耗
                 accountJson = reportMapper.selectDayReport(nowDate);
                 if (!Check.isNull(accountJson)) {
-                    JSONObject yesterdayJson = reportMapper.selectDayReport(anotherDay);
+                    JSONObject yesterdayJson = reportMapper.selectSumDayHourlyByHourAndDate(anotherDay, accountJson.getString("maxHour"));
                     if (!Check.isNull(yesterdayJson)) {
                         BigDecimal cost = accountJson.getBigDecimal("cost"); // 今日消耗
                         BigDecimal yesterdayCost = yesterdayJson.getBigDecimal("cost");// 昨日消耗