소스 검색

删除账户素材---

zhaoxian 1 년 전
부모
커밋
cf0c966924

+ 1 - 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -240,6 +240,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/overView/**", "anon");
         filterChainDefinitionMap.put("/agent/**", "anon");
         filterChainDefinitionMap.put("/auto/**", "anon");
+        filterChainDefinitionMap.put("/del/video/**", "anon");
         filterChainDefinitionMap.put("/task/kuaishouHostingTask/**", "anon");
         filterChainDefinitionMap.put("/audienceReport/**", "anon");
         filterChainDefinitionMap.put("/stare/**", "anon");

+ 4 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -266,6 +266,10 @@ public class KuaishouInterfaceConstant {
      */
     public static final String UPDATE_CREATIVE_STATUS = "/rest/openapi/v1/creative/update/status";
     /**
+     * 批量删除视频
+     */
+    public static final String DELETE_CREATIVE_VIDEO = "/rest/openapi/gw/dsp/file/ad/video/delete";
+    /**
      * 快手-广告主信息
      */
     public static final String ADVERTISER_INFO = "/rest/openapi/v1/advertiser/info";

+ 84 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/DelKuaiShouVideoGetController.java

@@ -0,0 +1,84 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.kuaishou.modules.batch.service.IDelKuaiShouVideoGetService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ *
+ */
+@Slf4j
+@Api(tags = "快手-获取视频接口")
+@RestController
+@RequestMapping("/del/video")
+public class DelKuaiShouVideoGetController {
+    @Autowired
+    private IDelKuaiShouVideoGetService kuaiShouVideoGetService;
+
+
+    @GetMapping(value = "/insertVideoList")
+    public Result<Object> insertAutoVideo(Long accountId) {
+        Result<Object> result = new Result<>();
+        try {
+            kuaiShouVideoGetService.insertDelVideoList(accountId);
+            result.success("操作成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    @GetMapping(value = "/getCreateInfo")
+    public Result<Object> getCreateInfo(Long accountId, String photoName) {
+        Result<Object> result = new Result<>();
+        try {
+            kuaiShouVideoGetService.getCreateInfo(accountId, photoName);
+            result.success("操作成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+
+    @GetMapping(value = "/changeCreativesPutStatus")
+    public Result<Object> changeCreativesPutStatus(Long accountId) {
+        Result<Object> result = new Result<>();
+        try {
+            kuaiShouVideoGetService.changeCreativesPutStatus(accountId);
+            result.success("操作成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    @GetMapping(value = "/deleteAccountVideos")
+    public Result<Object> deleteAccountVideos(Long accountId, String photoName) {
+        Result<Object> result = new Result<>();
+        try {
+            //1 获取账户下所有视频
+            kuaiShouVideoGetService.insertDelVideoList(accountId);
+            Thread.sleep(1000l);
+            //2 通过【素材名】查询相关视频和关联的创意、程序化创意
+            kuaiShouVideoGetService.getCreateInfo(accountId, photoName);
+            Thread.sleep(1000l);
+            //3 更改创意状态为【删除】,并删除账户下该视频
+            kuaiShouVideoGetService.changeCreativesPutStatus(accountId);
+            result.success("操作成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+}

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

@@ -0,0 +1,52 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * @Description: 快手-待删筛选
+ */
+@Data
+@TableName("ctop_del_kuaishou_video_get")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_del_kuaishou_video_get对象", description = "快手-待删筛选")
+public class DelKuaiShouVideoGet {
+
+    /**
+     * id
+     */
+    @TableId
+    private Long id;
+    private Long accountId;
+    private String photoId;
+    private String photoName;
+    private String signature;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+
+}

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

@@ -0,0 +1,43 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.DelKuaiShouVideoGet;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @Description: 快手-获取视频接口
+ * @Author: jeecg-boot
+ * @Date: 2019-07-25
+ * @Version: V1.0
+ */
+public interface DelKuaiShouVideoGetMapper extends BaseMapper<DelKuaiShouVideoGet> {
+
+    void replaceBatch(@Param(value = "videos") List<DelKuaiShouVideoGet> videoGetList);
+
+    void deleteByAccountId(@Param(value = "accountId") Long accountId);
+
+    List<String> queryPhototIdsByPhotoName(@Param(value = "accountId") Long accountId, @Param(value = "photoName") String photoName);
+
+    void replaceBatchVideoRelateCreatives(@Param("object") JSONObject object, @Param("creatives") JSONArray creatives);
+
+    void replaceBatchVideoRelateAdvancedCreatives(@Param("object") JSONObject object, @Param("advancedCreativeIds") JSONArray advancedCreativeIds);
+
+    List<Long> queryCreativeIds(@Param("accountId") Long accountId);
+
+    Set<Long> queryAdvancedCreativeIds(@Param("accountId") Long accountId);
+
+    void updateCreativesStatus(@Param("accountId") Long accountId, @Param("creativeIds") List<Long> creativeIds);
+
+    void updateAdvancedCreativesStatus(@Param("accountId") Long accountId, @Param("unitIds") List<Long> unitIds);
+
+    List<String> getPhotoIds(@Param("accountId") Long accountId, @Param("putStatus") String putStatus);
+
+    List<String> getPhotoIds2(@Param("accountId") Long accountId, @Param("putStatus") String putStatus);
+
+    void insertDelPhotoIdLog(@Param("accountId") Long accountId, @Param("photoIds") Set<String> photoIds, @Param("code") Integer code, @Param("message") String message);
+}

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

@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.batch.mapper.DelKuaiShouVideoGetMapper">
+    <insert id="replaceBatch">
+        replace into ctop_del_kuaishou_video_get(
+        account_id,
+        photo_id,
+        signature,
+        photo_name
+        )
+        values
+        <foreach collection="videos" item="video" separator=",">
+            (
+            #{video.accountId},
+            #{video.photoId},
+            #{video.signature},
+            #{video.photoName}
+            )
+        </foreach>
+    </insert>
+
+    <delete id="deleteByAccountId">
+        DELETE
+        FROM ctop_del_kuaishou_video_get
+        WHERE account_id = #{accountId}
+    </delete>
+
+    <select id="queryPhototIdsByPhotoName" resultType="String">
+        select photo_id
+        from ctop_del_kuaishou_video_get
+        where account_id = #{accountId}
+          AND photo_name Like CONCAT('%', #{photoName}, '%')
+    </select>
+
+    <insert id="replaceBatchVideoRelateCreatives">
+        replace
+        into ctop_del_kuaishou_video_relate_creatives(
+        account_id,
+        photo_id,
+        creative_id,
+        create_name)
+        values
+        <foreach collection="creatives" item="creative" separator=",">
+            (
+            #{object.account_id},
+            #{object.photo_id},
+            #{creative.creative_id},
+            #{creative.creative_name}
+            )
+        </foreach>
+    </insert>
+
+    <insert id="replaceBatchVideoRelateAdvancedCreatives">
+        replace
+        into ctop_del_kuaishou_video_relate_advanced_creatives(
+        account_id,
+        photo_id,
+        advanced_creative_id)
+        values
+        <foreach collection="advancedCreativeIds" item="advancedCreativeId" separator=",">
+            (
+            #{object.account_id},
+            #{object.photo_id},
+            #{advancedCreativeId}
+            )
+        </foreach>
+    </insert>
+
+    <select id="queryCreativeIds" resultType="Long">
+        select creative_id
+        from ctop_del_kuaishou_video_relate_creatives
+        where put_status = 0
+          AND account_id = #{accountId}
+    </select>
+
+    <select id="queryAdvancedCreativeIds" resultType="Long">
+        select advanced_creative_id
+        from ctop_del_kuaishou_video_relate_advanced_creatives
+        where put_status = 0
+          AND account_id = #{accountId}
+    </select>
+
+    <select id="getPhotoIds" resultType="String">
+        select photo_id
+        from ctop_del_kuaishou_video_relate_creatives
+        where put_status = #{putStatus}
+          AND account_id = #{accountId}
+        group by photo_id
+    </select>
+
+    <select id="getPhotoIds2" resultType="String">
+        select photo_id
+        from ctop_del_kuaishou_video_relate_advanced_creatives
+        where put_status = #{putStatus}
+          AND account_id = #{accountId}
+        group by photo_id
+    </select>
+
+    <update id="updateCreativesStatus">
+        UPDATE ctop_del_kuaishou_video_relate_creatives
+        SET put_status = 3
+        WHERE account_id = #{accountId}
+        AND creative_id IN
+        <foreach item="creativeId" index="index" collection="creativeIds"
+                 open="(" separator="," close=")">
+            #{creativeId}
+        </foreach>
+    </update>
+
+    <update id="updateAdvancedCreativesStatus">
+        UPDATE ctop_del_kuaishou_video_relate_advanced_creatives
+        SET put_status = 3
+        WHERE account_id = #{accountId}
+        AND advanced_creative_id IN
+        <foreach item="creativeId" index="index" collection="unitIds"
+                 open="(" separator="," close=")">
+            #{creativeId}
+        </foreach>
+    </update>
+
+    <insert id="insertDelPhotoIdLog">
+        REPLACE INTO ctop_del_kuaishou_delete_video_record (account_id, photo_id, photo_name,r_code,r_message)
+        SELECT account_id, photo_id, photo_name,'${code}','${message}'
+        FROM ctop_del_kuaishou_video_get
+        WHERE account_id = #{accountId}
+        and photo_id in
+        <foreach collection="photoIds" item="photoId" separator=","
+                 open="(" close=")">
+            #{photoId}
+        </foreach>
+    </insert>
+
+</mapper>

+ 22 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IDelKuaiShouVideoGetService.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.DelKuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+public interface IDelKuaiShouVideoGetService extends IService<DelKuaiShouVideoGet> {
+
+    void insertDelVideoList(Long accountId);
+
+    void getCreateInfo(Long accountId, String photoName);
+
+    void changeCreativesPutStatus(Long accountId);
+}
+

+ 285 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/DelKuaiShouVideoGetServiceImpl.java

@@ -0,0 +1,285 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.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.batch.entity.DelKuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.mapper.DelKuaiShouVideoGetMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IDelKuaiShouVideoGetService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+@Slf4j
+@Service
+public class DelKuaiShouVideoGetServiceImpl extends ServiceImpl<DelKuaiShouVideoGetMapper, DelKuaiShouVideoGet> implements IDelKuaiShouVideoGetService {
+    @Resource
+    private DelKuaiShouVideoGetMapper videoGetMapper;
+
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+
+    @Override
+    public void insertDelVideoList(Long accountId) {
+        //先删除历史记录,再添加最新数据
+        videoGetMapper.deleteByAccountId(accountId);
+
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        this.getDelVideoListByPage(token, 1);
+    }
+
+    private void getDelVideoListByPage(CtopOauthToken token, int page) {
+        try {
+            String date = DateUtils.formatDate(new Date());
+            Integer pageSize = 200;
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Content-Type", "application/json");
+            headers.put("Access-Token", token.getAccessToken());
+            Map<String, Object> param = new HashMap<>();
+            param.put("advertiser_id", token.getAccountId());
+            param.put("page_size", pageSize);
+            param.put("page", page);
+
+            String result = HttpUtils.httpPostRequest(url, param, headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (Check.isNull(resultJson)) {
+                return;
+            }
+            Integer code = resultJson.getInteger("code");
+            String message = resultJson.getString("message");
+            if (null == code || code != 0) {
+                log.error("获取快手视频列表数据异常:{},accountId:{}", message, token.getAccountId());
+                return;
+            }
+            JSONArray videoList = resultJson.getJSONObject("data").getJSONArray("details");
+            if (null == videoList || videoList.size() <= 0) {
+                log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
+                return;
+            }
+            Boolean doGet = true;
+            if (videoList.size() < pageSize) {
+                doGet = false;
+            }
+            JSONArray details = new JSONArray();
+            for (int i = 0; i < videoList.size(); i++) {
+                JSONObject video = videoList.getJSONObject(i);
+                details.add(video);
+            }
+            if (Check.isNull(details) || details.isEmpty()) {
+                return;
+            }
+            List<DelKuaiShouVideoGet> videoGetList = new ArrayList<>();
+            Long accountId = token.getAccountId();
+            for (int i = 0; i < details.size(); i++) {
+                JSONObject detailJson = details.getJSONObject(i);
+                if (Check.isNull(detailJson)) {
+                    continue;
+                }
+                DelKuaiShouVideoGet videoGet = new DelKuaiShouVideoGet();
+                videoGet.setAccountId(accountId);
+                videoGet.setPhotoId(detailJson.getString("photo_id"));
+                videoGet.setPhotoName(detailJson.getString("photo_name"));
+                videoGet.setSignature(detailJson.getString("signature"));
+                videoGetList.add(videoGet);
+            }
+            if (!Check.isNull(videoGetList)) {
+                videoGetMapper.replaceBatch(videoGetList);
+            }
+            if (doGet) {
+                getDelVideoListByPage(token, page + 1);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    @Override
+    public void getCreateInfo(Long accountId, String photoName) {
+        List<String> phototIds = videoGetMapper.queryPhototIdsByPhotoName(accountId, photoName);
+        videoRelateCreatives(accountId, phototIds);
+    }
+
+    public void videoRelateCreatives(Long accountId, List<String> photoIds) {
+        try {
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            for (String photoId : photoIds) {
+                String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_RELATE_CREATIVES;
+                Map<String, String> header = new HashMap<>();
+                header.put("Access-Token", token.getAccessToken());
+                header.put("Content-Type", "application/json");
+                JSONObject params = new JSONObject();
+                params.put("advertiser_id", accountId);
+                String[] photoIdArr = new String[]{photoId};
+                params.put("photo_ids", photoIdArr);
+                String result = HttpUtils.httpPostRequest(url, params, header);
+                JSONObject resultJson = JSONObject.parseObject(result);
+                if (!Check.isNull(resultJson)) {
+                    Integer code = resultJson.getInteger("code");
+                    if (code == 0) {
+                        JSONObject data = resultJson.getJSONObject("data");
+                        JSONArray relatedCreatives = data.getJSONArray("related_creatives");
+                        if (!Check.isNull(relatedCreatives) && relatedCreatives.size() > 0) {
+                            JSONObject object = relatedCreatives.getJSONObject(0);
+                            object.put("account_id", accountId);
+                            object.put("advancedCreativeIdsStr", object.getString("advanced_creative_ids"));
+                            JSONArray creatives = object.getJSONArray("creatives");
+                            if (!Check.isNull(creatives) && creatives.size() > 0) {
+                                videoGetMapper.replaceBatchVideoRelateCreatives(object, creatives);
+                            }
+                            JSONArray advancedCreativeIds = object.getJSONArray("advanced_creative_ids");
+                            if (!Check.isNull(advancedCreativeIds) && advancedCreativeIds.size() > 0) {
+                                videoGetMapper.replaceBatchVideoRelateAdvancedCreatives(object, advancedCreativeIds);
+                            }
+                        }
+                    } else {
+                        log.info("频库-视频关联创意数查询失败,入参:{},返回结果:{}", params, resultJson);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error("频库-视频关联创意数查询失败", e);
+        }
+    }
+
+
+    @Override
+    public void changeCreativesPutStatus(Long accountId) {
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        List<Long> allCreativeIds = videoGetMapper.queryCreativeIds(accountId);
+        //创意
+        if (!Check.isNull(allCreativeIds)) {
+            //最多20个ID
+            List<List<Long>> splitVideos = Lists.newArrayList(Lists.partition(allCreativeIds, 20));
+            for (List<Long> creativeIds : splitVideos) {
+                deleteCreatives(token.getAccessToken(), accountId, creativeIds);
+            }
+        }
+        //程序化创意
+        Set<Long> allAdvancedCreativeIds = videoGetMapper.queryAdvancedCreativeIds(accountId);
+        if (!Check.isNull(allAdvancedCreativeIds)) {
+            List<Long> allAdvancedCreativeIdsList = new ArrayList<>(allAdvancedCreativeIds);
+            //最多10个id
+            List<List<Long>> splitVideos = Lists.newArrayList(Lists.partition(allAdvancedCreativeIdsList, 10));
+            for (List<Long> unitIds : splitVideos) {
+                deleteUnitStatus(token.getAccessToken(), accountId, unitIds);
+            }
+        }
+
+        //批量删除视频
+        checkDeleteVideo(token.getAccessToken(), accountId);
+    }
+
+    //修改广告创意为删除状态
+    public void deleteCreatives(String token, Long accountId, List<Long> creativeIds) {
+        try {
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UPDATE_CREATIVE_STATUS;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token);
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("put_status", 3);//删除
+            params.put("advertiser_id", accountId);
+            params.put("creative_ids", creativeIds);
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                videoGetMapper.updateCreativesStatus(accountId, creativeIds);
+            } else {
+                log.error("修改广告创意删除状态失败,入参:{}, 结果:{}", params, resultJson);
+            }
+        } catch (Exception e) {
+            log.error("修改广告创意删除状态异常,advertiserId:{},creativeIds:{}", accountId, creativeIds);
+            e.printStackTrace();
+        }
+    }
+
+    //修改广告组为删除状态
+    public void deleteUnitStatus(String token, Long accountId, List<Long> unitIds) {
+        try {
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UPDATE_UNIT_STATUS;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token);
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", accountId);
+            params.put("unit_ids", unitIds);
+            params.put("put_status", 3);//删除
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                videoGetMapper.updateAdvancedCreativesStatus(accountId, unitIds);
+            } else {
+                log.error("修改广告组删除状态失败,入参:{}, 结果:{}", params, resultJson);
+            }
+        } catch (Exception e) {
+            log.error("修改广告组删除状态异常,advertiserId:{},unitIds:{}", accountId, unitIds);
+            e.printStackTrace();
+        }
+    }
+
+    private void checkDeleteVideo(String token, Long accountId) {
+        //查询   状态为0的,说明有删除失败,不执行删除视频操作
+        List<String> pids = videoGetMapper.getPhotoIds(accountId, "0");
+        List<String> pids2 = videoGetMapper.getPhotoIds2(accountId, "0");
+        if (Check.isNull(pids) && Check.isNull(pids2)) {
+            List<String> delphtotoids = videoGetMapper.getPhotoIds(accountId, "3");
+            List<String> delphtotoids2 = videoGetMapper.getPhotoIds2(accountId, "3");
+            //去重-转set
+            Set<String> photoIds = new HashSet<>(delphtotoids);
+            photoIds.addAll(delphtotoids2);
+            //执行删除
+            JSONObject resultJson = deleteVideo(token, accountId, photoIds);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                String message = resultJson.getString("message");
+                //添加执行结果记录
+                videoGetMapper.insertDelPhotoIdLog(accountId, photoIds, code, message);
+            }
+            log.info("删除账户视频,账户:{}, 结果:{}", accountId, resultJson);
+        } else {
+            log.error("创意和广告组删除状态未完全修改,不执行删除视频操作,账户accountId:{},参考信息:1创意:{} 2程序化创意:{}", accountId, pids, pids2);
+        }
+    }
+
+
+    //批量删除视频
+    public JSONObject deleteVideo(String token, Long accountId, Set<String> photoIds) {
+        try {
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.DELETE_CREATIVE_VIDEO;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token);
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", accountId);
+            params.put("photo_ids", photoIds);
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            return JSONObject.parseObject(result);
+        } catch (Exception e) {
+            log.error("批量删除账户视频异常,accountId:{},photoIds:{}", accountId, photoIds);
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+}