Procházet zdrojové kódy

Merge branch 'test' of http://git.tjyourong.com.cn/ctop/adsp-bytedance into test

huangxuechao před 4 roky
rodič
revize
efc90c3bd7

+ 1 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/ByteDanceGeneralCopywriterMapper.java

@@ -20,6 +20,7 @@ public interface ByteDanceGeneralCopywriterMapper extends BaseMapper<ByteDanceGe
     ByteDanceCreativeWordPackage selectCreativeWordPackageByName(String name);
 
     ByteDanceGeneralCopywriter getRandOne(@Param(value = "accountId") Long accountId);
+    List<ByteDanceGeneralCopywriter> getRandTen(@Param(value = "accountId") Long accountId);
 
     List<ByteDanceGeneralCopywriter> selectAllDataByTextCopywriter(@Param(value = "textCopywriter") String textCopywriter);
 }

+ 5 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceGeneralCopywriterMapper.xml

@@ -47,6 +47,11 @@
         select * from ctop_bytedance_general_copywriter where status = 1 and account_id = #{accountId} order by rand() limit 1
     </select>
 
+    <select id="getRandTen"
+            resultType="org.jeecg.modules.bytedance.advertise.entity.ByteDanceGeneralCopywriter">
+        select * from ctop_bytedance_general_copywriter where status = 1 and account_id = #{accountId} order by rand() limit 10
+    </select>
+
     <select id="selectAllDataByTextCopywriter" resultType="org.jeecg.modules.bytedance.advertise.entity.ByteDanceGeneralCopywriter">
         select * from ctop_bytedance_general_copywriter where text_copywriter = #{textCopywriter}
 

+ 12 - 12
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceVideoInfoMapper.xml

@@ -157,20 +157,20 @@
         'image' as materialType
         from ctop_bytedance_image_info image
         where account_id = #{accountId}
-        <if test="imageMode = '1'">
+        <if test="imageMode == '1'.toString()">
             and image.type = '1'
         </if>
-        <if test="imageMode = '2'">
+        <if test="imageMode == '2'.toString()">
             and (image.type = '2' or image.type = '4')
         </if>
-        <if test="imageMode = '3'">
+        <if test="imageMode == '3'.toString()">
             and (image.type = '3' or image.type = '4')
         </if>
-        and image.create_time &gt;= #{startTime}
-        and image.create_time &lt;= #{endTime}
+        and image.image_create_time &gt;= #{startTime}
+        and image.image_create_time &lt;= #{endTime}
         having creativeCnt &lt;= #{creativeCnt}
         and creativeNum = 0
-        order by create_time desc
+        order by image.image_create_time desc
             limit #{videoCnt}
     </select>
 
@@ -197,13 +197,13 @@
         group by report.material_id
         order by sum(report.cost) desc ) a
         left join (select distinct a.* from ctop_bytedance_image_info a where 1 = 1  and a.account_id = #{accountId}
-        <if test="imageMode = '1'">
+        <if test="imageMode == '1'.toString()">
             and a.type = '1'
         </if>
-        <if test="imageMode = '2'">
+        <if test="imageMode == '2'.toString()">
             and (a.type = '2' or a.type = '4')
         </if>
-        <if test="imageMode = '3'">
+        <if test="imageMode == '3'.toString()">
             and (a.type = '3' or a.type = '4')
         </if>)as image
         on a.material_id = image.material_id
@@ -239,13 +239,13 @@
         group by report.material_id
         order by sum(report.cost) desc) a
         left join (select distinct a.* from ctop_bytedance_image_info a where 1 = 1 and a.account_id =#{accountId}
-        <if test="imageMode = '1'">
+        <if test="imageMode == '1'.toString()">
             and a.type = '1'
         </if>
-        <if test="imageMode = '2'">
+        <if test="imageMode == '2'.toString()">
             and (a.type = '2' or a.type = '4')
         </if>
-        <if test="imageMode = '3'">
+        <if test="imageMode == '3'.toString()">
             and (a.type = '3' or a.type = '4')
         </if>) as image
         on a.material_id = image.material_id

+ 38 - 16
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java

@@ -356,7 +356,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         if ("video".equalsIgnoreCase(videoInfo.getMaterialType())){
             //视频类型
             //1-竖版视频 2-横版视频
-            String imageMode = videoInfo.getType() == 1 ? "CREATIVE_IMAGE_MODE_VIDEO_VERTICAL" : "CREATIVE_IMAGE_MODE_VIDEO";
+//            String imageMode = videoInfo.getType() == 1 ? "CREATIVE_IMAGE_MODE_VIDEO_VERTICAL" : "CREATIVE_IMAGE_MODE_VIDEO";
+            String imageMode = strategy.getCreativeImageMode();
             imageObject.put("image_mode",imageMode);
             imageObject.put("video_id",videoInfo.getVid());
             //获取视频封面id
@@ -366,7 +367,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             }
         }else if ("image".equalsIgnoreCase(videoInfo.getMaterialType())){
             //1-大图横图; 2-大图竖图
-            String imageMode = videoInfo.getType() == 1 ? "CREATIVE_IMAGE_MODE_LARGE" : "CREATIVE_IMAGE_MODE_LARGE_VERTICAL";
+//            String imageMode = videoInfo.getType() == 1 ? "CREATIVE_IMAGE_MODE_LARGE" : "CREATIVE_IMAGE_MODE_LARGE_VERTICAL";
+            String imageMode = strategy.getCreativeImageMode();
             imageObject.put("image_mode",imageMode);
             imageObject.put("image_ids",new String[]{videoInfo.getId()});
         }
@@ -375,6 +377,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         params.put("image_list",imageArray);
         JSONArray titleArray = new JSONArray();
         List<BytedanceVideoSlogenInfo> slogenInfos = slogenInfoService.listByParams(videoInfo.getSignature(),1);
+        //使用指定文案
         if(!Check.isNull(slogenInfos)){
             for (BytedanceVideoSlogenInfo slogenInfo:slogenInfos) {
                 if(titleArray.size() >= 10){    //接口中是要求一个视频最多10个标题
@@ -392,24 +395,43 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 titleArray.add(titleObject);
             }
         }
-        for(int i = 0; i < 3; i++){
-            if(titleArray.size() >= 10){
-                break;
+        // 视频 指定文案不够的时候 使用通用文案 最多3条
+        if ("video".equalsIgnoreCase(videoInfo.getMaterialType())){
+            for(int i = 0; i < 3; i++){
+                if(titleArray.size() >= 10){
+                    break;
+                }
+                ByteDanceGeneralCopywriter byteDanceGeneralCopywriter = byteDanceGeneralCopywriterMapper.getRandOne(strategy.getAccountId());
+                if(!Check.isNull(byteDanceGeneralCopywriter)){
+                    JSONObject titleObject = new JSONObject();
+                    titleObject.put("title",byteDanceGeneralCopywriter.getTextCopywriter());
+                    String creativeWordsIds = byteDanceGeneralCopywriter.getCreativeWordIds();
+                    if(null!=creativeWordsIds&&!creativeWordsIds.trim().equals("")){
+                        JSONArray creativeWordsArray = JSON.parseArray(creativeWordsIds);
+                        if(null!=creativeWordsArray&&!creativeWordsArray.isEmpty()){
+                            titleObject.put("creative_word_ids",creativeWordsArray);
+                        }
+                    }
+                    titleArray.add(titleObject);
+                }
             }
-            ByteDanceGeneralCopywriter byteDanceGeneralCopywriter = byteDanceGeneralCopywriterMapper.getRandOne(strategy.getAccountId());
-            if(!Check.isNull(byteDanceGeneralCopywriter)){
-                JSONObject titleObject = new JSONObject();
-                titleObject.put("title",byteDanceGeneralCopywriter.getTextCopywriter());
-                String creativeWordsIds = byteDanceGeneralCopywriter.getCreativeWordIds();
-                if(null!=creativeWordsIds&&!creativeWordsIds.trim().equals("")){
-                    JSONArray creativeWordsArray = JSON.parseArray(creativeWordsIds);
-                    if(null!=creativeWordsArray&&!creativeWordsArray.isEmpty()){
-                        titleObject.put("creative_word_ids",creativeWordsArray);
+            // 图片 使用通用文案 最多10条
+        }else if ("image".equalsIgnoreCase(videoInfo.getMaterialType())){
+            List<ByteDanceGeneralCopywriter> byteDanceGeneralCopywriterList = byteDanceGeneralCopywriterMapper.getRandTen(strategy.getAccountId());
+            if(!Check.isNull(byteDanceGeneralCopywriterList)){
+                for (ByteDanceGeneralCopywriter byteDanceGeneralCopywriter : byteDanceGeneralCopywriterList){
+                    JSONObject titleObject = new JSONObject();
+                    titleObject.put("title",byteDanceGeneralCopywriter.getTextCopywriter());
+                    String creativeWordsIds = byteDanceGeneralCopywriter.getCreativeWordIds();
+                    if(null!=creativeWordsIds&&!creativeWordsIds.trim().equals("")){
+                        JSONArray creativeWordsArray = JSON.parseArray(creativeWordsIds);
+                        if(null!=creativeWordsArray&&!creativeWordsArray.isEmpty()){
+                            titleObject.put("creative_word_ids",creativeWordsArray);
+                        }
                     }
+                    titleArray.add(titleObject);
                 }
-                titleArray.add(titleObject);
             }
-
         }
 
         if(!Check.isNull(titleArray)){

+ 9 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/AiBytedanceAdvertiserStrategyController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.bytedance.advertise.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -32,10 +33,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -457,10 +455,13 @@ public class AiBytedanceAdvertiserStrategyController {
 			if (Check.isNull(accountId)){
 				return Result.errorMsg("请选择账户。");
 			}
-			/*if (Check.isNull(landingType)){
-				return Result.errorMsg("投放内容不能为空");
-			}*/
-			return aiBytedanceAdvertiserStrategyService.getAdAudiencePackage(accountId,landingType,deliveryRange);
+			// 默认 定向包
+			Result resultDefault = aiBytedanceAdvertiserStrategyService.getAdAudiencePackage(accountId,landingType,"DEFAULT");
+			//穿山甲定向包
+			Result resultUnion = aiBytedanceAdvertiserStrategyService.getAdAudiencePackage(accountId,landingType,"UNION");
+			List list = (List) resultDefault.getResult();
+			list.add(resultUnion);
+			return Result.successMsg("获取定向包成功。",list);
 		}catch (Exception e){
 			log.error("获取定向包异常",e);
 			return Result.error("请求失败,请联系开发人员!");