Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

syh před 5 roky
rodič
revize
85de4b1ac3
32 změnil soubory, kde provedl 963 přidání a 150 odebrání
  1. 6 0
      jeecg-boot-module-system/pom.xml
  2. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/SalePerformanceDetailController.java
  3. 0 15
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/SalePerformanceDetailMapper.java
  4. 0 15
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ISalePerformanceDetailService.java
  5. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/PerformanceSaleServiceImpl.java
  6. 0 19
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/SalePerformanceDetailServiceImpl.java
  7. 29 10
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/controller/PerformanceShowCtrl.java
  8. 63 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/DesignDetail.java
  9. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/SalePerformanceDetail.java
  10. 4 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/CalculatePerformanceMapper.java
  11. 8 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/DesignDetailMapper.java
  12. 22 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/SalePerformanceDetailMapper.java
  13. 59 17
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/CalculatePerformanceMapper.xml
  14. 29 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/DesignDetailMapper.xml
  15. 28 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/SalePerformanceDetailMapper.xml
  16. 0 28
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/DesignDetailServiceImpl.java
  17. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/ICalculatePerformanceService.java
  18. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IDesignDetailService.java
  19. 23 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/ISalePerformanceDetailService.java
  20. 49 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/CalculatePerformanceServiceImpl.java
  21. 82 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/DesignDetailServiceImpl.java
  22. 230 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/SalePerformanceDetailServiceImpl.java
  23. 22 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/testCtrl.java
  24. 2 2
      jeecg-boot-module-system/src/main/resources/application-prod.yml
  25. 168 0
      jeecg-boot-module-system/src/main/resources/application-prod2.yml
  26. 2 2
      jeecg-boot-module-system/src/main/resources/application-test.yml
  27. 13 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/RandomUtil.java
  28. 78 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  29. 2 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  30. 5 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  31. 6 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreateServiceImpl.java
  32. 21 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

+ 6 - 0
jeecg-boot-module-system/pom.xml

@@ -232,6 +232,12 @@
             </properties>
             </properties>
         </profile>
         </profile>
         <profile>
         <profile>
+            <id>prod2</id>
+            <properties>
+                <activatedProperties>prod2</activatedProperties>
+            </properties>
+        </profile>
+        <profile>
             <id>wps</id>
             <id>wps</id>
             <properties>
             <properties>
                 <activatedProperties>wps</activatedProperties>
                 <activatedProperties>wps</activatedProperties>

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/SalePerformanceDetailController.java

@@ -11,8 +11,8 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.ctop.entity.SalePerformanceDetail;
-import org.jeecg.modules.ctop.service.ISalePerformanceDetailService;
+import org.jeecg.modules.performance.entity.SalePerformanceDetail;
+import org.jeecg.modules.performance.service.ISalePerformanceDetailService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.entity.ExportParams;

+ 0 - 15
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/SalePerformanceDetailMapper.java

@@ -1,15 +0,0 @@
-package org.jeecg.modules.ctop.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.jeecg.modules.ctop.entity.SalePerformanceDetail;
-
-/**
- * 销售绩效详细信息
- *
- * @author: jeecg-boot
- * @date: 2020-04-01
- * @cersion: V1.0
- */
-public interface SalePerformanceDetailMapper extends BaseMapper<SalePerformanceDetail> {
-
-}

+ 0 - 15
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ISalePerformanceDetailService.java

@@ -1,15 +0,0 @@
-package org.jeecg.modules.ctop.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import org.jeecg.modules.ctop.entity.SalePerformanceDetail;
-
-/**
- * 销售绩效详细信息
- *
- * @author jeecg-boot
- * @version V1.0
- * @date 2020-04-01
- */
-public interface ISalePerformanceDetailService extends IService<SalePerformanceDetail> {
-
-}

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/PerformanceSaleServiceImpl.java

@@ -6,10 +6,10 @@ import cn.com.ctop.performanceappraisal.service.IPerformanceService;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.entity.Advertiser;
 import org.jeecg.modules.ctop.entity.Advertiser;
-import org.jeecg.modules.ctop.entity.SalePerformanceDetail;
 import org.jeecg.modules.ctop.service.IAdvertiserService;
 import org.jeecg.modules.ctop.service.IAdvertiserService;
 import org.jeecg.modules.ctop.service.IPerformanceSaleService;
 import org.jeecg.modules.ctop.service.IPerformanceSaleService;
-import org.jeecg.modules.ctop.service.ISalePerformanceDetailService;
+import org.jeecg.modules.performance.entity.SalePerformanceDetail;
+import org.jeecg.modules.performance.service.ISalePerformanceDetailService;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.entity.SysUserRole;
 import org.jeecg.modules.system.entity.SysUserRole;
 import org.jeecg.modules.system.service.ISysUserRoleService;
 import org.jeecg.modules.system.service.ISysUserRoleService;

+ 0 - 19
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/SalePerformanceDetailServiceImpl.java

@@ -1,19 +0,0 @@
-package org.jeecg.modules.ctop.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.jeecg.modules.ctop.entity.SalePerformanceDetail;
-import org.jeecg.modules.ctop.mapper.SalePerformanceDetailMapper;
-import org.jeecg.modules.ctop.service.ISalePerformanceDetailService;
-import org.springframework.stereotype.Service;
-
-/**
- * 销售绩效详细信息
- *
- * @author jeecg-boot
- * @version V1.0
- * @date 2020-04-01
- */
-@Service
-public class SalePerformanceDetailServiceImpl extends ServiceImpl<SalePerformanceDetailMapper, SalePerformanceDetail> implements ISalePerformanceDetailService {
-
-}

+ 29 - 10
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/controller/PerformanceShowCtrl.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.performance.controller;
 package org.jeecg.modules.performance.controller;
 
 
+
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
@@ -8,9 +9,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.performance.entity.PerformanceQuarter;
 import org.jeecg.modules.performance.entity.PerformanceQuarter;
-import org.jeecg.modules.performance.service.IOperateDetailService;
-import org.jeecg.modules.performance.service.IPerformanceInfoService;
-import org.jeecg.modules.performance.service.IPerformanceQuarterService;
+import org.jeecg.modules.performance.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
@@ -35,6 +34,10 @@ public class PerformanceShowCtrl {
     IPerformanceQuarterService performanceQuarterService;
     IPerformanceQuarterService performanceQuarterService;
     @Autowired
     @Autowired
     IOperateDetailService operateDetailService;
     IOperateDetailService operateDetailService;
+    @Autowired
+    IDesignDetailService designDetailService;
+    @Autowired
+    ISalePerformanceDetailService salePerformanceDetailService;
 
 
     @GetMapping("/getPerformanceInfo")
     @GetMapping("/getPerformanceInfo")
     public Result<Map<String, Object>> getPerformanceInfo() {
     public Result<Map<String, Object>> getPerformanceInfo() {
@@ -46,9 +49,9 @@ public class PerformanceShowCtrl {
 
 
     @PostMapping("/{pageNo}/{pageSize}/{order}")
     @PostMapping("/{pageNo}/{pageSize}/{order}")
     public Result<PageInfo<PerformanceQuarter>> showPerformance(@PathVariable int pageNo,
     public Result<PageInfo<PerformanceQuarter>> showPerformance(@PathVariable int pageNo,
-                                                               @PathVariable int pageSize,
-                                                               @PathVariable String order,
-                                                               @RequestBody JSONObject requestBody) {
+                                                                @PathVariable int pageSize,
+                                                                @PathVariable String order,
+                                                                @RequestBody JSONObject requestBody) {
         Result<PageInfo<PerformanceQuarter>> result = new Result<>();
         Result<PageInfo<PerformanceQuarter>> result = new Result<>();
         PageInfo<PerformanceQuarter> pageInfo = performanceQuarterService.getPerformanceByConditionsPage(pageNo, pageSize, order, requestBody);
         PageInfo<PerformanceQuarter> pageInfo = performanceQuarterService.getPerformanceByConditionsPage(pageNo, pageSize, order, requestBody);
         result.setSuccess(true);
         result.setSuccess(true);
@@ -65,11 +68,11 @@ public class PerformanceShowCtrl {
     @PostMapping("/excel")
     @PostMapping("/excel")
     public void getExcelReport(@RequestBody JSONObject requestBody,
     public void getExcelReport(@RequestBody JSONObject requestBody,
                                HttpServletResponse response) {
                                HttpServletResponse response) {
-        List<PerformanceQuarter> excelData= performanceQuarterService.getPerformanceByConditions(requestBody);
+        List<PerformanceQuarter> excelData = performanceQuarterService.getPerformanceByConditions(requestBody);
         if (excelData.isEmpty()) {
         if (excelData.isEmpty()) {
             return;
             return;
         }
         }
-        String[] titles={"姓名","公司","职位","媒体类型","年份","季度","消耗","提成比例","绩效","管理岗绩效"};
+        String[] titles = {"姓名", "公司", "职位", "媒体类型", "年份", "季度", "消耗", "提成比例", "绩效", "管理岗绩效"};
 
 
         List<List<Object>> excelList = new ArrayList<>();
         List<List<Object>> excelList = new ArrayList<>();
         excelData.forEach(data -> {
         excelData.forEach(data -> {
@@ -77,7 +80,7 @@ public class PerformanceShowCtrl {
             temp.add(data.getUserName());
             temp.add(data.getUserName());
             temp.add(data.getCompanyName());
             temp.add(data.getCompanyName());
             temp.add(data.getRoleName());
             temp.add(data.getRoleName());
-            temp.add(data.getMediaType()==1?"头条":"快手");
+            temp.add(data.getMediaType() == 1 ? "头条" : "快手");
             temp.add(data.getYear());
             temp.add(data.getYear());
             temp.add(data.getQuarter());
             temp.add(data.getQuarter());
             temp.add(data.getCost());
             temp.add(data.getCost());
@@ -101,11 +104,27 @@ public class PerformanceShowCtrl {
     }
     }
 
 
     @PostMapping("/operateDetail")
     @PostMapping("/operateDetail")
-    public Result<List<JSONObject>> getOperateDetail(@RequestBody JSONObject requestBody){
+    public Result<List<JSONObject>> getOperateDetail(@RequestBody JSONObject requestBody) {
         Result<List<JSONObject>> result = new Result<>();
         Result<List<JSONObject>> result = new Result<>();
         result.setResult(operateDetailService.getOperateGroupAccountByUser(requestBody));
         result.setResult(operateDetailService.getOperateGroupAccountByUser(requestBody));
         result.setSuccess(true);
         result.setSuccess(true);
         return result;
         return result;
     }
     }
 
 
+    @PostMapping("/designDetail/{pageNo}/{pageSize}")
+    public Result<PageInfo<JSONObject>> getOperateDetail(@PathVariable int pageNo,
+                                                     @PathVariable int pageSize,
+                                                     @RequestBody JSONObject requestBody) {
+        Result<PageInfo<JSONObject>> result = new Result<>();
+        result.setResult(designDetailService.getDesignGroupMaterialByUser(requestBody,pageNo,pageSize));
+        result.setSuccess(true);
+        return result;
+    }
+    @PostMapping("/saleDetail")
+    public Result<List<JSONObject>> getSaleDetail(@RequestBody JSONObject requestBody) {
+        Result<List<JSONObject>> result = new Result<>();
+        result.setResult(salePerformanceDetailService.getSaleGroupAdByUser(requestBody));
+        result.setSuccess(true);
+        return result;
+    }
 }
 }

+ 63 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/DesignDetail.java

@@ -1,8 +1,13 @@
 package org.jeecg.modules.performance.entity;
 package org.jeecg.modules.performance.entity;
 
 
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import lombok.Data;
 
 
+import java.math.BigDecimal;
+import java.util.Date;
+
 /**
 /**
  * 设计消耗详细
  * 设计消耗详细
  */
  */
@@ -10,4 +15,62 @@ import lombok.Data;
 @TableName("ctop_performance_design_detail")
 @TableName("ctop_performance_design_detail")
 public class DesignDetail {
 public class DesignDetail {
 
 
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    /**
+     * 用户id
+     */
+    private String userId;
+    /**
+     * 媒体类型 1:头条 2:快手
+     */
+    private Integer mediaType;
+    /**
+     * 素材md5
+     */
+    private String materialCode;
+    /**
+     * 素材消耗
+     */
+    private BigDecimal materialCost;
+
+    /**
+     * 个人消耗
+     */
+    private BigDecimal personCost;
+    /**
+     * 提成比例
+     */
+    private BigDecimal percent;
+    /**
+     * leaderId
+     */
+    private String leaderId;
+    /**
+     * createTime
+     */
+    private String startDate;
+    /**
+     * updateTime
+     */
+    private String endDate;
+    /**
+     * createTime
+     */
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    private Date updateTime;
+
+    /**
+     * 预留字段
+     */
+    private BigDecimal cost1;
+    private BigDecimal cost2;
+
 }
 }
+

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/SalePerformanceDetail.java

@@ -1,4 +1,4 @@
-package org.jeecg.modules.ctop.entity;
+package org.jeecg.modules.performance.entity;
 
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;

+ 4 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/CalculatePerformanceMapper.java

@@ -10,4 +10,8 @@ public interface CalculatePerformanceMapper {
 
 
     List<JSONObject> queryOperateCostGroupByUser(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("mediaType")int mediaType);
     List<JSONObject> queryOperateCostGroupByUser(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("mediaType")int mediaType);
 
 
+    List<JSONObject> queryDesignCostGroupByUser(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("mediaType")int mediaType);
+
+    List<JSONObject> querySaleCostGroupByUser(@Param("year")int year, @Param("quarter")int quarter, @Param("mediaType")int mediaType);
+
 }
 }

+ 8 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/DesignDetailMapper.java

@@ -2,10 +2,16 @@ package org.jeecg.modules.performance.mapper;
 
 
 
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.performance.entity.DesignDetail;
 
 
 import java.util.List;
 import java.util.List;
 
 
-public interface DesignDetailMapper {
+public interface DesignDetailMapper extends BaseMapper<DesignDetail> {
+
+    List<JSONObject> queryMaterialDetailByDate(@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("mediaType") int mediaType);
+
+    List<JSONObject> queryDesignDetailBy(@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("userId") String userId,@Param("mediaType") int mediaType);
 
 
-    List<JSONObject> queryMaterialDetailByDate(String startDate,String endDate, int mediaType);
 }
 }

+ 22 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/SalePerformanceDetailMapper.java

@@ -0,0 +1,22 @@
+package org.jeecg.modules.performance.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.github.pagehelper.PageInfo;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.performance.entity.SalePerformanceDetail;
+
+import java.util.List;
+
+/**
+ * 销售绩效详细信息
+ *
+ * @author: jeecg-boot
+ * @date: 2020-04-01
+ * @cersion: V1.0
+ */
+public interface SalePerformanceDetailMapper extends BaseMapper<SalePerformanceDetail> {
+
+    List<JSONObject> querySaleGroupAdByUser(@Param("year") int year, @Param("quarter") int quarter, @Param("userId") String userId, @Param("mediaType") int mediaType);
+
+}

+ 59 - 17
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/CalculatePerformanceMapper.xml

@@ -4,24 +4,66 @@
 
 
     <select id="queryOperateCostGroupByUser" resultType="com.alibaba.fastjson.JSONObject">
     <select id="queryOperateCostGroupByUser" resultType="com.alibaba.fastjson.JSONObject">
         SELECT res.*,
         SELECT res.*,
-        (SELECT realname from sys_user user where user.id=res.userId limit 1) as userName,
-        (SELECT company_id from user_company company where company.user_id=res.userId limit 1) as 'companyId',
-        (SELECT company_name from user_company company where company.user_id=res.userId limit 1) as 'companyName',
-        (SELECT role_code from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleCode',
-        (SELECT role_name from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleName'
+               (SELECT realname from sys_user user where user.id=res.userId limit 1) as userName,
+               (SELECT company_id from user_company company where company.user_id=res.userId limit 1) as 'companyId',
+               (SELECT company_name from user_company company where company.user_id=res.userId limit 1) as 'companyName',
+               (SELECT role_code from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleCode',
+               (SELECT role_name from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleName'
         from (
         from (
-        SELECT
-        user_id as userId,
-        leader_id as leaderId,
-        sum(cost) as cost
-        FROM
-        ctop_performance_operate_detail
-        WHERE
-        media_type= #{mediaType}
-        AND	stat_date &gt;= #{startDate}
-        AND stat_date &lt;= #{endDate}
-        GROUP BY user_id
-        ) res
+                 SELECT
+                     user_id as userId,
+                     leader_id as leaderId,
+                     sum(cost) as cost
+                 FROM
+                     ctop_performance_operate_detail
+                 WHERE
+                     media_type= #{mediaType}
+                 AND	stat_date &gt;= #{startDate}
+                 AND stat_date &lt;= #{endDate}
+                 GROUP BY user_id
+             ) res
+    </select>
+
+    <select id="queryDesignCostGroupByUser" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT res.*,
+               (SELECT realname from sys_user user where user.id=res.userId limit 1) as userName,
+               (SELECT company_id from user_company company where company.user_id=res.userId limit 1) as 'companyId',
+               (SELECT company_name from user_company company where company.user_id=res.userId limit 1) as 'companyName',
+               (SELECT role_code from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleCode',
+               (SELECT role_name from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleName'
+        from (
+                 SELECT
+                     user_id as userId,
+                     sum(person_cost) as cost
+                 FROM
+                     ctop_performance_design_detail
+                 WHERE
+                     media_type= #{mediaType}
+                   and start_date= #{startDate}
+                   and end_date=#{endDate}
+                 GROUP BY user_id
+             ) res
+    </select>
+
+    <select id="querySaleCostGroupByUser" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT res.*,
+               (SELECT realname from sys_user user where user.id=res.userId limit 1) as userName,
+               (SELECT company_id from user_company company where company.user_id=res.userId limit 1) as 'companyId',
+               (SELECT company_name from user_company company where company.user_id=res.userId limit 1) as 'companyName',
+               (SELECT role_code from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleCode',
+               (SELECT role_name from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleName'
+        from (
+                 SELECT
+                     sale_id as userId,
+                     sum(total_cost) as cost
+                 FROM
+                     ctop_sale_performance_detail
+                 WHERE
+                     media_type= #{mediaType}
+                   and year= #{year}
+                   and quarter= #{quarter}
+                 GROUP BY sale_id
+             ) res
     </select>
     </select>
 
 
 </mapper>
 </mapper>

+ 29 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/DesignDetailMapper.xml

@@ -27,21 +27,21 @@
         FROM
         FROM
         (
         (
         SELECT
         SELECT
-        report.CODE,
+        report.code,
         sum(report.cost) AS cost,
         sum(report.cost) AS cost,
-        ascription.clip_id as clipID,
+        ascription.clip_id as clipId,
         ascription.plane_id as planeId,
         ascription.plane_id as planeId,
-        ascription.plan_id as planID,
-        ascription.shot_id as shotID,
+        ascription.plan_id as planId,
+        ascription.shot_id as shotId,
         ascription.material_id as materialId
         ascription.material_id as materialId
         FROM
         FROM
         ctop_material_report_total_result report
         ctop_material_report_total_result report
         LEFT JOIN ctop_material_info info on report.code=info.code
         LEFT JOIN ctop_material_info info on report.code=info.code
         LEFT JOIN ctop_material_ascription ascription ON info. CODE = ascription.material_id
         LEFT JOIN ctop_material_ascription ascription ON info. CODE = ascription.material_id
         WHERE
         WHERE
-        report.media_type = #{param3}
-        AND report.stat_date &gt;= #{param1}
-        AND report.stat_date &lt;= #{param2}
+        report.media_type = #{mediaType}
+        AND report.stat_date &gt;= #{startDate}
+        AND report.stat_date &lt;= #{endDate}
         GROUP BY
         GROUP BY
         report.CODE
         report.CODE
         ) res
         ) res
@@ -49,4 +49,26 @@
         res.cost > 0
         res.cost > 0
     </select>
     </select>
 
 
+    <select id="queryDesignDetailBy" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            t1.media_type AS mediaType,
+            (select realname from sys_user where id=t1.leader_id) AS leaderName,
+            t3.project_name AS projectName,
+            t2.material_name AS materialName,
+            t2.url,
+            t1.material_cost AS materialCost,
+            t1.person_cost AS personCost,
+            t1.percent
+        FROM
+            ctop_performance_design_detail t1
+                LEFT JOIN ctop_material_info t2 ON t1.material_code = t2. CODE
+                LEFT JOIN ctop_project t3 ON t2.project_id = t3.id
+        WHERE
+            t1.user_id = #{userId}
+          AND t1.start_date = #{startDate}
+          AND t1.media_type = #{mediaType}
+        GROUP BY
+            t1.material_code
+        ORDER BY person_cost desc
+    </select>
 </mapper>
 </mapper>

+ 28 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/SalePerformanceDetailMapper.xml

@@ -0,0 +1,28 @@
+<?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="org.jeecg.modules.performance.mapper.SalePerformanceDetailMapper">
+
+    <select id="querySaleGroupAdByUser" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t1.advertiser_id as ad,
+               t2.name,
+               sum(t1.total_cost) as totalCost,
+               sum(case when brand_new = 0
+                            then t1.total_cost else 0 end ) 'oldCost',
+               sum(case when brand_new = 1
+                            then t1.total_cost else 0 end ) 'newCost',
+               sum(case when brand_new = 0
+                            then t1.percent else 0 end ) 'oldPercent',
+               sum(case when brand_new = 1
+                            then t1.percent else 0 end ) 'newPercent'
+        FROM
+            ctop_sale_performance_detail t1
+                LEFT JOIN ctop_advertiser t2 on t1.advertiser_id=t2.id
+        WHERE
+            t1.sale_id = #{userId}
+          AND t1.YEAR = #{year}
+          AND t1.QUARTER = #{quarter}
+        GROUP BY
+            t1.advertiser_id
+    </select>
+
+</mapper>

+ 0 - 28
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/DesignDetailServiceImpl.java

@@ -1,28 +0,0 @@
-package org.jeecg.modules.performance.service;
-
-import com.alibaba.fastjson.JSONObject;
-import lombok.extern.slf4j.Slf4j;
-import org.jeecg.modules.performance.mapper.DesignDetailMapper;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-@Service
-@Slf4j
-public class DesignDetailServiceImpl implements IDesignDetailService {
-
-    @Autowired
-    DesignDetailMapper designDetailMapper;
-
-    @Override
-    public void UserCostCalculateByMaterial(String startDate, String endDate, int mediaType) {
-        //查询出来素材对应的cost
-        List<JSONObject> jsonObjectList=designDetailMapper.queryMaterialDetailByDate(startDate,endDate,mediaType);
-        if(jsonObjectList.isEmpty()){
-            log.error("没有素材数据");
-        }
-
-
-    }
-}

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/ICalculatePerformanceService.java

@@ -5,8 +5,8 @@ public interface ICalculatePerformanceService {
     //运营绩效计算
     //运营绩效计算
     void CalculateOperatePerformance(int year, String quarter, int mediaType);
     void CalculateOperatePerformance(int year, String quarter, int mediaType);
     //设计绩效计算
     //设计绩效计算
-    void CalculateDesignPerformance();
+    void CalculateDesignPerformance(int year, String quarter, int mediaType);
     //销售绩效计算
     //销售绩效计算
-    void CalculateSalePerformance();
+    void CalculateSalePerformance(int year, String quarter, int mediaType);
 
 
 }
 }

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IDesignDetailService.java

@@ -1,7 +1,12 @@
 package org.jeecg.modules.performance.service;
 package org.jeecg.modules.performance.service;
 
 
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+
 public interface IDesignDetailService {
 public interface IDesignDetailService {
 
 
     void UserCostCalculateByMaterial(String startDate, String endDate, int mediaType);
     void UserCostCalculateByMaterial(String startDate, String endDate, int mediaType);
 
 
+    PageInfo<JSONObject> getDesignGroupMaterialByUser(JSONObject requestBody,int pageNo,int pageSize);
+
 }
 }

+ 23 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/ISalePerformanceDetailService.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.performance.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.modules.performance.entity.SalePerformanceDetail;
+
+import java.util.List;
+
+/**
+ * 销售绩效详细信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-04-01
+ */
+public interface ISalePerformanceDetailService extends IService<SalePerformanceDetail> {
+
+    void loadSalesPerformance(String startDate, String endDate);
+
+    List<JSONObject> getSaleGroupAdByUser(JSONObject requestBody);
+
+}

+ 49 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/CalculatePerformanceServiceImpl.java

@@ -64,12 +64,57 @@ public class CalculatePerformanceServiceImpl implements ICalculatePerformanceSer
     }
     }
 
 
     @Override
     @Override
-    public void CalculateDesignPerformance() {
-
+    public void CalculateDesignPerformance(int year, String quarter, int mediaType) {
+        String startDate= year+"-"+ PeriodConstant.valueOf(quarter).getStart();
+        String endDate= year+"-"+PeriodConstant.valueOf(quarter).getEnd();
+        List<JSONObject> designCost = calculatePerformanceMapper.queryDesignCostGroupByUser(startDate, endDate, mediaType);
+        List<PerformanceQuarter> performanceQuarters = new ArrayList<>();
+        PerformanceQuarter performanceQuarter;
+        for(JSONObject op:designCost){
+            performanceQuarter = new PerformanceQuarter();
+            performanceQuarter.setUserId(op.getString("userId"));
+            performanceQuarter.setUserName(op.getString("userName"));
+            performanceQuarter.setCompanyId(op.getString("companyId"));
+            performanceQuarter.setCompanyName(op.getString("companyName"));
+            performanceQuarter.setDepartment("设计部");
+            performanceQuarter.setRoleCode(op.getString("roleCode"));
+            performanceQuarter.setRoleName(op.getString("roleName"));
+            performanceQuarter.setYear(year);
+            performanceQuarter.setQuarter(quarter);
+            BigDecimal cost=op.getBigDecimal("cost");
+            performanceQuarter.setCost(cost);
+            performanceQuarter.setPerformance(RateConstant.PERCENT_0);
+            performanceQuarter.setPoint(RateConstant.PERCENT_0);
+            performanceQuarter.setMediaType(mediaType);
+            performanceQuarters.add(performanceQuarter);
+        }
+        performanceQuarterService.saveBatch(performanceQuarters);
     }
     }
 
 
     @Override
     @Override
-    public void CalculateSalePerformance() {
-
+    public void CalculateSalePerformance(int year, String quarter, int mediaType) {
+        int quarterInt= Integer.parseInt(quarter.substring(1));
+        List<JSONObject> saleCost = calculatePerformanceMapper.querySaleCostGroupByUser(year, quarterInt, mediaType);
+        List<PerformanceQuarter> performanceQuarters = new ArrayList<>();
+        PerformanceQuarter performanceQuarter;
+        for(JSONObject op:saleCost){
+            performanceQuarter = new PerformanceQuarter();
+            performanceQuarter.setUserId(op.getString("userId"));
+            performanceQuarter.setUserName(op.getString("userName"));
+            performanceQuarter.setCompanyId(op.getString("companyId"));
+            performanceQuarter.setCompanyName(op.getString("companyName"));
+            performanceQuarter.setDepartment("销售部");
+            performanceQuarter.setRoleCode(op.getString("roleCode"));
+            performanceQuarter.setRoleName(op.getString("roleName"));
+            performanceQuarter.setYear(year);
+            performanceQuarter.setQuarter(quarter);
+            BigDecimal cost=op.getBigDecimal("cost");
+            performanceQuarter.setCost(cost);
+            performanceQuarter.setPerformance(RateConstant.PERCENT_0);
+            performanceQuarter.setPoint(RateConstant.PERCENT_0);
+            performanceQuarter.setMediaType(mediaType);
+            performanceQuarters.add(performanceQuarter);
+        }
+        performanceQuarterService.saveBatch(performanceQuarters);
     }
     }
 }
 }

+ 82 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/DesignDetailServiceImpl.java

@@ -0,0 +1,82 @@
+package org.jeecg.modules.performance.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.performance.constants.PeriodConstant;
+import org.jeecg.modules.performance.constants.RateConstant;
+import org.jeecg.modules.performance.entity.DesignDetail;
+import org.jeecg.modules.performance.mapper.DesignDetailMapper;
+import org.jeecg.modules.performance.service.IDesignDetailService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *  Created by JQ.bi on 2020.6.22
+ */
+@Service
+@Slf4j
+public class DesignDetailServiceImpl extends ServiceImpl<DesignDetailMapper, DesignDetail> implements IDesignDetailService {
+
+    @Autowired
+    DesignDetailMapper designDetailMapper;
+
+    @Override
+    public void UserCostCalculateByMaterial(String startDate, String endDate, int mediaType) {
+        //查询出来素材对应的cost
+        List<JSONObject> jsonObjectList = designDetailMapper.queryMaterialDetailByDate(startDate, endDate, mediaType);
+        if (jsonObjectList.isEmpty()) {
+            log.error("没有素材数据");
+        }
+        List<DesignDetail> designDetailList = new ArrayList<>();
+        jsonObjectList.forEach(it -> {
+            String leaderId=it.getString("leaderId")==null?"":it.getString("leaderId");
+            //TODO 暂时没有平面
+            if (!(null == it.getString("clipId") || it.getString("clipId").isEmpty())) {
+                designDetailList.add(this.getDesignDetail(it,"clipId",leaderId,RateConstant.PERCENT_30,startDate,endDate,mediaType));
+            }
+            if (!(null == it.getString("plan") || it.getString("plan").isEmpty())) {
+                designDetailList.add(this.getDesignDetail(it,"plan",leaderId,RateConstant.PERCENT_40,startDate,endDate,mediaType));
+            }
+            if (!(null == it.getString("shotId") || it.getString("shotId").isEmpty())) {
+                designDetailList.add(this.getDesignDetail(it,"clipId",leaderId,RateConstant.PERCENT_10,startDate,endDate,mediaType));
+            }
+            if (!(null == it.getString("leaderId") || it.getString("leaderId").isEmpty())) {
+                designDetailList.add(this.getDesignDetail(it,"leaderId",leaderId,RateConstant.PERCENT_20,startDate,endDate,mediaType));
+            }
+        });
+        this.saveBatch(designDetailList);
+    }
+
+    @Override
+    public PageInfo<JSONObject> getDesignGroupMaterialByUser(JSONObject requestBody,int pageNo,int pageSize) {
+        String userId=requestBody.getString("userId");
+        int year= requestBody.getInteger("year");
+        String quarter=requestBody.getString("quarter");
+        int mediaType=requestBody.getInteger("mediaType");
+        String startDate= year+"-"+ PeriodConstant.valueOf(quarter).getStart();
+        String endDate= year+"-"+PeriodConstant.valueOf(quarter).getEnd();
+        PageHelper.startPage(pageNo,pageSize);
+        return new PageInfo(designDetailMapper.queryDesignDetailBy(startDate,endDate,userId,mediaType));
+    }
+
+    private DesignDetail getDesignDetail(JSONObject jsonObject,String job, String leaderId,BigDecimal percent,String startDate, String endDate, int mediaType){
+        DesignDetail designDetail = new DesignDetail();
+        designDetail.setUserId(jsonObject.getString(job));
+        designDetail.setMediaType(mediaType);
+        designDetail.setMaterialCode(jsonObject.getString("code"));
+        designDetail.setMaterialCost(jsonObject.getBigDecimal("cost"));
+        designDetail.setPersonCost(jsonObject.getBigDecimal("cost").multiply(percent));
+        designDetail.setPercent(percent);
+        designDetail.setStartDate(startDate);
+        designDetail.setEndDate(endDate);
+        designDetail.setLeaderId(leaderId);
+        return designDetail;
+    }
+}

+ 230 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/SalePerformanceDetailServiceImpl.java

@@ -0,0 +1,230 @@
+package org.jeecg.modules.performance.service.impl;
+
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.performanceappraisal.service.IPerformanceService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.entity.Advertiser;
+import org.jeecg.modules.performance.constants.PeriodConstant;
+import org.jeecg.modules.performance.entity.SalePerformanceDetail;
+import org.jeecg.modules.performance.mapper.SalePerformanceDetailMapper;
+import org.jeecg.modules.ctop.service.IAdvertiserService;
+import org.jeecg.modules.performance.service.ISalePerformanceDetailService;
+import org.jeecg.modules.performance.constants.RateConstant;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.entity.SysUserRole;
+import org.jeecg.modules.system.service.ISysUserRoleService;
+import org.jeecg.modules.system.service.ISysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 销售绩效详细信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-04-01
+ */
+@Service
+@Slf4j
+public class SalePerformanceDetailServiceImpl extends ServiceImpl<SalePerformanceDetailMapper, SalePerformanceDetail> implements ISalePerformanceDetailService {
+
+    @Autowired
+    private ISysUserService sysUserService;
+    @Autowired
+    private IPerformanceService performanceService;
+    @Autowired
+    private ISysUserRoleService userRoleService;
+    @Autowired
+    private IAdvertiserService advertiserService;
+    @Autowired
+    private SalePerformanceDetailMapper salePerformanceDetailMapper;
+
+    @Override
+    public void loadSalesPerformance(String startDate, String endDate) {
+        //1:获取销售列表
+        List<SysUser> sales = sysUserService.getUserListByRoleId(CtopAdConstant.SYSTEM_SALE_CODE);
+        if (null != sales && sales.size() > 0) {
+            sales.forEach(this::countPerformance
+            );
+        }
+        //2:获取销售AM列表
+        List<SysUser> saleAms = sysUserService.getUserListByRoleId(CtopAdConstant.SYSTEM_SALE_AM_CODE);
+        if (null != saleAms && saleAms.size() > 0) {
+            saleAms.forEach(this::countPerformance
+            );
+        }
+    }
+
+
+    private void countPerformance(SysUser user) {
+//        Date getDate = DateUtils.addDay(new Date(), -1)
+        log.info("销售人员名称:{}", user.getRealname());
+        Date getDate = DateUtils.addDay(new Date(), -18);
+        String startDateStr = DateUtils.getQuarterStartDate(getDate);
+        String endDateStr = DateUtils.getQuarterEndDate(getDate);
+        //获取用户角色信息
+        SysUserRole userRole = userRoleService.getUserRoleByUserId(user.getId());
+        //1:获取快手季度总消耗 TODO 后续需要改成动态获取
+        BigDecimal kuaishouFinishMediaTask = RateConstant.PERCENT_0;
+        //2:获取快手个人季度总消耗
+        BigDecimal kuaishouFinishPersonnalTask = performanceService.getKuaishouSalesSeasonTotalCostByParams(startDateStr, endDateStr, user.getId(), null, null);
+        //1:获取头条季度总消耗 TODO 后续需要改成动态获取
+        BigDecimal bytedanceFinishMediaTask = CtopAdConstant.BYTEDANCE_MEDIA_TASK_COST;
+        //2:获取头条个人季度总消耗
+        BigDecimal bytedanceFinishPersonnalTask = performanceService.getBytedanceSalesSeasonTotalCostByParams(startDateStr, endDateStr, user.getId(), null, null);
+        //获取销售所属的广告主信息
+        List<Advertiser> advertiserList = advertiserService.getBySaleId(user.getId());
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date startSeasonDate = null;
+        Date endSeasonDate = null;
+        try {
+            startSeasonDate = dateFormat.parse(startDateStr);
+            endSeasonDate = dateFormat.parse(endDateStr);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        if (null != advertiserList && advertiserList.size() > 0) {
+            for (Advertiser advertiser : advertiserList) {
+                //1:根据广告主查询用户绑定信息
+                List<UserAllocation> allocations = advertiserService.getAllocationsByAdvertiserId(advertiser.getId());
+                if (null != allocations && allocations.size() > 0) {
+                    Date finalStartSeasonDate = startSeasonDate;
+                    Date finalEndSeasonDate = endSeasonDate;
+                    allocations.forEach(allocation -> {
+                        Date endOldDate = DateUtils.addDay(allocation.getCreateTime(), 90);
+                        if (finalStartSeasonDate.after(endOldDate)) {
+                            //季度开始时间大于新户结束时间(全部按照老户逻辑计算)
+                            saveSalePerformanceDetail(allocation, advertiser, user, userRole, DateUtils.getYear(getDate), DateUtils.getQuarter(getDate),
+                                    startDateStr, endDateStr, bytedanceFinishMediaTask, bytedanceFinishPersonnalTask, kuaishouFinishMediaTask,
+                                    kuaishouFinishPersonnalTask, 0);
+                        } else if (endOldDate.after(finalEndSeasonDate)) {
+                            saveSalePerformanceDetail(allocation, advertiser, user, userRole, DateUtils.getYear(getDate), DateUtils.getQuarter(getDate),
+                                    startDateStr, endDateStr, bytedanceFinishMediaTask, bytedanceFinishPersonnalTask, kuaishouFinishMediaTask,
+                                    kuaishouFinishPersonnalTask, 1);
+                        } else {
+                            //新户结束时间处于本季度中间
+                            String endduring1Date = DateUtils.formatDate(endOldDate);
+                            saveSalePerformanceDetail(allocation, advertiser, user, userRole, DateUtils.getYear(getDate), DateUtils.getQuarter(getDate),
+                                    startDateStr, endduring1Date, bytedanceFinishMediaTask, bytedanceFinishPersonnalTask, kuaishouFinishMediaTask,
+                                    kuaishouFinishPersonnalTask, 1);
+                            saveSalePerformanceDetail(allocation, advertiser, user, userRole, DateUtils.getYear(getDate), DateUtils.getQuarter(getDate),
+                                    startDateStr, endduring1Date, bytedanceFinishMediaTask, bytedanceFinishPersonnalTask, kuaishouFinishMediaTask,
+                                    kuaishouFinishPersonnalTask, 0);
+                        }
+                    });
+                }
+            }
+        }
+    }
+
+    private void saveSalePerformanceDetail(UserAllocation allocation, Advertiser advertiser, SysUser user, SysUserRole userRole, int year, int quarter, String startDate, String endDate, BigDecimal bytedanceFinishMediaTask, BigDecimal bytedanceFinishPersonnalTask, BigDecimal kuaishouFinishMediaTask, BigDecimal kuaishouFinishPersonnalTask, Integer brandNew) {
+        SalePerformanceDetail detail = new SalePerformanceDetail();
+        detail.setAccountId(allocation.getAccountId());
+        detail.setAdvertiserId(advertiser.getId());
+        detail.setSaleId(user.getId());
+        detail.setRoleId(userRole.getRoleId());
+        detail.setYear(year);
+        detail.setQuarter(quarter);
+        detail.setStartDate(startDate);
+        detail.setEndDate(endDate);
+        detail.setExtensionSelf(advertiser.getAdvertiserType());
+        detail.setBrandNew(brandNew);
+        if (null != user.getOrgCode()) {
+            if (user.getOrgCode().startsWith(CtopAdConstant.HB_BYTEDANCE_SALE_ORG_CODE)) {
+                detail.setMediaType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+                BigDecimal totalCost = performanceService.getSalesSeasonTotalCostByParams(startDate, endDate, null, null, allocation.getAccountId(), CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+                if (null == totalCost) {
+                    totalCost = BigDecimal.ZERO;
+                }
+                detail.setTotalCost(totalCost);
+                detail.setMediaTask(CtopAdConstant.BYTEDANCE_MEDIA_TASK_COST);
+                detail.setDoMediaTask(bytedanceFinishMediaTask);
+                detail.setPersonnalTask(CtopAdConstant.BYTEDANCE_PERSONAL_TASK_COST);
+                detail.setDoPersonalTask(bytedanceFinishPersonnalTask);
+                detail.setPercent(getPercentagePercent(detail));
+                detail.setPercentage(detail.getTotalCost().multiply(detail.getPercent()).setScale(2, RoundingMode.HALF_UP));
+                this.save(detail);
+            } else if (user.getOrgCode().startsWith(CtopAdConstant.HB_KUAISHOU_SALE_ORG_CODE)) {
+                detail.setMediaType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                BigDecimal totalCost = performanceService.getSalesSeasonTotalCostByParams(startDate, endDate, null, null, allocation.getAccountId(), CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == totalCost) {
+                    totalCost = BigDecimal.ZERO;
+                }
+                detail.setTotalCost(totalCost);
+                detail.setMediaTask(CtopAdConstant.KUAISHOU_MEDIA_TASK_COST);
+                detail.setDoMediaTask(kuaishouFinishMediaTask);
+                detail.setPersonnalTask(CtopAdConstant.KUAISHOU_PERSONAL_TASK_COST);
+                detail.setDoPersonalTask(kuaishouFinishPersonnalTask);
+                //提成比例
+                detail.setPercent(getPercentagePercent(detail));
+                detail.setPercentage(detail.getTotalCost().multiply(detail.getPercent()).setScale(2, RoundingMode.HALF_UP));
+                this.save(detail);
+            }
+        }
+    }
+
+    private BigDecimal getPercentagePercent(SalePerformanceDetail detail) {
+        BigDecimal percent = detail.getDoMediaTask().divide(detail.getMediaTask(), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
+        //AM非自拓客户
+        if (detail.getRoleId().equals(CtopAdConstant.SYSTEM_SALE_AM_CODE) && detail.getExtensionSelf() != 1) {
+            return new BigDecimal("0.0005");
+        }
+        if (detail.getMediaType().equals(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE)) {
+            //头条
+            if (detail.getBrandNew() == 0) {
+                return new BigDecimal("0.001");
+            }
+            if (percent.compareTo(new BigDecimal("100")) >= 0) {
+                return new BigDecimal("0.003");
+            } else if (percent.compareTo(new BigDecimal("80")) >= 0) {
+                return new BigDecimal("0.0025");
+            } else if (percent.compareTo(new BigDecimal("60")) >= 0) {
+                return new BigDecimal("0.002");
+            } else {
+                return BigDecimal.ZERO;
+            }
+        } else {
+            //快手
+            if (detail.getBrandNew() == 1) {
+                if (percent.compareTo(new BigDecimal("100")) >= 0) {
+                    return new BigDecimal("0.005");
+                } else if (percent.compareTo(new BigDecimal("80")) >= 0) {
+                    return new BigDecimal("0.004");
+                } else if (percent.compareTo(new BigDecimal("60")) >= 0) {
+                    return new BigDecimal("0.003");
+                } else {
+                    return BigDecimal.ZERO;
+                }
+            }
+            //自拓
+            if (detail.getExtensionSelf() == 1) {
+                return new BigDecimal("0.0015");
+            } else {
+                return new BigDecimal("0.001");
+            }
+        }
+    }
+
+    @Override
+    public List<JSONObject> getSaleGroupAdByUser(JSONObject requestBody) {
+        String userId=requestBody.getString("userId");
+        int year= requestBody.getInteger("year");
+        int quarter= Integer.parseInt(requestBody.getString("quarter").substring(1));
+        int mediaType=requestBody.getInteger("mediaType");
+        return salePerformanceDetailMapper.querySaleGroupAdByUser(year,quarter,userId,mediaType);
+    }
+
+}

+ 22 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/testCtrl.java

@@ -1,7 +1,9 @@
 package org.jeecg.modules.performance;
 package org.jeecg.modules.performance;
 
 
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.performance.service.ISalePerformanceDetailService;
 import org.jeecg.modules.performance.service.ICalculatePerformanceService;
 import org.jeecg.modules.performance.service.ICalculatePerformanceService;
+import org.jeecg.modules.performance.service.IDesignDetailService;
 import org.jeecg.modules.performance.service.IOperateDetailService;
 import org.jeecg.modules.performance.service.IOperateDetailService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -16,19 +18,34 @@ public class testCtrl {
     IOperateDetailService operateDetailService;
     IOperateDetailService operateDetailService;
 
 
     @Autowired
     @Autowired
+    IDesignDetailService designDetailService;
+
+    @Autowired
+    ISalePerformanceDetailService  salePerformanceDetailService;
+
+    @Autowired
     ICalculatePerformanceService  calculatePerformanceService;
     ICalculatePerformanceService  calculatePerformanceService;
 
 
     @GetMapping("/job/test/operator")
     @GetMapping("/job/test/operator")
     public String testOperator(){
     public String testOperator(){
-/*
-        Date nowDate= new Date();
 
 
+        Date nowDate= new Date();
         String startStatDate = DateUtils.getQuarterStartDate(nowDate);
         String startStatDate = DateUtils.getQuarterStartDate(nowDate);
         String endStatDate = DateUtils.getQuarterEndDate(nowDate);
         String endStatDate = DateUtils.getQuarterEndDate(nowDate);
 
 
-        operateDetailService.KsCostCalculateByAccount(startStatDate,endStatDate);
-        operateDetailService.BtCostCalculateByAccount(startStatDate,endStatDate);*/
-        calculatePerformanceService.CalculateOperatePerformance(2020,"Q2",2);
+        //计算运营消耗
+        /*operateDetailService.KsCostCalculateByAccount(startStatDate,endStatDate);
+        operateDetailService.(startStatDate,endStatDate);*/
+        //计算运营绩效
+        //calculatePerformanceService.CalculateOperatePerformance(2020,"Q2",2);
+        //计算设计消耗
+        //designDetailService.UserCostCalculateByMaterial(startStatDate,endStatDate,1);
+        //计算设计绩效
+        calculatePerformanceService.CalculateDesignPerformance(2020,"Q2",2);
+        //计算销售消耗
+        //salePerformanceDetailService.loadSalesPerformance(startStatDate,endStatDate);
+        //计算销售绩效
+        //calculatePerformanceService.CalculateSalePerformance(2020,"Q2",2);
         return "success";
         return "success";
     }
     }
 
 

+ 2 - 2
jeecg-boot-module-system/src/main/resources/application-prod.yml

@@ -28,8 +28,8 @@ spring:
             enable: true
             enable: true
             required: true
             required: true
   ## quartz定时任务,采用数据库方式
   ## quartz定时任务,采用数据库方式
-  quartz:
-    job-store-type: jdbc
+  #quartz:
+    #job-store-type: jdbc
   #json 时间戳统一转换
   #json 时间戳统一转换
   jackson:
   jackson:
     date-format:   yyyy-MM-dd HH:mm:ss
     date-format:   yyyy-MM-dd HH:mm:ss

+ 168 - 0
jeecg-boot-module-system/src/main/resources/application-prod2.yml

@@ -0,0 +1,168 @@
+server:
+  port: 8804
+  ip: 39.97.120.42
+  servlet:
+    context-path: /jeecg-boot
+    compression:
+      enabled: true
+      mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
+management:
+  endpoints:
+    web:
+      exposure:
+        include: metrics,httptrace
+spring:
+  servlet:
+    multipart:
+      max-file-size: -1
+      max-request-size: -1
+  mail:
+    host: smtp.163.com
+    username: jeecgos@163.com
+    password: ??
+    properties:
+      mail:
+        smtp:
+          auth: true
+          starttls:
+            enable: true
+            required: true
+  ## quartz定时任务,采用数据库方式
+  quartz:
+    job-store-type: jdbc
+  #json 时间戳统一转换
+  jackson:
+    date-format:   yyyy-MM-dd HH:mm:ss
+    time-zone:   GMT+8
+  aop:
+    proxy-target-class: true
+  #配置freemarker
+  freemarker:
+    # 设置模板后缀名
+    suffix: .ftl
+    # 设置文档类型
+    content-type: text/html
+    # 设置页面编码格式
+    charset: UTF-8
+    # 设置页面缓存
+    cache: false
+    prefer-file-system-access: false
+    # 设置ftl文件路径
+    template-loader-path:
+      - classpath:/templates
+  # 设置静态文件路径,js,css等
+  mvc:
+    static-path-pattern: /**
+  resource:
+    static-locations: classpath:/static/,classpath:/public/
+  autoconfigure:
+    exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
+  datasource:
+    url: jdbc:mysql://172.30.0.4:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    username: hcst
+    password: test@20190531
+    driver-class-name: com.mysql.jdbc.Driver
+    druid:
+      stat-view-servlet:
+        loginUsername: admin
+        loginPassword: hcst2016
+        enabled: true
+      web-stat-filter:
+        enabled: true
+    #      remove-abandoned: false
+    dynamic:
+      druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
+        # 连接池的配置信息
+        # 初始化大小,最小,最大
+        connection-init-sql: set names utf8mb4
+        initial-size: 5
+        min-idle: 5
+        maxActive: 20
+        # 配置获取连接等待超时的时间
+        maxWait: 60000
+        # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+        timeBetweenEvictionRunsMillis: 60000
+        # 配置一个连接在池中最小生存的时间,单位是毫秒
+        minEvictableIdleTimeMillis: 300000
+        validationQuery: SELECT 1 FROM DUAL
+        testWhileIdle: true
+        testOnBorrow: false
+        testOnReturn: false
+        # 打开PSCache,并且指定每个连接上PSCache的大小
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 20
+        # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+        filters: stat,slf4j
+        # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
+        connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
+      datasource:
+        master:
+          url: jdbc:mysql://172.30.0.4:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          username: hcst
+          password: test@20190531
+          driver-class-name: com.mysql.jdbc.Driver
+          # 多数据源配置
+          #multi-datasource1:
+          #url: jdbc:mysql://localhost:3306/jeecg-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
+          #username: root
+          #password: root
+          #driver-class-name: com.mysql.jdbc.Driver
+  #redis 配置
+  redis:
+    database: 0
+    host: 172.30.0.17
+    lettuce:
+      pool:
+        max-active: 8   #最大连接数据库连接数,设 0 为没有限制
+        max-idle: 8     #最大等待连接中的数量,设 0 为没有限制
+        max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
+        min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
+      shutdown-timeout: 100ms
+    password: foobared
+    port: 6379
+#mybatis plus 设置
+mybatis-plus:
+  mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml,classpath*:cn/com/ctop/**/xml/*Mapper.xml
+  global-config:
+    # 关闭MP3.0自带的banner
+    banner: false
+    db-config:
+      #主键类型  0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
+      id-type: 4
+      # 默认数据库表下划线命名
+      table-underline: true
+#  configuration:
+#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+#jeecg专用配置
+jeecg:
+  ffmpeg:
+    bin: ffmpeg
+  path:
+    #文件上传根目录 设置
+    upload: /data/upload
+    #webapp文件路径
+    webapp: /data/webapp
+    video-upload: /data/upload/video/
+    image-upload: /data/upload/image/
+    chrome-driver: /usr/bin/chromedriver
+    csv-upload: /data/upload/csv/
+    bak-database-file: /data/data/bak/
+    report-history: /data/upload/report/history/
+    report-daily: /data/upload/report/daily/
+kuaishou:
+  group-control:
+    path: http://39.106.184.70
+    port: 4723
+logging:
+  level:
+    root: info
+  config: classpath:logback-prod.xml
+chrome:
+  script:
+    clean: sh /data/webapp/cleanProcess.sh
+
+oss:
+  replace:
+    replace-value: oss-cn-beijing
+    replace-old-value: oss-cn-beijing
+    download: /data/file/video/

+ 2 - 2
jeecg-boot-module-system/src/main/resources/application-test.yml

@@ -1,7 +1,7 @@
 server:
 server:
   port: 8088
   port: 8088
   servlet:
   servlet:
-    context-path: /
+    context-path: /jeecg-boot
     compression:
     compression:
       enabled: true
       enabled: true
       mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
       mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
@@ -105,7 +105,7 @@ spring:
   #redis 配置
   #redis 配置
   redis:
   redis:
     database: 0
     database: 0
-    host: 172.30.0.17
+    host: 127.0.0.1
     lettuce:
     lettuce:
       pool:
       pool:
         max-active: 8   #最大连接数据库连接数,设 0 为没有限制
         max-active: 8   #最大连接数据库连接数,设 0 为没有限制

+ 13 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/RandomUtil.java

@@ -18,6 +18,19 @@ public class RandomUtil {
     }
     }
 
 
 
 
+    public static String verifyCodeV2() {
+
+        char[] c = charArray();//获取包含26个字母大小写和数字的字符数组
+
+        Random rd = new Random();
+        String code = "";
+        for (int k = 0; k < 4; k++) {
+            int index = rd.nextInt(c.length);//随机获取数组长度作为索引
+            code += c[index];//循环添加到字符串后面
+        }
+        return code;
+    }
+
     private static char[] charArray() {
     private static char[] charArray() {
         int i = 1234567890;
         int i = 1234567890;
         String s = "qwertyuiopasdfghjklzxcvbnm";
         String s = "qwertyuiopasdfghjklzxcvbnm";

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

@@ -1798,6 +1798,84 @@ public class BatchController {
         return result;
         return result;
     }
     }
 
 
+
+    /**
+     * 复制组
+     *
+     * @param requestJson
+     * @return
+     */
+/*    @PostMapping(value = "/copyUnitUpdate")
+    public Result<JSONObject> copyUnitUpdate(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            JSONObject returnJson = new JSONObject();
+
+            Long unitId = requestJson.getLong("unitId");
+            kuaiShouGroupService.getGroupByUnitId(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitId);
+            Long copyToCampaignId = requestJson.getLong("copyToCampaignId");
+            JSONArray failArr = new JSONArray();
+            //  Integer createCount = requestJson.getInteger("createCount");
+
+
+            Integer createType = requestJson.getInteger("createType");
+            if (createType == 1) { //系统生成
+                // 需要获取创建条数
+                Integer createCount = requestJson.getInteger("createCount");
+                String unitName = requestJson.getString("unitName");
+                if (unitName.contains("#")) {
+                    int lastIndexOf = unitName.lastIndexOf("#");
+                    unitName = unitName.substring(0, lastIndexOf);
+                }
+                requestJson.remove("unitName");
+                for (int i = 0; i < createCount; i++) {
+                    String randomName = unitName + RandomUtil.verifyCodeV2() + i;
+                    requestJson.put("unitName", randomName);
+                    JSONObject createJson = batchService.createUnit(requestJson, oauthToken);
+                    if (createJson.getInteger("code") != 0) {
+                        JSONObject errJson = new JSONObject();
+                        errJson.put("message", createJson.getString("message"));
+                        returnJson.put("unitName", randomName);
+                        failArr.add(errJson);
+                    }
+                }
+
+            } else if (createType == 2) { // 自定义
+                JSONArray unitNames = requestJson.getJSONArray("unitNames");
+                for (int i = 0; i < unitNames.size(); i++) {
+                    String unitName = unitNames.getString(i);
+                    requestJson.put("unitName", unitName);
+                    JSONObject createJson = batchService.createUnit(requestJson, oauthToken);
+                    if (createJson.getInteger("code") != 0) {
+                        JSONObject errJson = new JSONObject();
+                        errJson.put("message", createJson.getString("message"));
+                        returnJson.put("unitName", unitName);
+                        failArr.add(errJson);
+                    }
+
+                }
+            }
+
+
+            returnJson.put("failCount", failArr.size());
+            returnJson.put("failInfo", failArr);
+            result.setResult(returnJson);
+            result.setSuccess(true);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }*/
+
+
     /**
     /**
      * 获取人群包
      * 获取人群包
      *
      *

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

@@ -126,7 +126,7 @@ public interface IKuaishouInterfaceService {
      * @param requestJson
      * @param requestJson
      * @return
      * @return
      */
      */
-    Map<String, Object> adUnitCreate(String accessToken, Long advertiserId, JSONObject requestJson);
+    Map<String, Object> adUnitCreate(String accessToken, Long advertiserId, JSONObject requestJson, Integer count);
 
 
 
 
     /**
     /**
@@ -191,7 +191,7 @@ public interface IKuaishouInterfaceService {
      * @param advertiserId
      * @param advertiserId
      * @param requestJson
      * @param requestJson
      */
      */
-    Map<String, Object> creativeCreate(String accessToken, Long advertiserId, JSONObject requestJson);
+    Map<String, Object> creativeCreate(String accessToken, Long advertiserId, JSONObject requestJson, Integer count);
 
 
     /**
     /**
      * 根据创意id 获取创意信息
      * 根据创意id 获取创意信息

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

@@ -404,7 +404,7 @@ public class BatchServiceImpl implements IBatchService {
                     unitJson.put("unit_name", unitName);
                     unitJson.put("unit_name", unitName);
                 }
                 }
 
 
-                Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitJson);
+                Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitJson,1);
                 if (!Check.isNullMap(returnUnitMap)) {
                 if (!Check.isNullMap(returnUnitMap)) {
                     Integer code = (Integer) returnUnitMap.get("code");
                     Integer code = (Integer) returnUnitMap.get("code");
                     if (code == 0) {
                     if (code == 0) {
@@ -683,7 +683,7 @@ public class BatchServiceImpl implements IBatchService {
                     unitJson.put("unit_name", unitName);
                     unitJson.put("unit_name", unitName);
                 }
                 }
 
 
-                Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), group.getAccountId(), unitJson);
+                Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), group.getAccountId(), unitJson,1);
                 if (!Check.isNullMap(returnUnitMap)) {
                 if (!Check.isNullMap(returnUnitMap)) {
                     Integer code = (Integer) returnUnitMap.get("code");
                     Integer code = (Integer) returnUnitMap.get("code");
                     if (code == 0) {
                     if (code == 0) {
@@ -786,7 +786,7 @@ public class BatchServiceImpl implements IBatchService {
                 }*/
                 }*/
 
 
 
 
-                Map<String, Object> returnCreativeMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson);
+                Map<String, Object> returnCreativeMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson,1);
                 if (!Check.isNullMap(returnCreativeMap)) {
                 if (!Check.isNullMap(returnCreativeMap)) {
                     Integer code = (Integer) returnCreativeMap.get("code");
                     Integer code = (Integer) returnCreativeMap.get("code");
                     if (code == 0) {
                     if (code == 0) {
@@ -804,6 +804,7 @@ public class BatchServiceImpl implements IBatchService {
         }
         }
     }
     }
 
 
+
     /**
     /**
      * 获取广告组信息
      * 获取广告组信息
      *
      *
@@ -907,7 +908,7 @@ public class BatchServiceImpl implements IBatchService {
                                     }
                                     }
                                 }
                                 }
                                 creativeJson.put("image_token", imageToken);
                                 creativeJson.put("image_token", imageToken);
-                                Map<String, Object> returnUnitMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson);
+                                Map<String, Object> returnUnitMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson,1);
                                 if (!Check.isNullMap(returnUnitMap)) {
                                 if (!Check.isNullMap(returnUnitMap)) {
                                     Integer code = (Integer) returnUnitMap.get("code");
                                     Integer code = (Integer) returnUnitMap.get("code");
                                     if (code == 0) {
                                     if (code == 0) {

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

@@ -1,5 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaignCreate;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaignCreate;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaignTemplate;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaignTemplate;
@@ -17,8 +19,6 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
@@ -244,7 +244,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                     name = unitName;
                     name = unitName;
                 }
                 }
                 groupJson.put("unit_name", name);
                 groupJson.put("unit_name", name);
-                Map<String, Object> groupMap = kuaishouInterfaceService.adUnitCreate(accessToken, accountId, groupJson);
+                Map<String, Object> groupMap = kuaishouInterfaceService.adUnitCreate(accessToken, accountId, groupJson, 1);
                 if ((Integer) groupMap.get("code") != 0) {
                 if ((Integer) groupMap.get("code") != 0) {
                     log.error("创建广告组失败,accountId:{},unitName:{}", accountId, unitName);
                     log.error("创建广告组失败,accountId:{},unitName:{}", accountId, unitName);
                     return groupMap;
                     return groupMap;
@@ -391,7 +391,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                     } else {
                     } else {
                         createJson.put("creative_name", creativeName + "_" + i);
                         createJson.put("creative_name", creativeName + "_" + i);
                     }
                     }
-                    Map<String, Object> creativeMap = kuaishouInterfaceService.creativeCreate(accessToken, accountId, createJson);
+                    Map<String, Object> creativeMap = kuaishouInterfaceService.creativeCreate(accessToken, accountId, createJson, 1);
                     if ((Integer) creativeMap.get("code") != 0) {
                     if ((Integer) creativeMap.get("code") != 0) {
                         return creativeMap;
                         return creativeMap;
                     }
                     }
@@ -451,7 +451,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                         } else {
                         } else {
                             createJson.put("creative_name", creativeName + "_" + i);
                             createJson.put("creative_name", creativeName + "_" + i);
                         }
                         }
-                        Map<String, Object> creativeMap = kuaishouInterfaceService.creativeCreate(accessToken, accountId, createJson);
+                        Map<String, Object> creativeMap = kuaishouInterfaceService.creativeCreate(accessToken, accountId, createJson, 1);
                         if ((Integer) creativeMap.get("code") != 0) {
                         if ((Integer) creativeMap.get("code") != 0) {
                             log.error("后贴片视频素材批量创建创意失败,accountId:{},creativeName:{}", accountId, creativeName + "_" + i);
                             log.error("后贴片视频素材批量创建创意失败,accountId:{},creativeName:{}", accountId, creativeName + "_" + i);
                             return creativeMap;
                             return creativeMap;
@@ -492,7 +492,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                         JSONArray imageTokens = new JSONArray();
                         JSONArray imageTokens = new JSONArray();
                         imageTokens.add(imageMap.get("imageToken"));
                         imageTokens.add(imageMap.get("imageToken"));
                         createJson.put("image_tokens", imageTokens);
                         createJson.put("image_tokens", imageTokens);
-                        Map<String, Object> creativeMap = kuaishouInterfaceService.creativeCreate(accessToken, accountId, createJson);
+                        Map<String, Object> creativeMap = kuaishouInterfaceService.creativeCreate(accessToken, accountId, createJson, 1);
                         if ((Integer) creativeMap.get("code") != 0) {
                         if ((Integer) creativeMap.get("code") != 0) {
                             log.error("后贴片素材单张图片批量创建创意失败,accountId:{}", accountId);
                             log.error("后贴片素材单张图片批量创建创意失败,accountId:{}", accountId);
                             return creativeMap;
                             return creativeMap;

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

@@ -223,7 +223,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
                 kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
 
 
                 Date videoTime = videoTimeService.getVideoTime(kuaiShouVideoGet.getPhotoId(), token.getAccountId());
                 Date videoTime = videoTimeService.getVideoTime(kuaiShouVideoGet.getPhotoId(), token.getAccountId());
-                if(!Check.isNull(videoTime)){
+                if (!Check.isNull(videoTime)) {
                     kuaiShouVideoGet.setUploadDate(videoTime);
                     kuaiShouVideoGet.setUploadDate(videoTime);
                 }
                 }
 
 
@@ -995,7 +995,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
 
 
 
     @Override
     @Override
-    public Map<String, Object> adUnitCreate(String accessToken, Long advertiserId, JSONObject requestJson) {
+    public Map<String, Object> adUnitCreate(String accessToken, Long advertiserId, JSONObject requestJson, Integer count) {
         Map<String, Object> returnMap = new HashMap<>();
         Map<String, Object> returnMap = new HashMap<>();
         try {
         try {
             if (Check.isNull(requestJson)) {
             if (Check.isNull(requestJson)) {
@@ -1039,6 +1039,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     }
                     }
 
 
                 } else {
                 } else {
+
+                    if (code == 500000 && count <= 4) {
+
+                        adUnitCreate(accessToken, advertiserId, requestJson, count + 1);
+                    }
                     log.error("创建广告信息失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson);
                     log.error("创建广告信息失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson);
                     returnMap.put("code", -1);
                     returnMap.put("code", -1);
                     returnMap.put("message", resultJson.getString("message"));
                     returnMap.put("message", resultJson.getString("message"));
@@ -1046,6 +1051,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     returnMap.put("success", false);
                     returnMap.put("success", false);
                 }
                 }
             } else {
             } else {
+                if (count <= 4) {
+                    log.info("创建组失败,重试,入参:{}", requestJson);
+                    adUnitCreate(accessToken, advertiserId, requestJson, count + 1);
+                }
                 log.error("快手创建广告计划返回内容为空,advertiser_id:{},入参:{}", advertiserId, requestJson);
                 log.error("快手创建广告计划返回内容为空,advertiser_id:{},入参:{}", advertiserId, requestJson);
                 returnMap.put("code", -1);
                 returnMap.put("code", -1);
                 returnMap.put("message", "创建广告组异常");
                 returnMap.put("message", "创建广告组异常");
@@ -1713,7 +1722,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      * @param requestJson
      * @param requestJson
      */
      */
     @Override
     @Override
-    public Map<String, Object> creativeCreate(String accessToken, Long advertiserId, JSONObject requestJson) {
+    public Map<String, Object> creativeCreate(String accessToken, Long advertiserId, JSONObject requestJson, Integer count) {
         Map<String, Object> returnMap = new HashMap<>();
         Map<String, Object> returnMap = new HashMap<>();
         try {
         try {
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.AD_CREATIVE_CREATE;
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.AD_CREATIVE_CREATE;
@@ -1750,13 +1759,20 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         returnMap.put("success", true);
                         returnMap.put("success", true);
                     }
                     }
                 } else {
                 } else {
-                    log.error("创建广告创意失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson);
+                    if (code == 500000 && count <= 4) {
+                        creativeCreate(accessToken, advertiserId, requestJson, count + 1);
+                    }
+                    log.error("创建广告创意失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson, count + 1);
                     returnMap.put("code", -1);
                     returnMap.put("code", -1);
                     returnMap.put("message", resultJson.getString("message"));
                     returnMap.put("message", resultJson.getString("message"));
                     returnMap.put("desc", "创意创建失败");
                     returnMap.put("desc", "创意创建失败");
                     returnMap.put("success", false);
                     returnMap.put("success", false);
                 }
                 }
             } else {
             } else {
+                if (count <= 4) {
+                    creativeCreate(accessToken, advertiserId, requestJson, count + 1);
+                }
+
                 log.error("快手创建广告创意返回内容为空,advertiser_id:{},入参:{}", advertiserId, requestJson);
                 log.error("快手创建广告创意返回内容为空,advertiser_id:{},入参:{}", advertiserId, requestJson);
                 returnMap.put("code", -1);
                 returnMap.put("code", -1);
                 returnMap.put("message", "上传图片异常");
                 returnMap.put("message", "上传图片异常");
@@ -2892,7 +2908,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 }
                 }
                 var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
                 var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
                 Date videoTime = videoTimeService.getVideoTime(kuaiShouVideoGet.getPhotoId(), accountId);
                 Date videoTime = videoTimeService.getVideoTime(kuaiShouVideoGet.getPhotoId(), accountId);
-                if(!Check.isNull(videoTime)){
+                if (!Check.isNull(videoTime)) {
                     kuaiShouVideoGet.setUploadDate(videoTime);
                     kuaiShouVideoGet.setUploadDate(videoTime);
                 }
                 }
                 kuaiShouVideoGet.setAccountId(accountId);
                 kuaiShouVideoGet.setAccountId(accountId);