瀏覽代碼

批量 优化初版

zhaoxian 2 年之前
父節點
當前提交
bb1619cece

+ 8 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouBatchCampaignTemplate.java

@@ -38,7 +38,14 @@ public class KuaiShouBatchCampaignTemplate {
     @Excel(name = "账户ID", width = 15)
     @ApiModelProperty(value = "账户ID")
     private Long accountId;
-
+    /**
+     * 广告计划类型 0:信息流,1:搜索;不填默认信息流
+     */
+    private Integer adType;
+    /**
+     * 出价类型	0:默认1:最大转化(添加后不可修改)
+     */
+    private Integer bidType;
     private  Integer groupRule;
     /**
      * 计划名称

+ 10 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouBatchCreativeTemplate.java

@@ -101,6 +101,16 @@ public class KuaiShouBatchCreativeTemplate {
     @ApiModelProperty(value = "创意标签")
     private String creativeTag;
     /**
+     * 是否开启原生	0关闭,1开启,不填默认为0仅在计划 campaignType=2提升应用安装、5收集销售线索、7提升应用活跃、19推广快手小程序时,
+     * 可开启原生投放。
+     */
+    private Integer outerLoopNative;
+
+    /**
+     * 原生达人用户类型	2服务号原生,3聚星达人原生,当outer_loop_native为1时此项必填
+     */
+    private Integer kolUserType;
+    /**
      * 创建时间
      */
     @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")

+ 8 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouBatchCampaignPreview.java

@@ -110,6 +110,14 @@ public class KuaishouBatchCampaignPreview {
      */
     private String message;
     /**
+     * 广告计划类型 0:信息流,1:搜索;不填默认信息流
+     */
+    private Integer adType;
+    /**
+     * 出价类型	0:默认1:最大转化(添加后不可修改)
+     */
+    private Integer bidType;
+    /**
      * 创建成功后的计划ID
      */
     private Long campaignId;

+ 16 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouBatchCreativePreview.java

@@ -180,13 +180,28 @@ public class KuaishouBatchCreativePreview {
     /**
      * 是否创建成功 0 失败,1成功
      */
-    private int isSuccess;
+    private Integer isSuccess;
+
+    /**
+     * 是否开启原生	0关闭,1开启,不填默认为0仅在计划 campaignType=2提升应用安装、5收集销售线索、7提升应用活跃、19推广快手小程序时,
+     * 可开启原生投放。
+     */
+    private Integer outerLoopNative;
+
+    /**
+     * 原生达人用户类型	2服务号原生,3聚星达人原生,当outer_loop_native为1时此项必填
+     */
+    private Integer kolUserType;
 
     /**
      * 操作说明
      */
     private String message;
     /**
+     * 图片创意,图片的MD5
+     */
+    private String imageTokens;
+    /**
      * 创建成功后的计划ID
      */
     private Long campaignId;

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouTemplateMapper.java

@@ -20,4 +20,6 @@ public interface KuaishouTemplateMapper extends BaseMapper<KuaishouTemplate> {
     void replaceBatch(@Param("templateList") List<KuaishouTemplate> templateList);
 
     JSONObject queryByTemplateId(@Param("templateId") Long templateId);
+
+    void deleteOldTemplate(@Param("accountId") Long accountId);
 }

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouTemplateTargetMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -20,4 +21,6 @@ public interface KuaishouTemplateTargetMapper extends BaseMapper<KuaishouTemplat
     KuaishouTemplateTarget queryTemplateTarget(@Param("templateId") Long templateId, @Param("accountId")Long accountId);
 
     List<KuaishouTemplateTarget> queryTemplateTargetByIds(@Param("templateIds") List<Long> templateIds);
+
+    void deleteOldTemplateTarget(@Param("list")  List<JSONObject> list);
 }

+ 10 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouTemplateMapper.xml

@@ -50,13 +50,19 @@
 
 
     <select id="queryByTemplateId" resultType="com.alibaba.fastjson.JSONObject">
-        select t1.account_id,t1.template_id,t1.template_name,t3.dir_id,t3.project_id
+        select t1.account_id, t1.template_id, t1.template_name, t3.dir_id, t3.project_id
         from ctop_kuaishou_template t1
                  INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-                 left JOIN ctop_kuaishou_directional_package_rel t3 ON t1.template_id = t3.template_id AND t2.project_id = t3.project_id
-        where t1.template_id = #{templateId}
-        limit 1
+                 left JOIN ctop_kuaishou_directional_package_rel t3
+                           ON t1.template_id = t3.template_id AND t2.project_id = t3.project_id
+        where t1.template_id = #{templateId} limit 1
     </select>
 
 
+    <delete id="deleteOldTemplate">
+        delete
+        from ctop_kuaishou_template
+        where account_id = #{accountId}
+    </delete>
+
 </mapper>

+ 7 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouTemplateTargetMapper.xml

@@ -107,5 +107,12 @@
 
     </select>
 
+    <delete id="deleteOldTemplateTarget">
+        delete from ctop_kuaishou_template_target where template_id in
+        <foreach collection="list" item="item" separator=","
+                 open="(" close=")">
+            #{item.templateId}
+        </foreach>
+    </delete>
 
 </mapper>

+ 37 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouBatchCreativePreviewServiceImpl.java

@@ -5,11 +5,21 @@ import cn.com.ctop.common.module.entity.MaterialCutFrame;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
 import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.kuaishou.modules.batch.entity.*;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCampaignPreview;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCreativePreview;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCampaignPreviewMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCreativePreviewMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchGroupPreviewMapper;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchCreativePreviewService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -141,6 +151,12 @@ public class KuaishouBatchCreativePreviewServiceImpl extends ServiceImpl<Kuaisho
             JSONObject campaignJson = new JSONObject();
             campaignJson.put("campaign_name", campaign.getCampaignName());
             campaignJson.put("type", campaign.getCampaignType());
+            if (!Check.isNull(campaign.getAdType())) {
+                campaignJson.put("ad_type", campaign.getAdType());
+            }
+            if (!Check.isNull(campaign.getBidType())) {
+                campaignJson.put("bid_type", campaign.getBidType());
+            }
             if (!Check.isNull(campaign.getDayBudget())) {
                 campaignJson.put("day_budget", campaign.getDayBudget());
             }
@@ -375,11 +391,20 @@ public class KuaishouBatchCreativePreviewServiceImpl extends ServiceImpl<Kuaisho
             createJson.put("creative_name", creativePreview.getCreativeName()); // 创意名称
             if (!Check.isNull(creativePreview.getPhotoId())) {
                 createJson.put("photo_id", creativePreview.getPhotoId());  // 视频ID
+                KuaiShouVideoGet video = videoGetService.getVideoByPhotoId(Long.valueOf(creativePreview.getPhotoId()));
+                if (!Check.isNull(video)) {
+                    createJson.put("creative_material_type", video.getMaterialType());  // 素材类型
+                }
             }
-            KuaiShouVideoGet video = videoGetService.getVideoByPhotoId(Long.valueOf(creativePreview.getPhotoId()));
-            if (!Check.isNull(video)) {
-                createJson.put("creative_material_type", video.getMaterialType());  // 素材类型
+             if (!Check.isNull(creativePreview.getImageTokens())) {
+
+                createJson.put("photo_id", creativePreview.getPhotoId());  // 视频ID
+                KuaiShouVideoGet video = videoGetService.getVideoByPhotoId(Long.valueOf(creativePreview.getPhotoId()));
+                if (!Check.isNull(video)) {
+                    createJson.put("creative_material_type", video.getMaterialType());  // 素材类型
+                }
             }
+
             if (!Check.isNull(creativePreview.getActionBarText())) {
                 createJson.put("action_bar_text", creativePreview.getActionBarText());  // 行动号召按钮文案
             }
@@ -419,6 +444,13 @@ public class KuaishouBatchCreativePreviewServiceImpl extends ServiceImpl<Kuaisho
             if (!Check.isNull(creativePreview.getCreativeTag())) {
                 createJson.put("creative_tag", JSONObject.parseArray(creativePreview.getCreativeTag()));  // 创意标签
             }
+            Integer outerLoopNative = creativePreview.getOuterLoopNative();
+            if (!Check.isNull(outerLoopNative)) {
+                createJson.put("outer_loop_native", outerLoopNative);
+                if (outerLoopNative == 1) {
+                    createJson.put("kol_user_type", creativePreview.getKolUserType());
+                }
+            }
             String image_md5 = creativePreview.getImageSignature();
             String imageToken = null;
             if (!Check.isNull(image_md5)) {

+ 6 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateServiceImpl.java

@@ -213,6 +213,7 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
 
                 }
                 if (!Check.isNull(templateList)) {
+                    this.deleteOldTemplate(accountId);
                     templateMapper.replaceBatch(templateList);
                     templateTargetMapper.templateTargetList(templateTargetList);
                 }
@@ -220,19 +221,19 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
                 getTemplateByAccountId(accountId, accessToken, page + 1);
             } else {
                 log.error("获取模板信息返回信息错误:accountId:{},返回信息:{}", accountId, resultJson);
-
-
             }
-
-
         } else {
             log.error("获取模板信息返回信息为空:accountId:{}", accountId);
         }
+    }
 
+    private void deleteOldTemplate(Long accountId) {
+        List<JSONObject> list = templateMapper.getJsonArrByAccountId(accountId, null, null);
+        templateTargetMapper.deleteOldTemplateTarget(list);
+        templateMapper.deleteOldTemplate(accountId);
 
     }
 
-
     /**
      * 创建定向模板
      *