Parcourir la source

创意时报加入MD5

yumeng il y a 5 ans
Parent
commit
7ea5a41626

+ 7 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCreativeService.java

@@ -14,4 +14,11 @@ import java.util.List;
 public interface IKuaiShouCreativeService extends IService<KuaiShouCreative> {
 
     void replaceBatch(List<KuaiShouCreative> creatives);
+
+    /**
+     * 获取MD5
+     * @param creativeId
+     * @return
+     */
+    String getCodeByCreativeId(Long creativeId);
 }

+ 29 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java

@@ -1,8 +1,12 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouVideoGetMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -19,9 +23,34 @@ import java.util.List;
 public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMapper, KuaiShouCreative> implements IKuaiShouCreativeService {
     @Autowired
     private KuaiShouCreativeMapper kuaiShouCreativeMapper;
+    @Autowired
+    private KuaiShouVideoGetMapper kuaiShouVideoGetMapper;
 
     @Override
     public void replaceBatch(List<KuaiShouCreative> creatives) {
         kuaiShouCreativeMapper.replaceBatch(creatives);
     }
+
+    @Override
+    public String getCodeByCreativeId(Long creativeId) {
+        QueryWrapper<KuaiShouCreative> creativeQueryWrapper = new QueryWrapper<>();
+        creativeQueryWrapper.eq("creative_id", creativeId);
+        creativeQueryWrapper.orderByDesc("create_time");
+        creativeQueryWrapper.last("limit 1");
+        KuaiShouCreative kuaiShouCreative = kuaiShouCreativeMapper.selectOne(creativeQueryWrapper);
+        if (!Check.isNull(kuaiShouCreative)) {
+            String photoId = kuaiShouCreative.getPhotoId();
+            if (!Check.isNull(photoId)) {
+                QueryWrapper<KuaiShouVideoGet> videoGetQueryWrapper = new QueryWrapper<>();
+                videoGetQueryWrapper.eq("photo_id", photoId);
+                videoGetQueryWrapper.orderByDesc("create_time");
+                videoGetQueryWrapper.last("limit 1");
+                KuaiShouVideoGet kuaiShouVideoGet = kuaiShouVideoGetMapper.selectOne(videoGetQueryWrapper);
+                if (!Check.isNull(kuaiShouVideoGet)) {
+                    return kuaiShouVideoGet.getSignature();
+                }
+            }
+        }
+        return null;
+    }
 }

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

@@ -309,16 +309,16 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
                 kuaiShouVideoGet.setAccountId(token.getAccountId());
 
-            //    kuaiShouVideoGet.setCreateTime(new Date());
+                //    kuaiShouVideoGet.setCreateTime(new Date());
                 kuaiShouVideoGet.setUpdateTime(new Date());
                 Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
                 if (!Check.isNull(type)) {
                     kuaiShouVideoGet.setMaterialType(type);
                 }
                 kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
-               // videoGets.add(kuaiShouVideoGet);
+                // videoGets.add(kuaiShouVideoGet);
             }
-         //   kuaiShouVideoGetService.replaceBatch(videoGets);
+            //   kuaiShouVideoGetService.replaceBatch(videoGets);
             getVideoListByPage(token, startDate, endDate, page + 1);
 
         } catch (Exception e) {
@@ -781,8 +781,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         headers.put("Content-Type", "application/json");
         headers.put("Access-Token", token.getAccessToken());
         Map<String, Object> param = new HashMap<String, Object>();
-        param.put("start_date", DateUtils.formatDate(startDate));
-        param.put("end_date", DateUtils.formatDate(endDate));
+        if (!Check.isNull(startDate)) {
+            param.put("start_date", DateUtils.formatDate(startDate));
+        }
+        if (!Check.isNull(endDate)) {
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
         param.put("advertiser_id", token.getAccountId());
         param.put("temporal_granularity", "DAILY");
         param.put("page_size", 500);
@@ -810,6 +814,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             var creative = JSONObject.toJavaObject(detailJson, KuaishouReportDailyCreative.class);
             creative.setAccountId(token.getAccountId());
             creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate());
+
+            // 取得MD5
+            String signature = creativeService.getCodeByCreativeId(creative.getCreativeId());
+            if (!Check.isNull(signature)) {
+                creative.setSignature(signature);
+            }
             KuaishouReportDailyCreativeStatistic statistic = setDailyStatistic(creative, token);
             dailyCreativeStatisticService.saveOrUpdate(statistic);
             dailyCreativeService.saveOrUpdate(creative);
@@ -3428,10 +3438,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             kuaiShouVideoGet.setId("" + accountId + kuaiShouVideoGet.getPhotoId());
             kuaiShouVideoGet.setCreateTime(new Date());
             kuaiShouVideoGet.setUpdateTime(new Date());
-          //  videoGets.add(kuaiShouVideoGet);
+            //  videoGets.add(kuaiShouVideoGet);
             kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
         }
-       // kuaiShouVideoGetService.replaceBatch(videoGets);
+        // kuaiShouVideoGetService.replaceBatch(videoGets);
         getVideoList(token, accountId, startDate, endDate, page + 1);
     }
 

+ 3 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCreative.java

@@ -118,6 +118,9 @@ public class KuaishouReportDailyCreative implements Serializable {
     @JsonProperty
     private BigDecimal eventCreditGrantLandingPageCost;
     @JsonProperty
+    private String signature;
+
+    @JsonProperty
     private Date createTime;
     @JsonProperty
     private Date updateTime;