فهرست منبع

Merge branch 'V2.0.1' into test

zhaoxian 3 سال پیش
والد
کامیت
93bf932746
11فایلهای تغییر یافته به همراه133 افزوده شده و 104 حذف شده
  1. 3 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/StatusCode.java
  2. 44 7
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoStrategyController.java
  3. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoStrategy.java
  4. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoTargetMapper.xml
  5. 4 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoVideoMapper.xml
  6. 6 27
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoDoServiceImpl.java
  7. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoTargetServiceImpl.java
  8. 37 33
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java
  9. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelService.java
  10. 21 28
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java
  11. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AiKuaishouAdvertiserStrategyController.java

+ 3 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/StatusCode.java

@@ -69,7 +69,9 @@ public enum StatusCode {
     KUAISHOU_CRAWLER_APP_TASK_END("爬虫任务运行结束", 1, true),
     KUAISHOU_CRAWLER_APP_JOB_StART("任务开始执行开始", 0, true),
     KUAISHOU_CRAWLER_APP_JOB_END("任务运行结束", 1, true),
-    MODEL_VIDEO_NOT_EXIST("模板视频不存在或者已经被删除", 0, false);
+    MODEL_VIDEO_NOT_EXIST("模板视频不存在或者已经被删除", 0, false),
+
+    KUAISHOU_AUTO_STRATEGY_UPDATE("修改失败,该账户旧版自动投放策略已运行", 500, false);
     private String desc;
     private int code;
     private boolean flag;

+ 44 - 7
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoStrategyController.java

@@ -20,6 +20,8 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.common.util.RedisUtil;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.system.service.ISysRoleService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
@@ -31,7 +33,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -48,6 +49,7 @@ import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -81,6 +83,9 @@ public class AiKuaishouAccountAutoStrategyController {
     @Autowired
     private IAiKuaishouAdvertiserStrategyService aiKuaishouAdvertiserStrategyService;
 
+    @Autowired
+    private RedisUtil redisUtil;
+
     /**
      * 分页列表查询
      *
@@ -96,7 +101,7 @@ public class AiKuaishouAccountAutoStrategyController {
                                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                          HttpServletRequest req) {
         Result<PageInfo<AiKuaishouAccountAutoStrategy>> result = new Result<>();
-        if(Check.isNull(aiKuaishouAccountAutoStrategy.getUserId())){
+        if (Check.isNull(aiKuaishouAccountAutoStrategy.getUserId())) {
             result.setSuccess(false);
             result.setMessage("请选择用户");
             return result;
@@ -109,6 +114,7 @@ public class AiKuaishouAccountAutoStrategyController {
         PageInfo<AiKuaishouAccountAutoStrategy> pageInfo = aiKuaishouAccountAutoStrategyService.queryList(aiKuaishouAccountAutoStrategy);
         List<AiKuaishouAccountAutoStrategy> list = pageInfo.getList();
         List<AiKuaishouAccountAutoStrategy> setData = new ArrayList<>();
+        String date = DateUtils.formatDate(new Date());
         if (null != list && !list.isEmpty()) {
             list.forEach(record -> {
                 Long accountId = record.getAccountId();
@@ -116,9 +122,14 @@ public class AiKuaishouAccountAutoStrategyController {
                 if (null != allocation) {
                     record.setAuthName(allocation.getAuthName());
                 }
-                //TODO
-                record.setCustomCreatedUnitCnt(0);
-                record.setProgramCreatedUnitCnt(0);
+                String customkey = date + "_auto_custom_cnt_" + accountId;
+                Integer customUnitCnt = (Integer) redisUtil.get(customkey);
+                customUnitCnt = Check.isNull(customUnitCnt) ? 0 : customUnitCnt;
+                record.setCustomCreatedUnitCnt(customUnitCnt);
+                String programkey = date + "_auto_program_cnt_" + accountId;
+                Integer programUnitCnt = (Integer) redisUtil.get(programkey);
+                programUnitCnt = Check.isNull(programUnitCnt) ? 0 : programUnitCnt;
+                record.setProgramCreatedUnitCnt(programUnitCnt);
             });
         }
         pageInfo.setList(list);
@@ -139,14 +150,14 @@ public class AiKuaishouAccountAutoStrategyController {
         if (type == 1) {
             AiKuaishouAdvertiserStrategy getEntity = aiKuaishouAdvertiserStrategyService.getByAccountId(accountId);
             if (null != getEntity) {
-                return Result.error("该账户旧版自动投放配置信息已存在,请删除后再创建");
+                return Result.error("该账户旧版自动投放配置信息已存在,请关闭后再创建");
             }
         } else {
             QueryWrapper<AiKuaishouAccountAutoStrategy> queryWrapper = new QueryWrapper();
             queryWrapper.eq("account_id", accountId).last("limit 1");
             AiKuaishouAccountAutoStrategy one = aiKuaishouAccountAutoStrategyService.getOne(queryWrapper);
             if (null != one) {
-                return Result.error("该账户重构版自动投放配置信息已存在,请删除后再创建");
+                return Result.error("该账户重构版自动投放配置信息已存在,请关闭后再创建");
             }
         }
         return Result.ok("success");
@@ -232,6 +243,32 @@ public class AiKuaishouAccountAutoStrategyController {
         return result;
     }
 
+
+    /**
+     * 修改状态
+     *
+     * @return
+     */
+    @PostMapping(value = "/updateState")
+    public Result<AiKuaishouAccountAutoStrategy> updateState(@RequestBody AiKuaishouAccountAutoStrategy strategy) {
+        Result<AiKuaishouAccountAutoStrategy> result = new Result<AiKuaishouAccountAutoStrategy>();
+        AiKuaishouAccountAutoStrategy entity = aiKuaishouAccountAutoStrategyService.getById(strategy.getId());
+        if (entity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            AiKuaishouAdvertiserStrategy getEntity = aiKuaishouAdvertiserStrategyService.getByAccountId(entity.getAccountId());
+            if (null != getEntity && getEntity.getStatus() == strategy.getStatus() && strategy.getStatus() == 1) {
+                result.error500("修改失败,该账户旧版自动投放策略已运行");
+            }
+            boolean ok = aiKuaishouAccountAutoStrategyService.updateById(strategy);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
     /**
      * 通过id删除
      *

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoStrategy.java

@@ -375,7 +375,7 @@ public class AiKuaishouAccountAutoStrategy {
      */
     @Excel(name = "深度转化出价", width = 15)
     @ApiModelProperty(value = "深度转化出价")
-    private BigDecimal deepConversionBid;
+    private String deepConversionBid;
     /**
      * 是否创建程序化创意
      */

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoTargetMapper.xml

@@ -8,7 +8,7 @@
         FROM ctop_ai_kuaishou_account_auto_target
         where account_id = #{accountId}
         <if test="targetName != null">
-            and target_name = #{targetName}
+            and target_name LIKE CONCAT(CONCAT('%', #{targetName}), '%')
         </if>
         order by create_time desc
     </select>

+ 4 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoVideoMapper.xml

@@ -40,7 +40,7 @@
         <if test="createType == 'program'">
             AND program_status = 1
         </if>
-        <if test="channelType!=null">
+        <if test="channelType!=null and channelType!=2">
             AND channel_type = #{channelType}
         </if>
         <if test="statDate!=null">
@@ -56,7 +56,7 @@
         SELECT * FROM ctop_ai_kuaishou_account_auto_video
         WHERE custom_status = 1
         AND account_id = #{accountId}
-        <if test="channelType!=null">
+        <if test="channelType!=null and channelType!=2">
             AND channel_type = #{channelType}
         </if>
         <if test="statDate!=null">
@@ -91,7 +91,7 @@
         AND stat_date &gt;= DATE_SUB(#{statDate},INTERVAL 7 day)
         group by signature
         )
-        <if test="channelType!=null">
+        <if test="channelType!=null and channelType!=2">
             and channel_type = #{channelType}
         </if>
         <if test="keyword != null and keyword != '' ">
@@ -122,7 +122,7 @@
         AND stat_date &gt;= DATE_SUB(#{statDate},INTERVAL 60 day)
         group by signature
         )
-        <if test="channelType!=null">
+        <if test="channelType!=null and channelType!=2">
             and channel_type = #{channelType}
         </if>
         <if test="keyword != null and keyword != '' ">

+ 6 - 27
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoDoServiceImpl.java

@@ -356,16 +356,13 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
                         Integer redisCnt = (Integer) redisUtil.get(redisKey);
                         redisUtil.set(redisKey, redisCnt - 1, 100000L);
                         unitLevelOperationRecordService.saveOrUpdate(unitRecord);
-                        if (!Check.isNull(usedchannel)) {
-                            channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                        }
                         continue;
                     }
                     Long unitId = (Long) unitCreateResult.get("unitId");
                     unitRecord.setUnitId(unitId);
                     unitLevelOperationRecordService.saveOrUpdate(unitRecord);
                     if (!Check.isNull(usedchannel)) {
-                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
+                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId);
                     }
                     videoCnt--;
                     //更新自定义创建组数量
@@ -389,9 +386,6 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
             } catch (Exception e) {
                 e.printStackTrace();
                 log.error("(单应用)创建自定义广告组异常", e);
-                if (!Check.isNull(usedchannel)) {
-                    channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                }
             }
         } else {
             //多应用
@@ -773,16 +767,13 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
                     if (unitCode != 0) {
                         log.error("****** 程序化账户({})组创建失败,message:{}", accountId, unitMessage);
                         unitLevelOperationRecordService.saveOrUpdate(unitRecord);
-                        if (!Check.isNull(usedchannel)) {
-                            channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                        }
                         continue;
                     }
                     Long unitId = (Long) unitCreateResult.get("unitId");
                     unitRecord.setUnitId(unitId);
                     unitLevelOperationRecordService.saveOrUpdate(unitRecord);
                     if (!Check.isNull(usedchannel)) {
-                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
+                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId);
                     }
                     videoCnt--;
                     //更新程序化创建组数量
@@ -808,9 +799,6 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
             } catch (Exception e) {
                 e.printStackTrace();
                 log.error("(单应用)创建自定义广告组异常", e);
-                if (!Check.isNull(usedchannel)) {
-                    channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                }
             }
         } else {
             log.info("--------------------账户({})执行程序化多应用自动投放搭建:{}-----------------", accountId, typeName);
@@ -1041,16 +1029,13 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
             if (unitCode != 0) {
                 log.error("****** 账户({})组创建失败,入参:{},message:{}", accountId, unitParams.toString(), unitMessage);
                 unitLevelOperationRecordService.saveOrUpdate(unitRecord);
-                if (!Check.isNull(channel)) {
-                    channelService.callBackUpdateChannelRel("group", channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                }
                 continue;
             }
             Long unitId = (Long) unitCreateResult.get("unitId");
             unitRecord.setUnitId(unitId);
             unitLevelOperationRecordService.saveOrUpdate(unitRecord);
             if (!Check.isNull(channel)) {
-                channelService.callBackUpdateChannelRel("group", channel.getChannelCode(), accountId, newCampaignId, unitId, 1);
+                channelService.callBackUpdateChannelRel("group", channel.getChannelCode(), accountId, newCampaignId, unitId);
             }
             videoCnt--;
             //更新自定义创建组数量
@@ -1174,16 +1159,13 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
             if (unitCode != 0) {
                 log.error("****** 程序化账户({})组创建失败,入参:{},message:{}", accountId, unitParams, unitMessage);
                 unitLevelOperationRecordService.saveOrUpdate(unitRecord);
-                if (!Check.isNull(channel)) {
-                    channelService.callBackUpdateChannelRel("group", channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                }
                 continue;
             }
             Long unitId = (Long) unitCreateResult.get("unitId");
             unitRecord.setUnitId(unitId);
             unitLevelOperationRecordService.saveOrUpdate(unitRecord);
             if (!Check.isNull(channel)) {
-                channelService.callBackUpdateChannelRel("group", channel.getChannelCode(), accountId, newCampaignId, unitId, 1);
+                channelService.callBackUpdateChannelRel("group", channel.getChannelCode(), accountId, newCampaignId, unitId);
             }
             videoCnt--;
             //更新程序化创建组数量
@@ -1810,15 +1792,12 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
                 log.error("****** 自动投放重构创建计划失败,入参:{},message:{}", campaignParams.toJSONString(), message);
                 record.setCampaignId(0L);
                 aiKuaishouCampaignLevelOperationRecordService.saveOrUpdate(record);
-                if (!Check.isNull(channel)) {
-                    channelService.callBackUpdateChannelRel("plan", channel.getChannelCode(), token.getAccountId(), null, null, 0);
-                }
                 return null;
             }
             campaignId = (Long) campaignCreateResult.get("campaignId");
-            //回滚channel使用锁
+
             if (!Check.isNull(channel)) {
-                channelService.callBackUpdateChannelRel("plan", channel.getChannelCode(), token.getAccountId(), campaignId, null, 1);
+                channelService.callBackUpdateChannelRel("plan", channel.getChannelCode(), token.getAccountId(), campaignId, null);
             }
             record.setCampaignId(campaignId);
             aiKuaishouCampaignLevelOperationRecordService.saveOrUpdate(record);

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoTargetServiceImpl.java

@@ -62,7 +62,7 @@ public class AiKuaishouAccountAutoTargetServiceImpl extends ServiceImpl<AiKuaish
         wrapper.eq("target_name", requestJson.getString("targetName")).last("limit 1");
         AiKuaishouAccountAutoTarget one = this.getOne(wrapper);
         if (!Check.isNull(one) && one.getId() - requestJson.getLong("id") != 0) {
-            return Result.ok("账户下定向包名重复");
+            return Result.error("账户下定向包名重复");
         }
         AiKuaishouAccountAutoTarget target = JSONObject.toJavaObject(requestJson, AiKuaishouAccountAutoTarget.class);
         if (!Check.isNull(requestJson.getJSONArray("keyword"))) {

+ 37 - 33
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -8,14 +8,35 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
-import cn.com.ctop.kuaishou.modules.ai.entity.*;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouCampaignLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouCreativeLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouAppMultipleBids;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountCreativeOverrunInfo;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeAdsenceTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeMatTypeEnum;
-import cn.com.ctop.kuaishou.modules.ai.service.*;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCampaignLevelOperationRecordService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreateCreativeService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreativeLevelOperationRecordService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouUnitLevelOperationRecordService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountCreativeOverrunInfoService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
 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.service.*;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAppListService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+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.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItems;
 import cn.com.ctop.kuaishou.modules.channel.service.IKuaishouChannelService;
@@ -33,7 +54,14 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.text.ParseException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.UUID;
 
 @Slf4j
 @Service
@@ -299,9 +327,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 }
                 newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
                 if (null == newCampaignId) {
-                    if (!Check.isNull(channel)) {
-                        channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                    }
                     return videoCnt;
                 }
                 if (useChannel == 1) {
@@ -312,9 +337,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             if ("account".equals(level)) {
                                 usedchannel = channel;
                             } else {
-                                if (!Check.isNull(channel)) {
-                                    channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                                }
                                 return videoCnt;
                             }
                         }
@@ -389,9 +411,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     if (unitCode != 0) {
                         log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                        if (!Check.isNull(usedchannel)) {
-                            channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                        }
                         continue;
                     }
                     Long unitId = (Long) unitCreateResult.get("unitId");
@@ -399,7 +418,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                     videoCnt--;
                     if (!Check.isNull(usedchannel)) {
-                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
+                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId);
                     }
                     JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy, usedchannel);//TODO 添加素材
                     createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
@@ -411,9 +430,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             } catch (Exception e) {
                 e.printStackTrace();
                 log.error("创建自定义广告组异常", e);
-                if (!Check.isNull(usedchannel)) {
-                    channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                }
             }
         }
         return videoCnt;
@@ -667,9 +683,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 }
                 newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
                 if (null == newCampaignId) {
-                    if (!Check.isNull(channel)) {
-                        channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                    }
                     return;
                 }
                 if (useChannel == 1) {
@@ -680,9 +693,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             if ("account".equals(level)) {
                                 usedchannel = channel;
                             } else {
-                                if (!Check.isNull(channel)) {
-                                    channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                                }
                                 return;
                             }
                         }
@@ -761,16 +771,13 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     if (unitCode != 0) {
                         log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                        if (!Check.isNull(usedchannel)) {
-                            channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                        }
                         continue;
                     }
                     Long unitId = (Long) unitCreateResult.get("unitId");
                     unitLevelOperationRecord.setUnitId(unitId);
                     unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                     if (!Check.isNull(usedchannel)) {
-                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
+                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId);
                     }
                     JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null, usedchannel);
                     createProgramCreative(token, creativeParams, strategy);
@@ -778,9 +785,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             } catch (Exception e) {
                 e.printStackTrace();
                 log.error("创建程序化广告组异常", e);
-                if (!Check.isNull(usedchannel)) {
-                    channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                }
             }
         }
 
@@ -801,7 +805,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         Long unitNum = customUnitCnt * hour / 20;
         log.info("{}当前时间内需要创建组总数:{}", strategy.getAccountId(), unitNum);
         //查询当前账户创建自定义类型组数量
-        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(),4);
+        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(), 4);
         log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
         long remindCnt = unitNum - unitCreateCnt;
         if (remindCnt >= 1) {
@@ -834,7 +838,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         log.info("{}当天可创建组总数:{}", strategy.getAccountId(), unitNum);
         //查询当前账户创建自定义类型组数量
-        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(),4);
+        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(), 4);
         log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
         long remindCnt = unitNum - unitCreateCnt;
         if (remindCnt >= 1) {
@@ -1132,7 +1136,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         campaignId = (Long) campaignCreateResult.get("campaignId");
         if (!Check.isNull(channel)) {
-            channelService.callBackUpdateChannelRel("plan", channel.getChannelCode(), token.getAccountId(), campaignId, null, 1);
+            channelService.callBackUpdateChannelRel("plan", channel.getChannelCode(), token.getAccountId(), campaignId, null);
         }
         record.setCampaignId(campaignId);
         aiKuaishouCampaignLevelOperationRecordService.saveOrUpdate(record);

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelService.java

@@ -32,7 +32,7 @@ public interface IKuaishouChannelService extends IService<KuaishouChannel> {
 
     Result<Object> queryChannelLevel(JSONObject request);
 
-    void callBackUpdateChannelRel(String level, String channelCode, Long accoountId, Long planId, Long groupId, Integer state);
+    void callBackUpdateChannelRel(String level, String channelCode, Long accoountId, Long planId, Long groupId);
 
     KuaishouChannel queryUsedChannel(Long accountId, Long newCampaignId, String level);
 

+ 21 - 28
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java

@@ -1000,7 +1000,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
 
     @Override
     public void callBackUpdateChannelRel(String level, String channelCode, Long accountId, Long planId, Long
-            groupId, Integer state) {
+            groupId) {
         try {
             QueryWrapper<KuaishouChannel> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("account_id", accountId);
@@ -1008,33 +1008,26 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             KuaishouChannel one = this.getOne(queryWrapper);
             if (!Check.isNull(one)) {
                 one.setUpdateTime(new Date());
-                if (0 == state) {
-                    this.saveOrUpdate(one);
-                } else {
-                    QueryWrapper<KuaishouChannelRel> relqueryWrapper = new QueryWrapper<>();
-                    relqueryWrapper.eq("account_id", accountId);
-                    relqueryWrapper.eq("channel_code", channelCode).orderByAsc("create_time").last("limit 1");
-                    KuaishouChannelRel rel = channelRelService.getOne(relqueryWrapper);
-                    if (!Check.isNull(rel)) {
-                        if (!Check.isNull(rel.getCampaignId())) {
-                            rel.setId(null);
-                        }
-                        rel.setCampaignId(planId);
-                        rel.setUnitId(groupId);
-                        rel.setUpdateTime(new Date());
-                        channelRelService.save(rel);
-                        if ("plan".equals(level)) {
-                            Integer usageTimes = channelRelService.queryUsePlanCount(accountId, channelCode);
-                            one.setUsageTimes(usageTimes);
-//                            if (usageTimes > one.getHaveCycleTimes()) {
-//                                one.setHaveCycleTimes(usageTimes);
-//                            }
-                            this.saveOrUpdate(one);
-                        } else if ("group".equals(level)) {
-                            Integer usageTimes = channelRelService.queryUseGroupCount(accountId, channelCode);
-                            one.setUsageTimes(usageTimes);
-                            this.saveOrUpdate(one);
-                        }
+                QueryWrapper<KuaishouChannelRel> relqueryWrapper = new QueryWrapper<>();
+                relqueryWrapper.eq("account_id", accountId);
+                relqueryWrapper.eq("channel_code", channelCode).orderByAsc("create_time").last("limit 1");
+                KuaishouChannelRel rel = channelRelService.getOne(relqueryWrapper);
+                if (!Check.isNull(rel)) {
+                    if (!Check.isNull(rel.getCampaignId())) {
+                        rel.setId(null);
+                    }
+                    rel.setCampaignId(planId);
+                    rel.setUnitId(groupId);
+                    rel.setUpdateTime(new Date());
+                    channelRelService.save(rel);
+                    if ("plan".equals(level)) {
+                        Integer usageTimes = channelRelService.queryUsePlanCount(accountId, channelCode);
+                        one.setUsageTimes(usageTimes);
+                        this.saveOrUpdate(one);
+                    } else if ("group".equals(level)) {
+                        Integer usageTimes = channelRelService.queryUseGroupCount(accountId, channelCode);
+                        one.setUsageTimes(usageTimes);
+                        this.saveOrUpdate(one);
                     }
                 }
             }

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AiKuaishouAdvertiserStrategyController.java

@@ -6,12 +6,16 @@ import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoStrategy;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountAutoStrategyService;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
+import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItems;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
@@ -55,6 +59,9 @@ public class AiKuaishouAdvertiserStrategyController {
     @Autowired
     private IKuaiShouAppMultipleBidsService kuaiShouAppMultipleBidsService;
 
+    @Autowired
+    private IAiKuaishouAccountAutoStrategyService aiKuaishouAccountAutoStrategyService;
+
     /**
      * 分页列表查询
      *
@@ -188,6 +195,13 @@ public class AiKuaishouAdvertiserStrategyController {
         if (status != 0) {
             status = 1;
         }
+        QueryWrapper<AiKuaishouAccountAutoStrategy> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("project_id", aiKuaishouAdvertiserStrategyEntity.getAccountId());
+        AiKuaishouAccountAutoStrategy one = aiKuaishouAccountAutoStrategyService.getOne(queryWrapper);
+        if(null!=one&&one.getStatus() == status &&status ==1){
+            ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_AUTO_STRATEGY_UPDATE);
+            return result;
+        }
         aiKuaishouAdvertiserStrategyEntity.setStatus(status);
         aiKuaishouAdvertiserStrategyService.updateById(aiKuaishouAdvertiserStrategyEntity);
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);