Переглянути джерело

Merge remote-tracking branch 'origin/master'

syh 4 роки тому
батько
коміт
ca1ff3b2a4

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

@@ -0,0 +1,43 @@
+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);
+        if (Check.isNull(list)) {
+            return;
+        }
+        for (KuaiShouGroupTemplate template : list) {
+            CtopOauthToken token = tokenService.getTokenByAccountId(template.getAccountId());
+            if (Check.isNull(token)) {
+                continue;
+            }
+            groupTemplateService.createCreative(token.getAccessToken(), template.getUnitId(), template);
+        }
+    }
+}

+ 13 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -1201,6 +1201,19 @@ public class BatchController {
         return result;
     }
 
+
+    @GetMapping(value = "/getActionBarTextByType")
+    public Result<List<KuaiShouActionBarText>> getActionBarTextByType(Integer type) {
+        Result<List<KuaiShouActionBarText>> result = new Result<>();
+        QueryWrapper<KuaiShouActionBarText> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("type", type);
+        List<KuaiShouActionBarText> list = actionBarTextService.list(queryWrapper);
+        result.setSuccess(true);
+        result.setResult(list);
+        return result;
+    }
+
+
     /**
      * 创建创意
      *

+ 1 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouGroupTemplateController.java

@@ -102,14 +102,12 @@ public class KuaiShouGroupTemplateController {
      */
     @GetMapping(value = "/getApiCreateCount")
     public Result<Integer> getApiCreateCount(Long accountId) {
-
         Result<Integer> result = new Result<>();
         try {
             if (Check.isNull(accountId)) {
                 throw new Exception("accountId参数不能为空");
             }
             String date = DateUtils.getNowDate("yyyy-MM-dd");
-
             Integer count = kuaiShouGroupTemplateService.getApiCreateCount(accountId, date);
             result.setSuccess(true);
             result.setResult(count);
@@ -161,6 +159,7 @@ public class KuaiShouGroupTemplateController {
                                                               HttpServletRequest req) {
         Result<IPage<KuaiShouGroupTemplate>> result = new Result<>();
         QueryWrapper<KuaiShouGroupTemplate> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouGroupTemplate, req.getParameterMap());
+        queryWrapper.orderByDesc("create_time");
         Page<KuaiShouGroupTemplate> page = new Page<KuaiShouGroupTemplate>(pageNo, pageSize);
         IPage<KuaiShouGroupTemplate> pageList = kuaiShouGroupTemplateService.page(page, queryWrapper);
         result.setSuccess(true);

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTemplate.java

@@ -212,6 +212,7 @@ public class KuaiShouGroupTemplate {
     private String description;
     private Long siteId;
     private Integer createCreativeCount;
+    private Integer creativeStatus;
     private String creativeReviewDetail;
 
 

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupTemplateMapper.xml

@@ -18,13 +18,13 @@
       url as 'url'
       from ctop_material_cut_frame
       where video_signature = #{md5}
-      limit 15
+      limit 6
     </select>
     <select id="getApiCreateCount" resultType="java.lang.Integer">
     select count(1)
     from
     ctop_kuaishou_creative
-    where  aaccount_id = #{accountId}
+    where  account_id = #{accountId}
     and DATE_FORMAT(creative_create_time,'%Y-%m-%d') = #{date}
     </select>
 

+ 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);
 }

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

@@ -204,6 +204,8 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
                 template.setSiteId(site_id);
             }
             template.setTaskStatus(0);
+            template.setCreativeReviewDetail("创意待创建");
+            template.setCreativeStatus(0);
             templates.add(template);
         }
         boolean b = this.saveBatch(templates);
@@ -294,8 +296,8 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
                     if (!Check.isNull(template.getConvertId())) {
                         createUnitJson.put("convert_id", template.getConvertId()); //转化目标ID
                     }
-                    if (!Check.isNull(template.getUnitType())) {
-                        createUnitJson.put("url_type", template.getUnitType()); //url类型
+                    if (!Check.isNull(template.getUrlType())) {
+                        createUnitJson.put("url_type", template.getUrlType()); //url类型
                     }
                     if (!Check.isNull(template.getUrl())) {
                         createUnitJson.put("url", template.getUrl()); // 投放链接
@@ -315,7 +317,6 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
                     Integer code = (Integer) groupMap.get("code");
                     if (code == 0) {
                         updateTemplate.setTaskStatus(2);
-                        updateTemplate.setCreativeReviewDetail("创意待创建");
                         Long unit = (Long) groupMap.get("unitId");
                         updateTemplate.setUnitId((unit));
                         Thread thread = new Thread() {
@@ -328,6 +329,8 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
                     } else {
                         updateTemplate.setTaskStatus(3);
                         updateTemplate.setReviewDetail((String) groupMap.get("message"));
+                        updateTemplate.setCreativeStatus(3);
+                        updateTemplate.setCreativeReviewDetail("组创建失败");
                     }
                     updateById(updateTemplate);
                     try {
@@ -352,11 +355,20 @@ 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);
+            updateTemplate.setCreativeStatus(3);
+            updateTemplate.setCreativeReviewDetail("未获取到素材信息");
+            this.updateById(updateTemplate);
             return;
         }
         String md5 = md5Json.getString("md5");
@@ -427,17 +439,15 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         }
         createJson.put("creatives", creatives);
         Map<String, Object> creativeMap = iKuaishouInterfaceService.batchCreativeCreate(accessToken, template.getAccountId(), createJson, 1, template.getUserId());
-        KuaiShouGroupTemplate updateTemplate = new KuaiShouGroupTemplate();
-        updateTemplate.setId(template.getId());
         Integer code = (Integer) creativeMap.get("code");
         if (code == 0) {
+            updateTemplate.setCreativeStatus(2);
             updateTemplate.setCreativeReviewDetail("创意创建成功");
             updateTemplate.setCreateCreativeCount((Integer) creativeMap.get("count"));
         } else {
-            updateTemplate.setCreativeReviewDetail("创意创建失败:" + creativeMap.get("message"));
+            updateTemplate.setCreativeStatus(3);
+            updateTemplate.setCreativeReviewDetail((String) creativeMap.get("message"));
         }
         this.updateById(updateTemplate);
     }
-
-
 }