Pārlūkot izejas kodu

快手堆量创建

yumeng 4 gadi atpakaļ
vecāks
revīzija
50155faa76
13 mainītis faili ar 1151 papildinājumiem un 29 dzēšanām
  1. 5 13
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/CollectionSlogansController.java
  2. 343 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouGroupTemplateController.java
  3. 234 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTemplate.java
  4. 26 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupTemplateMapper.java
  5. 41 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupTemplateMapper.xml
  6. 34 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupTemplateService.java
  7. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouOverRunSendMessageService.java
  8. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  9. 2 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  10. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CrossAccountBatchServiceImpl.java
  11. 445 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTemplateServiceImpl.java
  12. 12 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouOverRunSendMessageServiceImpl.java
  13. 6 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

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

@@ -21,15 +21,7 @@ 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.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
@@ -86,7 +78,7 @@ public class CollectionSlogansController {
     /**
      * 添加
      *
-     * @param CollectionSlogans
+     * @param
      * @return
      */
     @AutoLog(value = "收藏的广告语-添加")
@@ -95,7 +87,7 @@ public class CollectionSlogansController {
     public Result<JSONObject> add(@RequestBody JSONObject requestJson) {
         Result<JSONObject> result = new Result<>();
         try {
-            if(Check.isNull(requestJson.getJSONArray("coverSlogansList"))&&Check.isNull(requestJson.getJSONArray("captionsList"))&&Check.isNull(requestJson.getJSONArray("creativeTag"))){
+            if (Check.isNull(requestJson.getJSONArray("coverSlogansList")) && Check.isNull(requestJson.getJSONArray("captionsList")) && Check.isNull(requestJson.getJSONArray("creativeTag"))) {
                 result.setMessage("请输入广告语");
                 result.setSuccess(false);
                 return result;
@@ -181,9 +173,9 @@ public class CollectionSlogansController {
     @AutoLog(value = "收藏的广告语-通过userId查询")
     @ApiOperation(value = "收藏的广告语-通过id查询", notes = "收藏的广告语-通过id查询")
     @GetMapping(value = "/getByUserId")
-    public Result<JSONObject> queryById(String userId,String accountId,String type) {
+    public Result<JSONObject> queryById(String userId, String accountId, String type) {
         Result<JSONObject> result = new Result<>();
-        JSONObject CollectionSlogans = CollectionSlogansService.getByUserId(userId,accountId,type);
+        JSONObject CollectionSlogans = CollectionSlogansService.getByUserId(userId, accountId, type);
         if (CollectionSlogans == null) {
             result.error500("未找到对应实体");
         } else {

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

@@ -0,0 +1,343 @@
+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.KuaiShouGroupTemplate;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
+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.DateUtils;
+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.*;
+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-12-15
+ */
+@Slf4j
+@Api(tags = "创建组模板")
+@RestController
+@RequestMapping("/batch/kuaiShouGroupTemplate")
+public class KuaiShouGroupTemplateController {
+    @Autowired
+    private IKuaiShouGroupTemplateService kuaiShouGroupTemplateService;
+
+
+    /**
+     * 批量创建广告组
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/submitUnitTask")
+    public Result<JSONObject> submitUnitTask(@RequestBody JSONObject requestJson) {
+        System.err.println(requestJson);
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("参数不能为空");
+            }
+            JSONObject returnJson = kuaiShouGroupTemplateService.submitUnitTask(requestJson);
+            result.setSuccess(true);
+            result.setResult(returnJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+
+    }
+
+    @GetMapping(value = "/createUnit")
+    public Result<JSONObject> createUnit() {
+        Result<JSONObject> result = new Result<>();
+        try {
+            kuaiShouGroupTemplateService.createUnit();
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+
+    }
+
+
+    /**
+     * 获取api今日创建创意数
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/getApiCreateCount")
+    public Result<Integer> getApiCreateCount(Long accountId) {
+
+        Result<Integer> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("accountId参数不能为空");
+            }
+            String date = DateUtils.getNowDate("yyyy-MM-dd");
+
+            Integer count = kuaiShouGroupTemplateService.getApiCreateCount(accountId, date);
+            result.setSuccess(true);
+            result.setResult(count);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+
+    }
+
+
+    @GetMapping(value = "/getUrlByPhotoId")
+    public Result<JSONObject> getUrlByPhotoId(Long photoId) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(photoId)) {
+                throw new Exception("photoId参数不能为空");
+            }
+            JSONObject urlJson = kuaiShouGroupTemplateService.getUrlByPhotoId(photoId);
+            result.setSuccess(true);
+            result.setResult(urlJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+
+    }
+
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaiShouGroupTemplate
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "创建组模板-分页列表查询")
+    @ApiOperation(value = "创建组模板-分页列表查询", notes = "创建组模板-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaiShouGroupTemplate>> queryPageList(KuaiShouGroupTemplate kuaiShouGroupTemplate,
+                                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                              HttpServletRequest req) {
+        Result<IPage<KuaiShouGroupTemplate>> result = new Result<>();
+        QueryWrapper<KuaiShouGroupTemplate> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouGroupTemplate, req.getParameterMap());
+        Page<KuaiShouGroupTemplate> page = new Page<KuaiShouGroupTemplate>(pageNo, pageSize);
+        IPage<KuaiShouGroupTemplate> pageList = kuaiShouGroupTemplateService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaiShouGroupTemplate
+     * @return
+     */
+    @AutoLog(value = "创建组模板-添加")
+    @ApiOperation(value = "创建组模板-添加", notes = "创建组模板-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaiShouGroupTemplate> add(@RequestBody KuaiShouGroupTemplate kuaiShouGroupTemplate) {
+        Result<KuaiShouGroupTemplate> result = new Result<>();
+        try {
+            kuaiShouGroupTemplateService.save(kuaiShouGroupTemplate);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaiShouGroupTemplate
+     * @return
+     */
+    @AutoLog(value = "创建组模板-编辑")
+    @ApiOperation(value = "创建组模板-编辑", notes = "创建组模板-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaiShouGroupTemplate> edit(@RequestBody KuaiShouGroupTemplate kuaiShouGroupTemplate) {
+        Result<KuaiShouGroupTemplate> result = new Result<KuaiShouGroupTemplate>();
+        KuaiShouGroupTemplate kuaiShouGroupTemplateEntity = kuaiShouGroupTemplateService.getById(kuaiShouGroupTemplate.getId());
+        if (kuaiShouGroupTemplateEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaiShouGroupTemplateService.updateById(kuaiShouGroupTemplate);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "创建组模板-通过id删除")
+    @ApiOperation(value = "创建组模板-通过id删除", notes = "创建组模板-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaiShouGroupTemplateService.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<KuaiShouGroupTemplate> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaiShouGroupTemplate> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaiShouGroupTemplateService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "创建组模板-通过id查询")
+    @ApiOperation(value = "创建组模板-通过id查询", notes = "创建组模板-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaiShouGroupTemplate> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaiShouGroupTemplate> result = new Result<>();
+        KuaiShouGroupTemplate kuaiShouGroupTemplate = kuaiShouGroupTemplateService.getById(id);
+        if (kuaiShouGroupTemplate == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaiShouGroupTemplate);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaiShouGroupTemplate> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaiShouGroupTemplate kuaiShouGroupTemplate = JSON.parseObject(deString, KuaiShouGroupTemplate.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouGroupTemplate, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaiShouGroupTemplate> pageList = kuaiShouGroupTemplateService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "创建组模板列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaiShouGroupTemplate.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<KuaiShouGroupTemplate> listKuaiShouGroupTemplates = ExcelImportUtil.importExcel(file.getInputStream(), KuaiShouGroupTemplate.class, params);
+                kuaiShouGroupTemplateService.saveBatch(listKuaiShouGroupTemplates);
+                return Result.ok("文件导入成功!数据行数:" + listKuaiShouGroupTemplates.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("文件导入失败!");
+    }
+
+}

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

@@ -0,0 +1,234 @@
+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-12-15
+ */
+@Data
+@TableName("ctop_kuaishou_group_template")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_group_template对象", description = "创建组模板")
+public class KuaiShouGroupTemplate {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+
+    private String userId;
+
+    /**
+     * 计划ID
+     */
+    @Excel(name = "计划ID", width = 15)
+    @ApiModelProperty(value = "计划ID")
+    private Long campaignId;
+    /**
+     * 广告组ID
+     */
+    @Excel(name = "广告组ID", width = 15)
+    @ApiModelProperty(value = "广告组ID")
+    private Long unitId;
+    /**
+     * 广告组名称
+     */
+    @Excel(name = "广告组名称", width = 15)
+    @ApiModelProperty(value = "广告组名称")
+    private String unitName;
+    /**
+     * 定向模板id
+     */
+    @Excel(name = "定向模板id", width = 15)
+    @ApiModelProperty(value = "定向模板id")
+    private Long templateId;
+    /**
+     * 优化目标出价类型 1: CPM 2: CPC 10:OCPM
+     */
+    @Excel(name = "优化目标出价类型 1: CPM 2: CPC 10:OCPM", width = 15)
+    @ApiModelProperty(value = "优化目标出价类型 1: CPM 2: CPC 10:OCPM")
+    private Integer bidType;
+    /**
+     * 优先从系统应用商店下载
+     */
+    @Excel(name = "优先从系统应用商店下载", width = 15)
+    @ApiModelProperty(value = "优先从系统应用商店下载")
+    private Integer useAppMarket;
+    /**
+     * 应用商店列表
+     */
+    @Excel(name = "应用商店列表", width = 15)
+    @ApiModelProperty(value = "应用商店列表")
+    private String appStore;
+    /**
+     * 出价
+     */
+    @Excel(name = "出价", width = 15)
+    @ApiModelProperty(value = "出价")
+    private Long bid;
+    /**
+     * OCPC出价
+     */
+    @Excel(name = "OCPC出价", width = 15)
+    @ApiModelProperty(value = "OCPC出价")
+    private Long cpaBid;
+    /**
+     * OCPX行为类型   1: CPM, 2: CPC,
+     */
+    @Excel(name = "OCPX行为类型   1: CPM, 2: CPC,", width = 15)
+    @ApiModelProperty(value = "OCPX行为类型   1: CPM, 2: CPC,")
+    private Integer ocpxActionType;
+    /**
+     * 深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无
+     */
+    @Excel(name = "深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无", width = 15)
+    @ApiModelProperty(value = "深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无")
+    private Integer deepConversionType;
+    /**
+     * 深度转化目标出价
+     */
+    @Excel(name = "深度转化目标出价", width = 15)
+    @ApiModelProperty(value = "深度转化目标出价")
+    private Long deepConversionBid;
+    /**
+     * 广告位 1:优选广告位;
+     */
+    @Excel(name = "广告位 1:优选广告位;", width = 15)
+    @ApiModelProperty(value = "广告位 1:优选广告位;")
+    private String sceneId;
+    /**
+     * 创意制作方式 4: 自定义
+     */
+    @Excel(name = "创意制作方式 4: 自定义", width = 15)
+    @ApiModelProperty(value = "创意制作方式 4: 自定义")
+    private Integer unitType;
+    /**
+     * 投放开始时间
+     */
+    @Excel(name = "投放开始时间", width = 15)
+    @ApiModelProperty(value = "投放开始时间")
+    private String beginTime;
+    /**
+     * 投放结束时间
+     */
+    @Excel(name = "投放结束时间", width = 15)
+    @ApiModelProperty(value = "投放结束时间")
+    private String endTime;
+    /**
+     * 投放时段
+     */
+    @Excel(name = "投放时段", width = 15)
+    @ApiModelProperty(value = "投放时段")
+    private String scheduleTime;
+    /**
+     * 单日预算
+     */
+    @Excel(name = "单日预算", width = 15)
+    @ApiModelProperty(value = "单日预算")
+    private Long dayBudget;
+    /**
+     * 转化目标
+     */
+    @Excel(name = "转化目标", width = 15)
+    @ApiModelProperty(value = "转化目标")
+    private Long convertId;
+    /**
+     * 当计划类型为3时(获取电商下单)时有返回。
+     */
+    @Excel(name = "当计划类型为3时(获取电商下单)时有返回。", width = 15)
+    @ApiModelProperty(value = "当计划类型为3时(获取电商下单)时有返回。")
+    private Integer urlType;
+    /**
+     * 投放链接
+     */
+    @Excel(name = "投放链接", width = 15)
+    @ApiModelProperty(value = "投放链接")
+    private String url;
+    /**
+     * APP ID
+     */
+    @Excel(name = "APP ID", width = 15)
+    @ApiModelProperty(value = "APP ID")
+    private Long appId;
+    /**
+     * 创意展现方式  0:未知, 1:轮播,
+     */
+    @Excel(name = "创意展现方式  0:未知, 1:轮播,", width = 15)
+    @ApiModelProperty(value = "创意展现方式  0:未知, 1:轮播,")
+    private Integer showMode;
+    /**
+     * 投放方式  0:未知, 1:正常投
+     */
+    @Excel(name = "投放方式  0:未知, 1:正常投", width = 15)
+    @ApiModelProperty(value = "投放方式  0:未知, 1:正常投")
+    private Integer speed;
+
+    private Long photoId;
+    /**
+     * 0:未提交 1:创建成功 2:创建失败
+     */
+    @Excel(name = "0:未提交 1:创建成功 2:创建失败", width = 15)
+    @ApiModelProperty(value = "0:未提交 1:创建成功 2:创建失败")
+    private Integer taskStatus;
+    /**
+     * 失败原因
+     */
+    @Excel(name = "失败原因", width = 15)
+    @ApiModelProperty(value = "失败原因")
+    private String reviewDetail;
+
+
+    private String clickTrackUrl;
+    private String actionbarClickUrl;
+    private Integer creativeCategory;
+    private String creativeTag;
+    private String creativeName;
+    private String actionBarText;
+    private String description;
+    private Long siteId;
+    private Integer createCreativeCount;
+    private String creativeReviewDetail;
+
+
+    /**
+     * 创建时间
+     */
+    @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;
+}

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

@@ -0,0 +1,26 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTemplate;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 创建组模板
+ *
+ * @author: jeecg-boot
+ * @date: 2020-12-15
+ * @cersion: V1.0
+ */
+public interface KuaiShouGroupTemplateMapper extends BaseMapper<KuaiShouGroupTemplate> {
+
+    JSONObject getMd5ByPhotoId(@Param("photoId") Long photoId);
+
+    List<JSONObject> getImageListByMd5(@Param("md5") String md5);
+
+    Integer getApiCreateCount(@Param("accountId") Long accountId, @Param("date") String date);
+
+    JSONObject getUrlByPhotoId(@Param("photoId") Long photoId);
+}

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

@@ -0,0 +1,41 @@
+<?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.KuaiShouGroupTemplateMapper">
+
+    <select id="getMd5ByPhotoId" resultType="com.alibaba.fastjson.JSONObject">
+    select
+    signature  as 'md5'
+    material_type as 'materialType'
+    from ctop_kuaishou_video_get
+    where  photo_id = #{photoId}
+    and signature is not null
+    limit 1
+    </select>
+
+    <select id="getImageListByMd5" resultType="com.alibaba.fastjson.JSONObject">
+      select
+      signature as 'md5',
+      url as 'url'
+      from ctop_material_cut_frame
+      where video_signature = #{md5}
+      limit 15
+    </select>
+    <select id="getApiCreateCount" resultType="java.lang.Integer">
+    select count(1)
+    from
+    ctop_kuaishou_creative
+    where  aaccount_id = #{accountId}
+    and DATE_FORMAT(creative_create_time,'%Y-%m-%d') = #{date}
+    </select>
+
+    <select id="getUrlByPhotoId" resultType="com.alibaba.fastjson.JSONObject">
+     select
+     cover_url as 'coverUrl',
+     url as 'url'
+     from
+     ctop_kuaishou_video_get
+     where  photo_id = #{photoId}
+     limit 1
+    </select>
+
+</mapper>

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

@@ -0,0 +1,34 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTemplate;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 创建组模板
+ * @Author: jeecg-boot
+ * @Date: 2020-12-15
+ * @Version: V1.0
+ */
+public interface IKuaiShouGroupTemplateService extends IService<KuaiShouGroupTemplate> {
+
+    JSONObject submitUnitTask(JSONObject requestJson) throws Exception;
+
+    void createUnit();
+
+    /**
+     * 获取api创建数
+     *
+     * @param accountId
+     * @return
+     */
+    Integer getApiCreateCount(Long accountId, String date);
+
+    /**
+     * 通过photoId 获取 url
+     *
+     * @param photoId
+     * @return
+     */
+    JSONObject getUrlByPhotoId(Long photoId);
+}

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

@@ -1,7 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
 public interface IKuaiShouOverRunSendMessageService {
-    void creativeOverRunSendMessage(Long accountId);
+    void creativeOverRunSendMessage(Long accountId, String userId);
 
 
 }

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

@@ -459,7 +459,7 @@ public interface IKuaishouInterfaceService {
     JSONArray getPageList(Long accountId, String token, Long appId, String viewComp);
 
 
-    Map<String, Object> batchCreativeCreate(String accessToken, Long advertiserId, JSONObject requestJson, Integer count);
+    Map<String, Object> batchCreativeCreate(String accessToken, Long advertiserId, JSONObject requestJson, Integer count, String userId);
 
     void getCreativeByCreativeIds(String accessToken, Long advertiserId, JSONArray creativeIds);
 

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

@@ -1520,7 +1520,7 @@ public class BatchServiceImpl implements IBatchService {
                                 creative.put("image_token", imageToken);
                                 creativeJson.put("click_track_url", click_track_url);
                             }
-                            if(!Check.isNull(actionbar_click_url)){
+                            if (!Check.isNull(actionbar_click_url)) {
                                 creativeJson.put("actionbar_click_url", actionbar_click_url);
                             }
 
@@ -1535,7 +1535,7 @@ public class BatchServiceImpl implements IBatchService {
             creativeJson.put("creatives", creatives);
         }
 
-        Map<String, Object> returnUnitMap = kuaishouInterfaceService.batchCreativeCreate(oauthToken.getAccessToken(), accountId, creativeJson, 1);
+        Map<String, Object> returnUnitMap = kuaishouInterfaceService.batchCreativeCreate(oauthToken.getAccessToken(), accountId, creativeJson, 1, null);
         return returnUnitMap;
     }
 

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

@@ -550,7 +550,7 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
                         aCreativeCreate(requestJson, count + 1);
                     }
                     if (code == 400001 && "/rest/openapi/v2/creative/create调用已超日限,次日可恢复调用".equals(resultJson.getString("message"))) {
-                        overRunSendMessageService.creativeOverRunSendMessage(advertiserId);
+                        overRunSendMessageService.creativeOverRunSendMessage(advertiserId, null);
                     }
                     log.error("创建广告创意失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson, count + 1);
                     retuenJson.put("code", -1);

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

@@ -0,0 +1,445 @@
+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.kuaishou.modules.batch.entity.KuaiShouGroupTemplate;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupTemplateMapper;
+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.IKuaishouInterfaceService;
+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 lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 创建组模板
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-15
+ */
+@Service
+@Slf4j
+public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupTemplateMapper, KuaiShouGroupTemplate> implements IKuaiShouGroupTemplateService {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService iKuaishouInterfaceService;
+    @Autowired
+    private KuaiShouGroupTemplateMapper groupTemplateMapper;
+    @Autowired
+    private IKuaiShouImageGetService imageGetService;
+    @Autowired
+    private IKuaiShouMaterialUploadService uploadService;
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+
+    @Override
+    public JSONObject submitUnitTask(JSONObject requestJson) throws Exception {
+        Long accountId = requestJson.getLong("accountId");
+        if (Check.isNull(accountId)) {
+            throw new Exception("accountId不能为空");
+        }
+        Long campaignId = requestJson.getLong("campaignId");
+        if (Check.isNull(campaignId)) {
+            throw new Exception("campaignId不能为空");
+        }
+        Integer createCount = requestJson.getInteger("createCount");
+        if (Check.isNull(createCount)) {
+            throw new Exception("创建数不能为空不能为空");
+        }
+        JSONArray photoArr = requestJson.getJSONArray("photoArr");
+        if (Check.isNull(photoArr)) {
+            throw new Exception("请选择需要创建的视频");
+        }
+        if (createCount != photoArr.size()) {
+            throw new Exception("视频数量必须和创建数量保持一致");
+        }
+        JSONObject returnJson = new JSONObject();
+
+        String userId = requestJson.getString("userId");
+        String unitName = requestJson.getString("unitName");
+        Long template_id = requestJson.getLong("templateId");
+        Integer bid_type = requestJson.getInteger("bidType");
+        Integer use_app_market = requestJson.getInteger("useAppMarket");
+        JSONArray app_store = requestJson.getJSONArray("appStore");
+        Long bid = requestJson.getLong("bid");
+        Long cpa_bid = requestJson.getLong("cpaBid");
+        Integer ocpx_action_type = requestJson.getInteger("ocpxActionType");
+        Integer deep_conversion_type = requestJson.getInteger("deepConversionType");
+        Long deep_conversion_bid = requestJson.getLong("deepConversionBid");
+        JSONArray scene_id = requestJson.getJSONArray("sceneId");
+        Integer unit_type = requestJson.getInteger("unitType");
+        String begin_time = requestJson.getString("beginTime");
+        String end_time = requestJson.getString("endTime");
+        String schedule_time = requestJson.getString("scheduleTime");
+        Long day_budget = requestJson.getLong("dayBudget");
+        Long convert_id = requestJson.getLong("convertId");
+        Integer url_type = requestJson.getInteger("urlType");
+        String url = requestJson.getString("url");
+        Long app_id = requestJson.getLong("appId");
+        Integer show_mode = requestJson.getInteger("showMode");
+        Integer speed = requestJson.getInteger("speed");
+        String click_track_url = requestJson.getString("click_track_url");
+        String actionbar_click_url = requestJson.getString("actionbar_click_url");
+        Integer creative_category = requestJson.getInteger("creative_category");
+        JSONArray creative_tag = requestJson.getJSONArray("creative_tag");
+        String creative_name = requestJson.getString("creative_name");
+        String action_bar_text = requestJson.getString("action_bar_text");
+        String description = requestJson.getString("description");
+        Long site_id = requestJson.getLong("site_id");
+
+        List<KuaiShouGroupTemplate> templates = new ArrayList<>();
+        for (int i = 0; i < createCount; i++) {
+            Long photoId = photoArr.getLong(i);
+            String name = unitName + "_" + i;
+            KuaiShouGroupTemplate template = new KuaiShouGroupTemplate();
+            template.setAccountId(accountId);
+            template.setUserId(userId);
+            template.setCampaignId(campaignId);
+            template.setUnitName(name);
+            template.setPhotoId(photoId);
+            if (!Check.isNull(template_id)) {
+                template.setTemplateId(template_id);
+            }
+            if (!Check.isNull(bid_type)) {
+                template.setBidType(bid_type);
+            }
+            if (!Check.isNull(use_app_market)) {
+                template.setUseAppMarket(use_app_market);
+            }
+            if (!Check.isNull(app_store)) {
+                template.setAppStore(app_store.toJSONString());
+            }
+            if (!Check.isNull(bid)) {
+                template.setBid(bid);
+            }
+            if (!Check.isNull(cpa_bid)) {
+                template.setCpaBid(cpa_bid);
+            }
+            if (!Check.isNull(ocpx_action_type)) {
+                template.setOcpxActionType(ocpx_action_type);
+            }
+            if (!Check.isNull(deep_conversion_type)) {
+                template.setDeepConversionType(deep_conversion_type);
+            }
+            if (!Check.isNull(deep_conversion_bid)) {
+                template.setDeepConversionBid(deep_conversion_bid);
+            }
+            if (!Check.isNull(scene_id)) {
+                template.setSceneId(scene_id.toJSONString());
+            }
+            if (!Check.isNull(unit_type)) {
+                template.setUrlType(unit_type);
+            }
+            if (!Check.isNull(begin_time)) {
+                template.setBeginTime(begin_time);
+            }
+            if (!Check.isNull(end_time)) {
+                template.setEndTime(end_time);
+            }
+            if (!Check.isNull(schedule_time)) {
+                template.setScheduleTime(schedule_time);
+            }
+            if (!Check.isNull(day_budget)) {
+                template.setDayBudget(day_budget);
+            }
+            if (!Check.isNull(convert_id)) {
+                template.setConvertId(convert_id);
+            }
+            if (!Check.isNull(url_type)) {
+                template.setUrlType(url_type);
+            }
+            if (!Check.isNull(url)) {
+                template.setUrl(url);
+            }
+            if (!Check.isNull(app_id)) {
+                template.setAppId(app_id);
+            }
+            if (!Check.isNull(show_mode)) {
+                template.setShowMode(show_mode);
+            }
+            if (!Check.isNull(speed)) {
+                template.setSpeed(speed);
+            }
+            if (!Check.isNull(click_track_url)) {
+                template.setClickTrackUrl(click_track_url);
+            }
+            if (!Check.isNull(actionbar_click_url)) {
+                template.setActionbarClickUrl(actionbar_click_url);
+            }
+            if (!Check.isNull(creative_category)) {
+                template.setCreativeCategory(creative_category);
+            }
+            if (!Check.isNull(creative_tag)) {
+                template.setCreativeTag(creative_tag.toJSONString());
+            }
+            if (!Check.isNull(creative_name)) {
+                template.setCreativeName(creative_name);
+            }
+            if (!Check.isNull(action_bar_text)) {
+                template.setActionBarText(action_bar_text);
+            }
+            if (!Check.isNull(description)) {
+                template.setDescription(description);
+            }
+            if (!Check.isNull(description)) {
+                template.setDescription(description);
+            }
+            if (!Check.isNull(site_id)) {
+                template.setSiteId(site_id);
+            }
+            template.setTaskStatus(0);
+            templates.add(template);
+        }
+        boolean b = this.saveBatch(templates);
+        if (b) {
+            returnJson.put("code", 0);
+            returnJson.put("size", templates.size());
+        } else {
+            returnJson.put("code", -1);
+            returnJson.put("message", "提交任务失败");
+        }
+
+        return returnJson;
+    }
+
+    @Override
+    public void createUnit() {
+        QueryWrapper<KuaiShouGroupTemplate> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("task_status", 0);
+        queryWrapper.orderByDesc("create_time");
+        queryWrapper.last("limit 30");
+        List<KuaiShouGroupTemplate> list = this.list(queryWrapper);
+        if (Check.isNull(list)) {
+            log.error("暂未未创建的组");
+            return;
+        }
+        for (KuaiShouGroupTemplate template : list) {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    Long accountId = template.getAccountId();
+                    CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+                    if (Check.isNull(token)) {
+                        return;
+                    }
+                    KuaiShouGroupTemplate updateTemplate = new KuaiShouGroupTemplate();
+                    updateTemplate.setId(template.getId());
+                    updateTemplate.setTaskStatus(1);
+                    updateById(updateTemplate);   // 修改状态为创建中
+                    JSONObject createUnitJson = new JSONObject();
+                    createUnitJson.put("campaign_id", template.getCampaignId());
+                    createUnitJson.put("unit_name", template.getUnitName());
+
+                    if (!Check.isNull(template.getTemplateId())) {
+                        createUnitJson.put("template_id", template.getTemplateId());
+                    }
+                    if (!Check.isNull(template.getBidType())) {
+                        createUnitJson.put("bid_type", template.getBidType()); // 优化目标类型
+                    }
+                    if (!Check.isNull(template.getUseAppMarket())) {
+                        createUnitJson.put("use_app_market", template.getUseAppMarket()); //优先从系统应用商店下载
+                    }
+                    if (!Check.isNull(template.getAppStore())) {
+                        createUnitJson.put("app_store", template.getAppStore()); //应用商店列表
+                    }
+                    if (!Check.isNull(template.getBid())) {
+                        createUnitJson.put("bid", template.getBid()); //出价
+                    }
+                    if (!Check.isNull(template.getCpaBid())) {
+                        createUnitJson.put("cpa_bid", template.getCpaBid()); //出价
+                    }
+                    if (!Check.isNull(template.getOcpxActionType())) {
+                        createUnitJson.put("ocpx_action_type", template.getOcpxActionType()); //优化目标
+                    }
+                    if (!Check.isNull(template.getDeepConversionType())) {
+                        createUnitJson.put("deep_conversion_type", template.getDeepConversionType()); //深度转化目标
+                    }
+                    if (!Check.isNull(template.getDeepConversionBid())) {
+                        createUnitJson.put("deep_conversion_bid", template.getDeepConversionBid()); //深度转化目标出价
+                    }
+                    if (!Check.isNull(template.getSceneId())) {
+                        createUnitJson.put("scene_id", template.getSceneId()); //资源位置
+                    }
+                    if (!Check.isNull(template.getUnitType())) {
+                        createUnitJson.put("unit_type", template.getUnitType()); //创意制作方式
+                    }
+                    if (!Check.isNull(template.getBeginTime())) {
+                        createUnitJson.put("begin_time", template.getBeginTime()); //投放开始时间
+                    }
+                    if (!Check.isNull(template.getEndTime())) {
+                        createUnitJson.put("end_time", template.getEndTime()); //投放结束时间
+                    }
+                    if (!Check.isNull(template.getScheduleTime())) {
+                        createUnitJson.put("schedule_time", template.getScheduleTime()); //投放时间段
+                    }
+                    if (!Check.isNull(template.getDayBudget())) {
+                        createUnitJson.put("day_budget", template.getDayBudget()); //单日预算金额
+                    }
+                    if (!Check.isNull(template.getConvertId())) {
+                        createUnitJson.put("convert_id", template.getConvertId()); //转化目标ID
+                    }
+                    if (!Check.isNull(template.getUnitType())) {
+                        createUnitJson.put("url_type", template.getUnitType()); //url类型
+                    }
+                    if (!Check.isNull(template.getUrl())) {
+                        createUnitJson.put("url", template.getUrl()); // 投放链接
+                    }
+                    if (!Check.isNull(template.getAppId())) {
+                        createUnitJson.put("app_id", template.getAppId()); // 应用ID
+                    }
+                    if (!Check.isNull(template.getShowMode())) {
+                        createUnitJson.put("show_mode", template.getShowMode()); // 创意展现方式
+                    }
+                    if (!Check.isNull(template.getSpeed())) {
+                        createUnitJson.put("speed", template.getSpeed()); // 投放方式
+                    }
+                    Map<String, Object> groupMap = iKuaishouInterfaceService.adUnitCreate(token.getAccessToken(), accountId, createUnitJson, 1);
+                    updateTemplate = new KuaiShouGroupTemplate();
+                    updateTemplate.setId(template.getId());
+                    Integer code = (Integer) groupMap.get("code");
+                    if (code == 0) {
+                        updateTemplate.setTaskStatus(2);
+                        updateTemplate.setCreativeReviewDetail("创意待创建");
+                        Long unit = (Long) groupMap.get("unitId");
+                        updateTemplate.setUnitId((unit));
+                        Thread thread = new Thread() {
+                            @Override
+                            public void run() {
+                                createCreative(token.getAccessToken(), unit, template);
+                            }
+                        };
+                        thread.start();
+
+
+                    } else {
+                        updateTemplate.setTaskStatus(3);
+                        updateTemplate.setReviewDetail((String) groupMap.get("message"));
+                    }
+                    updateById(updateTemplate);
+                    try {
+                        Thread.sleep(1 * 1000);
+                    } catch (InterruptedException e) {
+                        e.printStackTrace();
+                    }
+                }
+            });
+        }
+
+    }
+
+    @Override
+    public Integer getApiCreateCount(Long accountId, String date) {
+        return groupTemplateMapper.getApiCreateCount(accountId, date);
+    }
+
+    @Override
+    public JSONObject getUrlByPhotoId(Long photoId) {
+        return groupTemplateMapper.getUrlByPhotoId(photoId);
+    }
+
+
+    private void createCreative(String accessToken, Long unitId, KuaiShouGroupTemplate template) {
+        Long photoId = template.getPhotoId();
+        JSONObject md5Json = groupTemplateMapper.getMd5ByPhotoId(photoId);
+        if (Check.isNull(md5Json)) {
+            log.error("未获取到素材详细信息,accountId:{},unitId:{}", template.getAccountId(), unitId);
+            return;
+        }
+        String md5 = md5Json.getString("md5");
+        List<JSONObject> imageList = groupTemplateMapper.getImageListByMd5(md5);
+        JSONObject createJson = new JSONObject();
+        createJson.put("unit_id", unitId);
+        if (!Check.isNull(template.getClickTrackUrl())) {
+            createJson.put("click_track_url", template.getClickTrackUrl());
+        }
+        if (!Check.isNull(template.getActionbarClickUrl())) {
+            createJson.put("actionbar_click_url", template.getActionbarClickUrl());
+        }
+        if (!Check.isNull(template.getCreativeCategory())) {
+            createJson.put("creative_category", template.getCreativeCategory());
+        }
+        if (!Check.isNull(template.getCreativeTag())) {
+            createJson.put("creative_tag", template.getCreativeTag());
+        }
+        Integer materialType = md5Json.getInteger("materialType");
+        JSONArray creatives = new JSONArray();
+        if (Check.isNull(imageList)) {
+            JSONObject json = new JSONObject();
+            json.put("creative_name", template.getCreativeName());
+            json.put("photo_id", template.getPhotoId());
+            json.put("creative_material_type", materialType);
+            json.put("action_bar_text", template.getActionBarText());
+            json.put("description", template.getDescription());
+            if (Check.isNull(template.getSiteId())) {
+                json.put("site_id", template.getSiteId());
+            }
+            creatives.add(json);
+        } else {
+            for (int i = 0; i < imageList.size(); i++) {
+                JSONObject imageJson = imageList.get(i);
+                if (Check.isNull(imageJson)) {
+                    continue;
+                }
+                JSONObject json = new JSONObject();
+                String signature = imageJson.getString("md5");
+                String imageToken = null;
+                if (!Check.isNull(signature)) {
+                    QueryWrapper<KuaiShouImageGet> queryWrapper = new QueryWrapper<>();
+                    queryWrapper.eq("account_id", template.getAccountId());
+                    queryWrapper.eq("signature", signature);
+                    queryWrapper.last("limit 1");
+                    KuaiShouImageGet imageGet = imageGetService.getOne(queryWrapper);
+                    if (!Check.isNull(imageGet)) {
+                        imageToken = imageGet.getImageToken();
+                    } else {
+                        String url = imageJson.getString("url");
+                        imageToken = uploadService.kuauiShouImageUpload(url, signature, template.getAccountId(), accessToken);
+                    }
+                }
+                if (Check.isNull(imageToken)) {
+                    continue;
+                }
+                json.put("image_token", imageToken);
+                json.put("creative_name", template.getCreativeName() + "_" + i);
+                json.put("photo_id", template.getPhotoId());
+                json.put("creative_material_type", materialType);
+                json.put("action_bar_text", template.getActionBarText());
+                json.put("description", template.getDescription());
+                if (Check.isNull(template.getSiteId())) {
+                    json.put("site_id", template.getSiteId());
+                }
+                creatives.add(json);
+            }
+        }
+        createJson.put("creatives", creatives);
+        Map<String, Object> creativeMap = iKuaishouInterfaceService.batchCreativeCreate(accessToken, template.getAccountId(), createJson, 1, template.getUserId());
+        KuaiShouGroupTemplate updateTemplate = new KuaiShouGroupTemplate();
+        updateTemplate.setId(template.getId());
+        Integer code = (Integer) creativeMap.get("code");
+        if (code == 0) {
+            updateTemplate.setCreativeReviewDetail("创意创建成功");
+            updateTemplate.setCreateCreativeCount((Integer) creativeMap.get("count"));
+        } else {
+            updateTemplate.setCreativeReviewDetail("创意创建失败:" + creativeMap.get("message"));
+        }
+        this.updateById(updateTemplate);
+    }
+
+
+}

+ 12 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouOverRunSendMessageServiceImpl.java

@@ -40,7 +40,7 @@ public class KuaiShouOverRunSendMessageServiceImpl extends ServiceImpl<KuaishouO
 
 
     @Override
-    public void creativeOverRunSendMessage(Long accountId) {
+    public void creativeOverRunSendMessage(Long accountId, String userId) {
 
         try {
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
@@ -61,12 +61,18 @@ public class KuaiShouOverRunSendMessageServiceImpl extends ServiceImpl<KuaishouO
 
             UserAllocation userAllocation = userAllocationService.getByAccountId(accountId);
             if (!Check.isNull(userAllocation)) {
-                String message = messageTemplate.getCreativeOverRunMessage(accountId, creativeCount, userAllocation.getAuthName());
-                LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-                if (Check.isNull(sysUser)) {
-                    return;
+                String sendUserId;
+                if (!Check.isNull(userId)) {
+                    sendUserId = userId;
+                } else {
+                    LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+                    if (Check.isNull(sysUser)) {
+                        return;
+                    }
+                    sendUserId = sysUser.getId();
                 }
-                sendMessageService.sendMessage(sysUser.getId(), message);
+                String message = messageTemplate.getCreativeOverRunMessage(accountId, creativeCount, userAllocation.getAuthName());
+                sendMessageService.sendMessage(sendUserId, message);
                 KuaishouOverRunLog addOverRunLog = new KuaishouOverRunLog();
                 addOverRunLog.setAccountId(accountId);
                 addOverRunLog.setMailType(1);

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

@@ -1990,7 +1990,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     }
 
                     if (code == 400001 && "/rest/openapi/v2/creative/create调用已超日限,次日可恢复调用".equals(resultJson.getString("message"))) {
-                        overRunSendMessageService.creativeOverRunSendMessage(advertiserId);
+                        overRunSendMessageService.creativeOverRunSendMessage(advertiserId, null);
                     }
                     log.error("创建广告创意失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson, count + 1);
                     returnMap.put("code", -1);
@@ -2024,7 +2024,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
 
     @Override
-    public Map<String, Object> batchCreativeCreate(String accessToken, Long advertiserId, JSONObject requestJson, Integer count) {
+    public Map<String, Object> batchCreativeCreate(String accessToken, Long advertiserId, JSONObject requestJson, Integer count, String userId) {
         Map<String, Object> returnMap = new HashMap<>();
         try {
             String url = "https://ad.e.kuaishou.com/rest/openapi/v2/creative/batch/update";
@@ -2062,14 +2062,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         returnMap.put("code", 0);
                         returnMap.put("message", "success");
                         returnMap.put("success", true);
+                        returnMap.put("count", add_creative_ids.size());
                     }
                 } else {
                     if (code == 500000 && count <= 4) {
                         creativeCreate(accessToken, advertiserId, requestJson, count + 1);
                     }
 
-                    if (code == 400001 && "/rest/openapi/v2/creative/create调用已超日限,次日可恢复调用".equals(resultJson.getString("message"))) {
-                        overRunSendMessageService.creativeOverRunSendMessage(advertiserId);
+                    if (code == 400001 && "/rest/openapi/v2/creative/batch/update调用已超日限,次日可恢复调用".equals(resultJson.getString("message"))) {
+                        overRunSendMessageService.creativeOverRunSendMessage(advertiserId, userId);
                     }
                     log.error("创建广告创意失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson, count + 1);
                     returnMap.put("code", -1);
@@ -2079,7 +2080,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 }
             } else {
                 if (count <= 4) {
-                    batchCreativeCreate(accessToken, advertiserId, requestJson, count + 1);
+                    batchCreativeCreate(accessToken, advertiserId, requestJson, count + 1, userId);
                 }
 
                 log.error("快手创建广告创意返回内容为空,advertiser_id:{},入参:{}", advertiserId, requestJson);