Explorar el Código

Merge remote-tracking branch 'origin/master'

syh hace 4 años
padre
commit
b9df98583b
Se han modificado 17 ficheros con 657 adiciones y 36 borrados
  1. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCreativeReportLoadJob.java
  2. 1 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyCreativeReportLoadJob.java
  3. 39 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  4. 263 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/CollectionSlogansController.java
  5. 77 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/CollectionSlogans.java
  6. 4 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCreative.java
  7. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/CollectionSlogansMapper.java
  8. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/CollectionSlogansMapper.xml
  9. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml
  10. 8 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java
  11. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/ICollectionSlogansService.java
  12. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  13. 121 27
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  14. 69 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CollectionSlogansServiceImpl.java
  15. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java
  16. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  17. 23 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCreativeReportLoadJob.java

@@ -61,7 +61,7 @@ public class KuaishouDailyCreativeReportLoadJob implements Job {
                                     @Override
                                     public void run() {
                                         try {
-                                            kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate, campaignIds);
+                                            kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate, campaignIds, null);
                                         } catch (Exception e) {
                                             log.info("获取创意日报失败,accountId:{}", token.getAccountId());
                                         }

+ 1 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyCreativeReportLoadJob.java

@@ -52,7 +52,7 @@ public class KuaishouDailyCreativeReportLoadJob {
             }
             List<JSONArray> campaigns = campaignService.getJsonArrByAccount(token.getAccountId(), 50);
             if (null != campaigns && !campaigns.isEmpty()) {
-                campaigns.forEach(campaign -> executorService.submit(() -> kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate, campaign)));
+                campaigns.forEach(campaign -> executorService.submit(() -> kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate, campaign, null)));
             }
         });
         return ReturnT.SUCCESS;

+ 39 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -2325,6 +2325,11 @@ public class BatchController {
     }
 
 
+    /**
+     * 贴纸类型
+     * @param accountId
+     * @return
+     */
     @GetMapping(value = "/getCreativeWordStyles")
     public Result<JSONArray> getCreativeWordStyles(Long accountId) {
         Result<JSONArray> result = new Result<>();
@@ -2349,4 +2354,38 @@ public class BatchController {
 
         return result;
     }
+
+    /**
+     * 创意分类
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/getCreativeCategory")
+    public Result<JSONArray> getCreativeCategory(Long accountId) {
+        Result<JSONArray> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("入参为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
+            JSONArray data = batchService.getCreativeCategory(accountId, oauthToken.getAccessToken());
+            result.setSuccess(true);
+            result.setResult(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setResult(null);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
+
+
 }

+ 263 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/CollectionSlogansController.java

@@ -0,0 +1,263 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.CollectionSlogans;
+import cn.com.ctop.kuaishou.modules.batch.service.ICollectionSlogansService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+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.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+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;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 收藏的广告语
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-10-12
+ */
+@Slf4j
+@Api(tags = "收藏的广告语")
+@RestController
+@RequestMapping("/kuaishou/collectionSlogans")
+public class CollectionSlogansController {
+    @Autowired
+    private ICollectionSlogansService CollectionSlogansService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param CollectionSlogans
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "收藏的广告语-分页列表查询")
+    @ApiOperation(value = "收藏的广告语-分页列表查询", notes = "收藏的广告语-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<CollectionSlogans>> queryPageList(CollectionSlogans CollectionSlogans,
+                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                          HttpServletRequest req) {
+        Result<IPage<cn.com.ctop.kuaishou.modules.batch.entity.CollectionSlogans>> result = new Result<>();
+        QueryWrapper<CollectionSlogans> queryWrapper = QueryGenerator.initQueryWrapper(CollectionSlogans, req.getParameterMap());
+        Page<CollectionSlogans> page = new Page<CollectionSlogans>(pageNo, pageSize);
+        IPage<CollectionSlogans> pageList = CollectionSlogansService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param CollectionSlogans
+     * @return
+     */
+    @AutoLog(value = "收藏的广告语-添加")
+    @ApiOperation(value = "收藏的广告语-添加", notes = "收藏的广告语-添加")
+    @PostMapping(value = "/add")
+    public Result<JSONObject> add(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if(Check.isNull(requestJson.getJSONArray("coverSlogansList"))&&Check.isNull(requestJson.getJSONArray("captionsList"))){
+                result.setMessage("请输入广告语");
+                result.setSuccess(false);
+                return result;
+            }
+            CollectionSlogansService.saveCollectionSlogans(requestJson);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param CollectionSlogans
+     * @return
+     */
+    @AutoLog(value = "收藏的广告语-编辑")
+    @ApiOperation(value = "收藏的广告语-编辑", notes = "收藏的广告语-编辑")
+    @PutMapping(value = "/edit")
+    public Result<CollectionSlogans> edit(@RequestBody CollectionSlogans CollectionSlogans) {
+        Result<CollectionSlogans> result = new Result<CollectionSlogans>();
+        CollectionSlogans CollectionSlogansEntity = CollectionSlogansService.getById(CollectionSlogans.getId());
+        if (CollectionSlogansEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = CollectionSlogansService.updateById(CollectionSlogans);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "收藏的广告语-通过id删除")
+    @ApiOperation(value = "收藏的广告语-通过id删除", notes = "收藏的广告语-通过id删除")
+    @GetMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            CollectionSlogansService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "收藏的广告语-批量删除")
+    @ApiOperation(value = "收藏的广告语-批量删除", notes = "收藏的广告语-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<CollectionSlogans> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<CollectionSlogans> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.CollectionSlogansService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "收藏的广告语-通过userId查询")
+    @ApiOperation(value = "收藏的广告语-通过id查询", notes = "收藏的广告语-通过id查询")
+    @GetMapping(value = "/getByUserId")
+    public Result<JSONObject> queryById(String userId,String accountId,String type) {
+        Result<JSONObject> result = new Result<>();
+        JSONObject CollectionSlogans = CollectionSlogansService.getByUserId(userId,accountId,type);
+        if (CollectionSlogans == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(CollectionSlogans);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<CollectionSlogans> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                CollectionSlogans CollectionSlogans = JSON.parseObject(deString, CollectionSlogans.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(CollectionSlogans, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<CollectionSlogans> pageList = CollectionSlogansService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "收藏的广告语列表");
+        mv.addObject(NormalExcelConstants.CLASS, CollectionSlogans.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("收藏的广告语列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<CollectionSlogans> listCollectionSloganss = ExcelImportUtil.importExcel(file.getInputStream(), CollectionSlogans.class, params);
+                CollectionSlogansService.saveBatch(listCollectionSloganss);
+                return Result.ok("文件导入成功!数据行数:" + listCollectionSloganss.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

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

@@ -0,0 +1,77 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+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;
+
+/**
+ * 收藏的广告语
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-10-12
+ */
+@Data
+@TableName("ctop_kuaishou_slogans_collection")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_slogans_collection对象", description = "收藏的广告语")
+public class CollectionSlogans {
+
+    /**
+     * 主键
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "主键")
+    private Long id;
+    /**
+     * 类型1-封面广告语;2-广告语
+     */
+    @Excel(name = "类型1-封面广告语;2-广告语", width = 15)
+    @ApiModelProperty(value = "类型1-封面广告语;2-广告语")
+    private String type;
+    /**
+     * value
+     */
+    @Excel(name = "value", width = 15)
+    @ApiModelProperty(value = "value")
+    private String value;
+    /**
+     * 人员ID
+     */
+    @Excel(name = "人员ID", width = 15)
+    @ApiModelProperty(value = "人员ID")
+    private String userId;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * createTime
+     */
+    @Excel(name = "createTime", 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 = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @Excel(name = "updateTime", 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 = "updateTime")
+    private Date updateTime;
+}

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

@@ -58,7 +58,6 @@ public class KuaiShouCreative {
     @ApiModelProperty(value = "广告创意ID")
     private Long creativeId;
 
-
     /**
      * 素材类型
      */
@@ -221,4 +220,8 @@ public class KuaiShouCreative {
 
 
     private String photoIds;
+
+    private Integer creativeCategory;
+    private String creativeTag;
+
 }

+ 15 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/CollectionSlogansMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.CollectionSlogans;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 收藏的广告语
+ *
+ * @author: jeecg-boot
+ * @date: 2020-10-12
+ * @cersion: V1.0
+ */
+public interface CollectionSlogansMapper extends BaseMapper<CollectionSlogans> {
+
+}

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/CollectionSlogansMapper.xml

@@ -0,0 +1,5 @@
+<?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.cn.com.ctop.kuaishou.modules.batch.controller.mapper.CollectionSlogansMapper">
+
+</mapper>

+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml

@@ -37,6 +37,8 @@
         actionbar_click_url,
         creative_create_time,
         creative_update_time,
+        creative_category,
+        creative_tag,
         create_time,
         update_time)
         values
@@ -76,6 +78,8 @@
             #{creative.actionbarClickUrl},
             #{creative.creativeCreateTime},
             #{creative.creativeUpdateTime},
+            #{creative.creativeCategory},
+            #{creative.creativeTag},
             #{creative.createTime},
             #{creative.updateTime})
         </foreach>

+ 8 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java

@@ -158,4 +158,12 @@ public interface IBatchService {
      * @return
      */
     JSONArray getCreativeWordStyles(Long accountId, String accessToken);
+
+    /**
+     * 获取创意分类
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    JSONArray getCreativeCategory(Long accountId, String accessToken);
 }

+ 18 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/ICollectionSlogansService.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.CollectionSlogans;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 收藏的广告语
+ * @Author: jeecg-boot
+ * @Date: 2020-10-12
+ * @Version: V1.0
+ */
+public interface ICollectionSlogansService extends IService<CollectionSlogans> {
+
+    void saveCollectionSlogans(JSONObject requestJson);
+
+    JSONObject getByUserId(String userId, String accountId,String type);
+}

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

@@ -340,7 +340,7 @@ public interface IKuaishouInterfaceService {
      * @param endDate
      * @param campaignIds
      */
-    void getAdvertiserCreativeReportDaily(CtopOauthToken token, Date startDate, Date endDate, JSONArray campaignIds);
+    void getAdvertiserCreativeReportDaily(CtopOauthToken token, Date startDate, Date endDate, JSONArray campaignIds, JSONArray creativeIds);
 
     /**
      * 获取广告主时报

+ 121 - 27
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java

@@ -1072,7 +1072,13 @@ public class BatchServiceImpl implements IBatchService {
                 creativeJson.put("action_bar_text", action_bar_text);
                 creativeJson.put("description", description.trim());
                 creativeJson.put("creative_name", name);
-                //  creativeJson.put("click_track_url", click_track_url);
+                String imageToken = null;
+                if (!Check.isNull(creative.getStickerTitle()) && !Check.isNull(creative.getOverlayType())) {
+                    imageToken = creative.getOverlayBgImageToken();
+                } else {
+                    imageToken = creative.getImageToken();
+                }
+
 
                 //封面广告语标题
                 if (!Check.isNull(creative.getStickerTitle())) {
@@ -1083,6 +1089,7 @@ public class BatchServiceImpl implements IBatchService {
                     creativeJson.put("overlay_type", creative.getOverlayType());
                 }
 
+
                 // 第三方有效播放监测链接
                 if (!Check.isNull(creative.getAdPhotoPlayedT3sUrl())) {
                     creativeJson.put("ad_photo_played_t3s_url", creative.getAdPhotoPlayedT3sUrl());
@@ -1092,7 +1099,13 @@ public class BatchServiceImpl implements IBatchService {
                     creativeJson.put("actionbar_click_url", creative.getActionbarClickUrl());
                 }
 
-
+                /**
+                 * 创意标签
+                 */
+                if (!Check.isNull(creative.getCreativeCategory()) && !Check.isNull(!Check.isNull(creative.getCreativeTag()))) {
+                    creativeJson.put("creative_category", creative.getCreativeCategory());
+                    creativeJson.put("creative_tag", JSONArray.parseArray(creative.getCreativeTag()));
+                }
                 if (!Check.isNull(otherJson)) {
                     Boolean isUpdate = otherJson.getBoolean("isUpdate"); // 是否修改落地页
                     if (isUpdate) {
@@ -1117,8 +1130,7 @@ public class BatchServiceImpl implements IBatchService {
                             } else {
                                 String photo_id = creative.getPhotoId();
                                 creativeJson.put("photo_id", photo_id);
-                                String image = creative.getImageToken();
-                                creativeJson.put("image_token", image);
+                                creativeJson.put("image_token", imageToken);
                                 creativeJson.put("click_track_url", clickTrackUrl);
 
                             }
@@ -1137,8 +1149,7 @@ public class BatchServiceImpl implements IBatchService {
                             } else {
                                 String photo_id = creative.getPhotoId();
                                 creativeJson.put("photo_id", photo_id);
-                                String image = creative.getImageToken();
-                                creativeJson.put("image_token", image);
+                                creativeJson.put("image_token", imageToken);
                                 if (!Check.isNull(click_track_url)) {
                                     creativeJson.put("click_track_url", click_track_url);
                                 }
@@ -1159,8 +1170,8 @@ public class BatchServiceImpl implements IBatchService {
                         } else {
                             String photo_id = creative.getPhotoId();
                             creativeJson.put("photo_id", photo_id);
-                            String image = creative.getImageToken();
-                            creativeJson.put("image_token", image);
+                            creativeJson.put("image_token", imageToken);
+
                             if (!Check.isNull(click_track_url)) {
                                 creativeJson.put("click_track_url", click_track_url);
                             }
@@ -1186,8 +1197,7 @@ public class BatchServiceImpl implements IBatchService {
                     } else {
                         String photo_id = creative.getPhotoId();
                         creativeJson.put("photo_id", photo_id);
-                        String image = creative.getImageToken();
-                        creativeJson.put("image_token", image);
+                        creativeJson.put("image_token", imageToken);
                         if (!Check.isNull(click_track_url)) {
                             creativeJson.put("click_track_url", click_track_url);
                         }
@@ -1272,6 +1282,9 @@ public class BatchServiceImpl implements IBatchService {
         String action_bar_text = requestJson.getString("actionBarText");
         String click_track_url = requestJson.getString("clickTrackUrl");
         String site_id = requestJson.getString("siteId");
+        Integer creativeCategory = requestJson.getInteger("creativeCategory");// 创意分类
+        JSONArray creativeTag = requestJson.getJSONArray("creativeTag");
+
         JSONObject returnJson = new JSONObject();
         JSONArray successArr = new JSONArray();
         JSONArray failArr = new JSONArray();
@@ -1285,8 +1298,8 @@ public class BatchServiceImpl implements IBatchService {
 
                 String creativeMaterialType = dataJson.getString("creativeMaterialType");
                 String shortSlogan = dataJson.getString("shortSlogan");
-
-
+                String overlayType = dataJson.getString("overlayType");
+                String stickerTitle = dataJson.getString("stickerTitle");
                 if (!Check.isNull(dataJsons)) {
                     String description = dataJson.getString("description");
                     String photo_id = dataJson.getString("photoId");
@@ -1309,11 +1322,22 @@ public class BatchServiceImpl implements IBatchService {
                                     creativeJson.put("creative_material_type", creativeMaterialType);
                                 }
 
+                                if (!Check.isNull(overlayType)) {
+                                    creativeJson.put("overlay_type", overlayType);
+                                }
+                                if (!Check.isNull(stickerTitle)) {
+                                    creativeJson.put("sticker_title", stickerTitle);
+                                }
+
+                                if (!Check.isNull(creativeCategory) && !Check.isNull(creativeTag)) {
+                                    creativeJson.put("creative_category", creativeCategory);
+                                    creativeJson.put("creative_tag", creativeTag);
+                                }
+
                                 if (creativeMaterialType.equals("4")) {
                                     if (!Check.isNull("shortSlogan")) {
                                         creativeJson.put("short_slogan", shortSlogan);
                                     }
-
                                 }
                                 String imageToken = null;
                                 String signature = imageJson.getString("signature");
@@ -1789,27 +1813,97 @@ public class BatchServiceImpl implements IBatchService {
      */
     @Override
     public JSONArray getCreativeWordStyles(Long accountId, String accessToken) {
-        String url = "https://ad.e.kuaishou.com/rest/openapi/v1/tool/creative_word/styles";
-        Map<String, String> headers = new HashMap<String, String>();
-        headers.put("Content-Type", "application/json");
-        headers.put("Access-Token", accessToken);
-        Map<String, Object> param = new HashMap<String, Object>();
-        param.put("advertiser_id", accountId);
-
-        String result = HttpUtils.httpPostRequest(url, param, headers);
-        JSONObject resultJson = JSONObject.parseObject(result);
-        log.info("获取贴纸样式,accountId:{},data:{}", accountId, resultJson);
-        if (!Check.isNull(resultJson)) {
-            Integer code = resultJson.getInteger("code");
-            if (code == 0) {
-                return resultJson.getJSONArray("data");
+        try {
+            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/tool/creative_word/styles";
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Content-Type", "application/json");
+            headers.put("Access-Token", accessToken);
+            Map<String, Object> param = new HashMap<String, Object>();
+            param.put("advertiser_id", accountId);
+            String result = HttpUtils.httpPostRequest(url, param, headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    return resultJson.getJSONArray("data");
+                }
             }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
 
+
+    /**
+     * 获取创意分类
+     *
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    @Override
+    public JSONArray getCreativeCategory(Long accountId, String accessToken) {
+
+        try {
+            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/creative/creative_category/list";
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Content-Type", "application/json");
+            headers.put("Access-Token", accessToken);
+            Map<String, Object> param = new HashMap<String, Object>();
+            param.put("advertiser_id", accountId);
+            String result = HttpUtils.httpPostRequest(url, param, headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject data = resultJson.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+                        JSONArray details = data.getJSONArray("details");
+                        if (!Check.isNull(details)) {
+                            JSONArray returnArr = new JSONArray();
+                            for (int i = 0; i < details.size(); i++) {
+                                JSONObject jsonObject = details.getJSONObject(i);
+
+                                String level = jsonObject.getString("level");
+                                if ("1".equals(level)) {
+                                    JSONArray LevelArr = getSubLevel(jsonObject.getInteger("category_id"), details);
+                                    jsonObject.put("child", LevelArr);
+                                    returnArr.add(jsonObject);
+                                }
+                            }
+                            return returnArr;
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
         }
         return null;
     }
 
 
+    private JSONArray getSubLevel(Integer categoryId, JSONArray details) {
+
+        JSONArray secondArr = new JSONArray();
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject secondJson = details.getJSONObject(i);
+            if ("2".equals(secondJson.getString("level")) && categoryId.equals(secondJson.getInteger("parent_id"))) {
+                JSONArray thirdArr = new JSONArray();
+                for (int j = 0; j < details.size(); j++) {
+                    JSONObject thirdJson = details.getJSONObject(j);
+                    if ("3".equals(thirdJson.getString("level")) && secondJson.getInteger("category_id").equals(thirdJson.getInteger("parent_id"))) {
+                        thirdArr.add(thirdJson);
+                    }
+                }
+                secondJson.put("child", thirdArr);
+                secondArr.add(secondJson);
+            }
+        }
+        return secondArr;
+    }
+
 }
 
 

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

@@ -0,0 +1,69 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.CollectionSlogans;
+import cn.com.ctop.kuaishou.modules.batch.mapper.CollectionSlogansMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.ICollectionSlogansService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xxl.job.core.enums.NoEn;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 收藏的广告语
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-10-12
+ */
+@Service
+public class CollectionSlogansServiceImpl extends ServiceImpl<CollectionSlogansMapper, CollectionSlogans> implements ICollectionSlogansService {
+
+    @Autowired
+    CollectionSlogansMapper collectionSlogansMapper;
+
+    @Override
+    public void saveCollectionSlogans(JSONObject requestJson) {
+        CollectionSlogans co = new CollectionSlogans();
+        String userId = requestJson.getString("userId");
+        Long accountId = requestJson.getLong("accountId");
+        if (!Check.isNull(requestJson.getJSONArray("coverSlogansList"))) {
+            //封面广告语
+            co.setType(NoEn.NO1.valueStr());
+            co.setValue(requestJson.getJSONArray("coverSlogansList").toString());
+        }
+        if (!Check.isNull(requestJson.getJSONArray("captionsList"))) {
+            co.setType(NoEn.NO2.valueStr());
+            co.setValue(requestJson.getJSONArray("captionsList").toString());
+        }
+        co.setAccountId(accountId);
+        co.setUserId(userId);
+        JSONObject slogansJson = getByUserId(userId, accountId.toString(), co.getType());
+        if (!Check.isNull(slogansJson)) {
+            QueryWrapper<CollectionSlogans> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("id", slogansJson.getInteger("id"));
+            collectionSlogansMapper.update(co, queryWrapper);
+        } else {
+            collectionSlogansMapper.insert(co);
+        }
+    }
+
+    @Override
+    public JSONObject getByUserId(String userId, String accountId, String type) {
+        QueryWrapper<CollectionSlogans> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("user_id", userId);
+        queryWrapper.eq("type", type);
+        queryWrapper.last("limit 1");
+        CollectionSlogans slogans = collectionSlogansMapper.selectOne(queryWrapper);
+        JSONObject resultJson = null;
+        if (!Check.isNull(slogans)) {
+            resultJson = (JSONObject) JSONObject.toJSON(slogans);
+            resultJson.put("value", JSONArray.parseArray(slogans.getValue()));
+        }
+        return resultJson;
+    }
+}

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

@@ -149,6 +149,10 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
                     creative.setDescription(displayInfoJson.getString("description"));
                     creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
                 }
+                creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                    creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                }
                 creative.setCreateTime(new java.util.Date());
                 creative.setUpdateTime(new java.util.Date());
                 creative.setSiteId(detailJson.getLong("site_id"));

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

@@ -222,6 +222,10 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
                         creative.setDescription(displayInfoJson.getString("description"));
                         creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
                     }
+                    creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                    if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                        creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                    }
                     creative.setCreateTime(new Date());
                     creative.setUpdateTime(new Date());
                     creative.setSiteId(detailJson.getLong("site_id"));

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

@@ -657,11 +657,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
-    public void getAdvertiserCreativeReportDaily(CtopOauthToken token, Date startDate, Date endDate, JSONArray campaignIds) {
-        getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, campaignIds, 1);
+    public void getAdvertiserCreativeReportDaily(CtopOauthToken token, Date startDate, Date endDate, JSONArray campaignIds, JSONArray creativeIds) {
+        getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, campaignIds, creativeIds, 1);
     }
 
-    private void getAdvertiserCreativeReportDailyByPage(CtopOauthToken token, Date startDate, Date endDate, JSONArray campaignIds, int page) {
+    private void getAdvertiserCreativeReportDailyByPage(CtopOauthToken token, Date startDate, Date endDate, JSONArray campaignIds, JSONArray creativeIds, int page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_REPORT;
         Map<String, String> headers = new HashMap<String, String>();
         headers.put("Content-Type", "application/json");
@@ -677,7 +677,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             param.put("campaign_ids", campaignIds);
 
         }
+        if (!Check.isNull(creativeIds) && creativeIds.size() > 0) {
+            param.put("creative_ids", creativeIds);
 
+        }
         param.put("advertiser_id", token.getAccountId());
         param.put("temporal_granularity", "DAILY");
         param.put("page_size", 1000);
@@ -714,7 +717,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             dailyCreativeStatisticService.saveOrUpdate(statistic);
             dailyCreativeService.saveOrUpdate(creative);
         }
-        getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, campaignIds, page + 1);
+        getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, campaignIds, creativeIds, page + 1);
     }
 
     private KuaishouReportDailyCreativeStatistic setDailyStatistic(KuaishouReportDailyCreative creative, CtopOauthToken token) {
@@ -1336,7 +1339,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     if (!Check.isNull(detailJson.getJSONArray("material_url"))) {
                         creative.setMaterialUrl(detailJson.getJSONArray("material_url").toJSONString());
                     }
-
                     if (!Check.isNull(detailJson.getJSONArray("image_tokens"))) {
                         creative.setImageTokens(detailJson.getJSONArray("image_tokens").toJSONString());
                     }
@@ -1359,6 +1361,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     creative.setCreativeUpdateTime(detailJson.getDate("update_time"));
                     creative.setFirstFrameType(detailJson.getInteger("first_frame_type"));
                     creative.setShortSlogan(detailJson.getString("short_slogan"));
+                    creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                    if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                        creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                    }
                     creative.setActionbarClickUrl(detailJson.getString("actionbar_click_url"));
                     JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
                     if (!Check.isNull(displayInfoJson)) {
@@ -1542,6 +1548,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                     creative.setShortSlogan(detailJson.getString("short_slogan"));
                                     creative.setActionbarClickUrl(detailJson.getString("actionbar_click_url"));
                                     JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
+
+                                    creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                                    if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                                        creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                                    }
+
                                     if (!Check.isNull(displayInfoJson)) {
                                         creative.setDescription(displayInfoJson.getString("description"));
                                         creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
@@ -3066,6 +3078,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                     if (!Check.isNull(detailJson.getJSONArray("image_tokens"))) {
                                         creative.setImageTokens(detailJson.getJSONArray("image_tokens").toJSONString());
                                     }
+
+                                    creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                                    if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                                        creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                                    }
+
                                     creative.setStatus(detailJson.getInteger("status"));
                                     creative.setPutStatus(detailJson.getInteger("put_status"));
                                     creative.setCreateChannel(detailJson.getInteger("create_channel"));