Browse Source

报表,批量工具调整

yumeng 5 years ago
parent
commit
f3aac94189

+ 14 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java

@@ -467,10 +467,7 @@ public class BatchServiceImpl implements IBatchService {
     @Override
     public JSONObject copyUnit(KuaiShouGroup group, Long copyToCampaignId) {
         JSONObject returnJson = new JSONObject();
-
         try {
-
-
             CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(group.getAccountId());
             if (Check.isNull(oauthToken)) {
                 throw new Exception("未获取到token信息");
@@ -784,6 +781,20 @@ public class BatchServiceImpl implements IBatchService {
                 creativeJson.put("photo_id", photo_id);
                 creativeJson.put("click_track_url", click_track_url);
 
+                //封面广告语标题
+                if (!Check.isNull(creative.getStickerTitle())) {
+                    creativeJson.put("sticker_title", creative.getStickerTitle());
+                }
+                // 贴纸样式类型
+                if (!Check.isNull(creative.getOverlayType())) {
+                    creativeJson.put("overlay_type", creative.getOverlayType());
+                }
+                // 安卓下载中间页
+                if (!Check.isNull(creative.getSiteId())) {
+                    creativeJson.put("site_id", creative.getSiteId());
+                }
+
+
                 Map<String, Object> returnCreativeMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson);
                 if (!Check.isNullMap(returnCreativeMap)) {
                     Integer code = (Integer) returnCreativeMap.get("code");

+ 54 - 45
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/AccountReportMapper.xml

@@ -21,6 +21,22 @@
         ((sum(charge) / sum(activation)) / #{discount}) afterActivationPrice, -- 激活单价
         sum(event_register) eventRegister, -- 注册数
 
+        sum(form_count + activation) conversionNum, -- 转化数
+
+        (case
+        when sum(activation +form_count) != 0
+        then (sum(charge) / sum(activation +form_count))
+        else 0
+        end
+        ) conversionPrice, -- 转化单价
+
+        (case
+        when sum(activation +form_count) != 0
+        then (sum(charge) / sum(activation +form_count)) / #{discount}
+        else 0
+        end
+        ) afterConversionPrice, -- 折后转化单价
+
         (case
         when sum(event_register) != 0
         then (sum(charge) / sum(event_register))
@@ -57,13 +73,13 @@
         ((sum(charge) / sum(activation)) / #{discount}) afterActivationPrice, -- 激活单价
         account_id accountId,
         (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName,
-        sum(event_next_day_stay) eventNextDayStay,  -- 次留数
+        sum(event_next_day_stay) eventNextDayStay, -- 次留数
         (case
         when sum(activation) != 0
         then (sum(event_next_day_stay)/sum(activation))
         else 0
         end
-        ) eventNextDayStayRatio  -- 次留率=次留数/激活数
+        ) eventNextDayStayRatio -- 次留率=次留数/激活数
         from
         ctop_kuaishou_report_daily_account
         where account_id in
@@ -92,6 +108,8 @@
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
         ((sum(charge) / sum(activation)) / #{discount}) afterActivationPrice, -- 激活单价
         sum(event_register) eventRegister, -- 注册数
+        sum(form_count + activation) conversionNum, -- 转化数
+        (sum(charge) / sum(activation +form_count )) conversionPrice, -- 转化单价
         (case
         when sum(event_register) != 0
         then (sum(charge) / sum(event_register))
@@ -100,13 +118,13 @@
         ) eventRegisterCost, -- 注册成本
         account_id accountId,
         (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName,
-        sum(event_next_day_stay) eventNextDayStay,  -- 次留数
+        sum(event_next_day_stay) eventNextDayStay, -- 次留数
         (case
         when sum(activation) != 0
         then (sum(event_next_day_stay)/sum(activation))
         else 0
         end
-        ) eventNextDayStayRatio  -- 次留率=次留数/激活数
+        ) eventNextDayStayRatio -- 次留率=次留数/激活数
         from
         ctop_kuaishou_report_daily_account
         where stat_date &lt;= #{startDate}
@@ -135,6 +153,15 @@
         sum(activation) activationCount, -- 激活数
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
         sum(event_register) eventRegister, -- 注册数
+        sum(form_count + activation) conversionNum, -- 转化数
+
+        (
+        case when sum(activation +form_count ) != 0
+        then (sum(charge) / sum(activation +form_count))
+        else 0
+        end
+        )conversionPrice, -- 转化单价
+
 
         (case
         when sum(event_register) != 0
@@ -173,6 +200,14 @@
         sum(activation) activationCount, -- 激活数
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
         sum(event_register) eventRegister, -- 注册数
+        sum(form_count + activation) conversionNum, -- 转化数
+        (
+        case when sum(activation +form_count ) != 0
+        then (sum(charge) / sum(activation +form_count))
+        else 0
+        end
+        )conversionPrice, -- 转化单价
+
         (case
         when sum(event_register) != 0
         then (sum(charge) / sum(event_register))
@@ -181,13 +216,13 @@
         ) eventRegisterCost, -- 注册成本
         account_id accountId,
         (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName,
-        sum(event_next_day_stay) eventNextDayStay,  -- 次留数
+        sum(event_next_day_stay) eventNextDayStay, -- 次留数
         (case
         when sum(activation) != 0
         then ( sum(event_next_day_stay) / sum(activation) )
         else 0
         end
-        ) eventNextDayStayRatio  -- 次留率=次留数/激活数
+        ) eventNextDayStayRatio -- 次留率=次留数/激活数
         from
         ctop_kuaishou_report_daily_account
         where stat_date = #{statDate}
@@ -416,30 +451,17 @@
         sum(bclick) bClick,-- 行为数
         (
         CASE
-        WHEN sum(form_count) != 0 THEN
-        sum(form_count)
-        WHEN sum(activation) != 0 THEN
-        sum(activation)
-        ELSE
-        0
-        END
-        ) conversions, -- 转化数
-        (
-        CASE
-        WHEN sum(form_count) != 0 THEN
-        sum(charge) / sum(form_count)
-        WHEN sum(activation) != 0 THEN
-        sum(charge) / sum(activation)
+        WHEN sum(form_count + activation) != 0 THEN
+        sum(charge) / sum(form_count + activation)
         ELSE
         0
         END
         ) conversionPrice, -- 转化单价
+        sum(form_count + activation) conversions, -- 转化数
         (
         CASE
-        WHEN sum(form_count) != 0 THEN
-        (sum(charge) / sum(form_count)) / #{discount}
-        WHEN sum(activation) != 0 THEN
-        (sum(charge) / sum(activation)) / #{discount}
+        WHEN sum(form_count + activation) != 0 THEN
+        (sum(charge) / sum(form_count + activation)) / #{discount}
         ELSE
         0
         END
@@ -451,13 +473,13 @@
         else 0
         end
         ) eventRegisterCost, -- 注册成本
-        sum(event_next_day_stay) eventNextDayStay,  -- 次留数
+        sum(event_next_day_stay) eventNextDayStay, -- 次留数
         (case
         when sum(activation) != 0
         then (sum(event_next_day_stay)/sum(activation))
         else 0
         end
-        ) eventNextDayStayRatio  -- 次留率=次留数/激活数
+        ) eventNextDayStayRatio -- 次留率=次留数/激活数
 
         from
         ctop_kuaishou_report_daily_account
@@ -520,34 +542,21 @@
         else 0
         end
         ) cpm,
-
+        sum(form_count + activation) conversions, -- 转化数
         sum(bclick) bClick,-- 行为数
+
         (
         CASE
-        WHEN sum(form_count) != 0 THEN
-        sum(form_count)
-        WHEN sum(activation) != 0 THEN
-        sum(activation)
-        ELSE
-        0
-        END
-        ) conversions, -- 转化数
-        (
-        CASE
-        WHEN sum(form_count) != 0 THEN
-        sum(charge) / sum(form_count)
-        WHEN sum(activation) != 0 THEN
-        sum(charge) / sum(activation)
+        WHEN sum(activation + form_count) != 0 THEN
+        sum(charge) / sum(activation + form_count)
         ELSE
         0
         END
         ) conversionPrice, -- 转化单价
         (
         CASE
-        WHEN sum(form_count) != 0 THEN
-        (sum(charge) / sum(form_count)) / #{discount}
-        WHEN sum(activation) != 0 THEN
-        (sum(charge) / sum(activation)) / #{discount}
+        WHEN sum(activation + form_count) != 0 THEN
+        (sum(charge) / sum(activation + form_count)) / #{discount}
         ELSE
         0
         END

+ 7 - 33
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/DailyReportMapper.xml

@@ -26,7 +26,6 @@
             </if>
         </where>
         ) contractRebateRealCharged -- 激励花费
-
         FROM (
         SELECT
         sum(charge) cost, -- 消耗
@@ -73,25 +72,12 @@
         0
         END
         ) impression1kCost, -- 平均千次展现花费
+        sum(form_count + activation) conversions, -- 转化数
         (
         CASE
-        WHEN sum(form_count) != 0 THEN
-        sum(form_count)
-        WHEN sum(activation) != 0 THEN
-        sum(activation)
-        ELSE
-        0
-        END
-        ) conversions, -- 转化数
-        (
-        CASE
-        WHEN sum(form_count) != 0 THEN
-        (
-        truncate(sum(charge) / sum(form_count),2)
-        )
-        WHEN sum(activation) != 0 THEN
+        WHEN sum(form_count + activation) != 0 THEN
         (
-        truncate(sum(charge) / sum(activation),2)
+        truncate(sum(charge) / sum(form_count + activation),2)
         )
         ELSE
         0
@@ -184,25 +170,13 @@
         0
         END
         ) photoClickCost, -- 平均点击花费
+
+        sum(form_count + activation) conversions, -- 转化数
         (
         CASE
-        WHEN sum(form_count) != 0 THEN
-        sum(form_count)
-        WHEN sum(activation) != 0 THEN
-        sum(activation)
-        ELSE
-        0
-        END
-        ) conversions, -- 转化数
-        (
-        CASE
-        WHEN sum(form_count) != 0 THEN
-        (
-        truncate(sum(charge) / sum(form_count),2)
-        )
-        WHEN sum(activation) != 0 THEN
+        WHEN sum(form_count + activation) != 0 THEN
         (
-        truncate(sum(charge) / sum(activation),2)
+        truncate(sum(charge) / sum(form_count + activation),2)
         )
         ELSE
         0

+ 48 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/AccountReportServiceImpl.java

@@ -402,6 +402,53 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             chainRatioJson.put("bClickProportion", 0);
                         }
 
+                        // 转化数
+                        Long nowConversionNum = nowAccountSummary.getLong("conversionNum");
+                        Long yesterdayConversionNum = yesterdayAccountSummary.getLong("conversionNum");
+                        //表单提交数环比
+                        if (!Check.isNull(nowConversionNum) && !Check.isNull(yesterdayConversionNum)) {
+                            if (yesterdayAClick != 0L) {
+                                double nowConversionNumProportion = (nowConversionNum.doubleValue() - yesterdayConversionNum.doubleValue()) / yesterdayConversionNum.doubleValue();
+                                chainRatioJson.put("nowConversionNumProportion", nowConversionNumProportion);
+                            } else {
+                                chainRatioJson.put("nowConversionNumProportion", 0);
+                            }
+                        } else {
+                            chainRatioJson.put("nowConversionNumProportion", 0);
+                        }
+
+
+                        // 折后转化单价
+                        BigDecimal nowAfterConversionPrice = nowAccountSummary.getBigDecimal("afterConversionPrice");
+                        BigDecimal yesterdayAfterConversionPrice = yesterdayAccountSummary.getBigDecimal("afterConversionPrice");
+                        // 折前消耗单价
+                        if (!Check.isNull(nowAfterConversionPrice) && !Check.isNull(yesterdayAfterConversionPrice)) {
+                            if (yesterdayAfterConversionPrice.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal afterConversionPriceProportion = (nowAfterConversionPrice.subtract(yesterdayAfterConversionPrice)).divide(yesterdayAfterConversionPrice, 2, RoundingMode.HALF_UP);
+                                chainRatioJson.put("afterConversionPriceProportion", afterConversionPriceProportion);
+                            } else {
+                                chainRatioJson.put("afterConversionPriceProportion", 0);
+                            }
+                        } else {
+                            chainRatioJson.put("afterConversionPriceProportion", 0);
+                        }
+
+                        // 折前转化单价
+                        BigDecimal nowConversionPrice = nowAccountSummary.getBigDecimal("conversionPrice");
+                        BigDecimal yesterdayConversionPrice = yesterdayAccountSummary.getBigDecimal("conversionPrice");
+                        // 折前消耗单价
+                        if (!Check.isNull(nowConversionPrice) && !Check.isNull(yesterdayConversionPrice)) {
+                            if (yesterdayConversionPrice.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal beforeConversionPriceProportion = (nowConversionPrice.subtract(yesterdayConversionPrice)).divide(yesterdayConversionPrice, 2, RoundingMode.HALF_UP);
+                                chainRatioJson.put("beforeConversionPriceProportion", beforeConversionPriceProportion);
+                            } else {
+                                chainRatioJson.put("beforeConversionPriceProportion", 0);
+                            }
+                        } else {
+                            chainRatioJson.put("beforeConversionPriceProportion", 0);
+                        }
+
+
                         // 表单提交数
                         Long nowFormCount = nowAccountSummary.getLong("formCount");
                         Long yesterdayFormCount = yesterdayAccountSummary.getLong("formCount");
@@ -421,7 +468,7 @@ public class AccountReportServiceImpl implements IAccountReportService {
                         // 激活数
                         Long nowActivationCount = nowAccountSummary.getLong("activationCount");
                         Long yesterdayActivationCount = yesterdayAccountSummary.getLong("activationCount");
-                        //表单提交数环比
+                        //激活数环比
                         if (!Check.isNull(nowActivationCount) && !Check.isNull(yesterdayActivationCount)) {
                             if (yesterdayAClick != 0L) {
                                 double activationCountProportion = (nowActivationCount.doubleValue() - yesterdayActivationCount.doubleValue()) / yesterdayActivationCount.doubleValue();