Bladeren bron

盯盘运营经理,修改多日情况下 人员账户 数据异常问题

zhaoxian 4 jaren geleden
bovenliggende
commit
52bd08db09

+ 20 - 18
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportAccountDailyMapper.xml

@@ -285,13 +285,13 @@
                      AND media_id =2
                      AND media_id =2
                      GROUP BY user_id) t) as 'totle'
                      GROUP BY user_id) t) as 'totle'
                  FROM (
                  FROM (
-                     SELECT sum(charge) as 'charge', t2.user_id 'userId' FROM ctop_etl_kuaishou_report_account_daily t1
+                     SELECT sum (charge) as 'charge', t2.user_id 'userId' FROM ctop_etl_kuaishou_report_account_daily t1
                      LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
                      LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
                      WHERE t1.stat_date >= #{mStartDate}
                      WHERE t1.stat_date >= #{mStartDate}
                      AND t1.stat_date <= #{today}
                      AND t1.stat_date <= #{today}
                      AND media_id =2
                      AND media_id =2
                      GROUP BY user_id
                      GROUP BY user_id
-                     ORDER BY SUM(charge) DESC
+                     ORDER BY SUM (charge) DESC
                      ) t, (select @rownum := 0) a
                      ) t, (select @rownum := 0) a
              ) tt
              ) tt
         WHERE tt.userId = #{userId}
         WHERE tt.userId = #{userId}
@@ -520,22 +520,22 @@
     </select>
     </select>
 
 
     <select id="projectPageListTotal" resultType="java.lang.Integer">
     <select id="projectPageListTotal" resultType="java.lang.Integer">
-        SELECT IFNULL(SUM(1),0) from
-            (
-                SELECT
-                    t3.id
-                FROM ctop_etl_kuaishou_report_account_daily t1
-                         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-                         INNER JOIN ctop_project t3 ON t2.project_id = t3.id
-                where t1.stat_date &gt;= #{startTime}
-                  AND t1.stat_date &lt;= #{endTime}
-                GROUP BY t3.id
-                HAVING SUM(charge)>0
-            ) t
+        SELECT IFNULL(SUM(1), 0)
+        from (
+                 SELECT t3.id
+                 FROM ctop_etl_kuaishou_report_account_daily t1
+                          LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+                          INNER JOIN ctop_project t3 ON t2.project_id = t3.id
+                 where t1.stat_date &gt;= #{startTime}
+                   AND t1.stat_date &lt;= #{endTime}
+                 GROUP BY t3.id
+                 HAVING SUM(charge) > 0
+             ) t
     </select>
     </select>
 
 
     <select id="selectList" resultType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly">
     <select id="selectList" resultType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly">
-        SELECT * from ctop_etl_kuaishou_report_account_daily
+        SELECT *
+        from ctop_etl_kuaishou_report_account_daily
         WHERE stat_date &gt;= #{startDate}
         WHERE stat_date &gt;= #{startDate}
           and stat_date &lt;= #{endDate}
           and stat_date &lt;= #{endDate}
     </select>
     </select>
@@ -572,8 +572,9 @@
         ctop_etl_kuaishou_report_account_daily t1
         ctop_etl_kuaishou_report_account_daily t1
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         LEFT JOIN(
         LEFT JOIN(
-        SELECT user_id,COUNT(1) 'accountCount' FROM ctop_user_allocation i1
-        INNER JOIN ctop_etl_kuaishou_report_account_daily  i2 ON i1.account_id = i2.account_id
+        SELECT user_id,COUNT(1) 'accountCount' FROM (
+        SELECT user_id,i1.account_id FROM ctop_user_allocation i1
+        INNER JOIN ctop_etl_kuaishou_report_account_daily i2 ON i1.account_id = i2.account_id
         AND i2.stat_date &gt;= #{startTime}
         AND i2.stat_date &gt;= #{startTime}
         and i2.stat_date &lt;= #{endTime}
         and i2.stat_date &lt;= #{endTime}
         WHERE user_id IN
         WHERE user_id IN
@@ -581,7 +582,8 @@
                  open="(" separator="," close=")">
                  open="(" separator="," close=")">
             #{id}
             #{id}
         </foreach>
         </foreach>
-        GROUP BY user_id
+        GROUP BY user_id,i1.account_id
+        )t GROUP BY user_id
         ) t3 ON t2.user_id = t3.user_id
         ) t3 ON t2.user_id = t3.user_id
         LEFT JOIN (
         LEFT JOIN (
         SELECT
         SELECT