Ver Fonte

快手素材账户报表增加次留率、次留数

hcst_sunzhen há 5 anos atrás
pai
commit
18884d5cc7

+ 0 - 20
module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceReportController.java

@@ -187,15 +187,6 @@ public class BytedanceReportController {
                 });
             });
             ////
-
-
-
-
-
-
-
-
-
             Long endtime = System.currentTimeMillis();
             log.info("头条获取素材报表数据任务执行结束,执行耗时:{}秒", (endtime - starttime) / 1000);
         } catch (Exception e) {
@@ -218,7 +209,6 @@ public class BytedanceReportController {
             //    bytedanceReportService.bytedanceMaterialReportRetry(token,retry.getStartDate(),retry.getEndDate());
             //}
 
-
                 //
                 //多线程
                 final ExecutorService executorService = Executors.newFixedThreadPool(8);
@@ -239,16 +229,6 @@ public class BytedanceReportController {
                 });
                 ////
 
-                //
-
-
-
-
-
-
-
-
-
         } catch (Exception e) {
             log.error("条获取素材报表失败数据任务重试失败");
             e.printStackTrace();

+ 32 - 5
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/AccountReportMapper.xml

@@ -27,7 +27,6 @@
         else 0
         end
         ) eventRegisterCost -- 注册成本
-
         from
         ctop_kuaishou_report_hourly_account
         where stat_date = #{date}
@@ -57,7 +56,14 @@
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
         ((sum(charge) / sum(activation)) / #{discount}) afterActivationPrice, -- 激活单价
         account_id accountId,
-        (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
+        (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName,
+        sum(event_next_day_stay) eventNextDayStay,  -- 次留数
+        (case
+        when sum(activation) != 0
+        then (sum(event_next_day_stay)/sum(activation))
+        else 0
+        end
+        ) eventNextDayStayRatio  -- 次留率=次留数/激活数
         from
         ctop_kuaishou_report_daily_account
         where account_id in
@@ -93,7 +99,14 @@
         end
         ) eventRegisterCost, -- 注册成本
         account_id accountId,
-        (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
+        (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName,
+        sum(event_next_day_stay) eventNextDayStay,  -- 次留数
+        (case
+        when sum(activation) != 0
+        then (sum(event_next_day_stay)/sum(activation))
+        else 0
+        end
+        ) eventNextDayStayRatio  -- 次留率=次留数/激活数
         from
         ctop_kuaishou_report_daily_account
         where stat_date <= #{startDate}
@@ -167,7 +180,14 @@
         end
         ) eventRegisterCost, -- 注册成本
         account_id accountId,
-        (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
+        (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName,
+        sum(event_next_day_stay) eventNextDayStay,  -- 次留数
+        (case
+        when sum(activation) != 0
+        then ( sum(event_next_day_stay) / sum(activation) )
+        else 0
+        end
+        ) eventNextDayStayRatio  -- 次留率=次留数/激活数
         from
         ctop_kuaishou_report_daily_account
         where stat_date = #{statDate}
@@ -430,7 +450,14 @@
         then (sum(charge) / sum(event_register))
         else 0
         end
-        ) eventRegisterCost -- 注册成本
+        ) eventRegisterCost, -- 注册成本
+        sum(event_next_day_stay) eventNextDayStay,  -- 次留数
+        (case
+        when sum(activation) != 0
+        then (sum(event_next_day_stay)/sum(activation))
+        else 0
+        end
+        ) eventNextDayStayRatio  -- 次留率=次留数/激活数
 
         from
         ctop_kuaishou_report_daily_account

+ 28 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/AccountReportServiceImpl.java

@@ -523,6 +523,34 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             chainRatioJson.put("eventRegisterProportion", 0);
                         }
 
+                        //次留数
+                        Long nowEventNextDayStay = nowAccountSummary.getLong("activationCount");
+                        Long yesterdayEventNextDayStay = yesterdayAccountSummary.getLong("activationCount");
+                        //表单提交数环比
+                        if (!Check.isNull(nowEventNextDayStay) && !Check.isNull(yesterdayEventNextDayStay)) {
+                            if (yesterdayAClick != 0L) {
+                                double eventNextDayStayProportion = (nowEventNextDayStay.doubleValue() - yesterdayEventNextDayStay.doubleValue()) / yesterdayEventNextDayStay.doubleValue();
+                                chainRatioJson.put("eventNextDayStayProportion", eventNextDayStayProportion);
+                            } else {
+                                chainRatioJson.put("eventNextDayStayProportion", 0);
+                            }
+                        } else {
+                            chainRatioJson.put("eventNextDayStayProportion", 0);
+                        }
+
+
+                        BigDecimal nowEventNextDayStayRatio = nowAccountSummary.getBigDecimal("eventRegister");  // 今日注册数
+                        BigDecimal yesterdayEventNextDayStayRatio = yesterdayAccountSummary.getBigDecimal("eventRegister"); // 昨日注册数
+                        if (!Check.isNull(nowEventNextDayStayRatio) && !Check.isNull(yesterdayEventNextDayStayRatio)) {
+                            if (yesterdayEventNextDayStayRatio.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal eventNextDayStayRatioProportion = (nowEventNextDayStayRatio.subtract(yesterdayEventNextDayStayRatio)).divide(yesterdayEventNextDayStayRatio, 4, RoundingMode.HALF_UP);
+                                chainRatioJson.put("eventNextDayStayRatioProportion", eventNextDayStayRatioProportion);
+                            } else {
+                                chainRatioJson.put("eventNextDayStayRatioProportion", 0);
+                            }
+                        } else {
+                            chainRatioJson.put("eventNextDayStayRatioProportion", 0);
+                        }
 
                         returnJson.put("chainRatio", chainRatioJson);
                     }