yumeng 1 hafta önce
ebeveyn
işleme
b2db6c69f3

+ 1 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/MaterialStareMapper.java

@@ -77,6 +77,7 @@ public interface MaterialStareMapper {
     JSONObject getAdqPeriodCostSummary(@Param("currentStart") Long currentStart, @Param("currentEnd") Long currentEnd, @Param("lastStart") Long lastStart, @Param("lastEnd") Long lastEnd, @Param("list") Set<String> operatorUserIds);
     JSONObject getKuaiShouOperateSummary(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
     JSONObject getBytedanceOperateSummary(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
+    JSONObject getKuaiShouOperateProjectUserSummary(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("nowHour") Integer nowHour, @Param("list") Set<String> operatorUserIds);
     JSONObject getBytedanceOperateProjectUserSummary(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
     JSONObject getOperateTodayYesterdaySummary(@Param("tableName") String tableName, @Param("dateField") String dateField, @Param("costField") String costField, @Param("hourField") String hourField, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("nowHour") Integer nowHour, @Param("yesterday") Long yesterday, @Param("list") Set<String> operatorUserIds);
     String getAdqOperatorProjectNum(@Param("startDate") Long start, @Param("endDate") Long endDate, @Param("userIds") Set<String> userIds);

+ 25 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/MaterialStareMapper.xml

@@ -503,6 +503,31 @@
         </if>
     </select>
 
+    <select id="getKuaiShouOperateProjectUserSummary" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        COUNT(DISTINCT project_id) AS projectNum,
+        COUNT(DISTINCT user_id) AS userNum
+        FROM
+        application.kuaishou_account_report_hourly_dw
+        WHERE charge > 0
+        <if test="startDate != null and startDate != '' ">
+            AND stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            AND stat_date &lt;= #{endDate}
+        </if>
+        <if test="nowHour != null and nowHour != '' ">
+            AND hour &lt;= #{nowHour}
+        </if>
+        <if test='list!=null and list.size()>0'>
+            AND user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
     <select id="getBytedanceOperateSummary" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
         ROUND( SUM( cost ), 3 ) AS totalCost,

+ 13 - 4
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/MaterialStareServiceImpl.java

@@ -358,8 +358,11 @@ public class MaterialStareServiceImpl implements MaterialStareService {
             if (mediaType.equals("1")) {
                 long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
                 long endDate = Long.valueOf(DateUtils.getDateInteger(endTime));
+                boolean currentDay = startDate == endDate && startDate == nowDate;
                 JSONObject projectUserSummary = materialStareMapper.getBytedanceOperateProjectUserSummary(startDate, endDate, operatorUserIds);
-                JSONObject sectionSummary = materialStareMapper.getBytedanceOperateSummary(startDate, endDate, operatorUserIds);
+                JSONObject sectionSummary = currentDay
+                        ? materialStareMapper.getBytedanceTotalCost(startDate, endDate, nowHour, operatorUserIds)
+                        : materialStareMapper.getBytedanceOperateSummary(startDate, endDate, operatorUserIds);
                 JSONObject compareSummary = materialStareMapper.getOperateTodayYesterdaySummary(
                         "application.bytedance_advertiser_report_hourly_dw",
                         "stat_datetime",
@@ -390,7 +393,13 @@ public class MaterialStareServiceImpl implements MaterialStareService {
             if (mediaType.equals("2")) {
                 long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
                 long endDate = Long.valueOf(DateUtils.getDateInteger(endTime));
-                JSONObject summary = materialStareMapper.getKuaiShouOperateSummary(startDate, endDate, operatorUserIds);
+                boolean currentDay = startDate == endDate && startDate == nowDate;
+                JSONObject summary = currentDay
+                        ? materialStareMapper.getKuaiShouTotalCost(startDate, endDate, nowHour, operatorUserIds)
+                        : materialStareMapper.getKuaiShouOperateSummary(startDate, endDate, operatorUserIds);
+                JSONObject projectUserSummary = currentDay
+                        ? materialStareMapper.getKuaiShouOperateProjectUserSummary(startDate, endDate, nowHour, operatorUserIds)
+                        : materialStareMapper.getKuaiShouOperateSummary(startDate, endDate, operatorUserIds);
                 JSONObject compareSummary = materialStareMapper.getOperateTodayYesterdaySummary(
                         "application.kuaishou_account_report_hourly_dw",
                         "stat_date",
@@ -408,13 +417,13 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 resultMap.put("compare", formatRate(todayCost, yesterdayCost, decimalFormat));
                 double sectionCost = getJsonDouble(summary, "totalCost");
                 resultMap.put("sectionCost", sectionCost);
-                int activeUserNum = getJsonInt(summary, "userNum");
+                int activeUserNum = getJsonInt(projectUserSummary, "userNum");
                 Double userAverageAccount = safeDivide(getJsonDouble(summary, "accountNum"), activeUserNum);
                 Double userAveragecost = safeDivide(sectionCost, activeUserNum);
                 DecimalFormat df = new DecimalFormat("#.000");
                 resultMap.put("userAverageAccount", new Double(Math.ceil(userAverageAccount)).intValue());
                 resultMap.put("userAveragecost", df.format(userAveragecost));
-                resultMap.put("projectNum", String.valueOf(getJsonInt(summary, "projectNum")));
+                resultMap.put("projectNum", String.valueOf(getJsonInt(projectUserSummary, "projectNum")));
             }
             if (mediaType.equals("16")) {
                 JSONObject jsonObjectNow = materialStareMapper.getAdqTotalCost(nowDate, nowDate, nowHour, operatorUserIds);