Quellcode durchsuchen

分版位数据单独获取

yumeng vor 4 Jahren
Ursprung
Commit
fb71202809

+ 17 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAccountReportLoadJob.java

@@ -31,7 +31,23 @@ public class KuaishouDailyAccountReportLoadJob {
     public void execute() throws Exception {
         Date getDate = DateUtils.addDay(new Date(), -1);
         Date getDate2 = DateUtils.addDay(new Date(), -2);
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        if (null == tokens || tokens.isEmpty()) {
+            XxlJobHelper.log("定时获取快手数据异常:未获取到可用的token");
+            XxlJobHelper.handleFail();
+            return;
+        }
+        tokens.forEach(token -> executorService.submit(() -> {
+            kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate2, getDate, null);
+        }));
+    }
+
 
+    @XxlJob("kuaishouDailyAccountAdSceneReport")
+    public void kuaishouDailyAccountAdSceneReport() throws Exception {
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        Date getDate2 = DateUtils.addDay(new Date(), -2);
         //1:查询当日数据
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
         if (null == tokens || tokens.isEmpty()) {
@@ -41,7 +57,7 @@ public class KuaishouDailyAccountReportLoadJob {
         }
         tokens.forEach(token -> executorService.submit(() -> {
             kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate2, getDate, "adScene");
-            kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate2, getDate, null);
         }));
     }
+
 }

+ 5 - 22
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -52,7 +52,6 @@ import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.ExecutorService;
@@ -336,30 +335,14 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 detailJson.put("photo_show", detailJson.getString("show"));
                 KuaishouReportDailyAccount KuaishouReportDailyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportDailyAccount.class);
                 KuaishouReportDailyAccount.setAccountId(token.getAccountId());
-                if (Check.isNull(reportDims)) {
-                    BigDecimal totalCharge = KuaishouReportDailyAccount.getCharge();
-                    if (BigDecimalUtil.compareToDecimal(totalCharge, new BigDecimal(0)) == 0 || Check.isNull(totalCharge)) {
-                        return;
-                    }
-                    // 非联盟消耗
-                    BigDecimal sumCharge = dailyAccountMapper.getSumChargeByAccountIdAndStatDate(KuaishouReportDailyAccount.getAccountId(), KuaishouReportDailyAccount.getStatDate());
-                    if (Check.isNull(sumCharge) || BigDecimalUtil.compareToDecimal(sumCharge, new BigDecimal(0)) == 0) {
-                        KuaishouReportDailyAccount.setCharge(totalCharge);
-                        KuaishouReportDailyAccount.setAdScene("广告联盟");
-                    } else {
-                        if (BigDecimalUtil.compareToDecimal(totalCharge, sumCharge) == 0) {
-                            return;
-                        }
-                        BigDecimal lianMengCharge = BigDecimalUtil.subtractBigDecimal(totalCharge, sumCharge);
-                        KuaishouReportDailyAccount.setCharge(lianMengCharge);
-                        KuaishouReportDailyAccount.setAdScene("广告联盟");
-                    }
-
-                }
                 addList.add(KuaishouReportDailyAccount);
             }
         }
-        dailyAccountMapper.replaceBatch(addList);
+        if (Check.isNull(reportDims)) {
+            dailyAccountMapper.replaceBatch(addList);
+        } else {
+            dailyAccountMapper.replaceBatchAdScene(addList);
+        }
         getAccountDailyReportByPage(token, startDate, endDate, page + 1, reportDims);
     }
 

+ 19 - 21
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java

@@ -1,11 +1,7 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.common.module.vo.KuaishouReportAccountDailyDTOEntity;
-import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountDaily;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouVideoInfoDTO;
-import cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO;
+import cn.com.ctop.kuaishou.modules.report.entity.*;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -21,39 +17,41 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
 
     List<JSONObject> selectCost(@Param("accountId") Long accountId, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
-    List<ProjectAccountDTO> getKuaishouProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectList")List<Long> projectList, @Param("yn")Integer yn);
+    List<ProjectAccountDTO> getKuaishouProjectInfo(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectList") List<Long> projectList, @Param("yn") Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("projectId")Long projectId, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectList")List<Long> projectList, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("projectId") Long projectId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectList") List<Long> projectList, @Param("accountIds") List<Long> accountIds, @Param("yn") Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("projectList")List<Long> projectList, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("accountId")Long accountId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("projectList") List<Long> projectList, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("accountId") Long accountId, @Param("accountIds") List<Long> accountIds, @Param("yn") Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("projectList")List<Long> projectList, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("campaignId")Long campaignId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("projectList") List<Long> projectList, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("campaignId") Long campaignId, @Param("accountIds") List<Long> accountIds, @Param("yn") Integer yn);
 
-    List<Long> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+    List<Long> queryProjectMemberByUserId(@Param("userId") String userId, @Param("mediaIds") List<Long> mediaIds);
 
-    List<Long> queryProjectInfoBySaleId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+    List<Long> queryProjectInfoBySaleId(@Param("userId") String userId, @Param("mediaIds") List<Long> mediaIds);
 
-    List<ProjectAccountDTO> queryProjectMemberByIds(@Param("projectIds")List<Long> projectIds);
+    List<ProjectAccountDTO> queryProjectMemberByIds(@Param("projectIds") List<Long> projectIds);
 
-    String getRoleCodeByUserId(@Param("userId")String userId);
+    String getRoleCodeByUserId(@Param("userId") String userId);
 
-    List<Long> queryProjectMemberByAdmins(@Param("mediaIds")List<Long> mediaIds);
+    List<Long> queryProjectMemberByAdmins(@Param("mediaIds") List<Long> mediaIds);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("projectList")List<Long> projectList, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("unitId")Long unitId, @Param("accountIds") List<Long> accoundIds, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("projectList") List<Long> projectList, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("unitId") Long unitId, @Param("accountIds") List<Long> accoundIds, @Param("yn") Integer yn);
 
-    KuaishouVideoInfoDTO getVideoUrl(@Param("photoId")Long photoId);
+    KuaishouVideoInfoDTO getVideoUrl(@Param("photoId") Long photoId);
 
-    List<Long> getUserProjectAccountIds(@Param("userId")String userId, @Param("yn")Integer yn);
+    List<Long> getUserProjectAccountIds(@Param("userId") String userId, @Param("yn") Integer yn);
 
-    List<Long> getUserProjectAccountIdsByAdmin(@Param("yn")Integer yn);
+    List<Long> getUserProjectAccountIdsByAdmin(@Param("yn") Integer yn);
 
-    List<Long> getSaleProjectAccountIds(@Param("userId")String userId, @Param("yn")Integer yn);
+    List<Long> getSaleProjectAccountIds(@Param("userId") String userId, @Param("yn") Integer yn);
 
-    List<KuaishouReportAccountDailyDTOEntity> getKuaishouProjectInfoEntity(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectList")List<Long> projectList, @Param("yn")Integer yn);
+    List<KuaishouReportAccountDailyDTOEntity> getKuaishouProjectInfoEntity(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectList") List<Long> projectList, @Param("yn") Integer yn);
 
     void replaceBatch(@Param("addList") List<KuaishouReportDailyAccount> addList);
 
+    void replaceBatchAdScene(@Param("addList") List<KuaishouReportDailyAccount> addList);
+
     List<EtlKuaishouReportAccountDaily> queryEveryDayDataForAccount();
 
-    BigDecimal getSumChargeByAccountIdAndStatDate(@Param("accountId") Long accountId,@Param("statDate") String statDate);
+    BigDecimal getSumChargeByAccountIdAndStatDate(@Param("accountId") Long accountId, @Param("statDate") String statDate);
 }

+ 122 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml

@@ -205,6 +205,128 @@
     </insert>
 
 
+    <insert id="replaceBatchAdScene">
+        replace into ctop_kuaishou_report_daily_account_ad_scene(
+        account_id,
+        ad_scene,
+        charge,
+        photo_show,
+        aclick,
+        bclick,
+        photo_share,
+        photo_comment,
+        photo_like,
+        follow,
+        cancel_follow,
+        report,
+        block,
+        negative,
+        download_started,
+        download_completed,
+        activation,
+        submit,
+        stat_date,
+        photo_click,
+        photo_click_ratio,
+        action_ratio,
+        impression_1k_cost,
+        photo_click_cost,
+        action_cost,
+        event_pay_first_day,
+        event_pay_purchase_amount_first_day,
+        event_pay_first_day_roi,
+        event_pay,
+        event_pay_purchase_amount,
+        event_pay_roi,
+        event_register,
+        event_register_cost,
+        event_register_ratio,
+        event_jin_jian_app,
+        event_jin_jian_app_cost,
+        event_credit_grant_app,
+        event_credit_grant_app_cost,
+        event_credit_grant_app_ratio,
+        event_order_paid,
+        event_order_paid_purchase_amount,
+        event_jin_jian_landing_page,
+        event_jin_jian_landing_page_cost,
+        event_credit_grant_landing_page,
+        event_credit_grant_landing_page_cost,
+        event_credit_grant_landing_ratio,
+        event_next_day_stay_cost,
+        event_next_day_stay_ratio,
+        form_action_ratio,
+        event_order_paid_cost,
+        event_next_day_stay,
+        form_cost,
+        form_count,
+        play_3s_ratio
+
+        )
+        values
+        <foreach collection="addList" item="add" separator=",">
+            (
+            #{add.accountId},
+            #{add.adScene},
+            #{add.charge},
+            #{add.photoShow},
+            #{add.aclick},
+            #{add.bclick},
+            #{add.photoShare},
+            #{add.photoComment},
+            #{add.photoLike},
+            #{add.follow},
+            #{add.cancelFollow},
+            #{add.report},
+            #{add.block},
+            #{add.negative},
+            #{add.downloadStarted},
+            #{add.downloadCompleted},
+            #{add.activation},
+            #{add.submit},
+            #{add.statDate},
+            #{add.photoClick},
+            #{add.photoClickRatio},
+            #{add.actionRatio},
+            #{add.impression1kCost},
+            #{add.photoClickCost},
+            #{add.actionCost},
+            #{add.eventPayFirstDay},
+            #{add.eventPayPurchaseAmountFirstDay},
+            #{add.eventPayFirstDayRoi},
+            #{add.eventPay},
+            #{add.eventPayPurchaseAmount},
+            #{add.eventPayRoi},
+            #{add.eventRegister},
+            #{add.eventRegisterCost},
+            #{add.eventRegisterRatio},
+            #{add.eventJinJianApp},
+            #{add.eventJinJianAppCost},
+            #{add.eventCreditGrantApp},
+            #{add.eventCreditGrantAppCost},
+            #{add.eventCreditGrantAppRatio},
+            #{add.eventOrderPaid},
+            #{add.eventOrderPaidPurchaseAmount},
+            #{add.eventJinJianLandingPage},
+            #{add.eventJinJianLandingPageCost},
+            #{add.eventCreditGrantLandingPage},
+            #{add.eventCreditGrantLandingPageCost},
+            #{add.eventCreditGrantLandingRatio},
+            #{add.eventNextDayStayCost},
+            #{add.eventNextDayStayRatio},
+            #{add.formActionRatio},
+            #{add.eventOrderPaidCost},
+            #{add.eventNextDayStay},
+            #{add.formCost},
+            #{add.formCount},
+            #{add.play3sRatio}
+
+            )
+        </foreach>
+
+    </insert>
+
+
     <insert id="insertSelective" parameterType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount">
         replace into ctop_kuaishou_report_daily_account
         <trim prefix="(" suffix=")" suffixOverrides=",">