فهرست منبع

修改头条账户报表

jiequan.bi 5 سال پیش
والد
کامیت
99753d705b

+ 3 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceAccountReportMapper.java

@@ -32,6 +32,9 @@ public interface BytedanceAccountReportMapper {
     //根据时间查询数据按账户分组
     List<JSONObject> querySumByDateGroupAccount(@Param("filed") String filed,@Param("endDate") String endDate, @Param("startDate") String startDate,@Param("accountIds") JSONArray accountIds,String target, String order);
 
+    //根据时间查询数据按账户时间分组
+    List<JSONObject> querySumByDateGroupAccountAndDate(@Param("filed") String filed,@Param("endDate") String endDate, @Param("startDate") String startDate,@Param("accountIds") JSONArray accountIds,String target, String order);
+
     //根据开始、结束时间 查询明细数据
     List<JSONObject> queryDetailByStartEndDate(@Param("endDate") String endDate, @Param("startDate") String startDate,@Param("accountIds") JSONArray accountIds);
 

+ 22 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceAccountReportMapper.xml

@@ -123,6 +123,7 @@
 
     <select id="querySumByDateGroupAccount" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
+          DATE_FORMAT(t1.stat_datetime,'%Y-%m-%d') as statDate,
           t2.account_id as accountId,
           t2.auth_name as authName,
           ${filed}
@@ -141,6 +142,27 @@
         order by ${target} ${order}
     </select>
 
+    <select id="querySumByDateGroupAccountAndDate" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        DATE_FORMAT(t1.stat_datetime,'%Y-%m-%d') as statDate,
+        t2.account_id as accountId,
+        t2.auth_name as authName,
+        ${filed}
+        FROM
+        ctop_bytedance_report_advertiser_daily t1
+        left join ctop_user_allocation t2 on t1.advertiser_id=t2.account_id
+        WHERE
+        t1.stat_datetime &lt;= #{endDate} '00:00:00'
+        AND t1.stat_datetime &gt;= #{startDate}
+        AND t1.advertiser_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        group by t1.stat_datetime
+        order by ${target} ${order}
+    </select>
+
     <select id="queryDetailByStartEndDate" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
           ROUND(sum(cost),2) cost,

+ 5 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAccountReportServiceImpl.java

@@ -95,7 +95,11 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
             result.add(beforeSum);
             result.add(countTotal(afterSum, beforeSum));
         } else {
-            result = bytedanceAccountReportMapper.querySumByDateGroupAccount(filedAll, endDate, startDate, accounts, target, order);
+            if(accounts.size()>1){
+                result = bytedanceAccountReportMapper.querySumByDateGroupAccount(filedAll, endDate, startDate, accounts, target, order);
+            }else{
+                result = bytedanceAccountReportMapper.querySumByDateGroupAccountAndDate(filedAll, endDate, startDate, accounts, target, order);
+            }
             result.add(bytedanceAccountReportMapper.queryAllSumByStartEndDate(filedAll, endDate, startDate, accounts));
         }
         return result;