Procházet zdrojové kódy

Merge remote-tracking branch 'origin/kuaishou-ai-advertising' into kuaishou-ai-advertising

jiequan.bi před 4 roky
rodič
revize
f7d01374b7

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -56,6 +56,7 @@ public class ShiroConfig {
         Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
         // 配置不会被拦截的链接 顺序判断
         //登录接口排除
+        filterChainDefinitionMap.put("/ctop/materialInfo/**", "anon");
         filterChainDefinitionMap.put("/sys/mLogin", "anon");
         filterChainDefinitionMap.put("/sys/login", "anon");
         filterChainDefinitionMap.put("/sys/wxlogin", "anon");

+ 281 - 104
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiStrategyServiceImpl.java

@@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -68,124 +69,295 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
             log.info("token获取失败=>accountId:{}",strategy.getAccountId());
             return;
         }
-        //策略类型
-        String scenes = strategy.getScenes();
-        //根据策略类型获取策略模板信息
-        AiKuaishouStrategyTemplate strategyTemplate = templateService.getOneByParams(scenes, 1);
-        if(null == strategyTemplate){
-            log.info("策略模板信息获取失败=>testDirection:{}",scenes);
-            return;
-        }
         //1:获取相应账户下的最新的5条素材信息
-        List<KuaiShouVideoGet> videoGets = videoGetService.getNewVideoByAccountId(accountId,5);
+        List<KuaiShouVideoGet> videoGets = videoGetService.getNewVideoByAccountId(accountId,1);
         if(null == videoGets){
             log.info("素材获取失败=>accountId:{}",accountId);
             return;
         }
-        //2:根据测试方向获取相应的定向拆分数据类型
-        List<AiKuaishouStrategyTargetBase>targetBases = targetBaseService.listByType(strategyTemplate.getTestDirection());
-        if(null == targetBases){
-            log.info("定向拆分信息获取失败=>testDirection:{}",strategyTemplate.getTestDirection());
-            return;
-        }
-        //3:获取相应字段相应的用户定义域
-        String definitionDomain = getStragyDefDomain(strategyTemplate,strategy);
-        System.out.println(definitionDomain);
-        //4:计算定向拆分逻辑
-        List<AiKuaishouStrategyTargetBase>getBases = splitBasesByDomain(definitionDomain,targetBases);
-        if(null == getBases||getBases.isEmpty()){
-            log.info("定向拆分失败=>definitionDomain:{}",definitionDomain);
-            return;
-        }
-        //5、策略--策略模板 关联表,写入数据库
-        AiKuaishouStrategyMiddle strategyMiddle = new AiKuaishouStrategyMiddle(strategyTemplate.getId(),strategy.getId());
-        middleService.save(strategyMiddle);
-
-        //7、一个计划,拼装创建计划的入参json
-        JSONObject campaignParams = new JSONObject();
-        campaignParams.put("advertiser_id",token.getAccountId());
-        Date campaignDate = new Date();
-        String timestamp = DateUtils.formatDate(campaignDate,"yyyyMMddHHmmss");
-        campaignParams.put("campaign_name",strategy.getStrategyName()+ timestamp);
-        campaignParams.put("type",Integer.parseInt(strategy.getMarketingGoal()));
-        campaignParams.put("day_budget",0L);
-        Map<String, Object> campaignCreateResult = kuaishouInterfaceService.campaignCreate(token.getAccessToken(), token.getAccountId(), campaignParams);
-        Integer code = (Integer) campaignCreateResult.get("code");
-        String message = (String) campaignCreateResult.get("message");
-        if(code != 0 ){
-            log.info("计划创建失败=>message:{}",message);
-            return;
-        }
-        Long campaignId = (Long) campaignCreateResult.get("campaignId");
-        int unitCnt = 0;
-        // 8、根据定向和素材,两层循环 创建组和创意
-        for (AiKuaishouStrategyTargetBase item:getBases) {
-            unitCnt++;
-            // 策略定向拆分数据,写入数据库
-            AiKuaishouStrategyTargetUnion targetUnion = new AiKuaishouStrategyTargetUnion(strategyMiddle.getId(),item.getId(),item.getTargetContent());
-            targetUnionService.save(targetUnion);
-            // 选择素材,创建创意
-            for(KuaiShouVideoGet videoItem: videoGets){
-                //拼装广告组参数
-                JSONObject unitParams = createUnitParams(token,campaignId,strategy,strategyTemplate, item,timestamp,unitCnt);
-                Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
-                Integer unitCode = (Integer) unitCreateResult.get("code");
-                String unitMessage = (String) unitCreateResult.get("message");
-                if(unitCode != 0 ){
-                    log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
-                    continue;
-                }
-                Long unitId = (Long) unitCreateResult.get("unitId");
-
-                JSONObject creativeParams = creativeParams(token,unitId,videoItem,unitCnt,strategy);
-                JSONArray sceneIdJsonArray = JSONArray.parseArray(strategy.getSceneId());
-                // 如果广告位只包含 上下滑大屏广告(6),则一个素材搭配1张封面,生成1个创意
-                if (sceneIdJsonArray.contains(6) && sceneIdJsonArray.size() == 1){
-                    //直接创建创意
-                    createCreative(token,creativeParams,campaignId,unitId,strategy,targetUnion,1,videoItem);
-                } else {
-                    // 素材自带的封面 ctop_material_image_info 内部素材的自带封面,素造的没有
-                    // 素材的智能抽帧封面 ctop_material_cut_frame 其中素造的为8张封面,内部的为15张封面
-                    List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
-                    List<MaterialImageInfo> orgFrameList = materialImageInfoService.getListByVideoSignature(videoItem.getSignature());
-                    // 其他情况下,一个素材搭配15张封面,生成15个创意
-                    if ((null == cutFrameList||cutFrameList.isEmpty())&&(null == orgFrameList|| orgFrameList.isEmpty())){
-                        log.info("未获取到视频封面=>videoSignature:{}",videoItem.getSignature());
+        //策略类型
+        String scenes = strategy.getScenes();
+        if(scenes.equals("1")){
+            //素材+出价
+            List<Long>getCapbids = splitCapBidByDomain(strategy.getCpaBidMin(),strategy.getCpaBidMax(),strategy.getStepSize());
+            if(null == getCapbids||getCapbids.isEmpty()){
+                log.info("出价范围异常=>start:{};end:{}",strategy.getCpaBidMin().toString(),strategy.getCpaBidMax().toString());
+                return;
+            }
+            //7、一个计划,拼装创建计划的入参json
+            JSONObject campaignParams = new JSONObject();
+            campaignParams.put("advertiser_id",token.getAccountId());
+            Date campaignDate = new Date();
+            String timestamp = DateUtils.formatDate(campaignDate,"yyyyMMddHHmmss");
+            campaignParams.put("campaign_name",strategy.getStrategyName()+ timestamp);
+            campaignParams.put("type",Integer.parseInt(strategy.getMarketingGoal()));
+            campaignParams.put("day_budget",0L);
+            Map<String, Object> campaignCreateResult = kuaishouInterfaceService.campaignCreate(token.getAccessToken(), token.getAccountId(), campaignParams);
+            Integer code = (Integer) campaignCreateResult.get("code");
+            String message = (String) campaignCreateResult.get("message");
+            if(code != 0 ){
+                log.info("计划创建失败=>message:{}",message);
+                return;
+            }
+            Long campaignId = (Long) campaignCreateResult.get("campaignId");
+            int unitCnt = 0;
+            // 8、根据定向和素材,两层循环 创建组和创意
+            for (Long item:getCapbids) {
+                unitCnt++;
+                // 选择素材,创建创意
+                for(KuaiShouVideoGet videoItem: videoGets){
+                    //拼装广告组参数
+                    JSONObject unitParams = createUnitParams(token,campaignId,strategy,item,timestamp,unitCnt);
+                    Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
+                    Integer unitCode = (Integer) unitCreateResult.get("code");
+                    String unitMessage = (String) unitCreateResult.get("message");
+                    if(unitCode != 0 ){
+                        log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
                         continue;
                     }
-                    int creativeCnt = 1;
-                    if (null!=orgFrameList&&!orgFrameList.isEmpty()) {
-                        for (int i = 0; i < orgFrameList.size(); i++) {
-                            System.out.println(creativeCnt);
-                            String imageCode = orgFrameList.get(i).getCode();
-                            String imageUrl = orgFrameList.get(i).getUrl();
-                            String imageToken = getImageToken(imageUrl,imageCode,accountId,token.getAccessToken());
-                            creativeParams.put("image_token",imageToken);
-                            createCreative(token,creativeParams,campaignId,unitId,strategy,targetUnion,creativeCnt,videoItem);
-                            creativeCnt++;
-                            if (creativeCnt > 15) {
-                                break;
+                    Long unitId = (Long) unitCreateResult.get("unitId");
+                    JSONObject creativeParams = creativeParams(token,unitId,videoItem,unitCnt,strategy);
+                    JSONArray sceneIdJsonArray = JSONArray.parseArray(strategy.getSceneId());
+                    // 如果广告位只包含 上下滑大屏广告(6),则一个素材搭配1张封面,生成1个创意
+                    if (sceneIdJsonArray.contains(6) && sceneIdJsonArray.size() == 1){
+                        //直接创建创意
+                        createCreative(token,creativeParams,campaignId,unitId,strategy,null,1,videoItem);
+                    } else {
+                        // 素材自带的封面 ctop_material_image_info 内部素材的自带封面,素造的没有
+                        // 素材的智能抽帧封面 ctop_material_cut_frame 其中素造的为8张封面,内部的为15张封面
+                        List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
+                        List<MaterialImageInfo> orgFrameList = materialImageInfoService.getListByVideoSignature(videoItem.getSignature());
+                        // 其他情况下,一个素材搭配15张封面,生成15个创意
+                        if ((null == cutFrameList||cutFrameList.isEmpty())&&(null == orgFrameList|| orgFrameList.isEmpty())){
+                            log.info("未获取到视频封面=>videoSignature:{}",videoItem.getSignature());
+                            continue;
+                        }
+                        int creativeCnt = 1;
+                        if (null!=orgFrameList&&!orgFrameList.isEmpty()) {
+                            for (int i = 0; i < orgFrameList.size(); i++) {
+                                String imageCode = orgFrameList.get(i).getCode();
+                                String imageUrl = orgFrameList.get(i).getUrl();
+                                String imageToken = getImageToken(imageUrl,imageCode,accountId,token.getAccessToken());
+                                creativeParams.put("image_token",imageToken);
+                                createCreative(token,creativeParams,campaignId,unitId,strategy,null,creativeCnt,videoItem);
+                                creativeCnt++;
+                                if (creativeCnt > 5) {
+                                    break;
+                                }
                             }
                         }
+
+                        if ((null!=cutFrameList&&!cutFrameList.isEmpty()) && (creativeCnt<=15)){
+                            for (int i = 0; i < cutFrameList.size(); i++) {
+                                String imageCode = cutFrameList.get(i).getSignature();
+                                String imageUrl = cutFrameList.get(i).getUrl();
+                                String imageToken = getImageToken(imageUrl,imageCode,accountId,token.getAccessToken());
+                                creativeParams.put("image_token",imageToken);
+                                createCreative(token,creativeParams,campaignId,unitId,strategy,null,creativeCnt,videoItem);
+                                creativeCnt ++;
+                                if (creativeCnt > 5) {
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+
+        }else if(scenes.equals(2)){
+            //素材+定向
+            //根据策略类型获取策略模板信息
+            AiKuaishouStrategyTemplate strategyTemplate = templateService.getOneByParams(scenes, 1);
+            if(null == strategyTemplate){
+                log.info("策略模板信息获取失败=>testDirection:{}",scenes);
+                return;
+            }
+            //2:根据测试方向获取相应的定向拆分数据类型
+            List<AiKuaishouStrategyTargetBase>targetBases = targetBaseService.listByType(strategyTemplate.getTestDirection());
+            if(null == targetBases){
+                log.info("定向拆分信息获取失败=>testDirection:{}",strategyTemplate.getTestDirection());
+                return;
+            }
+            //3:获取相应字段相应的用户定义域
+            String definitionDomain = getStragyDefDomain(strategyTemplate,strategy);
+            System.out.println(definitionDomain);
+            //4:计算定向拆分逻辑
+            List<AiKuaishouStrategyTargetBase>getBases = splitBasesByDomain(definitionDomain,targetBases);
+            if(null == getBases||getBases.isEmpty()){
+                log.info("定向拆分失败=>definitionDomain:{}",definitionDomain);
+                return;
+            }
+            //5、策略--策略模板 关联表,写入数据库
+            AiKuaishouStrategyMiddle strategyMiddle = new AiKuaishouStrategyMiddle(strategyTemplate.getId(),strategy.getId());
+            middleService.save(strategyMiddle);
+            //7、一个计划,拼装创建计划的入参json
+            JSONObject campaignParams = new JSONObject();
+            campaignParams.put("advertiser_id",token.getAccountId());
+            Date campaignDate = new Date();
+            String timestamp = DateUtils.formatDate(campaignDate,"yyyyMMddHHmmss");
+            campaignParams.put("campaign_name",strategy.getStrategyName()+ timestamp);
+            campaignParams.put("type",Integer.parseInt(strategy.getMarketingGoal()));
+            campaignParams.put("day_budget",0L);
+            Map<String, Object> campaignCreateResult = kuaishouInterfaceService.campaignCreate(token.getAccessToken(), token.getAccountId(), campaignParams);
+            Integer code = (Integer) campaignCreateResult.get("code");
+            String message = (String) campaignCreateResult.get("message");
+            if(code != 0 ){
+                log.info("计划创建失败=>message:{}",message);
+                return;
+            }
+            Long campaignId = (Long) campaignCreateResult.get("campaignId");
+            int unitCnt = 0;
+            // 8、根据定向和素材,两层循环 创建组和创意
+            for (AiKuaishouStrategyTargetBase item:getBases) {
+                unitCnt++;
+                // 策略定向拆分数据,写入数据库
+                AiKuaishouStrategyTargetUnion targetUnion = new AiKuaishouStrategyTargetUnion(strategyMiddle.getId(),item.getId(),item.getTargetContent());
+                targetUnionService.save(targetUnion);
+                // 选择素材,创建创意
+                for(KuaiShouVideoGet videoItem: videoGets){
+                    //拼装广告组参数
+                    JSONObject unitParams = createUnitParams(token,campaignId,strategy,strategyTemplate, item,timestamp,unitCnt);
+                    Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
+                    Integer unitCode = (Integer) unitCreateResult.get("code");
+                    String unitMessage = (String) unitCreateResult.get("message");
+                    if(unitCode != 0 ){
+                        log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
+                        continue;
                     }
+                    Long unitId = (Long) unitCreateResult.get("unitId");
+
+                    JSONObject creativeParams = creativeParams(token,unitId,videoItem,unitCnt,strategy);
+                    JSONArray sceneIdJsonArray = JSONArray.parseArray(strategy.getSceneId());
+                    // 如果广告位只包含 上下滑大屏广告(6),则一个素材搭配1张封面,生成1个创意
+                    if (sceneIdJsonArray.contains(6) && sceneIdJsonArray.size() == 1){
+                        //直接创建创意
+                        createCreative(token,creativeParams,campaignId,unitId,strategy,targetUnion,1,videoItem);
+                    } else {
+                        // 素材自带的封面 ctop_material_image_info 内部素材的自带封面,素造的没有
+                        // 素材的智能抽帧封面 ctop_material_cut_frame 其中素造的为8张封面,内部的为15张封面
+                        List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
+                        List<MaterialImageInfo> orgFrameList = materialImageInfoService.getListByVideoSignature(videoItem.getSignature());
+                        // 其他情况下,一个素材搭配15张封面,生成15个创意
+                        if ((null == cutFrameList||cutFrameList.isEmpty())&&(null == orgFrameList|| orgFrameList.isEmpty())){
+                            log.info("未获取到视频封面=>videoSignature:{}",videoItem.getSignature());
+                            continue;
+                        }
+                        int creativeCnt = 1;
+                        if (null!=orgFrameList&&!orgFrameList.isEmpty()) {
+                            for (int i = 0; i < orgFrameList.size(); i++) {
+                                String imageCode = orgFrameList.get(i).getCode();
+                                String imageUrl = orgFrameList.get(i).getUrl();
+                                String imageToken = getImageToken(imageUrl,imageCode,accountId,token.getAccessToken());
+                                creativeParams.put("image_token",imageToken);
+                                createCreative(token,creativeParams,campaignId,unitId,strategy,targetUnion,creativeCnt,videoItem);
+                                creativeCnt++;
+                                if (creativeCnt > 5) {
+                                    break;
+                                }
+                            }
+                        }
 
-                    if ((null!=cutFrameList&&!cutFrameList.isEmpty()) && (creativeCnt<=15)){
-                        for (int i = 0; i < cutFrameList.size(); i++) {
-                            System.out.println(creativeCnt);
-                            String imageCode = cutFrameList.get(i).getSignature();
-                            String imageUrl = cutFrameList.get(i).getUrl();
-                            String imageToken = getImageToken(imageUrl,imageCode,accountId,token.getAccessToken());
-                            creativeParams.put("image_token",imageToken);
-                            createCreative(token,creativeParams,campaignId,unitId,strategy,targetUnion,creativeCnt,videoItem);
-                            creativeCnt ++;
-                            if (creativeCnt > 15) {
-                                break;
+                        if ((null!=cutFrameList&&!cutFrameList.isEmpty()) && (creativeCnt<=15)){
+                            for (int i = 0; i < cutFrameList.size(); i++) {
+                                String imageCode = cutFrameList.get(i).getSignature();
+                                String imageUrl = cutFrameList.get(i).getUrl();
+                                String imageToken = getImageToken(imageUrl,imageCode,accountId,token.getAccessToken());
+                                creativeParams.put("image_token",imageToken);
+                                createCreative(token,creativeParams,campaignId,unitId,strategy,targetUnion,creativeCnt,videoItem);
+                                creativeCnt ++;
+                                if (creativeCnt > 5) {
+                                    break;
+                                }
                             }
                         }
                     }
                 }
             }
         }
+
+    }
+
+    private JSONObject createUnitParams(CtopOauthToken token, Long campaignId, KuaishouStrategy strategy, Long item, String timestamp, int unitCnt) {
+        // 拼装创建组的入参 json
+        JSONObject unitParams = new JSONObject();
+        unitParams.put("advertiser_id",token.getAccountId());
+        unitParams.put("campaign_id",campaignId);
+        String uuid = UUID.randomUUID().toString();
+        unitParams.put("unit_name", strategy.getStrategyName() + "cpaBid-" + item.toString()+"-" + uuid + unitCnt);
+        unitParams.put("bid_type",10);
+        unitParams.put("ocpx_action_type",180);
+
+        if(null!=strategy.getUseAppMarket()&&!"".equals(strategy.getUseAppMarket())){
+            unitParams.put("use_app_market",Integer.parseInt(strategy.getUseAppMarket()));
+        }
+        if(null!=strategy.getAppStore()&&!"".equals(strategy.getAppStore())){
+            unitParams.put("app_store",JSONArray.parseArray(strategy.getAppStore()));
+        }
+
+        // 在本策略中,都是 OCPM 的出价方式
+        unitParams.put("cpa_bid",item);
+        unitParams.put("ocpx_action_type",strategy.getOcpxActionType());
+        unitParams.put("deep_conversion_type",strategy.getDeepConversionType());
+        unitParams.put("deep_conversion_bid",strategy.getDeepConversionBid());
+        unitParams.put("scene_id",JSONArray.parseArray(strategy.getSceneId()));
+        unitParams.put("unit_type",4);
+
+        // 格式为yyyy-MM-dd,需大于等于当前时间
+        unitParams.put("begin_time",DateUtils.formatDate(new Date()));
+        if(null!=strategy.getConvertId()){
+            unitParams.put("convert_id",strategy.getConvertId());
+        }
+        // 当计划类型是3/4/5时必填
+        if(null!=strategy.getUrl()&&!"".equals(strategy.getUrl())){
+            unitParams.put("url",strategy.getUrl());
+        }
+        JSONArray appIds = JSONArray.parseArray(strategy.getAppIds());
+        //TODO 先只做单appId的逻辑
+        if(null!=appIds&&!appIds.isEmpty()){
+            unitParams.put("app_id",appIds.getLong(0));
+        }
+        unitParams.put("show_mode",2);
+        unitParams.put("speed",1);
+        // 设置定向内容
+        JSONObject targetJsonObject = new JSONObject();
+        targetJsonObject.put("region",JSONArray.parseArray(strategy.getRegion()));
+        targetJsonObject.put("ages_range",JSONArray.parseArray(strategy.getAgesRange()));
+        targetJsonObject.put("gender",strategy.getGender());
+        targetJsonObject.put("platform_os",strategy.getPlatformOs());
+        JSONArray population = JSONArray.parseArray(strategy.getPopulation());
+        if(null!=population&&!population.isEmpty()){
+            targetJsonObject.put("population",population);
+        }
+        JSONArray excludePopulation = JSONArray.parseArray(strategy.getExcludePopulation());
+        if(null!=excludePopulation&&!excludePopulation.isEmpty()){
+            targetJsonObject.put("paid_audience",excludePopulation);
+        }
+
+        unitParams.put("target",targetJsonObject);
+        return unitParams;
+    }
+
+    private static List<Long> splitCapBidByDomain(Long cpaBidMin, Long cpaBidMax, Long stepSize) {
+        List<Long>result = new ArrayList<>();
+        if(cpaBidMin>cpaBidMax){
+            return result;
+        }
+        if(cpaBidMin.equals(cpaBidMax)){
+            result.add(cpaBidMin);
+            return result;
+        }
+        if(cpaBidMin<cpaBidMax){
+            result.add(cpaBidMin);
+            result.add(cpaBidMax);
+            while (cpaBidMin<cpaBidMax){
+                cpaBidMin+=stepSize;
+                if(cpaBidMin>= cpaBidMax){
+                    return result;
+                }
+                result.add(cpaBidMin);
+            }
+        }
+        return result;
     }
 
     private JSONObject creativeParams(CtopOauthToken token,Long unitId,KuaiShouVideoGet videoItem,int unitCnt,KuaishouStrategy strategy){
@@ -197,8 +369,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
         creativeParams.put("creative_name","智能创意-"+uuid+unitCnt+"-"+1);
         creativeParams.put("creative_material_type",videoItem.getMaterialType());
         creativeParams.put("action_bar_text","立即下载");
-        //TODO 广告语
-        creativeParams.put("description","测试广告语");
+        creativeParams.put("description","太美了!来电显示设为视频铃声,来电话就开始播放~");
         // 安卓下载中间页ID
         JSONArray siteIdArray = JSONArray.parseArray(strategy.getSiteId());
         if(null == siteIdArray||!siteIdArray.isEmpty()){
@@ -286,24 +457,28 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
         unitParams.put("speed",1);
         // 设置定向内容
         JSONObject targetJsonObject = new JSONObject();
+        //TODO 34
         if (strategyTemplate.getTestDirection().equals("region")){
             targetJsonObject.put("region",JSONArray.parseArray(item.getTargetContent()));
         } else {
             targetJsonObject.put("region",JSONArray.parseArray(strategy.getRegion()));
         }
 
+        //TODO 5
         if (strategyTemplate.getTestDirection().equals("age")){
             targetJsonObject.put("ages_range",JSONArray.parseArray(item.getTargetContent()));
         } else{
             targetJsonObject.put("ages_range",JSONArray.parseArray(strategy.getAgesRange()));
         }
 
+        //TODO 3
         if (strategyTemplate.getTestDirection().equals("gender")){
             targetJsonObject.put("gender",item.getTargetContent());
         } else {
             targetJsonObject.put("gender",strategy.getGender());
         }
 
+        //TODO
         if (strategyTemplate.getTestDirection().equals("operation_system")){
             targetJsonObject.put("platform_os",item.getTargetContent());
         } else {
@@ -341,7 +516,9 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
         mapCreative.setVideoSignature(videoGet.getSignature());
         mapCreative.setCreativeId(creativeId);
         mapCreative.setStrategyId(strategy.getId());
-        mapCreative.setStrategyTargetUnionId(targetUnion.getId());
+        if(null!=targetUnion){
+            mapCreative.setStrategyTargetUnionId(targetUnion.getId());
+        }
         mapCreativeService.save(mapCreative);
     }
 

+ 9 - 0
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -414,4 +414,13 @@ public class SampleTest {
             reportService.getAdvertiserReport(token,DateUtils.addDay(new Date(),-i),DateUtils.addDay(new Date(),-i),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
         }
     }
+
+    @Test
+    public void loadKuaishouVideo(){
+        String endDate = DateUtils.getNowDate("yyyy-MM-dd");
+        CtopOauthToken token = tokenService.getTokenByAccountId(9743023L);
+//        kuaishouInterfaceService.getVideoList(token, endDate, endDate);
+        kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, new Date(), new Date(), null, null);
+    }
+
 }

+ 0 - 1
module-common/src/main/java/cn/com/ctop/common/module/utils/LoadFileUtil.java

@@ -19,7 +19,6 @@ public class LoadFileUtil {
      */
     public static String downLoadFromUrl(String urlStr, String savePath) {
         try {
-
             String fileName = AesEncryptUtil.getUrlDecoderString(urlStr.substring(urlStr.lastIndexOf("/") + 1));
             URL url = new URL(urlStr);
 

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

@@ -100,4 +100,5 @@ public class KuaiShouVideoGet {
     private Integer channelType;
     private Integer status;
     private Long userId;
+    private Integer aiStatus;
 }

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

@@ -10,6 +10,7 @@ import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -35,6 +36,12 @@ public class KuaishouStrategy {
     private String createBy;
     private String creativeTag;
     private Integer creativeCategory;
+    //转化目标最低出价
+    private Long cpaBidMin;
+    //转化目标最高出价
+    private Long cpaBidMax;
+    //出价拆分步长
+    private Long stepSize;
     /**
      * 账户ID
      */

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java

@@ -20,5 +20,5 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
 
     List<KuaiShouVideoGetVo> getVideoList(Map<String, Object> stringObjectMap);
 
-    List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId,Integer videoNums);
+    List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId,Integer videoAiStatus);
 }

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

@@ -38,9 +38,6 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     private KuaiShouVideoGetMapper videoGetMapper;
     @Autowired
     private IMaterialCutFrameService materialCutFrameService;
-    static ExecutorService executorService = Executors.newFixedThreadPool(15);
-
-
     @Value("${oss.replace.download}")
     private String downloadUrl;
 
@@ -125,17 +122,15 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     }
 
     @Override
-    public List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId,Integer videoNums) {
+    public List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId,Integer aiStatus) {
         QueryWrapper<KuaiShouVideoGet>queryWrapper = new QueryWrapper<>();
         if(null!=accountId&&accountId!=0){
             queryWrapper.eq("account_id",accountId);
         }
-        queryWrapper.orderByDesc("stat_date");
-        if(null!=videoNums&&videoNums!=0){
-            queryWrapper.last("limit "+videoNums);
-        }else {
-            queryWrapper.last("limit 10");
+        if(null!=aiStatus&&aiStatus!=0){
+            queryWrapper.eq("ai_status",aiStatus);
         }
+        queryWrapper.orderByDesc("stat_date");
         return this.list(queryWrapper);
     }
 }

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

@@ -753,14 +753,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             detailJson.put("photo_like", like);
             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);
         }
         getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, campaignIds, creativeIds, page + 1);
@@ -817,7 +814,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             List<KuaishouReportDailyCreative> dailyCreatives = kuaishouResult.getData().getDetails();
             dailyCreatives.forEach((creative) -> {
                 creative.setAccountId(advertiserId);
-                creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate());
                 dailyCreativeService.saveOrUpdate(creative);
             });
         } catch (Exception e) {

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.report.entity;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -14,11 +15,15 @@ import java.util.Date;
 @TableName("ctop_kuaishou_report_daily_creative")
 public class KuaishouReportDailyCreative implements Serializable {
     private static final long serialVersionUID = 1L;
-    @TableId
-    private String id;
+    @TableId(type = IdType.AUTO)
+    private Long id;
     private Long accountId;
     @JsonProperty("creative_id")
     private Long creativeId;
+    private Long  unitId;
+    private String unitName;
+    private Long campaignId;
+    private String campaignName;
 
     @JsonProperty("stat_date")
     private String statDate;
@@ -34,9 +39,9 @@ public class KuaishouReportDailyCreative implements Serializable {
     @JsonProperty
     private Long bclick;
     @JsonProperty
-    private Long share;
+    private Long photoShare;
     @JsonProperty
-    private Long comment;
+    private Long photoComment;
     @JsonProperty
     private Long photoLike;
     @JsonProperty

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

@@ -394,7 +394,6 @@ public class KuaishouReportDailyCreativeStatistic {
     private String url;
 
     public KuaishouReportDailyCreativeStatistic(KuaishouReportDailyCreative creative) {
-        this.id = creative.getId();
         this.accountId = creative.getAccountId();
         this.creativeId = creative.getCreativeId();
         this.statDate = creative.getStatDate();
@@ -431,8 +430,8 @@ public class KuaishouReportDailyCreativeStatistic {
         this.eventPayFirstDay = creative.getEventPayFirstDay();
         this.photoClickCost = creative.getPhotoClickCost();
         this.actionCost = creative.getActionCost();
-        this.share = creative.getShare();
-        this.comment = creative.getComment();
+        this.share = creative.getPhotoShare();
+        this.comment = creative.getPhotoComment();
         this.photoLike = creative.getPhotoLike();
         this.follow = creative.getFollow();
         this.report = creative.getReport();