Pārlūkot izejas kodu

重试创建创意

yumeng 4 gadi atpakaļ
vecāks
revīzija
2b9f2d3d41

+ 40 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCreateCreativeJob.java

@@ -0,0 +1,40 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTemplate;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+public class KuaishouCreateCreativeJob {
+
+
+    @Autowired
+    private IKuaiShouGroupTemplateService groupTemplateService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+
+    @XxlJob("kuaihouCreateCreative")
+    public void execute() {
+        QueryWrapper<KuaiShouGroupTemplate> templateQueryWrapper = new QueryWrapper<>();
+        templateQueryWrapper.eq("task_status", 2);
+        templateQueryWrapper.eq("creative_status", 0);
+        templateQueryWrapper.orderByAsc("create_time");
+        templateQueryWrapper.last("limit 20");
+        List<KuaiShouGroupTemplate> list = groupTemplateService.list(templateQueryWrapper);
+        for (KuaiShouGroupTemplate template : list) {
+            CtopOauthToken token = tokenService.getTokenByAccountId(template.getAccountId());
+            if (Check.isNull(token)) {
+                continue;
+            }
+            groupTemplateService.createCreative(token.getAccessToken(), template.getUnitId(), template);
+        }
+    }
+}

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

@@ -31,4 +31,6 @@ public interface IKuaiShouGroupTemplateService extends IService<KuaiShouGroupTem
      * @return
      */
     JSONObject getUrlByPhotoId(Long photoId);
+
+    void createCreative(String accessToken, Long unitId, KuaiShouGroupTemplate template);
 }

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

@@ -353,15 +353,14 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
     }
 
 
-    private void createCreative(String accessToken, Long unitId, KuaiShouGroupTemplate template) {
+    @Override
+    public void createCreative(String accessToken, Long unitId, KuaiShouGroupTemplate template) {
         KuaiShouGroupTemplate updateTemplate = new KuaiShouGroupTemplate();
         updateTemplate.setId(template.getId());
         updateTemplate.setCreativeStatus(1);
         updateTemplate.setCreativeReviewDetail("创意创建中");
         this.updateById(updateTemplate);
         Long photoId = template.getPhotoId();
-
-
         JSONObject md5Json = groupTemplateMapper.getMd5ByPhotoId(photoId);
         if (Check.isNull(md5Json)) {
             log.error("未获取到素材详细信息,accountId:{},unitId:{}", template.getAccountId(), unitId);