Prechádzať zdrojové kódy

Merge branch 'master_batch_v2'

# Conflicts:
#	jeecg-boot-module-system/src/main/resources/application-dev.yml
yumeng 4 rokov pred
rodič
commit
c096655d6d
32 zmenil súbory, kde vykonal 2710 pridanie a 665 odobranie
  1. 5 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  2. 658 654
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java
  3. 248 0
      module-common/src/main/java/cn/com/ctop/common/module/controller/WarningOperationLogController.java
  4. 2 1
      module-common/src/main/java/cn/com/ctop/common/module/entity/Project.java
  5. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/UserAllocation.java
  6. 75 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/WarningOperationLog.java
  7. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/ProjectMapper.java
  8. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  9. 15 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/WarningOperationLogMapper.java
  10. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/ProjectMapper.xml
  11. 6 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  12. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/WarningOperationLogMapper.xml
  13. 23 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMessageTemplate.java
  14. 14 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IWarningOperationLogService.java
  15. 35 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java
  16. 19 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/WarningOperationLogServiceImpl.java
  17. 8 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  18. 317 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateController.java
  19. 248 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateTargetController.java
  20. 68 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouTemplate.java
  21. 212 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouTemplateTarget.java
  22. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouTemplateMapper.java
  23. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouTemplateTargetMapper.java
  24. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouTemplateMapper.xml
  25. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouTemplateTargetMapper.xml
  26. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouTemplateService.java
  27. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouTemplateTargetService.java
  28. 31 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IWarningOperationService.java
  29. 44 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  30. 447 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateServiceImpl.java
  31. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateTargetServiceImpl.java
  32. 117 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/WarningOperationServiceImpl.java

+ 5 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -666,7 +666,7 @@ public class TestController {
             List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(tokenQueryWrapper);
             if (!Check.isNull(ctopOauthTokens)) {
                 for (CtopOauthToken token : ctopOauthTokens) {
-                    historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
+                    historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), "2020-09-01", "2020-10-01", CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
                 }
 
             }
@@ -826,9 +826,11 @@ public class TestController {
         oauthTokenQueryWrapper.last("limit 1");
         CtopOauthToken token = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
         try {
-            kuaishouInterfaceService.getCampaignList(token, null, null);
+            // kuaishouInterfaceService.getCampaignList(token, null, null);
             //1:获取全量广告组数据
-            kuaishouInterfaceService.getGroupList(token, null, null);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Date parse = simpleDateFormat.parse("2020-11-11");
+            kuaishouInterfaceService.getGroupList(token, parse, parse);
         } catch (Exception e) {
             e.printStackTrace();
         }

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 658 - 654
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java


+ 248 - 0
module-common/src/main/java/cn/com/ctop/common/module/controller/WarningOperationLogController.java

@@ -0,0 +1,248 @@
+package cn.com.ctop.common.module.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.entity.WarningOperationLog;
+import cn.com.ctop.common.module.service.IWarningOperationLogService;
+import com.alibaba.fastjson.JSON;
+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.*;
+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-11-11
+ */
+@Slf4j
+@Api(tags = "预警操作记录")
+@RestController
+@RequestMapping("/wa/warningOperationLog")
+public class WarningOperationLogController {
+    @Autowired
+    private IWarningOperationLogService warningOperationLogService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param warningOperationLog
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "预警操作记录-分页列表查询")
+    @ApiOperation(value = "预警操作记录-分页列表查询", notes = "预警操作记录-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<WarningOperationLog>> queryPageList(WarningOperationLog warningOperationLog,
+                                                            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                            HttpServletRequest req) {
+        Result<IPage<WarningOperationLog>> result = new Result<>();
+        QueryWrapper<WarningOperationLog> queryWrapper = QueryGenerator.initQueryWrapper(warningOperationLog, req.getParameterMap());
+        Page<WarningOperationLog> page = new Page<WarningOperationLog>(pageNo, pageSize);
+        IPage<WarningOperationLog> pageList = warningOperationLogService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param warningOperationLog
+     * @return
+     */
+    @AutoLog(value = "预警操作记录-添加")
+    @ApiOperation(value = "预警操作记录-添加", notes = "预警操作记录-添加")
+    @PostMapping(value = "/add")
+    public Result<WarningOperationLog> add(@RequestBody WarningOperationLog warningOperationLog) {
+        Result<WarningOperationLog> result = new Result<>();
+        try {
+            warningOperationLogService.save(warningOperationLog);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param warningOperationLog
+     * @return
+     */
+    @AutoLog(value = "预警操作记录-编辑")
+    @ApiOperation(value = "预警操作记录-编辑", notes = "预警操作记录-编辑")
+    @PutMapping(value = "/edit")
+    public Result<WarningOperationLog> edit(@RequestBody WarningOperationLog warningOperationLog) {
+        Result<WarningOperationLog> result = new Result<WarningOperationLog>();
+        WarningOperationLog warningOperationLogEntity = warningOperationLogService.getById(warningOperationLog.getId());
+        if (warningOperationLogEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = warningOperationLogService.updateById(warningOperationLog);
+            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 {
+            warningOperationLogService.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<WarningOperationLog> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<WarningOperationLog> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.warningOperationLogService.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<WarningOperationLog> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<WarningOperationLog> result = new Result<>();
+        WarningOperationLog warningOperationLog = warningOperationLogService.getById(id);
+        if (warningOperationLog == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(warningOperationLog);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<WarningOperationLog> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                WarningOperationLog warningOperationLog = JSON.parseObject(deString, WarningOperationLog.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(warningOperationLog, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<WarningOperationLog> pageList = warningOperationLogService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "预警操作记录列表");
+        mv.addObject(NormalExcelConstants.CLASS, WarningOperationLog.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<WarningOperationLog> listWarningOperationLogs = ExcelImportUtil.importExcel(file.getInputStream(), WarningOperationLog.class, params);
+                warningOperationLogService.saveBatch(listWarningOperationLogs);
+                return Result.ok("文件导入成功!数据行数:" + listWarningOperationLogs.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("文件导入失败!");
+    }
+
+}

+ 2 - 1
module-common/src/main/java/cn/com/ctop/common/module/entity/Project.java

@@ -127,7 +127,8 @@ public class Project {
 
     @TableField(exist = false)
     private Integer needExamine;
-
+    private Integer bidType;
+    private Integer ocpxActionType;
 
    /* @TableField(exist = false)
     private String responsibleName; // 运营负责人

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/UserAllocation.java

@@ -126,6 +126,9 @@ public class UserAllocation implements Serializable {
     @ApiModelProperty(value = "平台类型 1 头条 2快手")
     private String mediaId;
 
+
+
+
    /* @TableField(exist = false)
     private String advertiserName;
 

+ 75 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/WarningOperationLog.java

@@ -0,0 +1,75 @@
+package cn.com.ctop.common.module.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+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 java.util.Date;
+
+/**
+ * 预警操作记录
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-11-11
+ */
+@Data
+@TableName("ctop_warning_operation_log")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_warning_operation_log对象", description = "预警操作记录")
+public class WarningOperationLog {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long unitId;
+    /**
+     * 发送人
+     */
+    @Excel(name = "发送人", width = 15)
+    @ApiModelProperty(value = "发送人")
+    private String userId;
+    /**
+     * 标题
+     */
+    @Excel(name = "标题", width = 15)
+    @ApiModelProperty(value = "标题")
+    private String subject;
+    /**
+     * 预警类型 1 出价方式  2 出价过高
+     */
+    @Excel(name = "预警类型 1 出价方式  2 出价过高 ", width = 15)
+    @ApiModelProperty(value = "预警类型 1 出价方式  2 出价过高 ")
+    private Integer warningType;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/ProjectMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.Project;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -14,4 +15,6 @@ import org.apache.ibatis.annotations.Param;
 public interface ProjectMapper extends BaseMapper<Project> {
 
     String getNameByAccountId(@Param("accountId") Long accountId);
+
+    JSONObject getWarningInfoByProjectId(@Param("projectId") Long projectId);
 }

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -25,4 +25,6 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     List<JSONObject> getUserIdListByProjectId(@Param("projectId") Long projectId);
 
     List<JSONObject> getAccountIdListByUserId(@Param("userId") Long userId);
+
+    Long getProjectIdByAccountId(@Param("accountId") Long accountId);
 }

+ 15 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/WarningOperationLogMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.WarningOperationLog;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 预警操作记录
+ *
+ * @author: jeecg-boot
+ * @date: 2020-11-11
+ * @cersion: V1.0
+ */
+public interface WarningOperationLogMapper extends BaseMapper<WarningOperationLog> {
+
+}

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/ProjectMapper.xml

@@ -10,4 +10,15 @@
      )
     </select>
 
+    <select id="getWarningInfoByProjectId" resultType="com.alibaba.fastjson.JSONObject">
+     select
+     id projectId,
+     project_name projectName,
+     max_bid maxBid,
+     bid_type bidType,
+     ocpx_action_type ocpxActionType
+     from ctop_project
+     where id = #{projectId}
+    </select>
+
 </mapper>

+ 6 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -63,5 +63,11 @@
     AND t1.account_status = 0
     </select>
 
+    <select id="getProjectIdByAccountId" resultType="java.lang.Long">
+    select  project_id  from  ctop_user_allocation
+    where account_id = #{accountId}
+    limit 1
+    </select>
+
 
 </mapper>

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/WarningOperationLogMapper.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.common.module.mapper.WarningOperationLogMapper">
+
+</mapper>

+ 23 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMessageTemplate.java

@@ -58,4 +58,27 @@ public interface IMessageTemplate {
      */
     String getAlarmCostMessage(JSONObject cost);
 
+    /**
+     * 快手 组出价方式错误消息模板
+     *
+     * @param projectName
+     * @param advertiserId
+     * @param unitId
+     * @param unit_name
+     * @return
+     */
+
+    String getKuaiShouBidTypeMessage(String projectName, Long advertiserId, Long unitId, String unit_name);
+
+
+    /**
+     * 快手 组出价过高消息模板
+     *
+     * @param projectName
+     * @param advertiserId
+     * @param unitId
+     * @param unit_name
+     * @return
+     */
+    String getKuaiShouBidMessage(String projectName, Long advertiserId, Long unitId, String unit_name);
 }

+ 14 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IWarningOperationLogService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.WarningOperationLog;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 预警操作记录
+ * @Author: jeecg-boot
+ * @Date: 2020-11-11
+ * @Version: V1.0
+ */
+public interface IWarningOperationLogService extends IService<WarningOperationLog> {
+
+}

+ 35 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java

@@ -156,4 +156,39 @@ public class MessageTemplateImpl implements IMessageTemplate {
                 .append(obj.getString("end"));
         return text.toString();
     }
+
+
+    /**
+     * @param projectName
+     * @param advertiserId
+     * @param unitId
+     * @param unit_name
+     * @return
+     */
+
+    @Override
+    public String getKuaiShouBidTypeMessage(String projectName, Long advertiserId, Long unitId, String unit_name) {
+        StringBuilder text = new StringBuilder();
+        text.append("出价方式错误预警").append("<br/>")
+                .append("您的项目:").append(projectName + ",").append("<br/>")
+                .append("下的账户:").append(advertiserId + ",").append("<br/>")
+                .append("广告组id为:").append(unitId).append("<br/>")
+                .append("广告组名称为:").append(unit_name).append("<br/>")
+                .append("出价方式设置错误。").append("<br/>")
+                .append("系统已执行暂停此组操作,请您及时查看!");
+        return text.toString();
+    }
+
+    @Override
+    public String getKuaiShouBidMessage(String projectName, Long advertiserId, Long unitId, String unit_name) {
+        StringBuilder text = new StringBuilder();
+        text.append("出价过高预警").append("<br/>")
+                .append("您的项目:").append(projectName + ",").append("<br/>")
+                .append("下的账户:").append(advertiserId + ",").append("<br/>")
+                .append("广告组id为:").append(unitId).append("<br/>")
+                .append("广告组名称为:").append(unit_name).append("<br/>")
+                .append("出价设置错过高。").append("<br/>")
+                .append("系统已执行暂停此组操作,请您及时查看!");
+        return text.toString();
+    }
 }

+ 19 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/WarningOperationLogServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.WarningOperationLog;
+import cn.com.ctop.common.module.mapper.WarningOperationLogMapper;
+import cn.com.ctop.common.module.service.IWarningOperationLogService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 预警操作记录
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-11-11
+ */
+@Service
+public class WarningOperationLogServiceImpl extends ServiceImpl<WarningOperationLogMapper, WarningOperationLog> implements IWarningOperationLogService {
+
+}

+ 8 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -76,6 +76,14 @@ public class KuaishouInterfaceConstant {
      */
     public static final String IMAGE_GET = "/rest/openapi/v1/file/ad/image/get";
     /**
+     * 获取慕模列表
+     */
+    public static final String TEMPLATE_LIST = "/rest/openapi/v1/target/template/list";
+    /**
+     * 创建定向模板
+     */
+    public static final String TEMPLATE_CREATE = "/rest/openapi/v1/target/template/create";
+    /**
      * 获取地域信息
      */
     public static final String REGION_LIST = "/rest/openapi/v1/region/list";

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

@@ -0,0 +1,317 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+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.KuaishouTemplate;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
+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.*;
+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-11-09
+ */
+@Slf4j
+@Api(tags = "快手-定向模板")
+@RestController
+@RequestMapping("/batch/kuaishouTemplate")
+public class KuaishouTemplateController {
+    @Autowired
+    private IKuaishouTemplateService kuaishouTemplateService;
+
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouTemplate
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "快手-定向模板-分页列表查询")
+    @ApiOperation(value = "快手-定向模板-分页列表查询", notes = "快手-定向模板-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouTemplate>> queryPageList(KuaishouTemplate kuaishouTemplate,
+                                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                         HttpServletRequest req) {
+        Result<IPage<KuaishouTemplate>> result = new Result<>();
+        QueryWrapper<KuaishouTemplate> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouTemplate, req.getParameterMap());
+        Page<KuaishouTemplate> page = new Page<KuaishouTemplate>(pageNo, pageSize);
+        IPage<KuaishouTemplate> pageList = kuaishouTemplateService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+
+    /**
+     * 根据账户获取定向模板列表
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/getTemplateByAccountId")
+    public Result<Boolean> queryPageList(Long accountId) {
+
+        Result<Boolean> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("请选择账户id");
+            }
+
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
+            kuaishouTemplateService.getTemplateByAccountId(accountId, oauthToken.getAccessToken(), 1);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
+     * 创建定向模板
+     *
+     * @param
+     * @return
+     */
+    @GetMapping(value = "/createTemplate")
+    public Result<Boolean> createTemplate(@RequestBody JSONObject requestJson) {
+        Result<Boolean> result = new Result<>();
+        try {
+
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("请选择账户id");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            JSONObject returnJson = kuaishouTemplateService.createTemplate(accountId, oauthToken.getAccessToken(), requestJson);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
+     * 添加
+     *
+     * @param kuaishouTemplate
+     * @return
+     */
+    @AutoLog(value = "快手-定向模板-添加")
+    @ApiOperation(value = "快手-定向模板-添加", notes = "快手-定向模板-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouTemplate> add(@RequestBody KuaishouTemplate kuaishouTemplate) {
+        Result<KuaishouTemplate> result = new Result<>();
+        try {
+            kuaishouTemplateService.save(kuaishouTemplate);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouTemplate
+     * @return
+     */
+    @AutoLog(value = "快手-定向模板-编辑")
+    @ApiOperation(value = "快手-定向模板-编辑", notes = "快手-定向模板-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouTemplate> edit(@RequestBody KuaishouTemplate kuaishouTemplate) {
+        Result<KuaishouTemplate> result = new Result<KuaishouTemplate>();
+        KuaishouTemplate kuaishouTemplateEntity = kuaishouTemplateService.getById(kuaishouTemplate.getId());
+        if (kuaishouTemplateEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouTemplateService.updateById(kuaishouTemplate);
+            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 {
+            kuaishouTemplateService.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<KuaishouTemplate> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouTemplate> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouTemplateService.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<KuaishouTemplate> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouTemplate> result = new Result<>();
+        KuaishouTemplate kuaishouTemplate = kuaishouTemplateService.getById(id);
+        if (kuaishouTemplate == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouTemplate);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouTemplate> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouTemplate kuaishouTemplate = JSON.parseObject(deString, KuaishouTemplate.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouTemplate, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouTemplate> pageList = kuaishouTemplateService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "快手-定向模板列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouTemplate.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<KuaishouTemplate> listKuaishouTemplates = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouTemplate.class, params);
+                kuaishouTemplateService.saveBatch(listKuaishouTemplates);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouTemplates.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("文件导入失败!");
+    }
+
+}

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

@@ -0,0 +1,248 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateTargetService;
+import com.alibaba.fastjson.JSON;
+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.*;
+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-11-09
+ */
+@Slf4j
+@Api(tags = "快手-定向模板-详情")
+@RestController
+@RequestMapping("/batch/kuaishouTemplateTarget")
+public class KuaishouTemplateTargetController {
+    @Autowired
+    private IKuaishouTemplateTargetService kuaishouTemplateTargetService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouTemplateTarget
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "快手-定向模板-详情-分页列表查询")
+    @ApiOperation(value = "快手-定向模板-详情-分页列表查询", notes = "快手-定向模板-详情-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouTemplateTarget>> queryPageList(KuaishouTemplateTarget kuaishouTemplateTarget,
+                                                               @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                               @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                               HttpServletRequest req) {
+        Result<IPage<KuaishouTemplateTarget>> result = new Result<>();
+        QueryWrapper<KuaishouTemplateTarget> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouTemplateTarget, req.getParameterMap());
+        Page<KuaishouTemplateTarget> page = new Page<KuaishouTemplateTarget>(pageNo, pageSize);
+        IPage<KuaishouTemplateTarget> pageList = kuaishouTemplateTargetService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouTemplateTarget
+     * @return
+     */
+    @AutoLog(value = "快手-定向模板-详情-添加")
+    @ApiOperation(value = "快手-定向模板-详情-添加", notes = "快手-定向模板-详情-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouTemplateTarget> add(@RequestBody KuaishouTemplateTarget kuaishouTemplateTarget) {
+        Result<KuaishouTemplateTarget> result = new Result<>();
+        try {
+            kuaishouTemplateTargetService.save(kuaishouTemplateTarget);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouTemplateTarget
+     * @return
+     */
+    @AutoLog(value = "快手-定向模板-详情-编辑")
+    @ApiOperation(value = "快手-定向模板-详情-编辑", notes = "快手-定向模板-详情-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouTemplateTarget> edit(@RequestBody KuaishouTemplateTarget kuaishouTemplateTarget) {
+        Result<KuaishouTemplateTarget> result = new Result<KuaishouTemplateTarget>();
+        KuaishouTemplateTarget kuaishouTemplateTargetEntity = kuaishouTemplateTargetService.getById(kuaishouTemplateTarget.getId());
+        if (kuaishouTemplateTargetEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouTemplateTargetService.updateById(kuaishouTemplateTarget);
+            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 {
+            kuaishouTemplateTargetService.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<KuaishouTemplateTarget> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouTemplateTarget> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouTemplateTargetService.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<KuaishouTemplateTarget> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouTemplateTarget> result = new Result<>();
+        KuaishouTemplateTarget kuaishouTemplateTarget = kuaishouTemplateTargetService.getById(id);
+        if (kuaishouTemplateTarget == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouTemplateTarget);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouTemplateTarget> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouTemplateTarget kuaishouTemplateTarget = JSON.parseObject(deString, KuaishouTemplateTarget.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouTemplateTarget, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouTemplateTarget> pageList = kuaishouTemplateTargetService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "快手-定向模板-详情列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouTemplateTarget.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<KuaishouTemplateTarget> listKuaishouTemplateTargets = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouTemplateTarget.class, params);
+                kuaishouTemplateTargetService.saveBatch(listKuaishouTemplateTargets);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouTemplateTargets.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("文件导入失败!");
+    }
+
+}

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

@@ -0,0 +1,68 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+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 java.util.Date;
+
+/**
+ * 快手-定向模板
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-11-09
+ */
+@Data
+@TableName("ctop_kuaishou_template")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_template对象", description = "快手-定向模板")
+public class KuaishouTemplate {
+
+    /**
+     * id
+     */
+    @ApiModelProperty(value = "id")
+    private String id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 定向模板id
+     */
+    @Excel(name = "定向模板id", width = 15)
+    @ApiModelProperty(value = "定向模板id")
+    private Long templateId;
+    /**
+     * 模板名称
+     */
+    @Excel(name = "模板名称", width = 15)
+    @ApiModelProperty(value = "模板名称")
+    private String templateName;
+    /**
+     * 绑定组个数
+     */
+    @Excel(name = "绑定组个数", width = 15)
+    @ApiModelProperty(value = "绑定组个数")
+    private Integer unitCount;
+    /**
+     * 定向模板创建时间
+     */
+    @Excel(name = "定向模板创建时间", width = 15)
+    @ApiModelProperty(value = "定向模板创建时间")
+    private Date createTime;
+    /**
+     * 定向模板修改时间
+     */
+    @Excel(name = "定向模板修改时间", width = 15)
+    @ApiModelProperty(value = "定向模板修改时间")
+    private Date updateTime;
+}

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

@@ -0,0 +1,212 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+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 java.util.Date;
+
+/**
+ * 快手-定向模板-详情
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-11-09
+ */
+@Data
+@TableName("ctop_kuaishou_template_target")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_template_target对象", description = "快手-定向模板-详情")
+public class KuaishouTemplateTarget {
+
+    /**
+     * id
+     */
+    @ApiModelProperty(value = "id")
+    private String id;
+    /**
+     * 定向模板id
+     */
+    @Excel(name = "定向模板id", width = 15)
+    @ApiModelProperty(value = "定向模板id")
+    private Long templateId;
+    /**
+     * 地域
+     */
+    @Excel(name = "地域", width = 15)
+    @ApiModelProperty(value = "地域")
+    private String region;
+    /**
+     * 商圈定向
+     */
+    @Excel(name = "商圈定向", width = 15)
+    @ApiModelProperty(value = "商圈定向")
+    private String districtIds;
+    /**
+     * 用户类型 0:实时1:常驻 2:不限
+     */
+    @Excel(name = "用户类型 0:实时1:常驻 2:不限 ", width = 15)
+    @ApiModelProperty(value = "用户类型 0:实时1:常驻 2:不限 ")
+    private Integer userType;
+    /**
+     * 可选年龄段 18:18-23岁 24:24-30岁 31:31-40岁 41:41-49岁 50:50-100岁
+     */
+    @Excel(name = "可选年龄段 18:18-23岁 24:24-30岁 31:31-40岁 41:41-49岁 50:50-100岁 ", width = 15)
+    @ApiModelProperty(value = "可选年龄段 18:18-23岁 24:24-30岁 31:31-40岁 41:41-49岁 50:50-100岁 ")
+    private String agesRange;
+    /**
+     * 年龄最小值
+     */
+    @Excel(name = "年龄最小值", width = 15)
+    @ApiModelProperty(value = "年龄最小值")
+    private Integer min;
+    /**
+     * 年龄最大值
+     */
+    @Excel(name = "年龄最大值", width = 15)
+    @ApiModelProperty(value = "年龄最大值")
+    private Integer max;
+    /**
+     * 性别 1:女性, 2:男性,0 表示不限
+     */
+    @Excel(name = "性别 1:女性, 2:男性,0 表示不限", width = 15)
+    @ApiModelProperty(value = "性别 1:女性, 2:男性,0 表示不限")
+    private Integer gender;
+    /**
+     * 定向的 os 版本 应用安装类计划以app_id中的platform_os为准 1:Android,2:iOS,0 表示不限
+     */
+    @Excel(name = "定向的 os 版本 应用安装类计划以app_id中的platform_os为准 1:Android,2:iOS,0 表示不限", width = 15)
+    @ApiModelProperty(value = "定向的 os 版本 应用安装类计划以app_id中的platform_os为准 1:Android,2:iOS,0 表示不限")
+    private Integer platformOs;
+    /**
+     * Android 版本 3:不限,4:4.x+,5:5.x+,6:6.x+,7:7.x+
+     */
+    @Excel(name = "Android 版本 3:不限,4:4.x+,5:5.x+,6:6.x+,7:7.x+", width = 15)
+    @ApiModelProperty(value = "Android 版本 3:不限,4:4.x+,5:5.x+,6:6.x+,7:7.x+")
+    private Integer androidOsv;
+    /**
+     * iOS 版本 6:不限, 7:7.x+, 8:8.x+, 9:9.x+, 10:10.x+
+     */
+    @Excel(name = "iOS 版本 6:不限, 7:7.x+, 8:8.x+, 9:9.x+, 10:10.x+", width = 15)
+    @ApiModelProperty(value = "iOS 版本 6:不限, 7:7.x+, 8:8.x+, 9:9.x+, 10:10.x+")
+    private Integer iosOsv;
+    /**
+     * 网络环境 1:WI-FI,2:移动网络,0:表示不限
+     */
+    @Excel(name = "网络环境 1:WI-FI,2:移动网络,0:表示不限", width = 15)
+    @ApiModelProperty(value = "网络环境 1:WI-FI,2:移动网络,0:表示不限")
+    private Integer network;
+    /**
+     * 过滤已转化人群纬度 0:不限 1:广告组 2:广告计划 3:本账户 4:公司主体 5:APP
+     */
+    @Excel(name = "过滤已转化人群纬度 0:不限 1:广告组 2:广告计划 3:本账户 4:公司主体 5:APP", width = 15)
+    @ApiModelProperty(value = "过滤已转化人群纬度 0:不限 1:广告组 2:广告计划 3:本账户 4:公司主体 5:APP")
+    private Integer filterConvertedLevel;
+    /**
+     * 设备品牌  1:OPPO,2:VIVO, 3:华为,4:小米,5:荣耀,6:三星,7:金立,8:魅族,9:乐视,10:其他,11:苹果(只有 platform_os 为不限时支持此选项);传值为 [] 表示不限;当 platform_os 表示 iOS 的时候,没有设备品牌定向
+     */
+    @Excel(name = "设备品牌  1:OPPO,2:VIVO, 3:华为,4:小米,5:荣耀,6:三星,7:金立,8:魅族,9:乐视,10:其他,11:苹果(只有 platform_os 为不限时支持此选项);传值为 [] 表示不限;当 platform_os 表示 iOS 的时候,没有设备品牌定向", width = 15)
+    @ApiModelProperty(value = "设备品牌  1:OPPO,2:VIVO, 3:华为,4:小米,5:荣耀,6:三星,7:金立,8:魅族,9:乐视,10:其他,11:苹果(只有 platform_os 为不限时支持此选项);传值为 [] 表示不限;当 platform_os 表示 iOS 的时候,没有设备品牌定向")
+    private String deviceBrand;
+    /**
+     * 设备价格 1:1,500元以下,2:1,501~2,000,3:2,001~2,500,4:2,501~3,000,5、3,001~3,500,6:3,501~4,000,7:4,001~4,500,8:4,501~5,000,9:5,001~5,500,10:5,500元以上,传值为 [] 表示不限
+     */
+    @Excel(name = "设备价格 1:1,500元以下,2:1,501~2,000,3:2,001~2,500,4:2,501~3,000,5、3,001~3,500,6:3,501~4,000,7:4,001~4,500,8:4,501~5,000,9:5,001~5,500,10:5,500元以上,传值为 [] 表示不限", width = 15)
+    @ApiModelProperty(value = "设备价格 1:1,500元以下,2:1,501~2,000,3:2,001~2,500,4:2,501~3,000,5、3,001~3,500,6:3,501~4,000,7:4,001~4,500,8:4,501~5,000,9:5,001~5,500,10:5,500元以上,传值为 [] 表示不限")
+    private String devicePrice;
+    /**
+     * 商业兴趣类型 0:默认值 1:智能投放 2:兴趣标签
+     */
+    @Excel(name = "商业兴趣类型 0:默认值 1:智能投放 2:兴趣标签", width = 15)
+    @ApiModelProperty(value = "商业兴趣类型 0:默认值 1:智能投放 2:兴趣标签")
+    private Integer businessInterestType;
+    /**
+     * 商业兴趣
+     */
+    @Excel(name = "商业兴趣", width = 15)
+    @ApiModelProperty(value = "商业兴趣")
+    private String businessInterest;
+    /**
+     * 网红类别
+     */
+    @Excel(name = "网红类别", width = 15)
+    @ApiModelProperty(value = "网红类别")
+    private String fansStar;
+    /**
+     * 兴趣视频
+     */
+    @Excel(name = "兴趣视频", width = 15)
+    @ApiModelProperty(value = "兴趣视频")
+    private String interestVideo;
+    /**
+     * APP行为-按分类
+     */
+    @Excel(name = "APP行为-按分类", width = 15)
+    @ApiModelProperty(value = "APP行为-按分类")
+    private String appInterest;
+    /**
+     * APP行为-按APP名称
+     */
+    @Excel(name = "APP行为-按APP名称", width = 15)
+    @ApiModelProperty(value = "APP行为-按APP名称")
+    private String appIds;
+    /**
+     * 定向人群包
+     */
+    @Excel(name = "定向人群包", width = 15)
+    @ApiModelProperty(value = "定向人群包")
+    private String population;
+    /**
+     * 付费人群包
+     */
+    @Excel(name = "付费人群包", width = 15)
+    @ApiModelProperty(value = "付费人群包")
+    private String paidAudience;
+    /**
+     * 排除人群包
+     */
+    @Excel(name = "排除人群包", width = 15)
+    @ApiModelProperty(value = "排除人群包")
+    private String excludePopulation;
+    /**
+     * 开启智能扩量 默认为0,为1时打开智能扩量,其他数值报错;关闭智能扩量时,以下三个字段必须为0
+     */
+    @Excel(name = "开启智能扩量 默认为0,为1时打开智能扩量,其他数值报错;关闭智能扩量时,以下三个字段必须为0", width = 15)
+    @ApiModelProperty(value = "开启智能扩量 默认为0,为1时打开智能扩量,其他数值报错;关闭智能扩量时,以下三个字段必须为0")
+    private Integer isOpen;
+    /**
+     * 不可突破年龄 默认为0(可突破/无需控制),定向age数据不为空时,可设为1(不可突破)
+     */
+    @Excel(name = "不可突破年龄 默认为0(可突破/无需控制),定向age数据不为空时,可设为1(不可突破)", width = 15)
+    @ApiModelProperty(value = "不可突破年龄 默认为0(可突破/无需控制),定向age数据不为空时,可设为1(不可突破)")
+    private Integer noAgeBreak;
+    /**
+     * 不可突破性别 默认为0(可突破/无需控制),定向gender数据不为空时,可设为1(不可突破
+     */
+    @Excel(name = "不可突破性别 默认为0(可突破/无需控制),定向gender数据不为空时,可设为1(不可突破", width = 15)
+    @ApiModelProperty(value = "不可突破性别 默认为0(可突破/无需控制),定向gender数据不为空时,可设为1(不可突破")
+    private Integer noGenderBreak;
+    /**
+     * 不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)
+     */
+    @Excel(name = "不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)", width = 15)
+    @ApiModelProperty(value = "不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)")
+    private Integer noAreaBreak;
+    /**
+     * 定向模板创建时间
+     */
+    @Excel(name = "定向模板创建时间", width = 15)
+    @ApiModelProperty(value = "定向模板创建时间")
+    private Date createTime;
+    /**
+     * 定向模板修改时间
+     */
+    @Excel(name = "定向模板修改时间", width = 15)
+    @ApiModelProperty(value = "定向模板修改时间")
+    private Date updateTime;
+}

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplate;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手-定向模板
+ *
+ * @author: jeecg-boot
+ * @date: 2020-11-09
+ * @cersion: V1.0
+ */
+public interface KuaishouTemplateMapper extends BaseMapper<KuaishouTemplate> {
+
+}

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手-定向模板-详情
+ *
+ * @author: jeecg-boot
+ * @date: 2020-11-09
+ * @cersion: V1.0
+ */
+public interface KuaishouTemplateTargetMapper extends BaseMapper<KuaishouTemplateTarget> {
+
+}

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouTemplateMapper.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.kuaishou.modules.batch.mapper.KuaishouTemplateMapper">
+
+</mapper>

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouTemplateTargetMapper.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.kuaishou.modules.batch.mapper.KuaishouTemplateTargetMapper">
+
+</mapper>

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplate;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 快手-定向模板
+ * @Author: jeecg-boot
+ * @Date: 2020-11-09
+ * @Version: V1.0
+ */
+public interface IKuaishouTemplateService extends IService<KuaishouTemplate> {
+
+    void getTemplateByAccountId(Long accountId, String accessToken, Integer page);
+
+    JSONObject createTemplate(Long accountId, String accessToken, JSONObject requestJson);
+
+
+    JSONObject updateTemplate(Long accountId, String accessToken, JSONObject requestJson);
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 快手-定向模板-详情
+ * @Author: jeecg-boot
+ * @Date: 2020-11-09
+ * @Version: V1.0
+ */
+public interface IKuaishouTemplateTargetService extends IService<KuaishouTemplateTarget> {
+
+}

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

@@ -0,0 +1,31 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import com.alibaba.fastjson.JSONObject;
+
+public interface IWarningOperationService {
+    JSONObject getBidTypeAndMaxBid(Long accountId);
+
+    /**
+     * 快手 出价方式 预警 && 操作
+     *
+     * @param projectId
+     * @param projectName
+     * @param advertiserId
+     * @param unitId
+     * @param unit_name
+     */
+    void kuaiShouWarningOperation(Long projectId, String projectName, Long advertiserId, Long unitId, String unit_name);
+
+
+    /**
+     * 出价 过高预警 && 操作
+     *
+     * @param projectId
+     * @param projectName
+     * @param advertiserId
+     * @param unitId
+     * @param unit_name
+     */
+
+    void kuaiShouBidWarningOperation(Long projectId, String projectName, Long advertiserId, Long unitId, String unit_name);
+}

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

@@ -138,6 +138,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     private IKuaiShouGroupService getKuaiShouGroupService;
     @Autowired
     private IKuaiShouAdvertiserBaseInfoService KuaiShouAdvertiserBaseInfoService;
+    @Autowired
+    private IWarningOperationService warningOperationService;
 
 
     @Override
@@ -1201,7 +1203,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
         JSONObject param = new JSONObject();
         param.put("advertiser_id", token.getAccountId());
-        param.put("page_size", 200);
+        param.put("page_size", 500);
         param.put("page", page);
         if (startDate != null && endDate != null) {
             param.put("start_date", DateUtils.formatDate(startDate));
@@ -1230,25 +1232,60 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         getGroupListByPage(token, startDate, endDate, page + 1);
     }
 
-
+    static ExecutorService executorBidTypeService = Executors.newFixedThreadPool(20);
+    static ExecutorService executorMaxBidService = Executors.newFixedThreadPool(5);
     private void addGroup(Long advertiserId, JSONArray details) {
+        JSONObject json = warningOperationService.getBidTypeAndMaxBid(advertiserId);
+        Long maxBid = json.getLong("maxBid");// 最高出价
+        Integer bidType = json.getInteger("bidType"); // 出价方式
+        Integer ocpxActionType = json.getInteger("ocpxActionType"); // 优化目标
         if (!Check.isNull(details)) {
             List<KuaiShouGroup> groups = new ArrayList<>();
             for (int i = 0; i < details.size(); i++) {
                 JSONObject detail = JSONObject.parseObject(details.get(i).toString());
                 if (!Check.isNull(detail)) {
-                    KuaiShouGroup group = new KuaiShouGroup();
+                    Integer bid_type = detail.getInteger("bid_type");
+                    Long bid = detail.getLong("bid");
+                    Long cpa_bid = detail.getLong("cpa_bid");
+                    Long day_budget = detail.getLong("day_budget");
+                    Integer ocpx_action_type = detail.getInteger("ocpx_action_type");
                     Long unitId = detail.getLong("unit_id");
+                    String unit_name = detail.getString("unit_name");
+                    Integer status = detail.getInteger("status");
+                    Integer put_status = detail.getInteger("put_status");
+                    if (put_status == 1) { // 组状态为 投放中的
+                        if (status != 15) { // 广告组状态为非暂停
+                            if ((!bidType.equals(bid_type)) || (!ocpxActionType.equals(ocpx_action_type))) { // 出价方式设置非法
+                                if (day_budget > 500 * 1000 || day_budget == 0) { // 预算大于500 或者不限制预算 需要发送通知 并且进行暂停操作
+                                    executorBidTypeService.submit(new Runnable() {
+                                        @Override
+                                        public void run() {
+                                            warningOperationService.kuaiShouWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
+                                        }
+                                    });
+                                }
+                            }
+                            if (bid > maxBid || cpa_bid > maxBid) {
+                                executorMaxBidService.submit(new Runnable() {
+                                    @Override
+                                    public void run() {
+                                        warningOperationService.kuaiShouBidWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
+                                    }
+                                });
+                            }
+                        }
+                    }
+                    KuaiShouGroup group = new KuaiShouGroup();
                     group.setId("" + advertiserId + unitId);
                     group.setAccountId(advertiserId);
                     group.setCampaignId(detail.getLong("campaign_id"));
                     group.setUnitId(unitId);
-                    group.setUnitName(detail.getString("unit_name"));
-                    group.setStatus(detail.getInteger("status"));
-                    group.setPutStatus(detail.getInteger("put_status"));
+                    group.setUnitName(unit_name);
+                    group.setStatus(status);
+                    group.setPutStatus(put_status);
                     group.setCreateChannel(detail.getInteger("create_channel"));
                     group.setReviewDetail(detail.getString("review_detail"));
-                    group.setBidType(detail.getInteger("bid_type"));
+                    group.setBidType(bid_type);
                     group.setBid(detail.getLong("bid"));
                     group.setCpaBid(detail.getLong("cpa_bid"));
                     group.setOcpxActionType(detail.getInteger("ocpx_action_type"));

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

@@ -0,0 +1,447 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplate;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateTargetService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+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.HashMap;
+import java.util.Map;
+
+/**
+ * 快手-定向模板
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-11-09
+ */
+@Slf4j
+@Service
+public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMapper, KuaishouTemplate> implements IKuaishouTemplateService {
+    @Autowired
+    private IKuaishouTemplateTargetService templateTargetService;
+
+    @Override
+    public void getTemplateByAccountId(Long accountId, String accessToken, Integer page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_LIST;
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        param.put("page", page);
+        param.put("page_size", 500);
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Access-Token", accessToken);
+        headers.put("Content-Type", " application/json");
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (!Check.isNull(resultJson)) {
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                JSONObject dataJson = resultJson.getJSONObject("data");
+                if (!Check.isNull(dataJson)) {
+                    return;
+                }
+                JSONArray details = dataJson.getJSONArray("details");
+                if (!Check.isNull(details)) {
+                    return;
+                }
+                for (int i = 0; i < details.size(); i++) {
+                    JSONObject jsonObject = details.getJSONObject(i);
+                    Long templateId = jsonObject.getLong("template_id");
+                    KuaishouTemplate template = new KuaishouTemplate();
+                    template.setId(accountId + "_" + templateId);
+                    template.setAccountId(accountId);
+                    template.setTemplateId(templateId);
+                    template.setTemplateName(jsonObject.getString("template_name"));
+                    template.setUnitCount(jsonObject.getInteger("unit_count"));
+                    template.setCreateTime(jsonObject.getDate("create_time"));
+                    template.setUpdateTime(jsonObject.getDate("updateTime"));
+                    this.saveOrUpdate(template);
+                    JSONObject targetJson = jsonObject.getJSONObject("target");
+                    if (!Check.isNull(targetJson)) {
+                        KuaishouTemplateTarget templateTarget = new KuaishouTemplateTarget();
+                        templateTarget.setId(accountId + "_" + templateId);
+                        templateTarget.setTemplateId(templateId);
+                        if (!Check.isNull(targetJson.getJSONArray("region"))) {
+                            templateTarget.setRegion(targetJson.getJSONArray("region").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("district_ids"))) {
+                            templateTarget.setDistrictIds(targetJson.getJSONArray("district_ids").toString());
+                        }
+                        if (!Check.isNull(targetJson.getInteger("user_type"))) {
+                            templateTarget.setUserType(targetJson.getInteger("user_type"));
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("ages_range"))) {
+                            templateTarget.setAgesRange(targetJson.getJSONArray("ages_range").toJSONString());
+                        }
+                        JSONObject ageJson = targetJson.getJSONObject("age");
+                        if (!Check.isNull(ageJson)) {
+                            templateTarget.setMin(ageJson.getInteger("min"));
+                            templateTarget.setMax(ageJson.getInteger("max"));
+                        }
+                        if (!Check.isNull(targetJson.getInteger("gender"))) {
+                            templateTarget.setGender(targetJson.getInteger("gender"));
+                        }
+                        if (!Check.isNull(targetJson.getInteger("platform_os"))) {
+                            templateTarget.setPlatformOs(targetJson.getInteger("platform_os"));
+                        }
+                        if (!Check.isNull(targetJson.getInteger("android_osv"))) {
+                            templateTarget.setAndroidOsv(targetJson.getInteger("android_osv"));
+                        }
+                        if (!Check.isNull(targetJson.getInteger("ios_osv"))) {
+                            templateTarget.setIosOsv(targetJson.getInteger("ios_osv"));
+                        }
+                        if (!Check.isNull(targetJson.getInteger("network"))) {
+                            templateTarget.setNetwork(targetJson.getInteger("network"));
+                        }
+                        if (!Check.isNull(targetJson.getInteger("filter_converted_level"))) {
+                            templateTarget.setFilterConvertedLevel(targetJson.getInteger("filter_converted_level"));
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("device_brand"))) {
+                            templateTarget.setDeviceBrand(targetJson.getJSONArray("device_brand").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("device_price"))) {
+                            templateTarget.setDevicePrice(targetJson.getJSONArray("device_price").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getInteger("business_interest_type"))) {
+                            templateTarget.setBusinessInterestType(targetJson.getInteger("business_interest_type"));
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("business_interest"))) {
+                            templateTarget.setBusinessInterest(targetJson.getJSONArray("business_interest").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("fans_star"))) {
+                            templateTarget.setFansStar(targetJson.getJSONArray("fans_star").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("interest_video"))) {
+                            templateTarget.setInterestVideo(targetJson.getJSONArray("interest_video").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("app_interest"))) {
+                            templateTarget.setAppInterest(targetJson.getJSONArray("app_interest").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("app_ids"))) {
+                            templateTarget.setAppIds(targetJson.getJSONArray("app_ids").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("population"))) {
+                            templateTarget.setPopulation(targetJson.getJSONArray("population").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("paid_audience"))) {
+                            templateTarget.setPaidAudience(targetJson.getJSONArray("paid_audience").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("exclude_population"))) {
+                            templateTarget.setExcludePopulation(targetJson.getJSONArray("exclude_population").toJSONString());
+                        }
+                        JSONObject intelliExtendJson = targetJson.getJSONObject("intelli_extend");
+                        if (!Check.isNull(intelliExtendJson)) {
+                            if (!Check.isNull(intelliExtendJson.getInteger("is_open"))) {
+                                templateTarget.setIsOpen(intelliExtendJson.getInteger("is_open"));
+                            }
+                            if (!Check.isNull(intelliExtendJson.getInteger("no_age_break"))) {
+                                templateTarget.setNoAgeBreak(intelliExtendJson.getInteger("no_age_break"));
+                            }
+                            if (!Check.isNull(intelliExtendJson.getInteger("no_gender_break"))) {
+                                templateTarget.setNoGenderBreak(intelliExtendJson.getInteger("no_gender_break"));
+                            }
+                            if (!Check.isNull(intelliExtendJson.getInteger("no_area_break"))) {
+                                templateTarget.setNoAreaBreak(intelliExtendJson.getInteger("no_area_break"));
+                            }
+                        }
+                        templateTargetService.saveOrUpdate(templateTarget);
+                    }
+
+                }
+
+                getTemplateByAccountId(accountId, accessToken, page + 1);
+            } else {
+                log.error("获取模板信息返回信息错误:accountId:{},返回信息:{}", accountId, resultJson);
+
+
+            }
+
+
+        } else {
+            log.error("获取模板信息返回信息为空:accountId:{}", accountId);
+        }
+
+
+    }
+
+
+    /**
+     * 创建定向模板
+     *
+     * @param accountId
+     * @param accessToken
+     * @param requestJson
+     * @return
+     */
+    @Override
+    public JSONObject createTemplate(Long accountId, String accessToken, JSONObject requestJson) {
+
+
+        try {
+            if (Check.isNull(requestJson.getString("templateName"))) {
+                throw new Exception("定向模板名称为必传项");
+            }
+
+            JSONObject param = new JSONObject();
+            param.put("advertiser_id", accountId);
+            param.put("template_name", requestJson.getString("templateName"));
+            JSONObject targetJson = new JSONObject();
+            if (!Check.isNull(requestJson.getJSONArray("region"))) {
+                targetJson.put("region", requestJson.getJSONArray("region"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("districtIds"))) {
+                targetJson.put("district_ids", requestJson.getJSONArray("districtIds"));
+            }
+            if (!Check.isNull(requestJson.getInteger("userType"))) {
+                targetJson.put("user_type", requestJson.getInteger("userType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("agesRange"))) {
+                targetJson.put("ages_range", requestJson.getJSONArray("agesRange"));
+            }
+
+            JSONObject ageJson = new JSONObject();
+            if (!Check.isNull(requestJson.getInteger("min"))) {
+                ageJson.put("min", requestJson.getInteger("min"));
+            }
+            if (!Check.isNull(requestJson.getInteger("max"))) {
+                ageJson.put("max", requestJson.getInteger("max"));
+            }
+            if (!Check.isNull(ageJson)) {
+                targetJson.put("age", ageJson);
+            }
+
+            if (!Check.isNull(requestJson.getInteger("gender"))) {
+                targetJson.put("gender", requestJson.getInteger("gender"));
+            }
+            if (!Check.isNull(requestJson.getInteger("platformOs"))) {
+                targetJson.put("platform_os", requestJson.getInteger("platformOs"));
+            }
+            if (!Check.isNull(requestJson.getInteger("androidOsv"))) {
+                targetJson.put("android_osv", requestJson.getInteger("androidOsv"));
+            }
+            if (!Check.isNull(requestJson.getInteger("iosOsv"))) {
+                targetJson.put("ios_osv", requestJson.getInteger("iosOsv"));
+            }
+            if (!Check.isNull(requestJson.getInteger("network"))) {
+                targetJson.put("network", requestJson.getInteger("network"));
+            }
+            if (!Check.isNull(requestJson.getInteger("filterConvertedLevel"))) {
+                targetJson.put("filter_converted_level", requestJson.getInteger("filterConvertedLevel"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("deviceBrand"))) {
+                targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
+                targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
+            }
+            if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
+                targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
+                targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
+                targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
+                targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
+                targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("appIds"))) {
+                targetJson.put("app_ids", requestJson.getJSONArray("appIds"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("population"))) {
+                targetJson.put("population", requestJson.getJSONArray("population"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("paidAudience"))) {
+                targetJson.put("paid_audience", requestJson.getJSONArray("paidAudience"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
+                targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
+            }
+            JSONObject intelliExtendJson = new JSONObject();
+
+            if (!Check.isNull(requestJson.getInteger("isOpen"))) {
+                intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
+            }
+            if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
+                intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
+            }
+            if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
+                intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
+            }
+            if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
+                intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
+            }
+            if (!Check.isNull(intelliExtendJson)) {
+                targetJson.put("intelli_extend", intelliExtendJson);
+            }
+            if (!Check.isNull(targetJson)) {
+                param.put("target", targetJson);
+            }
+
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Access-Token", accessToken);
+            headers.put("Content-Type", " application/json");
+
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_CREATE;
+            System.err.println(param);
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+
+            JSONObject resultJson = JSONObject.parseObject(result);
+            System.err.println(resultJson);
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+
+    /**
+     * 修改定向模板
+     *
+     * @param accountId
+     * @param accessToken
+     * @param requestJson
+     * @return
+     */
+    @Override
+    public JSONObject updateTemplate(Long accountId, String accessToken, JSONObject requestJson) {
+        try {
+            if (Check.isNull(requestJson.getString("templateName"))) {
+                throw new Exception("定向模板名称为必传项");
+            }
+
+            JSONObject param = new JSONObject();
+            param.put("advertiser_id", accountId);
+            param.put("template_name", requestJson.getString("templateName"));
+            JSONObject targetJson = new JSONObject();
+            if (!Check.isNull(requestJson.getJSONArray("region"))) {
+                targetJson.put("region", requestJson.getJSONArray("region"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("districtIds"))) {
+                targetJson.put("district_ids", requestJson.getJSONArray("districtIds"));
+            }
+            if (!Check.isNull(requestJson.getInteger("userType"))) {
+                targetJson.put("user_type", requestJson.getInteger("userType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("agesRange"))) {
+                targetJson.put("ages_range", requestJson.getJSONArray("agesRange"));
+            }
+
+            JSONObject ageJson = new JSONObject();
+            if (!Check.isNull(requestJson.getInteger("min"))) {
+                ageJson.put("min", requestJson.getInteger("min"));
+            }
+            if (!Check.isNull(requestJson.getInteger("max"))) {
+                ageJson.put("max", requestJson.getInteger("max"));
+            }
+            if (!Check.isNull(ageJson)) {
+                targetJson.put("age", ageJson);
+            }
+
+            if (!Check.isNull(requestJson.getInteger("gender"))) {
+                targetJson.put("gender", requestJson.getInteger("gender"));
+            }
+            if (!Check.isNull(requestJson.getInteger("platformOs"))) {
+                targetJson.put("platform_os", requestJson.getInteger("platformOs"));
+            }
+            if (!Check.isNull(requestJson.getInteger("androidOsv"))) {
+                targetJson.put("android_osv", requestJson.getInteger("androidOsv"));
+            }
+            if (!Check.isNull(requestJson.getInteger("iosOsv"))) {
+                targetJson.put("ios_osv", requestJson.getInteger("iosOsv"));
+            }
+            if (!Check.isNull(requestJson.getInteger("network"))) {
+                targetJson.put("network", requestJson.getInteger("network"));
+            }
+            if (!Check.isNull(requestJson.getInteger("filterConvertedLevel"))) {
+                targetJson.put("filter_converted_level", requestJson.getInteger("filterConvertedLevel"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("deviceBrand"))) {
+                targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
+                targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
+            }
+            if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
+                targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
+                targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
+                targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
+                targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
+                targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("appIds"))) {
+                targetJson.put("app_ids", requestJson.getJSONArray("appIds"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("population"))) {
+                targetJson.put("population", requestJson.getJSONArray("population"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("paidAudience"))) {
+                targetJson.put("paid_audience", requestJson.getJSONArray("paidAudience"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
+                targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
+            }
+            JSONObject intelliExtendJson = new JSONObject();
+
+            if (!Check.isNull(requestJson.getInteger("isOpen"))) {
+                intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
+            }
+            if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
+                intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
+            }
+            if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
+                intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
+            }
+            if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
+                intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
+            }
+            if (!Check.isNull(intelliExtendJson)) {
+                targetJson.put("intelli_extend", intelliExtendJson);
+            }
+            if (!Check.isNull(targetJson)) {
+                param.put("target", targetJson);
+            }
+
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Access-Token", accessToken);
+            headers.put("Content-Type", " application/json");
+
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_CREATE;
+            System.err.println(param);
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+
+            JSONObject resultJson = JSONObject.parseObject(result);
+            System.err.println(resultJson);
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+}

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

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateTargetMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateTargetService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 快手-定向模板-详情
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-11-09
+ */
+@Service
+public class KuaishouTemplateTargetServiceImpl extends ServiceImpl<KuaishouTemplateTargetMapper, KuaishouTemplateTarget> implements IKuaishouTemplateTargetService {
+
+}

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

@@ -0,0 +1,117 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.WarningOperationLog;
+import cn.com.ctop.common.module.mapper.ProjectMapper;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IMessageTemplate;
+import cn.com.ctop.common.module.service.ISendMessageService;
+import cn.com.ctop.common.module.service.IWarningOperationLogService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IWarningOperationService;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class WarningOperationServiceImpl implements IWarningOperationService {
+    @Autowired
+    private ProjectMapper projectMapper;
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
+    @Autowired
+    private IMessageTemplate messageTemplate;
+    @Autowired
+    private IKuaiShouUpdateService updateService;
+    @Autowired
+    private ISendMessageService sendMessageService;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    private IWarningOperationLogService warningOperationLogService;
+
+    @Override
+    public JSONObject getBidTypeAndMaxBid(Long accountId) {
+        Long projectId = userAllocationMapper.getProjectIdByAccountId(accountId);
+        if (Check.isNull(projectId)) {
+            log.error("此账户未绑定项目");
+            return null;
+        }
+        JSONObject warningJson = projectMapper.getWarningInfoByProjectId(projectId);
+        return warningJson;
+    }
+
+
+    /**
+     * 快手出价方式预警 && 操作
+     *
+     * @param projectId
+     * @param projectName
+     * @param advertiserId
+     * @param unitId
+     * @param unit_name
+     */
+
+    @Override
+    public void kuaiShouWarningOperation(Long projectId, String projectName, Long advertiserId, Long unitId, String unit_name) {
+
+        String userId = userAllocationMapper.queryUserIdByAccountId(advertiserId);
+        try {
+            String text = messageTemplate.getKuaiShouBidTypeMessage(projectName, advertiserId, unitId, unit_name);
+
+            sendMessageService.sendMessage(userId, text);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        CtopOauthToken token = oauthTokenService.getTokenByAccountId(advertiserId);
+        updateService.updateUnitStatus(token.getAccessToken(), advertiserId, unitId, 2, "admin");
+        WarningOperationLog warningOperationLog = new WarningOperationLog();
+        warningOperationLog.setAccountId(advertiserId);
+        warningOperationLog.setSubject("出价方式预警");
+        warningOperationLog.setUnitId(unitId);
+        warningOperationLog.setUserId(userId);
+        warningOperationLog.setWarningType(1);
+        warningOperationLogService.save(warningOperationLog);
+
+
+    }
+
+
+    /**
+     * 出价 过高预警 && 操作
+     *
+     * @param projectId
+     * @param projectName
+     * @param advertiserId
+     * @param unitId
+     * @param unit_name
+     */
+
+    @Override
+    public void kuaiShouBidWarningOperation(Long projectId, String projectName, Long advertiserId, Long unitId, String unit_name) {
+        String userId = userAllocationMapper.queryUserIdByAccountId(advertiserId);
+        try {
+            String text = messageTemplate.getKuaiShouBidMessage(projectName, advertiserId, unitId, unit_name);
+
+            sendMessageService.sendMessage(userId, text);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        CtopOauthToken token = oauthTokenService.getTokenByAccountId(advertiserId);
+        updateService.updateUnitStatus(token.getAccessToken(), advertiserId, unitId, 2, "admin");
+
+        WarningOperationLog warningOperationLog = new WarningOperationLog();
+        warningOperationLog.setAccountId(advertiserId);
+        warningOperationLog.setSubject("出价过高预警");
+        warningOperationLog.setUnitId(unitId);
+        warningOperationLog.setUserId(userId);
+        warningOperationLog.setWarningType(2);
+        warningOperationLogService.save(warningOperationLog);
+
+    }
+}