yumeng 1 день назад
Родитель
Сommit
e9dd203bbd
17 измененных файлов с 995 добавлено и 168 удалено
  1. 4 21
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/BytedanceController.java
  2. 263 0
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/BytedanceAdvertiserFundDaily.java
  3. 414 0
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/BytedanceMaterialReportDaily.java
  4. 7 0
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/AdvertiserFundGetDailyMapper.java
  5. 11 0
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/BytedanceMaterialReportMapper.java
  6. 46 0
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/AdvertiserFundGetDailyMapper.xml
  7. 1 1
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/AdvertiserFundGetMapper.xml
  8. 71 0
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/BytedanceMaterialReportMapper.xml
  9. 2 0
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IAdvertiserFundGetServer.java
  10. 1 5
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IBytedanceMaterialReportService.java
  11. 52 1
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/AdvertiserFundGetServerImpl.java
  12. 0 1
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BytedanceAccountReportServiceImpl.java
  13. 100 120
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BytedanceMaterialReportServiceImpl.java
  14. 0 5
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/utils/FieldsConfig.java
  15. 21 0
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/AdvertiserFundGetJob.java
  16. 1 1
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedancePromoterReportJob.java
  17. 1 13
      nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceReportRetryJob.java

+ 4 - 21
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/BytedanceController.java

@@ -89,8 +89,8 @@ public class BytedanceController {
 
     @GetMapping("/getAdvertiserFundGet")
     public void getAdvertiserFundGet() {
-        Long advertiserId = 1851213792607364L;
-        String accessToken = "d99c62d791180d2a6adfe149f5996e0a769acbdd";
+        Long advertiserId = 1849662855632003L;
+        String accessToken = "100e885efcf74113ef12ef39077a5d5d40865d8b";
         advertiserFundGetServer.getAdvertiserFundGet(advertiserId, accessToken);
 
 
@@ -390,25 +390,8 @@ public class BytedanceController {
 
     @GetMapping("/materialDaily")
     public void materialDaily(@RequestParam(required = false) Long advertiserId, String startDate, String endDate) {
-        List<JSONObject> costAccount = productReportService.getCostAccount(advertiserId, startDate, endDate);
-        for (JSONObject jsonObject : costAccount) {
-            executor10Service1.submit(() -> {
-                Long adverId = jsonObject.getLong("advertiserId");
-                String accessToken = jsonObject.getString("accessToken");
-                bytedanceMaterialReportService.getBytedanceMaterialDailyReport(adverId, startDate, endDate, 1, null, 1, 0, 1);
-            });
-        }
-    }
+        bytedanceMaterialReportService.getBytedanceMaterialDailyReport(1849662855632003L, "100e885efcf74113ef12ef39077a5d5d40865d8b", startDate, endDate, 1, null, 1, 0, 1);
 
-    @GetMapping("/materialVideoGet")
-    public void materialVideoGet(@RequestParam(required = false) Long advertiserId, String startDate, String endDate) {
-        List<JSONObject> costAccount = productReportService.getCostAccount(advertiserId, startDate, endDate);
-        for (JSONObject jsonObject : costAccount) {
-            executor10Service1.submit(() -> {
-                Long adverId = jsonObject.getLong("advertiserId");
-                bytedanceMaterialReportService.getBytedanceMaterialVideo(adverId, null, null, null, 1, null, 1, 0, 1);
-            });
-        }
     }
 
     @GetMapping("/promoterDaily")
@@ -437,7 +420,7 @@ public class BytedanceController {
 
     @GetMapping("/advertiserPromoterHour")
     public void advertiserPromoterHour(String advertiserIds, String startDate, String endDate) {
-        for (String advertiserId : advertiserIds.split(",")){
+        for (String advertiserId : advertiserIds.split(",")) {
             executor10Service1.submit(() -> {
                 String accessToken = accountReportService.getTokenByAdvertiserId(Long.valueOf(advertiserId));
                 promoterReportService.getBytedancePromoterHour(Long.valueOf(advertiserId), accessToken, startDate, endDate, 1, 1);

+ 263 - 0
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/BytedanceAdvertiserFundDaily.java

@@ -0,0 +1,263 @@
+package cn.com.ctop.job.bytedance.data.entity;
+
+import java.math.BigDecimal;
+
+/**
+ * 广告主账户资金日统计(/open_api/2/advertiser/fund/daily_stat/ 返回,一天一条)
+ */
+public class BytedanceAdvertiserFundDaily {
+    private Long advertiserId;
+
+    /**
+     * 数据日期 yyyyMMdd
+     */
+    private Integer statDate;
+
+    /**
+     * 余额(元)
+     */
+    private BigDecimal balance;
+
+    /**
+     * 现金消耗(元)
+     */
+    private BigDecimal cashCost;
+
+    /**
+     * 企业钱包消耗(元)
+     */
+    private BigDecimal companyWalletCost;
+
+    /**
+     * 补偿赠款消耗(元)
+     */
+    private BigDecimal compensationRewardCost;
+
+    /**
+     * 总消耗(元)
+     */
+    private BigDecimal cost;
+
+    /**
+     * 抵扣消耗(元)
+     */
+    private BigDecimal deductionCost;
+
+    /**
+     * 冻结(元)
+     */
+    private BigDecimal frozen;
+
+    /**
+     * 赠款余额(元)
+     */
+    private BigDecimal grantBalance;
+
+    /**
+     * 入账(元)
+     */
+    private BigDecimal income;
+
+    /**
+     * 非赠款余额(元)
+     */
+    private BigDecimal nonGrantBalance;
+
+    /**
+     * 实时优惠券消耗(元)
+     */
+    private BigDecimal realtimeCouponCost;
+
+    /**
+     * 返货奖励消耗(元)
+     */
+    private BigDecimal returnGoodsRewardCost;
+
+    /**
+     * 奖励消耗(元)
+     */
+    private BigDecimal rewardCost;
+
+    /**
+     * 共享钱包消耗(元)
+     */
+    private BigDecimal sharedWalletCost;
+
+    /**
+     * 转入(元)
+     */
+    private BigDecimal transferIn;
+
+    /**
+     * 转出(元)
+     */
+    private BigDecimal transferOut;
+
+    public Long getAdvertiserId() {
+        return advertiserId;
+    }
+
+    public void setAdvertiserId(Long advertiserId) {
+        this.advertiserId = advertiserId;
+    }
+
+    public Integer getStatDate() {
+        return statDate;
+    }
+
+    public void setStatDate(Integer statDate) {
+        this.statDate = statDate;
+    }
+
+    public BigDecimal getBalance() {
+        return balance;
+    }
+
+    public void setBalance(BigDecimal balance) {
+        this.balance = balance;
+    }
+
+    public BigDecimal getCashCost() {
+        return cashCost;
+    }
+
+    public void setCashCost(BigDecimal cashCost) {
+        this.cashCost = cashCost;
+    }
+
+    public BigDecimal getCompanyWalletCost() {
+        return companyWalletCost;
+    }
+
+    public void setCompanyWalletCost(BigDecimal companyWalletCost) {
+        this.companyWalletCost = companyWalletCost;
+    }
+
+    public BigDecimal getCompensationRewardCost() {
+        return compensationRewardCost;
+    }
+
+    public void setCompensationRewardCost(BigDecimal compensationRewardCost) {
+        this.compensationRewardCost = compensationRewardCost;
+    }
+
+    public BigDecimal getCost() {
+        return cost;
+    }
+
+    public void setCost(BigDecimal cost) {
+        this.cost = cost;
+    }
+
+    public BigDecimal getDeductionCost() {
+        return deductionCost;
+    }
+
+    public void setDeductionCost(BigDecimal deductionCost) {
+        this.deductionCost = deductionCost;
+    }
+
+    public BigDecimal getFrozen() {
+        return frozen;
+    }
+
+    public void setFrozen(BigDecimal frozen) {
+        this.frozen = frozen;
+    }
+
+    public BigDecimal getGrantBalance() {
+        return grantBalance;
+    }
+
+    public void setGrantBalance(BigDecimal grantBalance) {
+        this.grantBalance = grantBalance;
+    }
+
+    public BigDecimal getIncome() {
+        return income;
+    }
+
+    public void setIncome(BigDecimal income) {
+        this.income = income;
+    }
+
+    public BigDecimal getNonGrantBalance() {
+        return nonGrantBalance;
+    }
+
+    public void setNonGrantBalance(BigDecimal nonGrantBalance) {
+        this.nonGrantBalance = nonGrantBalance;
+    }
+
+    public BigDecimal getRealtimeCouponCost() {
+        return realtimeCouponCost;
+    }
+
+    public void setRealtimeCouponCost(BigDecimal realtimeCouponCost) {
+        this.realtimeCouponCost = realtimeCouponCost;
+    }
+
+    public BigDecimal getReturnGoodsRewardCost() {
+        return returnGoodsRewardCost;
+    }
+
+    public void setReturnGoodsRewardCost(BigDecimal returnGoodsRewardCost) {
+        this.returnGoodsRewardCost = returnGoodsRewardCost;
+    }
+
+    public BigDecimal getRewardCost() {
+        return rewardCost;
+    }
+
+    public void setRewardCost(BigDecimal rewardCost) {
+        this.rewardCost = rewardCost;
+    }
+
+    public BigDecimal getSharedWalletCost() {
+        return sharedWalletCost;
+    }
+
+    public void setSharedWalletCost(BigDecimal sharedWalletCost) {
+        this.sharedWalletCost = sharedWalletCost;
+    }
+
+    public BigDecimal getTransferIn() {
+        return transferIn;
+    }
+
+    public void setTransferIn(BigDecimal transferIn) {
+        this.transferIn = transferIn;
+    }
+
+    public BigDecimal getTransferOut() {
+        return transferOut;
+    }
+
+    public void setTransferOut(BigDecimal transferOut) {
+        this.transferOut = transferOut;
+    }
+
+    @Override
+    public String toString() {
+        return "BytedanceAdvertiserFundDaily{" +
+                "advertiserId=" + advertiserId +
+                ", statDate=" + statDate +
+                ", balance=" + balance +
+                ", cashCost=" + cashCost +
+                ", companyWalletCost=" + companyWalletCost +
+                ", compensationRewardCost=" + compensationRewardCost +
+                ", cost=" + cost +
+                ", deductionCost=" + deductionCost +
+                ", frozen=" + frozen +
+                ", grantBalance=" + grantBalance +
+                ", income=" + income +
+                ", nonGrantBalance=" + nonGrantBalance +
+                ", realtimeCouponCost=" + realtimeCouponCost +
+                ", returnGoodsRewardCost=" + returnGoodsRewardCost +
+                ", rewardCost=" + rewardCost +
+                ", sharedWalletCost=" + sharedWalletCost +
+                ", transferIn=" + transferIn +
+                ", transferOut=" + transferOut +
+                '}';
+    }
+}

+ 414 - 0
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/BytedanceMaterialReportDaily.java

@@ -0,0 +1,414 @@
+package cn.com.ctop.job.bytedance.data.entity;
+
+import java.math.BigDecimal;
+
+
+/**
+ * 头条素材日报对象 media_bytedance_material_report_daily
+ *
+ * @author ruoyi
+ * @date 2025-03-07
+ */
+public class BytedanceMaterialReportDaily {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 广告主ID
+     */
+    private Long advertiserId;
+
+    /**
+     * 数据起始时间
+     */
+    private Integer statTimeDay;
+
+    /**
+     * 素材ID
+     */
+    private Long materialId;
+
+    /**
+     * 素材形式
+     */
+    private String imageMode;
+
+    /**
+     * 素材名称
+     */
+    private String materialName;
+
+    /**
+     * 播放链接
+     */
+    private String videoUrl;
+
+    /**
+     * 封面图
+     */
+    private String coverImageUrl;
+
+    /**
+     * 应用下载数据-付费金额
+     */
+    private BigDecimal statPayAmount;
+
+    /**
+     * 展现数据-总花费
+     */
+    private BigDecimal statCost;
+
+    /**
+     * 应用下载数据–激活数
+     */
+    private Long active;
+
+    /**
+     * 应用下载数据-注册数
+     */
+    private Long eventRegister;
+
+    /**
+     * 下载完成数
+     */
+    private Long downloadFinishCnt;
+
+    /**
+     * 次留人数
+     */
+    private Long attributionNextDayOpenCnt;
+
+    /**
+     * 关键行为数
+     */
+    private Long gameAddiction;
+
+    /**
+     * 激活当日在APP内的付费金额
+     */
+    private BigDecimal attributionGameInAppLtv1day;
+
+    /**
+     * 媒体|深度转化数(计费时间)
+     */
+    private Long attributionDeepConvertCnt;
+
+    /**
+     * 付费次数
+     */
+    private Long gamePayCount;
+
+    /**
+     * 转化数据-转化数
+     */
+    private Long convertCnt;
+
+    /**
+     * 展现数据-展示数
+     */
+    private Long showCnt;
+
+    /**
+     * 首次付费数
+     */
+    private Long activePay;
+
+    /**
+     * 展现数据-点击数
+     */
+    private Long clickCnt;
+
+    /**
+     * 展现数据-点击数
+     */
+    private Long clickStartCnt;
+
+    /**
+     * 媒体|转化数(计费时间)
+     */
+    private Long attributionConvertCnt;
+
+    /**
+     * 转化数据-深度转化数
+     */
+    private Long deepConvertCnt;
+
+    /**
+     * 有效播放数
+     */
+    private Long validPlay;
+
+    /**
+     * 计费当日付费金额
+     */
+    private BigDecimal attributionBillingGameInAppLtv1day;
+    private BigDecimal attributionMicroGame0dLtv;
+    private BigDecimal attributionMicroGame3dLtv;
+    private BigDecimal attributionMicroGame7dLtv;
+
+    public Long getEventRegister() {
+        return eventRegister;
+    }
+
+    public void setEventRegister(Long eventRegister) {
+        this.eventRegister = eventRegister;
+    }
+
+    public Long getAdvertiserId() {
+        return advertiserId;
+    }
+
+    public void setAdvertiserId(Long advertiserId) {
+        this.advertiserId = advertiserId;
+    }
+
+    public Integer getStatTimeDay() {
+        return statTimeDay;
+    }
+
+    public void setStatTimeDay(Integer statTimeDay) {
+        this.statTimeDay = statTimeDay;
+    }
+
+    public Long getMaterialId() {
+        return materialId;
+    }
+
+    public void setMaterialId(Long materialId) {
+        this.materialId = materialId;
+    }
+
+    public String getImageMode() {
+        return imageMode;
+    }
+
+    public void setImageMode(String imageMode) {
+        this.imageMode = imageMode;
+    }
+
+    public String getMaterialName() {
+        return materialName;
+    }
+
+    public void setMaterialName(String materialName) {
+        this.materialName = materialName;
+    }
+
+    public String getVideoUrl() {
+        return videoUrl;
+    }
+
+    public void setVideoUrl(String videoUrl) {
+        this.videoUrl = videoUrl;
+    }
+
+    public String getCoverImageUrl() {
+        return coverImageUrl;
+    }
+
+    public void setCoverImageUrl(String coverImageUrl) {
+        this.coverImageUrl = coverImageUrl;
+    }
+
+    public BigDecimal getStatPayAmount() {
+        return statPayAmount;
+    }
+
+    public void setStatPayAmount(BigDecimal statPayAmount) {
+        this.statPayAmount = statPayAmount;
+    }
+
+    public BigDecimal getStatCost() {
+        return statCost;
+    }
+
+    public void setStatCost(BigDecimal statCost) {
+        this.statCost = statCost;
+    }
+
+    public Long getActive() {
+        return active;
+    }
+
+    public void setActive(Long active) {
+        this.active = active;
+    }
+
+    public Long getDownloadFinishCnt() {
+        return downloadFinishCnt;
+    }
+
+    public void setDownloadFinishCnt(Long downloadFinishCnt) {
+        this.downloadFinishCnt = downloadFinishCnt;
+    }
+
+    public Long getAttributionNextDayOpenCnt() {
+        return attributionNextDayOpenCnt;
+    }
+
+    public void setAttributionNextDayOpenCnt(Long attributionNextDayOpenCnt) {
+        this.attributionNextDayOpenCnt = attributionNextDayOpenCnt;
+    }
+
+    public Long getGameAddiction() {
+        return gameAddiction;
+    }
+
+    public void setGameAddiction(Long gameAddiction) {
+        this.gameAddiction = gameAddiction;
+    }
+
+    public BigDecimal getAttributionGameInAppLtv1day() {
+        return attributionGameInAppLtv1day;
+    }
+
+    public void setAttributionGameInAppLtv1day(BigDecimal attributionGameInAppLtv1day) {
+        this.attributionGameInAppLtv1day = attributionGameInAppLtv1day;
+    }
+
+    public Long getAttributionDeepConvertCnt() {
+        return attributionDeepConvertCnt;
+    }
+
+    public void setAttributionDeepConvertCnt(Long attributionDeepConvertCnt) {
+        this.attributionDeepConvertCnt = attributionDeepConvertCnt;
+    }
+
+    public Long getGamePayCount() {
+        return gamePayCount;
+    }
+
+    public void setGamePayCount(Long gamePayCount) {
+        this.gamePayCount = gamePayCount;
+    }
+
+    public Long getConvertCnt() {
+        return convertCnt;
+    }
+
+    public void setConvertCnt(Long convertCnt) {
+        this.convertCnt = convertCnt;
+    }
+
+    public Long getShowCnt() {
+        return showCnt;
+    }
+
+    public void setShowCnt(Long showCnt) {
+        this.showCnt = showCnt;
+    }
+
+    public Long getActivePay() {
+        return activePay;
+    }
+
+    public void setActivePay(Long activePay) {
+        this.activePay = activePay;
+    }
+
+    public Long getClickCnt() {
+        return clickCnt;
+    }
+
+    public void setClickCnt(Long clickCnt) {
+        this.clickCnt = clickCnt;
+    }
+
+    public Long getClickStartCnt() {
+        return clickStartCnt;
+    }
+
+    public void setClickStartCnt(Long clickStartCnt) {
+        this.clickStartCnt = clickStartCnt;
+    }
+
+    public Long getAttributionConvertCnt() {
+        return attributionConvertCnt;
+    }
+
+    public void setAttributionConvertCnt(Long attributionConvertCnt) {
+        this.attributionConvertCnt = attributionConvertCnt;
+    }
+
+    public Long getDeepConvertCnt() {
+        return deepConvertCnt;
+    }
+
+    public void setDeepConvertCnt(Long deepConvertCnt) {
+        this.deepConvertCnt = deepConvertCnt;
+    }
+
+    public Long getValidPlay() {
+        return validPlay;
+    }
+
+    public void setValidPlay(Long validPlay) {
+        this.validPlay = validPlay;
+    }
+
+    public BigDecimal getAttributionBillingGameInAppLtv1day() {
+        return attributionBillingGameInAppLtv1day;
+    }
+
+    public void setAttributionBillingGameInAppLtv1day(BigDecimal attributionBillingGameInAppLtv1day) {
+        this.attributionBillingGameInAppLtv1day = attributionBillingGameInAppLtv1day;
+    }
+
+    public BigDecimal getAttributionMicroGame0dLtv() {
+        return attributionMicroGame0dLtv;
+    }
+
+    public void setAttributionMicroGame0dLtv(BigDecimal attributionMicroGame0dLtv) {
+        this.attributionMicroGame0dLtv = attributionMicroGame0dLtv;
+    }
+
+    public BigDecimal getAttributionMicroGame3dLtv() {
+        return attributionMicroGame3dLtv;
+    }
+
+    public void setAttributionMicroGame3dLtv(BigDecimal attributionMicroGame3dLtv) {
+        this.attributionMicroGame3dLtv = attributionMicroGame3dLtv;
+    }
+
+    public BigDecimal getAttributionMicroGame7dLtv() {
+        return attributionMicroGame7dLtv;
+    }
+
+    public void setAttributionMicroGame7dLtv(BigDecimal attributionMicroGame7dLtv) {
+        this.attributionMicroGame7dLtv = attributionMicroGame7dLtv;
+    }
+
+    @Override
+    public String toString() {
+        return "BytedanceMaterialReportDaily{" +
+                "advertiserId=" + advertiserId +
+                ", statTimeDay=" + statTimeDay +
+                ", materialId=" + materialId +
+                ", imageMode='" + imageMode + '\'' +
+                ", materialName='" + materialName + '\'' +
+                ", videoUrl='" + videoUrl + '\'' +
+                ", coverImageUrl='" + coverImageUrl + '\'' +
+                ", statPayAmount=" + statPayAmount +
+                ", statCost=" + statCost +
+                ", active=" + active +
+                ", eventRegister=" + eventRegister +
+                ", downloadFinishCnt=" + downloadFinishCnt +
+                ", attributionNextDayOpenCnt=" + attributionNextDayOpenCnt +
+                ", gameAddiction=" + gameAddiction +
+                ", attributionGameInAppLtv1day=" + attributionGameInAppLtv1day +
+                ", attributionDeepConvertCnt=" + attributionDeepConvertCnt +
+                ", gamePayCount=" + gamePayCount +
+                ", convertCnt=" + convertCnt +
+                ", showCnt=" + showCnt +
+                ", activePay=" + activePay +
+                ", clickCnt=" + clickCnt +
+                ", clickStartCnt=" + clickStartCnt +
+                ", attributionConvertCnt=" + attributionConvertCnt +
+                ", deepConvertCnt=" + deepConvertCnt +
+                ", validPlay=" + validPlay +
+                ", attributionBillingGameInAppLtv1day=" + attributionBillingGameInAppLtv1day +
+                ", attributionMicroGame0dLtv=" + attributionMicroGame0dLtv +
+                ", attributionMicroGame3dLtv=" + attributionMicroGame3dLtv +
+                ", attributionMicroGame7dLtv=" + attributionMicroGame7dLtv +
+                '}';
+    }
+}

+ 7 - 0
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/AdvertiserFundGetDailyMapper.java

@@ -0,0 +1,7 @@
+package cn.com.ctop.job.bytedance.data.mapper;
+
+import cn.com.ctop.job.bytedance.data.entity.BytedanceAdvertiserFundDaily;
+
+public interface AdvertiserFundGetDailyMapper {
+    void insertData(BytedanceAdvertiserFundDaily advertiserFundDaily);
+}

+ 11 - 0
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/BytedanceMaterialReportMapper.java

@@ -0,0 +1,11 @@
+package cn.com.ctop.job.bytedance.data.mapper;
+
+import cn.com.ctop.job.bytedance.data.entity.BytedanceMaterialReportDaily;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface BytedanceMaterialReportMapper {
+
+    void replaceMaterialReportDailies(@Param("list") List<BytedanceMaterialReportDaily> materialReportDailies);
+}

+ 46 - 0
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/AdvertiserFundGetDailyMapper.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="cn.com.ctop.job.bytedance.data.mapper.AdvertiserFundGetDailyMapper">
+
+    <insert id="insertData">
+        replace INTO nuojing_data.media_bytedance_advertiser_fund_daily (
+            advertiser_id,
+            stat_date,
+            balance,
+            cash_cost,
+            company_wallet_cost,
+            compensation_reward_cost,
+            cost,
+            deduction_cost,
+            frozen,
+            grant_balance,
+            income,
+            non_grant_balance,
+            realtime_coupon_cost,
+            return_goods_reward_cost,
+            reward_cost,
+            shared_wallet_cost,
+            transfer_in,
+            transfer_out
+        ) VALUES (
+                     #{advertiserId},
+                     #{statDate},
+                     #{balance},
+                     #{cashCost},
+                     #{companyWalletCost},
+                     #{compensationRewardCost},
+                     #{cost},
+                     #{deductionCost},
+                     #{frozen},
+                     #{grantBalance},
+                     #{income},
+                     #{nonGrantBalance},
+                     #{realtimeCouponCost},
+                     #{returnGoodsRewardCost},
+                     #{rewardCost},
+                     #{sharedWalletCost},
+                     #{transferIn},
+                     #{transferOut}
+                 )
+    </insert>
+</mapper>

+ 1 - 1
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/AdvertiserFundGetMapper.xml

@@ -4,7 +4,7 @@
 
 
     <insert id="insertData">
-        replace INTO nuojing_data.bytedance_advertiser_fund (
+        replace INTO nuojing_data.media_bytedance_advertiser_fund (
             advertiser_id,
             stat_date,
             wallet_total_balance_valid,

+ 71 - 0
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/BytedanceMaterialReportMapper.xml

@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="cn.com.ctop.job.bytedance.data.mapper.BytedanceMaterialReportMapper">
+    <insert id="replaceMaterialReportDailies" parameterType="java.util.List">
+        replace into nuojing_data.media_bytedance_material_report_daily (
+        advertiser_id,
+        stat_time_day,
+        material_id,
+        image_mode,
+        material_name,
+        video_url,
+        cover_image_url,
+        stat_pay_amount,
+        stat_cost,
+        `active`,
+        event_register,
+        download_finish_cnt,
+        attribution_next_day_open_cnt,
+        game_addiction,
+        attribution_game_in_app_ltv_1day,
+        attribution_deep_convert_cnt,
+        game_pay_count,
+        convert_cnt,
+        show_cnt,
+        active_pay,
+        click_cnt,
+        click_start_cnt,
+        attribution_convert_cnt,
+        deep_convert_cnt,
+        valid_play,
+        attribution_billing_game_in_app_ltv_1day,
+        attribution_micro_game_0d_ltv,
+        attribution_micro_game_3d_ltv,
+        attribution_micro_game_7d_ltv
+        )
+        values
+        <foreach collection="list" item="item" separator=",">
+            (
+            #{item.advertiserId},
+            #{item.statTimeDay},
+            #{item.materialId},
+            #{item.imageMode},
+            #{item.materialName},
+            #{item.videoUrl},
+            #{item.coverImageUrl},
+            #{item.statPayAmount},
+            #{item.statCost},
+            #{item.active},
+            #{item.eventRegister},
+            #{item.downloadFinishCnt},
+            #{item.attributionNextDayOpenCnt},
+            #{item.gameAddiction},
+            #{item.attributionGameInAppLtv1day},
+            #{item.attributionDeepConvertCnt},
+            #{item.gamePayCount},
+            #{item.convertCnt},
+            #{item.showCnt},
+            #{item.activePay},
+            #{item.clickCnt},
+            #{item.clickStartCnt},
+            #{item.attributionConvertCnt},
+            #{item.deepConvertCnt},
+            #{item.validPlay},
+            #{item.attributionBillingGameInAppLtv1day},
+            #{item.attributionMicroGame0dLtv},
+            #{item.attributionMicroGame3dLtv},
+            #{item.attributionMicroGame7dLtv}
+            )
+        </foreach>
+    </insert>
+</mapper>

+ 2 - 0
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IAdvertiserFundGetServer.java

@@ -2,4 +2,6 @@ package cn.com.ctop.job.bytedance.data.service;
 
 public interface IAdvertiserFundGetServer {
     void getAdvertiserFundGet(Long advertiserId, String accessToken);
+
+    void getAdvertiserFundDaily(Long advertiserId, String accessToken);
 }

+ 1 - 5
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IBytedanceMaterialReportService.java

@@ -1,10 +1,6 @@
 package cn.com.ctop.job.bytedance.data.service;
 
-import java.util.Set;
-
 public interface IBytedanceMaterialReportService {
-    void getBytedanceMaterialDailyReport(Long advertiserId, String startDate, String endDate, Integer page,
+    void getBytedanceMaterialDailyReport(Long advertiserId,String accessToken, String startDate, String endDate, Integer page,
                                          Long errorId, Integer isLog, Integer isSend, int retry);
-
-    void getBytedanceMaterialVideo(Long advertiserId, Set<Long> materialIds, String startTime, String endTime, Integer page, Long errorId, Integer isLog, Integer isSend, int retry);
 }

+ 52 - 1
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/AdvertiserFundGetServerImpl.java

@@ -1,12 +1,15 @@
 package cn.com.ctop.job.bytedance.data.service.impl;
 
 import cn.com.ctop.job.bytedance.data.entity.BytedanceAdvertiserFund;
+import cn.com.ctop.job.bytedance.data.entity.BytedanceAdvertiserFundDaily;
+import cn.com.ctop.job.bytedance.data.mapper.AdvertiserFundGetDailyMapper;
 import cn.com.ctop.job.bytedance.data.mapper.AdvertiserFundGetMapper;
 import cn.com.ctop.job.bytedance.data.service.IAdvertiserFundGetServer;
 import cn.com.ctop.job.bytedance.data.utils.Check;
 import cn.com.ctop.job.bytedance.data.utils.DateUtils;
 import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
 import cn.com.ctop.job.bytedance.utils.RateLimitUtil;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,9 +25,12 @@ public class AdvertiserFundGetServerImpl implements IAdvertiserFundGetServer {
     private AdvertiserFundGetMapper advertiserFundGetMapper;
 
     @Autowired
+    private AdvertiserFundGetDailyMapper advertiserFundGetDailyMapper;
+
+    @Autowired
     private RateLimitUtil rateLimitUtil;
 
-    private static String devAppId = "1742489802322972";
+    private static String devAppId = "1876837323659296";
 
     @Override
     public void getAdvertiserFundGet(Long advertiserId, String accessToken) {
@@ -59,6 +65,51 @@ public class AdvertiserFundGetServerImpl implements IAdvertiserFundGetServer {
         BytedanceAdvertiserFund advertiserFund = JSONObject.parseObject(data.toJSONString(), BytedanceAdvertiserFund.class);
         advertiserFund.setStatDate(statDate);
         advertiserFundGetMapper.insertData(advertiserFund);
+    }
+
+    @Override
+    public void getAdvertiserFundDaily(Long advertiserId, String accessToken) {
+        String yesterday = DateUtils.getNowAddDate("yyyy-MM-dd", -1);
+        String dailyStatUrl = "https://ad.oceanengine.com/open_api/2/advertiser/fund/daily_stat/";
+        Map<String, Object> dailyParams = new HashMap<>();
+        dailyParams.put("advertiser_id", advertiserId);
+        dailyParams.put("start_date", yesterday);
+        dailyParams.put("end_date", yesterday);
+        dailyParams.put("page", 1);
+        dailyParams.put("page_size", 100);
 
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", accessToken);
+        headers.put("Content-Type", "application/json;charset=UTF-8");
+        try {
+            String dailyResp = null;
+            if (rateLimitUtil.acquire(devAppId, dailyStatUrl)) {
+                dailyResp = HttpUtils.httpGet(dailyStatUrl, dailyParams, headers);
+            }
+            JSONObject dailyResult = Check.isNull(dailyResp) ? null : JSONObject.parseObject(dailyResp);
+            if (Check.isNull(dailyResult)) {
+                log.info("获取账户昨日资金日统计返回为空,账户id:{}", advertiserId);
+                return;
+            }
+            if (dailyResult.getInteger("code") != 0) {
+                log.error("获取账户昨日资金日统计失败,账户ID:{},返回信息:{}", advertiserId, dailyResult);
+                return;
+            }
+            JSONObject dailyData = dailyResult.getJSONObject("data");
+            JSONArray list = Check.isNull(dailyData) ? null : dailyData.getJSONArray("list");
+            if (Check.isNull(list) || list.isEmpty()) {
+                log.info("账户昨日资金日统计数据为空,账户id:{},日期:{}", advertiserId, yesterday);
+                return;
+            }
+            Integer statDate = DateUtils.getDateInteger(yesterday);
+            for (int i = 0; i < list.size(); i++) {
+                BytedanceAdvertiserFundDaily fundDaily = list.getObject(i, BytedanceAdvertiserFundDaily.class);
+                fundDaily.setAdvertiserId(advertiserId);
+                fundDaily.setStatDate(statDate);
+                advertiserFundGetDailyMapper.insertData(fundDaily);
+            }
+        } catch (Exception e) {
+            log.error("获取账户昨日资金日统计异常,账户ID:{}", advertiserId, e);
+        }
     }
 }

+ 0 - 1
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BytedanceAccountReportServiceImpl.java

@@ -281,7 +281,6 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
     public void getBytedanceAccountDaily(Long advertiserId, String accessToken, String startDate, String endDate, Integer page, Integer isLog) {
         try {
 
-
             String url = "https://api.oceanengine.com/open_api/v3.0/report/custom/get/";
             Map<String, Object> paramsMap = new HashMap<>();
             paramsMap.put("advertiser_id", advertiserId);

+ 100 - 120
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BytedanceMaterialReportServiceImpl.java

@@ -1,6 +1,8 @@
 package cn.com.ctop.job.bytedance.data.service.impl;
 
 import cn.com.ctop.job.bytedance.data.entity.BytedanceErrorLog;
+import cn.com.ctop.job.bytedance.data.entity.BytedanceMaterialReportDaily;
+import cn.com.ctop.job.bytedance.data.mapper.BytedanceMaterialReportMapper;
 import cn.com.ctop.job.bytedance.data.mapper.BytedancePromoterReportMapper;
 import cn.com.ctop.job.bytedance.data.mapper.BytedanceRefreshTokenMapper;
 import cn.com.ctop.job.bytedance.data.service.IBytedanceMaterialReportService;
@@ -8,6 +10,7 @@ import cn.com.ctop.job.bytedance.data.utils.AlertUtils;
 import cn.com.ctop.job.bytedance.data.utils.Check;
 import cn.com.ctop.job.bytedance.data.utils.FieldsConfig;
 import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
+import cn.com.ctop.job.bytedance.data.utils.JsonUtils;
 import cn.com.ctop.job.bytedance.utils.RateLimitUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -19,7 +22,6 @@ import org.springframework.stereotype.Service;
 
 import java.time.Duration;
 import java.util.*;
-import java.util.stream.Collectors;
 
 @Service
 @Slf4j
@@ -27,21 +29,18 @@ public class BytedanceMaterialReportServiceImpl implements IBytedanceMaterialRep
     @Autowired
     private BytedancePromoterReportMapper promoterReportMapper;
     @Autowired
-    private BytedanceRefreshTokenMapper tokenMapper;
+    private BytedanceMaterialReportMapper materialReportMapper;
     @Autowired
-    private RedisTemplate redisTemplate_db2;
+    private BytedanceRefreshTokenMapper tokenMapper;
     @Autowired
     private RateLimitUtil rateLimitUtil;
+    @Autowired
+    private RedisTemplate redisTemplate_db2;
+    private static String devAppId = "1876837323659296"; // ByteDance Developer App ID
 
     @Override
-    public void getBytedanceMaterialDailyReport(Long advertiserId, String startDate, String endDate, Integer page, Long errorId, Integer isLog, Integer isSend, int retry) {
+    public void getBytedanceMaterialDailyReport(Long advertiserId,String accessToken,  String startDate, String endDate, Integer page, Long errorId, Integer isLog, Integer isSend, int retry) {
         try {
-            JSONObject authConfig = tokenMapper.getAuthConfig(advertiserId);
-            if (Check.isNull(authConfig)) {
-                log.info("账户id:{},获取素材日报token为空", advertiserId);
-            }
-            String accessToken = authConfig.getString("access_token");
-            String devAppId = authConfig.getString("app_id");
             String url = "https://api.oceanengine.com/open_api/v3.0/report/custom/get/";
             Map<String, Object> paramsMap = new HashMap<>();
             paramsMap.put("advertiser_id", advertiserId);
@@ -62,14 +61,15 @@ public class BytedanceMaterialReportServiceImpl implements IBytedanceMaterialRep
                 s = HttpUtils.httpGet(url, paramsMap, headers);
             }
             JSONObject result = JSONObject.parseObject(s);
-            Set<Long> materialIds = new HashSet<>();
+            List<BytedanceMaterialReportDaily> materialReportDailies = new ArrayList<>();
+            Set<Long> videoIds = new HashSet<>();
             if (Check.isNull(result)) {
                 log.info("账户id:{},素材日报请求结果返回为空", advertiserId);
                 if (isLog == 1) {
                     BytedanceErrorLog errorInfo = new BytedanceErrorLog();
                     errorInfo.setAdvertiserId(advertiserId);
-                    errorInfo.setStartDate(startDate);
-                    errorInfo.setEndDate(endDate);
+                    errorInfo.setStartDate(Check.isNull(startDate) ? "" : startDate);
+                    errorInfo.setEndDate(Check.isNull(endDate) ? "" : endDate);
                     errorInfo.setDataDimension("material");
                     errorInfo.setDataType("daily");
                     errorInfo.setMsg("请求结果返回为空");
@@ -90,15 +90,23 @@ public class BytedanceMaterialReportServiceImpl implements IBytedanceMaterialRep
                             JSONObject metricsJson = rowJson.getJSONObject("metrics");
                             JSONObject dimensionsJson = rowJson.getJSONObject("dimensions");
 
-                            dimensionsJson.putAll(metricsJson);
-                            dimensionsJson.put("stat_time_day", dimensionsJson.getString("stat_time_day").replace("-", ""));
-                            dimensionsJson.put("advertiser_id", advertiserId);
-
                             Long materialId = dimensionsJson.getLong("material_id");
                             String imageMode = dimensionsJson.getString("image_mode");
-                            if (!materialIds.contains(materialId) && imageMode.contains("视频") && !redisTemplate_db2.hasKey("mvid:1:" + materialId)) {
-                                materialIds.add(materialId);
+                            // 标题素材行与视频素材行重复归因同一份消耗,剔除避免消耗统计翻倍
+                            if (imageMode != null && imageMode.contains("标题")) {
+                                continue;
+                            }
+                            if (imageMode != null && imageMode.contains("视频")) {
+                                videoIds.add(materialId);
                             }
+
+                            BytedanceMaterialReportDaily materialReportDaily = JSONObject.parseObject(JsonUtils.normalizeMetrics(metricsJson).toJSONString(), BytedanceMaterialReportDaily.class);
+                            materialReportDaily.setAdvertiserId(advertiserId);
+                            materialReportDaily.setStatTimeDay(Integer.valueOf(dimensionsJson.getString("stat_time_day").replace("-", "")));
+                            materialReportDaily.setMaterialId(materialId);
+                            materialReportDaily.setImageMode(imageMode);
+                            materialReportDaily.setMaterialName(dimensionsJson.getString("ad_platform_material_name"));
+                            materialReportDailies.add(materialReportDaily);
                         }
                     }
                 }
@@ -108,15 +116,15 @@ public class BytedanceMaterialReportServiceImpl implements IBytedanceMaterialRep
                         Thread.sleep(800);
                     } catch (Exception ignored) {
                     }
-                    getBytedanceMaterialDailyReport(advertiserId, startDate, endDate, page, errorId, isLog, isSend, retry + 1);
+                    getBytedanceMaterialDailyReport(advertiserId, accessToken,startDate, endDate, page, errorId, isLog, isSend, retry + 1);
                     return;
                 }
                 log.info("账户id:{},日期:{}素材日报请求结果失败,返回数据:{}", advertiserId, startDate, result);
                 if (isLog == 1) {
                     BytedanceErrorLog errorInfo = new BytedanceErrorLog();
                     errorInfo.setAdvertiserId(advertiserId);
-                    errorInfo.setStartDate(startDate);
-                    errorInfo.setEndDate(endDate);
+                    errorInfo.setStartDate(Check.isNull(startDate) ? "" : startDate);
+                    errorInfo.setEndDate(Check.isNull(endDate) ? "" : endDate);
                     errorInfo.setDataDimension("material");
                     errorInfo.setDataType("daily");
                     errorInfo.setMsg(result.getString("message"));
@@ -125,12 +133,13 @@ public class BytedanceMaterialReportServiceImpl implements IBytedanceMaterialRep
                 return;
             }
 
-            if (!Check.isNull(materialIds)) {
-                getBytedanceMaterialVideo(advertiserId, materialIds, null, null, 1, null, 1, null, 1);
+            if (!Check.isNull(materialReportDailies)) {
+                fillVideoInfo(advertiserId, accessToken, videoIds, materialReportDailies);
+                materialReportMapper.replaceMaterialReportDailies(materialReportDailies);
             }
 
             if (page < totalPage) {
-                getBytedanceMaterialDailyReport(advertiserId, startDate, endDate, page + 1, errorId, isLog, isSend, 1);
+                getBytedanceMaterialDailyReport(advertiserId, accessToken, startDate, endDate, page + 1, errorId, isLog, isSend, 1);
             } else {
                 log.info("账户ID:{}, 开始日期:{}, 结束日期:{}, totalPage:{}, 素材日报数据请求成功", advertiserId, startDate, endDate, totalPage);
                 if (errorId != null) {
@@ -146,110 +155,81 @@ public class BytedanceMaterialReportServiceImpl implements IBytedanceMaterialRep
         }
     }
 
-    public void getBytedanceMaterialVideo(Long advertiserId, Set<Long> materialIds, String startTime, String endTime, Integer page, Long errorId, Integer isLog, Integer isSend, int retry) {
-        try {
-            JSONObject authConfig = tokenMapper.getAuthConfig(advertiserId);
-            if (Check.isNull(authConfig) || authConfig.getString("access_token") == null) {
-                log.info("账户id:{},获取视频素材token为空", advertiserId);
+    /**
+     * 视频素材批量补充播放链接和封面图(每批最多100个),获取失败不影响指标数据落库
+     */
+    private void fillVideoInfo(Long advertiserId, String accessToken, Set<Long> videoIds, List<BytedanceMaterialReportDaily> materialReportDailies) {
+        if (Check.isNull(videoIds)) {
+            return;
+        }
+        Map<Long, JSONObject> videoInfoMap = new HashMap<>();
+        // 优先从redis缓存取视频地址(以素材ID为key),取不到的再批量调接口
+        List<Long> missIds = new ArrayList<>();
+        for (Long materialId : videoIds) {
+            Object cache = redisTemplate_db2.opsForValue().get("mvid:info:" + materialId);
+            if (!Check.isNull(cache)) {
+                videoInfoMap.put(materialId, JSONObject.parseObject(cache.toString()));
+            } else {
+                missIds.add(materialId);
             }
-            String accessToken = authConfig.getString("access_token");
-            String devAppId = authConfig.getString("app_id");
-
+        }
+        try {
             String url = "https://api.oceanengine.com/open_api/2/file/video/get/";
-            Map<String, Object> paramsMap = new HashMap<>();
-            paramsMap.put("advertiser_id", advertiserId);
-            JSONObject filtering = new JSONObject();
-            if (!Check.isNull(startTime) && !Check.isNull(endTime)) {
-                filtering.put("start_time", startTime);
-                filtering.put("end_time", endTime);
-            }
-            if (!Check.isNull(materialIds)) {
-                List<Long> collect = materialIds.stream().filter(id -> !redisTemplate_db2.hasKey("mvid:1:" + id)).collect(Collectors.toList());
-                if (!Check.isNull(collect)) {
-                    filtering.put("material_ids", collect);
-                } else {
-                    if (errorId != null) {
-                        promoterReportMapper.deleteInfoByErrorId(errorId);
-                    }
-                    return;
+            List<Long> materialIds = new ArrayList<>(missIds);
+            for (int i = 0; i < materialIds.size(); i += 100) {
+                List<Long> batch = materialIds.subList(i, Math.min(i + 100, materialIds.size()));
+                Map<String, Object> paramsMap = new HashMap<>();
+                paramsMap.put("advertiser_id", advertiserId);
+                JSONObject filtering = new JSONObject();
+                filtering.put("material_ids", batch);
+                paramsMap.put("filtering", filtering);
+                paramsMap.put("page", 1);
+                paramsMap.put("page_size", 100);
+                Map<String, String> headers = new HashMap<>();
+                headers.put("Access-Token", accessToken);
+                headers.put("Content-Type", "application/json");
+                String s = null;
+                if (rateLimitUtil.acquire(devAppId, url)) {
+                    s = HttpUtils.httpGet(url, paramsMap, headers);
                 }
-            }
-            paramsMap.put("filtering", filtering);
-            paramsMap.put("page", page);
-            paramsMap.put("page_size", 100);
-            Map<String, String> headers = new HashMap<>();
-            headers.put("Access-Token", accessToken);
-            headers.put("Content-Type", "application/json");
-            String s = null;
-            if (rateLimitUtil.acquire(devAppId, url)) {
-                s = HttpUtils.httpGet(url, paramsMap, headers);
-            }
-            JSONObject result = JSONObject.parseObject(s);
-            if (Check.isNull(result)) {
-                log.info("账户id:{},获取视频素材结果返回为空", advertiserId);
-                if (isLog == 1) {
-                    BytedanceErrorLog errorInfo = new BytedanceErrorLog();
-                    errorInfo.setAdvertiserId(advertiserId);
-                    errorInfo.setStartDate(Check.isNull(startTime) ? "" : startTime);
-                    errorInfo.setEndDate(Check.isNull(endTime) ? "" : endTime);
-                    errorInfo.setDataDimension("material_video_get");
-                    errorInfo.setDataType("daily");
-                    errorInfo.setMsg(new JSONObject().fluentPut("msg", "结果为空").fluentPut("material_ids", materialIds).toJSONString());
-                    promoterReportMapper.replaceErrorInfo(errorInfo);
+                JSONObject result = JSONObject.parseObject(s);
+                if (Check.isNull(result) || result.getInteger("code") == null || result.getInteger("code") != 0) {
+                    log.info("账户id:{},获取视频素材播放链接失败,返回数据:{}", advertiserId, result);
+                    continue;
                 }
-                return;
-            }
-            Integer code = result.getInteger("code");
-            int totalPage = 1;
-            if (code == 0) {
                 JSONObject data = result.getJSONObject("data");
-                if (!Check.isNull(data)) {
-                    totalPage = data.getJSONObject("page_info").getIntValue("total_page");
-                    JSONArray rows = data.getJSONArray("list");
-                    if (!Check.isNull(rows)) {
-                        for (int i = 0; i < rows.size(); i++) {
-                            JSONObject rowJson = rows.getJSONObject(i);
-                            String materialId = rowJson.getString("material_id");
-                            redisTemplate_db2.opsForValue().set("mvid:1:" + materialId, materialId, Duration.ofSeconds(30 * 24 * 3600 + (int) (Math.random() * 7200)));
-                            rowJson.put("advertiser_id", advertiserId);
-                        }
-                    }
+                if (Check.isNull(data) || Check.isNull(data.getJSONArray("list"))) {
+                    continue;
                 }
-            } else {
-                if (retry <= 5 && code != 40110) {
-                    try {
-                        Thread.sleep(800);
-                    } catch (Exception ignored) {
-                    }
-                    getBytedanceMaterialVideo(advertiserId, materialIds, startTime, endTime, page, errorId, isLog, isSend, retry + 1);
-                    return;
-                }
-                log.info("账户id:{},日期:{}获取视频素材失败,返回数据:{}", advertiserId, startTime, result);
-                if (isLog == 1) {
-                    BytedanceErrorLog errorInfo = new BytedanceErrorLog();
-                    errorInfo.setAdvertiserId(advertiserId);
-                    errorInfo.setStartDate(Check.isNull(startTime) ? "" : startTime);
-                    errorInfo.setEndDate(Check.isNull(endTime) ? "" : endTime);
-                    errorInfo.setDataDimension("material_video_get");
-                    errorInfo.setDataType("daily");
-                    errorInfo.setMsg(result.fluentPut("material_ids", materialIds).toJSONString());
-                    promoterReportMapper.replaceErrorInfo(errorInfo);
-                }
-                return;
-            }
-            if (page < totalPage) {
-                getBytedanceMaterialVideo(advertiserId, materialIds, startTime, endTime, page + 1, errorId, isLog, isSend, 1);
-            } else {
-                log.info("账户ID:{}, 开始日期:{}, 结束日期:{}, totalPage:{}, 获取视频素材成功", advertiserId, startTime, endTime, totalPage);
-                if (errorId != null) {
-                    promoterReportMapper.deleteInfoByErrorId(errorId);
-                }
-                if (isSend != null && 1 == isSend) {
-                    AlertUtils.sendMessage(advertiserId, startTime, endTime, 1, "material", 1, null);
+                JSONArray list = data.getJSONArray("list");
+                for (int j = 0; j < list.size(); j++) {
+                    JSONObject rowJson = list.getJSONObject(j);
+                    Long materialId = rowJson.getLong("material_id");
+                    // 接口实际返回字段:url=播放地址,poster_url=封面图
+                    String videoUrl = Check.isNull(rowJson.getString("url")) ? rowJson.getString("video_url") : rowJson.getString("url");
+                    String coverImageUrl = Check.isNull(rowJson.getString("poster_url")) ? rowJson.getString("cover_image_url") : rowJson.getString("poster_url");
+                    rowJson.put("video_url", videoUrl);
+                    rowJson.put("cover_image_url", coverImageUrl);
+                    videoInfoMap.put(materialId, rowJson);
+                    // 缓存视频和封面地址,30天+随机0~2小时过期
+                    JSONObject cacheJson = new JSONObject();
+                    cacheJson.put("video_url", videoUrl);
+                    cacheJson.put("cover_image_url", coverImageUrl);
+                    redisTemplate_db2.opsForValue().set("mvid:info:" + materialId, cacheJson.toJSONString(), Duration.ofSeconds(30 * 24 * 3600 + (int) (Math.random() * 7200)));
                 }
             }
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("账户id:{},获取视频素材播放链接异常", advertiserId, e);
+        }
+        if (Check.isNull(videoInfoMap)) {
+            return;
+        }
+        for (BytedanceMaterialReportDaily reportDaily : materialReportDailies) {
+            JSONObject videoInfo = videoInfoMap.get(reportDaily.getMaterialId());
+            if (!Check.isNull(videoInfo)) {
+                reportDaily.setVideoUrl(videoInfo.getString("video_url"));
+                reportDaily.setCoverImageUrl(videoInfo.getString("cover_image_url"));
+            }
         }
     }
 }

+ 0 - 5
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/utils/FieldsConfig.java

@@ -51,14 +51,9 @@ public class FieldsConfig {
     public static JSONArray getMaterialDailyDimensions() {
         JSONArray dimensions = new JSONArray();
         dimensions.add("stat_time_day");
-        dimensions.add("cdp_project_id");
-        dimensions.add("cdp_project_name");
-        dimensions.add("cdp_promotion_id");
-        dimensions.add("cdp_promotion_name");
         dimensions.add("material_id");
         dimensions.add("image_mode");
         dimensions.add("ad_platform_material_name");
-        dimensions.add("ad_platform_material_content");
         return dimensions;
 
     }

+ 21 - 0
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/AdvertiserFundGetJob.java

@@ -43,5 +43,26 @@ public class AdvertiserFundGetJob {
 
     }
 
+    @XxlJob("getAdvertiserFundDaily")
+    public void getAdvertiserFundDaily() throws Exception {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String[] s = param.split("_");
+        Long advertiserId = Long.valueOf(s[0]);
+        String accessToken = s[1];
+        executorService.submit(new Runnable() {
+            @Override
+            public void run() {
+                advertiserFundGetServer.getAdvertiserFundDaily(advertiserId, accessToken);
+
+            }
+        });
+
+
+    }
+
 
 }

+ 1 - 1
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedancePromoterReportJob.java

@@ -45,7 +45,7 @@ public class BytedancePromoterReportJob {
         dailyExecutorService.submit(new Runnable() {
             @Override
             public void run() {
-                bytedanceMaterialReportService.getBytedanceMaterialDailyReport(advertiserId, date, date, 1, null, 1, 0, 1);
+                bytedanceMaterialReportService.getBytedanceMaterialDailyReport(advertiserId, accessToken, date, date, 1, null, 1, 0, 1);
             }
         });
     }

+ 1 - 13
nj_job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceReportRetryJob.java

@@ -128,19 +128,7 @@ public class BytedanceReportRetryJob {
                     materialRetrExecutor.submit(new Runnable() {
                         @Override
                         public void run() {
-                            bytedanceMaterialReportService.getBytedanceMaterialDailyReport(advertiserId, startDate, endDate, 1, id, null, isSend, 1);
-                        }
-                    });
-                } else if ("material_video_get".equals(dataDimension)) {
-                    HashSet<Long> materialIds = new HashSet<>();
-                    JSONObject msgObject = JSONObject.parseObject(msg);
-                    if (msgObject != null && msgObject.getJSONArray("material_ids") != null) {
-                        materialIds.addAll(msgObject.getJSONArray("material_ids").toJavaList(Long.class));
-                    }
-                    materialRetrExecutor.submit(new Runnable() {
-                        @Override
-                        public void run() {
-                            bytedanceMaterialReportService.getBytedanceMaterialVideo(advertiserId, materialIds, startDate, endDate, 1, id, null, isSend, 1);
+                            bytedanceMaterialReportService.getBytedanceMaterialDailyReport(advertiserId, accessToken, startDate, endDate, 1, id, null, isSend, 1);
                         }
                     });
                 } else if ("promotion_list".equals(dataDimension)) {