Browse Source

Merge branch 'test' of http://39.106.184.70:3000/ctop/adsp-boot into test

xuzuoyun 5 years ago
parent
commit
cd8a9af198
76 changed files with 1801 additions and 265 deletions
  1. 120 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java
  2. 11 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java
  3. 55 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CreativeTitleController.java
  4. 9 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java
  5. 248 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/SalePerformanceDetailController.java
  6. 49 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  7. 6 12
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  8. 179 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/SalePerformanceDetail.java
  9. 6 9
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/DailyFlowsJob.java
  10. 9 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouAppListJob.java
  11. 3 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCampaignGroupJob.java
  12. 1 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportLoadJob.java
  13. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCampaignReportLoadJob.java
  14. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCreativeReportLoadJob.java
  15. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyGroupReportLoadJob.java
  16. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyLoadFileJob.java
  17. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyReportTaskJob.java
  18. 57 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouGroupJob.java
  19. 1 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyAccountReportLoadJob.java
  20. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyAccountWarningLoadJob.java
  21. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCampaignReportLoadJob.java
  22. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCreativeReportLoadJob.java
  23. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyGroupReportLoadJob.java
  24. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouMaterialsLoadJob.java
  25. 66 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouNowDateCampaignJob.java
  26. 15 15
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCreativeLoadJob.java
  27. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouNowDateGroupJob.java
  28. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouSuZaoLoadJob.java
  29. 6 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/AdvertiserMapper.java
  30. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/SalePerformanceDetailMapper.java
  31. 65 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/AdvertiserMapper.xml
  32. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/SalePerformanceDetailMapper.xml
  33. 6 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IAdvertiserService.java
  34. 11 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ICreativeTitleService.java
  35. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/PerformanceAreaService.java
  36. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ISalePerformanceDetailService.java
  37. 31 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/AdvertiserServiceImpl.java
  38. 7 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java
  39. 4 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CpaBidWarningServiceImpl.java
  40. 83 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CreativeTitleServiceImpl.java
  41. 0 60
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/PerformanceAreaServiceImpl.java
  42. 199 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/PerformanceSaleServiceImpl.java
  43. 19 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/SalePerformanceDetailServiceImpl.java
  44. 29 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vo/SheetInfoVo.java
  45. 110 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/KuaishouXxlEntity.java
  46. 14 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
  47. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java
  48. 12 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml
  49. 5 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserRoleService.java
  50. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserService.java
  51. 14 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserRoleServiceImpl.java
  52. 9 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
  53. 43 12
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  54. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/CtopOauthTokenMapper.java
  55. 10 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml
  56. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java
  57. 4 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  58. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  59. 13 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  60. 27 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/CtopAdConstant.java
  61. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  62. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCreative.java
  63. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroup.java
  64. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml
  65. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml
  66. 3 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/AccountWarningServiceImpl.java
  67. 12 10
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  68. 1 1
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/KuaiShouYiCheReportMapper.xml
  69. 46 47
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/MaterialReportMapper.xml
  70. 2 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/IReportService.java
  71. 3 2
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/ByteDanceHourlyAccountWarningServiceImpl.java
  72. 10 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/ReportServiceImpl.java
  73. 2 2
      performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/mapper/PerformanceMapper.java
  74. 28 16
      performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/mapper/xml/PerformanceMapper.xml
  75. 4 2
      performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/service/IPerformanceService.java
  76. 41 6
      performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/service/impl/PerformanceServiceImpl.java

+ 120 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java

@@ -1,9 +1,17 @@
 package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.bytedance.mapper.MaterialReportMapper;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.common.module.utils.StringUtils;
+import com.alibaba.excel.EasyExcelFactory;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.metadata.Sheet;
 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;
@@ -13,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.ctop.entity.Advertiser;
 import org.jeecg.modules.ctop.entity.Project;
@@ -20,6 +29,8 @@ import org.jeecg.modules.ctop.mapper.ProjectMapper;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IAdvertiserService;
 import org.jeecg.modules.ctop.service.IProjectService;
+import org.jeecg.modules.ctop.vo.SheetInfoVo;
+import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
 import org.jeecg.modules.system.entity.SysCategory;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.entity.UserCompany;
@@ -40,6 +51,7 @@ import org.springframework.web.servlet.ModelAndView;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.*;
@@ -67,6 +79,8 @@ public class AdvertiserController {
     private ProjectMapper projectMapper;
     @Autowired
     private ProjectMemberMapper projectMemberMapper;
+    @Autowired
+    private IUserAllocationService userAllocationService;
 
 
     /**
@@ -159,6 +173,7 @@ public class AdvertiserController {
 
     @Autowired
     private ISysUserService sysUserService;
+
     /**
      * 添加
      *
@@ -225,6 +240,11 @@ public class AdvertiserController {
             Project updateProject = new Project();
             updateProject.setAdvertiserName(advertiser.getName());
             projectService.update(updateProject, projectQueryWrapper);
+            QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+            userAllocationQueryWrapper.eq("advertiser_id", advertiser.getId());
+            UserAllocation updateUserAllocation = new UserAllocation();
+            updateUserAllocation.setAdvertiserName(advertiser.getName());
+            userAllocationService.update(updateUserAllocation, userAllocationQueryWrapper);
             if (ok) {
                 result.success("修改成功!");
             }
@@ -379,4 +399,104 @@ public class AdvertiserController {
         }
         return Result.ok("文件导入失败!");
     }
+
+    /**
+     * 导出报表
+     *
+     * @return
+     */
+    @RequestMapping(value = "/xxlDailyReportList")
+    @ResponseBody
+    public Map<String, Object> xxlReportList(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject data) throws Exception {
+        Map<String, Object> result = new HashMap<>();
+        List<SheetInfoVo> sheets = new ArrayList<>();
+        //查询总的消耗信息
+        Long projectId = data.getLong("projectId");
+        String systemType = data.getString("systemType");
+        if (null == systemType || systemType.trim().equals("")) {
+            systemType = null;
+        }
+        SheetInfoVo totalSheetVo = advertiserService.getXxlStatisticInfo(projectId, systemType, null, "汇总表");
+        sheets.add(totalSheetVo);
+        if(null == systemType){
+            List<SheetInfoVo>vos = advertiserService.getSystemTypeXxlStatisticInfo(projectId);
+            if(null!=vos&&vos.size()>0){
+                for(SheetInfoVo vo:vos){
+                    sheets.add(vo);
+                }
+            }
+        }
+        List<UserAllocation> allocations = userAllocationService.getByProjectId(projectId, systemType);
+        if (null != allocations && allocations.size() > 0) {
+            for (UserAllocation allocation : allocations) {
+                SheetInfoVo vo = advertiserService.getXxlStatisticInfo(projectId, systemType, allocation.getAccountId(), allocation.getAuthName());
+                sheets.add(vo);
+            }
+        }
+        result.put("data", sheets);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
+    /**
+     * 导出报表
+     *
+     * @return
+     */
+    @RequestMapping(value = "/exportXxlDailyReport")
+    @ResponseBody
+    public void exportXxl(HttpServletRequest request, HttpServletResponse response, Long projectId, String systemType) throws Exception {
+        List<SheetInfoVo> sheets = new ArrayList<>();
+        if (null == systemType || systemType.trim().equals("")) {
+            systemType = null;
+        }
+        //查询总的消耗信息
+        SheetInfoVo totalSheetVo = advertiserService.getXxlStatisticInfo(projectId, systemType, null, "汇总表");
+        sheets.add(totalSheetVo);
+        if(null == systemType){
+            List<SheetInfoVo>vos = advertiserService.getSystemTypeXxlStatisticInfo(projectId);
+            if(null!=vos&&vos.size()>0){
+                for(SheetInfoVo vo:vos){
+                    sheets.add(vo);
+                }
+            }
+        }
+        List<UserAllocation> allocations = userAllocationService.getByProjectId(projectId, systemType);
+        if (null != allocations && allocations.size() > 0) {
+            for (UserAllocation allocation : allocations) {
+                SheetInfoVo vo = advertiserService.getXxlStatisticInfo(projectId, systemType, allocation.getAccountId(), allocation.getAuthName());
+                sheets.add(vo);
+            }
+        }
+
+        OutputStream outputStream = response.getOutputStream();
+        String date = DateUtils.formatDate(new Date());
+        this.setResponseHeader(response, "爱上消消消日报" + date + ".xls");
+        ExcelWriter excelWriter = EasyExcelFactory.getWriter(outputStream);
+        for (int i = 0; i < sheets.size(); i++) {
+            Sheet sheet = new Sheet(i + 1, 0, KuaishouXxlEntity.class);
+            sheet.setSheetName(sheets.get(i).getSheetName());
+            excelWriter.write(sheets.get(i).getDetails(), sheet);
+        }
+        excelWriter.finish();
+        outputStream.flush();
+        outputStream.close();
+    }
+
+    //发送响应流方法
+    public void setResponseHeader(HttpServletResponse response, String fileName) {
+        try {
+            try {
+                fileName = new String(fileName.getBytes(), "ISO8859-1");
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            response.setContentType("application/octet-stream;charset=ISO8859-1");
+            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
+            response.addHeader("Pargam", "no-cache");
+            response.addHeader("Cache-Control", "no-cache");
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
 }

+ 11 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.bytedance.service.IReportService;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
@@ -350,6 +351,13 @@ public class CallbackController {
             }
             //账号绑定
             bindAccountAuthService.addBindAccount(token.getAccountId(), KuaishouInterfaceConstant.LOGIN_TYPE_BYTEDANCE, advertiserId);
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    reportService.loadBytedanceHistoryData(token);
+                }
+            };
+            thread.start();
             returnMap.put("code", 0);
             returnMap.put("desc", "success");
         } catch (Exception e) {
@@ -360,4 +368,7 @@ public class CallbackController {
         return returnMap;
     }
 
+    @Autowired
+    private IReportService reportService;
+
 }

+ 55 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CreativeTitleController.java

@@ -0,0 +1,55 @@
+package org.jeecg.modules.ctop.controller;
+
+import com.alibaba.fastjson.JSONArray;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.ctop.service.ICreativeTitleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/ctop/creativeTitle/")
+public class CreativeTitleController {
+    @Autowired
+    private ICreativeTitleService creativeTitleService;
+
+
+    @GetMapping("getTitleLabel")
+    public Result<JSONArray> getTitleLabel() {
+        Result<JSONArray> result = new Result<>();
+        JSONArray labelArr = creativeTitleService.getTitleLabel();
+        result.setSuccess(true);
+        result.setResult(labelArr);
+        return result;
+
+
+    }
+
+
+    @GetMapping("titleSuggestion")
+    public Result<JSONArray> titleSuggestion(String firstCategory, String secondCategory, String keywords) {
+        Result<JSONArray> result = new Result<>();
+        JSONArray labelArr = creativeTitleService.titleSuggestion(firstCategory, secondCategory, keywords);
+        result.setSuccess(true);
+        result.setResult(labelArr);
+        return result;
+
+
+    }
+
+
+
+    @GetMapping("titleSearch")
+    public Result<JSONArray> titleSearch(String firstCategory, String secondCategory, String keywords) {
+        Result<JSONArray> result = new Result<>();
+        JSONArray labelArr = creativeTitleService.titleSearch(firstCategory, secondCategory, keywords);
+        result.setSuccess(true);
+        result.setResult(labelArr);
+        return result;
+
+
+    }
+
+
+}

+ 9 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.ctop.controller;
 
 
 import cn.com.ctop.bytedance.mapper.MaterialReportMapper;
+import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSON;
@@ -28,7 +29,6 @@ import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.ctop.service.ITransferAccountService;
 import org.jeecg.modules.system.entity.SysUser;
-import org.jeecg.modules.system.mapper.UserCompanyMapper;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -73,9 +73,9 @@ public class ProjectController {
     @Autowired
     private MaterialReportMapper materialReportMapper;
     @Autowired
-    private UserCompanyMapper userCompanyMapper;
-    @Autowired
     private ITransferAccountService transferAccountService;
+    @Autowired
+    private IUserAllocationService userAllocationService;
 
     /**
      * 根据 项目 媒体类型 查看项目
@@ -303,13 +303,17 @@ public class ProjectController {
         } else {
             boolean ok = projectService.updateById(project);
 
-
             QueryWrapper<ProjectMember> memberQueryWrapper = new QueryWrapper<>();
             memberQueryWrapper.eq("project_id", project.getId());
             ProjectMember updateMember = new ProjectMember();
             updateMember.setProjectName(project.getProjectName());
             projectMemberService.update(updateMember, memberQueryWrapper);
-            //      projectMemberMapper.update()
+
+            QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+            userAllocationQueryWrapper.eq("project_id", project.getId());
+            UserAllocation updateUserAllocation = new UserAllocation();
+            updateUserAllocation.setProjectName(project.getProjectName());
+            userAllocationService.update(updateUserAllocation, userAllocationQueryWrapper);
 
             if (ok) {
                 result.success("修改成功!");
@@ -319,8 +323,6 @@ public class ProjectController {
         return result;
     }
 
-    @Autowired
-    private IUserAllocationService userAllocationService;
 
     /**
      * 通过id删除

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

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

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

@@ -163,7 +163,7 @@ public class TestController {
         return "Success";
     }
 
-    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+    static ExecutorService executorService = Executors.newFixedThreadPool(10);
 
     @GetMapping(value = "/getVideoAndImage")
     public String getVideoAndImage() {
@@ -267,6 +267,26 @@ public class TestController {
         thread.start();
     }
 
+    @GetMapping("loadBytedanceHistoryData")
+    public Map<String, Object> loadBytedanceHistoryData() {
+        Map<String, Object> result = new HashMap<>();
+        //1:查询所有头条的token数据
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (null != tokens && tokens.size() > 0) {
+            tokens.forEach(token -> {
+                //拉取往期数据
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        reportService.loadBytedanceHistoryData(token);
+                    }
+                });
+            });
+        }
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
 
     @Autowired
     private IUserAllocationService userAllocationService;
@@ -847,4 +867,32 @@ public class TestController {
     }
 
 
+    @GetMapping(value = "/getAllGroupList")
+    public void getAllGroupList() {
+
+        try {
+
+            QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
+            oauthTokenQueryWrapper.eq("media_id", 2);
+            List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);
+            if (!Check.isNull(ctopOauthTokens)) {
+                for (CtopOauthToken token : ctopOauthTokens) {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            if (!Check.isNull(token)) {
+                                log.info("获取组,账号id:{}", token.getAccountId());
+                                kuaishouInterfaceService.getGroupList(token, null, null);
+                            }
+                        }
+                    });
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+
 }

+ 6 - 12
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java

@@ -70,15 +70,6 @@ public class UserAllocationController {
     private IProjectMemberService projectMemberService;
 
 
-    @PostMapping(value = "/transferAccount")
-    public Result transferAccount(Long accountId, Long projectId) {
-
-
-        return null;
-
-    }
-
-
     @GetMapping(value = "/accountTurnProject")
     public Result getAccountList(Long accountId, Long projectId) {
         Result result = new Result<>();
@@ -179,7 +170,7 @@ public class UserAllocationController {
 
             String roleCode = materialReportMapper.getRoleCodeByUserId(userId);
             if (!"admin".equals(roleCode) && !"kuaishouOperationManager".equals(roleCode)
-                    && !"kuaishouOperationManager".equals(roleCode) && !"designTeamLeader".equals(roleCode)) {
+                    && !"kuaishouOperationManager".equals(roleCode) && !"designTeamLeader".equals(roleCode) && !"touTiaoOperationManager".equals(roleCode)) {
                 queryWrapper.eq("user_id", userId);
             }
             queryWrapper.orderByDesc("create_time");
@@ -246,8 +237,11 @@ public class UserAllocationController {
         Result<IPage<UserAllocation>> result = new Result<IPage<UserAllocation>>();
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         QueryWrapper<UserAllocation> queryWrapper = QueryGenerator.initQueryWrapper(userAllocation, req.getParameterMap());
-        queryWrapper.eq("user_id", user.getId());
-        queryWrapper.orderByDesc("id");
+        String roleCode = materialReportMapper.getRoleCodeByUserId(user.getId());
+        if (!"admin".equals(roleCode)) {
+            queryWrapper.eq("user_id", user.getId());
+            queryWrapper.orderByDesc("id");
+        }
         Page<UserAllocation> page = new Page<UserAllocation>(pageNo, pageSize);
         IPage<UserAllocation> pageList = userAllocationService.page(page, queryWrapper);
         result.setSuccess(true);

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

@@ -0,0 +1,179 @@
+package org.jeecg.modules.ctop.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-04-01
+ */
+@Data
+@TableName("ctop_sale_performance_detail")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_sale_performance_detail对象", description = "销售绩效详细信息")
+public class SalePerformanceDetail {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 销售人员id
+     */
+    @Excel(name = "销售人员id", width = 15)
+    @ApiModelProperty(value = "销售人员id")
+    private String saleId;
+    /**
+     * 角色id
+     */
+    @Excel(name = "角色id", width = 15)
+    @ApiModelProperty(value = "角色id")
+    private String roleId;
+    /**
+     * 媒体类型
+     */
+    @Excel(name = "媒体类型", width = 15)
+    @ApiModelProperty(value = "媒体类型")
+    private String mediaType;
+    /**
+     * 广告主id
+     */
+    @Excel(name = "广告主id", width = 15)
+    @ApiModelProperty(value = "广告主id")
+    private String advertiserId;
+    /**
+     * 年
+     */
+    @Excel(name = "年", width = 15)
+    @ApiModelProperty(value = "年")
+    private Integer year;
+    /**
+     * 季度
+     */
+    @Excel(name = "季度", width = 15)
+    @ApiModelProperty(value = "季度")
+    private Integer quarter;
+    /**
+     * 开始时间
+     */
+    @Excel(name = "开始时间", width = 15)
+    @ApiModelProperty(value = "开始时间")
+    private String startDate;
+    /**
+     * 结束时间
+     */
+    @Excel(name = "结束时间", width = 15)
+    @ApiModelProperty(value = "结束时间")
+    private String endDate;
+    /**
+     * 总消耗
+     */
+    @Excel(name = "总消耗", width = 15)
+    @ApiModelProperty(value = "总消耗")
+    private java.math.BigDecimal totalCost;
+    /**
+     * 媒体任务
+     */
+    @Excel(name = "媒体任务", width = 15)
+    @ApiModelProperty(value = "媒体任务")
+    private java.math.BigDecimal mediaTask;
+    /**
+     * 媒体任务完成情况
+     */
+    @Excel(name = "媒体任务完成情况", width = 15)
+    @ApiModelProperty(value = "媒体任务完成情况")
+    private java.math.BigDecimal doMediaTask;
+    /**
+     * 个人任务
+     */
+    @Excel(name = "个人任务", width = 15)
+    @ApiModelProperty(value = "个人任务")
+    private java.math.BigDecimal personnalTask;
+    /**
+     * 个人任务完成情况
+     */
+    @Excel(name = "个人任务完成情况", width = 15)
+    @ApiModelProperty(value = "个人任务完成情况")
+    private java.math.BigDecimal doPersonalTask;
+    /**
+     * 是否自拓客户
+     */
+    @Excel(name = "是否自拓客户", width = 15)
+    @ApiModelProperty(value = "是否自拓客户")
+    private Integer extensionSelf;
+    /**
+     * 是否新客
+     */
+    @Excel(name = "是否新客", width = 15)
+    @ApiModelProperty(value = "是否新客")
+    private Integer brandNew;
+    /**
+     * 提成百分比
+     */
+    @Excel(name = "提成百分比", width = 15)
+    @ApiModelProperty(value = "提成百分比")
+    private java.math.BigDecimal percent;
+    /**
+     * 提成金额
+     */
+    @Excel(name = "提成金额", width = 15)
+    @ApiModelProperty(value = "提成金额")
+    private java.math.BigDecimal percentage;
+    /**
+     * createTime
+     */
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+
+    @Override
+    public String toString() {
+        return "SalePerformanceDetail{" +
+                "id=" + id +
+                ", saleId='" + saleId + '\'' +
+                ", roleId='" + roleId + '\'' +
+                ", mediaType='" + mediaType + '\'' +
+                ", advertiserId='" + advertiserId + '\'' +
+                ", year=" + year +
+                ", quarter=" + quarter +
+                ", startDate='" + startDate + '\'' +
+                ", endDate='" + endDate + '\'' +
+                ", totalCost=" + totalCost +
+                ", mediaTask=" + mediaTask +
+                ", doMediaTask=" + doMediaTask +
+                ", personnalTask=" + personnalTask +
+                ", doPersonalTask=" + doPersonalTask +
+                ", extensionSelf=" + extensionSelf +
+                ", brandNew=" + brandNew +
+                ", percent=" + percent +
+                ", percentage=" + percentage +
+                ", createTime=" + createTime +
+                ", updateTime=" + updateTime +
+                '}';
+    }
+
+
+    public SalePerformanceDetail() {
+        this.createTime = new Date();
+        this.updateTime = new Date();
+    }
+}

+ 6 - 9
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/DailyFlowsJob.java

@@ -1,10 +1,9 @@
 package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
@@ -16,7 +15,8 @@ public class DailyFlowsJob implements Job {
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
     @Autowired
-    private CtopOauthTokenMapper oauthTokenMapper;
+    private ICtopOauthTokenService oauthTokenService;
+
 
     /**
      * 刷新token
@@ -26,12 +26,9 @@ public class DailyFlowsJob implements Job {
      */
     @Override
     public void execute(JobExecutionContext jobExecutionContext) {
-        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("media_id", "2");
-        queryWrapper.groupBy("account_id");
-        List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(queryWrapper);
-        if (!Check.isNull(ctopOauthTokens)) {
-            for (CtopOauthToken ctopOauthToken : ctopOauthTokens) {
+        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        if (!Check.isNull(tokens)) {
+            for (CtopOauthToken ctopOauthToken : tokens) {
                 kuaishouInterfaceService.getDailyFlows(ctopOauthToken);
             }
 

+ 9 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouAppListJob.java

@@ -2,8 +2,9 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
@@ -21,8 +22,10 @@ import java.util.concurrent.Executors;
 public class KuaishouAppListJob implements Job {
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
+
     @Autowired
-    private CtopOauthTokenMapper oauthTokenMapper;
+    private ICtopOauthTokenService oauthTokenService;
+
 
     static ExecutorService executorService = Executors.newFixedThreadPool(2);
 
@@ -32,10 +35,11 @@ public class KuaishouAppListJob implements Job {
         Thread thread = new Thread() {
             @Override
             public void run() {
-                QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
-                oauthTokenQueryWrapper.eq("media_id", 2);
-                List<CtopOauthToken> tokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);
+                List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
                 for (CtopOauthToken token : tokens) {
+                    if (Check.isNull(token)) {
+                        continue;
+                    }
                     executorService.submit(new Runnable() {
                         @Override
                         public void run() {

+ 3 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCampaignGroupJob.java

@@ -2,7 +2,6 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import lombok.extern.slf4j.Slf4j;
 import org.quartz.Job;
@@ -15,7 +14,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 @Slf4j
-public class KuaishouCampaignGroupJob implements Job {
+public class KuaishouCampaignJob implements Job {
     @Autowired
     private ICtopOauthTokenService tokenService;
     @Autowired
@@ -31,8 +30,8 @@ public class KuaishouCampaignGroupJob implements Job {
             @Override
             public void run() {
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-                executorService = Executors.newFixedThreadPool(3);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+                executorService = Executors.newFixedThreadPool(5);
                 tokens.forEach(token -> {
                     executorService.submit(new Runnable() {
                         @Override
@@ -40,8 +39,6 @@ public class KuaishouCampaignGroupJob implements Job {
                             try {
                                 //1:获取全量广告计划数据
                                 kuaishouInterfaceService.getCampaignList(token, null, null);
-                                //1:获取全量广告组数据
-                                kuaishouInterfaceService.getGroupList(token, null, null);
                             } catch (Exception e) {
                                 e.printStackTrace();
                             } finally {

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

@@ -2,7 +2,6 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -38,7 +37,7 @@ public class KuaishouDailyAccountReportLoadJob implements Job {
                 kuaishouInterfaceService.deleteHourlyReport(deleteDate);
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

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

@@ -38,7 +38,7 @@ public class KuaishouDailyCampaignReportLoadJob implements Job {
                 kuaishouInterfaceService.deleteHourlyReport(deleteDate);
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

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

@@ -46,7 +46,7 @@ public class KuaishouDailyCreativeReportLoadJob implements Job {
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
                 executorService = Executors.newFixedThreadPool(4);
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

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

@@ -38,7 +38,7 @@ public class KuaishouDailyGroupReportLoadJob implements Job {
                 kuaishouInterfaceService.deleteHourlyReport(deleteDate);
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

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

@@ -40,7 +40,7 @@ public class KuaishouDailyLoadFileJob implements Job {
                 String nowDate = DateUtils.getDate("yyyy-MM-dd");
                 String statDate = getAnotherDay("yyyy-MM-dd", nowDate, -1);
                 //  查询快手token
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

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

@@ -26,7 +26,7 @@ public class KuaishouDailyReportTaskJob implements Job {
         log.info("快手获取日报数据任务执行开始");
         Long start = System.currentTimeMillis();
         Date getDate = DateUtils.addDay(new Date(), -1);
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
         if (null == tokens || tokens.size() <= 0) {
             log.info("快手获取日报数据任务执行失败:未获取到可用的token");
             return;

+ 57 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouGroupJob.java

@@ -0,0 +1,57 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+public class KuaishouGroupJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    static ExecutorService executorService = null;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+                executorService = Executors.newFixedThreadPool(3);
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+
+                                kuaishouInterfaceService.getGroupList(token, null, null);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                            }
+                        }
+                    });
+                });
+                log.info("快手物料数据同步完成");
+            }
+
+        };
+        thread.start();
+
+
+    }
+}

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

@@ -2,7 +2,6 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -46,7 +45,7 @@ public class KuaishouHourlyAccountReportLoadJob implements Job {
                     getDate = DateUtils.addDay(getDate, -1);
                 }
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

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

@@ -38,7 +38,7 @@ public class KuaishouHourlyAccountWarningLoadJob implements Job {
                 log.info("开始时段消耗预警定时任务");
                 long l = System.currentTimeMillis();
                 try {
-                    List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                    List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                     if (null == tokens || tokens.size() <= 0) {
                         log.info("定时获取快手数据异常:未获取到可用的token");
                         return;

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

@@ -47,7 +47,7 @@ public class KuaishouHourlyCampaignReportLoadJob implements Job {
                     getDate = DateUtils.addDay(getDate, -1);
                 }
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

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

@@ -46,7 +46,7 @@ public class KuaishouHourlyCreativeReportLoadJob implements Job {
                     getDate = DateUtils.addDay(getDate, -1);
                 }
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

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

@@ -46,7 +46,7 @@ public class KuaishouHourlyGroupReportLoadJob implements Job {
                     getDate = DateUtils.addDay(getDate, -1);
                 }
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {
                     log.info("定时获取快手数据异常:未获取到可用的token");
                     return;

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

@@ -34,7 +34,7 @@ public class KuaishouMaterialsLoadJob implements Job {
                 Date startDate = DateUtils.addDay(new Date(), -1);
                 Date endDate = new Date();
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 executorService = Executors.newFixedThreadPool(8);
                 tokens.forEach(token -> {
                     executorService.submit(new Runnable() {

+ 66 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouNowDateCampaignJob.java

@@ -0,0 +1,66 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+public class KuaishouNowDateCampaignJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    static ExecutorService executorService = null;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+
+        Thread thread = new Thread() {
+            @SneakyThrows
+            @Override
+            public void run() {
+                //1:查询当日数据
+                Date endDate  = DateUtils.getDate();
+                String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
+                SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
+                Date startDate = sim.parse(anotherDay);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+                executorService = Executors.newFixedThreadPool(5);
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                kuaishouInterfaceService.getCampaignList(token, startDate, endDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                            }
+                        }
+                    });
+                });
+                log.info("快手物料数据同步完成");
+            }
+
+        };
+        thread.start();
+
+
+    }
+
+}

+ 15 - 15
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCreativeLoadJob.java

@@ -2,8 +2,8 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.quartz.Job;
@@ -11,13 +11,14 @@ import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 @Slf4j
-public class KuaishouCreativeLoadJob implements Job {
+public class KuaishouNowDateCreativeJob implements Job {
     @Autowired
     private ICtopOauthTokenService tokenService;
     @Autowired
@@ -25,30 +26,26 @@ public class KuaishouCreativeLoadJob implements Job {
 
     static ExecutorService executorService = null;
 
-    /**
-     * 获取全量创意
-     *
-     * @param jobExecutionContext
-     * @throws JobExecutionException
-     */
-
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+
         Thread thread = new Thread() {
+            @SneakyThrows
             @Override
             public void run() {
-                //增加接口的开始和结束日期
-                Date startDate = DateUtils.addDay(new Date(), -1);
-                Date endDate = new Date();
                 //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-                executorService = Executors.newFixedThreadPool(4);
+                Date endDate  = DateUtils.getDate();
+                String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
+                SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
+                Date startDate = sim.parse(anotherDay);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+                executorService = Executors.newFixedThreadPool(5);
                 tokens.forEach(token -> {
                     executorService.submit(new Runnable() {
                         @Override
                         public void run() {
                             try {
-                                //1:获取全量创意数据
                                 kuaishouInterfaceService.getCreativeList(token, startDate, endDate);
                             } catch (Exception e) {
                                 e.printStackTrace();
@@ -59,8 +56,11 @@ public class KuaishouCreativeLoadJob implements Job {
                 });
                 log.info("快手物料数据同步完成");
             }
+
         };
         thread.start();
 
+
     }
+
 }

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

@@ -41,7 +41,7 @@ public class KuaishouNowDateGroupJob implements Job {
                 String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
                 SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
                 Date startDate = sim.parse(anotherDay);
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 executorService = Executors.newFixedThreadPool(5);
                 tokens.forEach(token -> {
                     executorService.submit(new Runnable() {

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

@@ -28,7 +28,7 @@ public class KuaishouSuZaoLoadJob implements Job {
         Thread thread = new Thread() {
             @Override
             public void run() {
-                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 executorService = Executors.newFixedThreadPool(8);
                 tokens.forEach(token -> {
                     executorService.submit(new Runnable() {

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

@@ -1,7 +1,11 @@
 package org.jeecg.modules.ctop.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.ctop.entity.Advertiser;
+import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
+
+import java.util.List;
 
 /**
  * @Description: 广告主信息表
@@ -11,4 +15,6 @@ import org.jeecg.modules.ctop.entity.Advertiser;
  */
 public interface AdvertiserMapper extends BaseMapper<Advertiser> {
 
+    List<KuaishouXxlEntity> getXXlStatisticInfo(@Param(value = "projectId") Long projectId, @Param(value = "systemType") String systemType, @Param(value = "accountId") Long accountId, @Param(value = "groupBy") String groupBy);
+
 }

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

@@ -0,0 +1,15 @@
+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> {
+
+}

+ 65 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/AdvertiserMapper.xml

@@ -2,4 +2,68 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.ctop.mapper.AdvertiserMapper">
 
-</mapper>
+    <select id="getXXlStatisticInfo" resultType="org.jeecg.modules.excelutil.entity.KuaishouXxlEntity">
+        select
+        report.stat_date as date,
+        round(sum(report.charge),2) as cost,
+        round(sum(
+        case
+        when g.deep_conversion_bid != 0
+        then report.charge
+        else 0
+        end),2) as doubleBid,
+        round(sum(
+        case
+        when g.deep_conversion_bid = 0
+        then report.charge
+        else 0
+        end),2) as singleBid,
+        sum(activation) as active,
+        (case
+        when sum(report.charge)!=0 and sum(activation)!=0
+        then round(sum(report.charge) / sum(activation), 2)
+        else 0
+        end
+        ) as activeCost,
+        (
+        select
+        count(1)
+        from
+        ctop_kuaishou_group g2
+        left join ctop_user_allocation allocation2 on g2.account_id = allocation2.account_id
+        where
+        1=1
+        <if test="projectId != null">
+            and allocation2.project_id = #{projectId}
+        </if>
+        <if test="systemType != null">
+            and allocation2.system_type = #{systemType}
+        </if>
+        <if test="accountId != null">
+            and allocation2.account_id = #{accountId}
+        </if>
+        and
+        date_format(g2.group_create_time, '%Y-%m-%d') = report.stat_date
+        ) as planNum,
+        '' as mat
+        from
+        ctop_kuaishou_report_daily_group report
+        left join ctop_kuaishou_group g on g.unit_id = report.unit_id
+        left join ctop_user_allocation allocation on allocation.account_id = report.account_id
+        where
+        1=1
+        <if test="projectId != null">
+            and allocation.project_id = #{projectId}
+        </if>
+        <if test="systemType != null">
+            and allocation.system_type = #{systemType}
+        </if>
+        <if test="accountId != null">
+            and allocation.account_id = #{accountId}
+        </if>
+        <if test="groupBy != null">
+            group by report.stat_date;
+        </if>
+
+    </select>
+</mapper>

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/SalePerformanceDetailMapper.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="org.jeecg.modules.ctop.mapper.SalePerformanceDetailMapper">
+
+</mapper>

+ 6 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IAdvertiserService.java

@@ -1,7 +1,8 @@
 package org.jeecg.modules.ctop.service;
 
-import org.jeecg.modules.ctop.entity.Advertiser;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ctop.entity.Advertiser;
+import org.jeecg.modules.ctop.vo.SheetInfoVo;
 
 import java.util.List;
 
@@ -14,4 +15,8 @@ import java.util.List;
 public interface IAdvertiserService extends IService<Advertiser> {
 
     List<Advertiser> getBySaleId(String saleId);
+
+    SheetInfoVo getXxlStatisticInfo(Long projectId, String systemType, Long accountId, String sheetName);
+
+    List<SheetInfoVo> getSystemTypeXxlStatisticInfo(Long projectId);
 }

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

@@ -0,0 +1,11 @@
+package org.jeecg.modules.ctop.service;
+
+import com.alibaba.fastjson.JSONArray;
+
+public interface ICreativeTitleService {
+    JSONArray getTitleLabel();
+
+    JSONArray titleSuggestion(String firstCategory, String secondCategory, String keywords);
+
+    JSONArray titleSearch(String firstCategory, String secondCategory, String keywords);
+}

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/PerformanceAreaService.java

@@ -1,5 +1,5 @@
 package org.jeecg.modules.ctop.service;
 
-public interface PerformanceAreaService {
+public interface IPerformanceSaleService {
     void loadSalsePerformance();
 }

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

@@ -0,0 +1,15 @@
+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> {
+
+}

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

@@ -1,13 +1,16 @@
 package org.jeecg.modules.ctop.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.modules.ctop.entity.Advertiser;
 import org.jeecg.modules.ctop.mapper.AdvertiserMapper;
 import org.jeecg.modules.ctop.service.IAdvertiserService;
+import org.jeecg.modules.ctop.vo.SheetInfoVo;
+import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -19,10 +22,36 @@ import java.util.List;
 @Service
 public class AdvertiserServiceImpl extends ServiceImpl<AdvertiserMapper, Advertiser> implements IAdvertiserService {
 
+    @Autowired
+    private AdvertiserMapper advertiserMapper;
     @Override
     public List<Advertiser> getBySaleId(String saleId) {
         QueryWrapper<Advertiser> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("sale_id", saleId);
         return this.list(queryWrapper);
     }
+
+    @Override
+    public SheetInfoVo getXxlStatisticInfo(Long projectId, String systemType, Long accountId, String sheetName) {
+        SheetInfoVo vo = new SheetInfoVo();
+        List<KuaishouXxlEntity> details = new ArrayList<>();
+        vo.setSheetName(sheetName);
+        List<KuaishouXxlEntity> totalList = advertiserMapper.getXXlStatisticInfo(projectId, systemType, accountId, null);
+        KuaishouXxlEntity totalEntity = totalList.get(0);
+        totalEntity.setDate("汇总");
+        details.add(totalEntity);
+        details.addAll(advertiserMapper.getXXlStatisticInfo(projectId, systemType, accountId, "state_date"));
+        vo.setDetails(details);
+        return vo;
+    }
+
+    @Override
+    public List<SheetInfoVo> getSystemTypeXxlStatisticInfo(Long projectId) {
+        List<SheetInfoVo>vos = new ArrayList<>();
+        SheetInfoVo android = getXxlStatisticInfo(projectId,"android",null,"android汇总表");
+        vos.add(android);
+        SheetInfoVo ios = getXxlStatisticInfo(projectId,"ios",null,"ios汇总表");
+        vos.add(ios);
+        return vos;
+    }
 }

+ 7 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java

@@ -68,13 +68,16 @@ public class BidWarningServiceImpl implements IBidWarningService {
                     List<UserAllocation> userAllocations = getUserAllocationsByProjectId(projectId);
                     if (!Check.isNull(userAllocations)) {
                         for (UserAllocation userAllocation : userAllocations) {
+                            if (userAllocation.getAccountStatus() == 1) {
+                                continue;
+                            }
                             Long accountId = userAllocation.getAccountId();
                             List<String> unitWarning = new ArrayList<>();
-                            if("1".equals(userAllocation.getMediaId())){
+                            if ("1".equals(userAllocation.getMediaId())) {
                                 BigDecimal bid = new BigDecimal(maxBid);
                                 BigDecimal bigDecimal = BigDecimalUtil.divideBigDecimal(bid, new BigDecimal(1000));
-                                unitWarning = byteDanceAdvertisePlanService.selectWarningGroup(accountId,bigDecimal);
-                            }else if("2".equals(userAllocation.getMediaId())){
+                                unitWarning = byteDanceAdvertisePlanService.selectWarningGroup(accountId, bigDecimal);
+                            } else if ("2".equals(userAllocation.getMediaId())) {
                                 unitWarning = groupMapper.selectWarningGroup(accountId, maxBid);
                             }
 
@@ -93,6 +96,7 @@ public class BidWarningServiceImpl implements IBidWarningService {
 
 
     }
+
     private List<UserAllocation> getUserAllocationsByProjectId(Long projectId) {
         QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
         userAllocationQueryWrapper.eq("project_id", projectId);

+ 4 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CpaBidWarningServiceImpl.java

@@ -58,6 +58,9 @@ public class CpaBidWarningServiceImpl implements ICpaBidWarningService {
             List<UserAllocation> userAllocations = getUserAllocationsByProjectId(project.getId());
             if (!Check.isNull(userAllocations)) {
                 for (UserAllocation userAllocation : userAllocations) {
+                    if (userAllocation.getAccountStatus() == 1) {
+                        continue;
+                    }
                     Long accountId = userAllocation.getAccountId();
                     List<String> unitWarning = new ArrayList<>();
                     if ("1".equals(userAllocation.getMediaId())) {
@@ -68,7 +71,7 @@ public class CpaBidWarningServiceImpl implements ICpaBidWarningService {
                     }
 
                     if (!Check.isNull(unitWarning)) {
-                        sendMessage(project.getMediaId(), accountId, project.getId(), project.getProjectName(), userAllocation.getAuthName(), unitWarning,maxDeepCpaBid );
+                        sendMessage(project.getMediaId(), accountId, project.getId(), project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxDeepCpaBid);
                     }
                 }
             }

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

@@ -0,0 +1,83 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.modules.ctop.service.ICreativeTitleService;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Service
+public class CreativeTitleServiceImpl implements ICreativeTitleService {
+    @Override
+    public JSONArray getTitleLabel() {
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        String result = HttpUtils.httpGet("https://cc.oceanengine.com/creative_center_server/api/title/new_title_label", null, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (resultJson.getInteger("code") == 0) {
+            JSONObject dataJson = resultJson.getJSONObject("data");
+            if (!Check.isNull(dataJson)) {
+                return dataJson.getJSONArray("title_label");
+            }
+
+        }
+        return null;
+    }
+
+
+    @Override
+    public JSONArray titleSuggestion(String firstCategory, String secondCategory, String keywords) {
+        if (Check.isNull(keywords)) {
+            return null;
+        }
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        Map<String, Object> paramsMap = new HashMap<>();
+        paramsMap.put("first_category", firstCategory);
+        paramsMap.put("second_category", secondCategory);
+        JSONObject json = new JSONObject();
+        json.put("keywords", keywords);
+        paramsMap.put("params", json);
+
+        String result = HttpUtils.httpGet("https://cc.oceanengine.com/creative_center_server/api/title/title_suggestion", paramsMap, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (resultJson.getInteger("code") == 0) {
+            JSONObject dataJson = resultJson.getJSONObject("data");
+            if (!Check.isNull(dataJson)) {
+                return dataJson.getJSONArray("titles");
+            }
+
+        }
+        return null;
+    }
+
+    @Override
+    public JSONArray titleSearch(String firstCategory, String secondCategory, String keywords) {
+        if (Check.isNull(keywords)) {
+            return null;
+        }
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        Map<String, Object> paramsMap = new HashMap<>();
+        paramsMap.put("first_category", firstCategory);
+        paramsMap.put("second_category", secondCategory);
+        JSONObject json = new JSONObject();
+        json.put("keywords", keywords);
+        paramsMap.put("params", json);
+        String result = HttpUtils.httpGet("https://cc.oceanengine.com/creative_center_server/api/title/title_search", paramsMap, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (resultJson.getInteger("code") == 0) {
+            JSONObject dataJson = resultJson.getJSONObject("data");
+            if (!Check.isNull(dataJson)) {
+                return dataJson.getJSONArray("titles");
+            }
+
+        }
+        return null;
+    }
+}

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

@@ -1,60 +0,0 @@
-package org.jeecg.modules.ctop.service.impl;
-
-import cn.com.ctop.performanceappraisal.service.IPerformanceService;
-import org.jeecg.common.util.DateUtils;
-import org.jeecg.modules.ctop.entity.Advertiser;
-import org.jeecg.modules.ctop.service.IAdvertiserService;
-import org.jeecg.modules.ctop.service.PerformanceAreaService;
-import org.jeecg.modules.system.entity.SysUser;
-import org.jeecg.modules.system.service.ISysUserService;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-
-public class PerformanceAreaServiceImpl implements PerformanceAreaService {
-
-    @Autowired
-    private ISysUserService sysUserService;
-    @Autowired
-    private IPerformanceService performanceService;
-
-    @Override
-    public void loadSalsePerformance() {
-        //1:获取销售列表
-        List<SysUser> sales = sysUserService.getUserListByRoleId("75ee837e6f3de29c0e3ed75d4629438e");
-        //2:获取销售AM列表
-        List<SysUser> saleAms = sysUserService.getUserListByRoleId("f5a68aa2acf86e842100f0fa4b050d28");
-    }
-
-    public void countPerformance(SysUser user) {
-        Date getDate = DateUtils.addDay(new Date(), -1);
-        String startDate = DateUtils.getQuarterStartDate(getDate);
-        String endDate = DateUtils.getQuarterEndDate(getDate);
-        //1:获取快手季度总消耗
-        BigDecimal kuaishouDoSeasonTask = performanceService.getKuaishouSeasonTotalCost(startDate, endDate);
-        //2:获取快手个人季度总消耗
-        BigDecimal kuaishouDoPersonnalTask = performanceService.getKuaishouSalesSeasonTotalCost(startDate, endDate, user.getId());
-        //1:获取头条季度总消耗
-        BigDecimal bytedanceDoSeasonTask = performanceService.getBytedanceSeasonTotalCost(startDate, endDate);
-        //2:获取头条个人季度总消耗
-        BigDecimal bytedanceDoPersonnalTask = performanceService.getBytedanceSalesSeasonTotalCost(startDate, endDate, user.getId());
-        //获取销售所属的广告主信息
-        List<Advertiser> advertiserList = advertiserService.getBySaleId(user.getId());
-
-        if (null != advertiserList && advertiserList.size() > 0) {
-            for (Advertiser advertiser : advertiserList) {
-                Date endODate = DateUtils.addDay(advertiser.getCreateTime(), 90);
-                if (1 == 1) {
-
-                } else {
-
-                }
-            }
-        }
-    }
-
-    @Autowired
-    private IAdvertiserService advertiserService;
-}

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

@@ -0,0 +1,199 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.performanceappraisal.service.IPerformanceService;
+import org.jeecg.common.util.DateUtils;
+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.IPerformanceSaleService;
+import org.jeecg.modules.ctop.service.ISalePerformanceDetailService;
+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;
+
+@Service
+public class PerformanceSaleServiceImpl implements IPerformanceSaleService {
+
+    @Autowired
+    private ISysUserService sysUserService;
+    @Autowired
+    private IPerformanceService performanceService;
+
+    @Override
+    public void loadSalsePerformance() {
+        //1:获取销售列表
+        List<SysUser> sales = sysUserService.getUserListByRoleId(CtopAdConstant.SYSTEM_SALE_CODE);
+        if (null != sales && sales.size() > 0) {
+            sales.forEach(sale -> {
+                countPerformance(sale);
+            });
+        }
+        //2:获取销售AM列表
+        List<SysUser> saleAms = sysUserService.getUserListByRoleId(CtopAdConstant.SYSTEM_SALE_AM_CODE);
+        if (null != saleAms && saleAms.size() > 0) {
+            saleAms.forEach(saleAm -> {
+                countPerformance(saleAm);
+            });
+        }
+    }
+
+    @Autowired
+    private ISysUserRoleService userRoleService;
+    @Autowired
+    private ISalePerformanceDetailService salePerformanceDetailService;
+
+    public void countPerformance(SysUser user) {
+//        Date getDate = DateUtils.addDay(new Date(), -1)
+        Date getDate = DateUtils.addDay(new Date(), -5);
+        String startDateStr = DateUtils.getQuarterStartDate(getDate);
+        String endDateStr = DateUtils.getQuarterEndDate(getDate);
+        //获取用户角色信息
+        SysUserRole userRole = userRoleService.getUserRoleByUserId(user.getId());
+        //1:获取快手季度总消耗
+        BigDecimal kuaishouFinishMediaTask = performanceService.getKuaishouSeasonTotalCost(startDateStr, endDateStr);
+        //2:获取快手个人季度总消耗
+        BigDecimal kuaishouFinishPersonnalTask = performanceService.getKuaishouSalesSeasonTotalCostByParams(startDateStr, endDateStr, user.getId(), null);
+        //1:获取头条季度总消耗
+        BigDecimal bytedanceFinishMediaTask = performanceService.getBytedanceSeasonTotalCost(startDateStr, endDateStr);
+        //2:获取头条个人季度总消耗
+        BigDecimal bytedanceFinishPersonnalTask = performanceService.getBytedanceSalesSeasonTotalCostByParams(startDateStr, endDateStr, user.getId(), null);
+        //获取销售所属的广告主信息
+        List<Advertiser> advertiserList = advertiserService.getBySaleId(user.getId());
+
+        if (null != advertiserList && advertiserList.size() > 0) {
+            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();
+            }
+
+            for (Advertiser advertiser : advertiserList) {
+                Date endOldDate = DateUtils.addDay(advertiser.getCreateTime(), 90);
+                if (startSeasonDate.after(endOldDate)) {
+                    //季度开始时间大于新户结束时间(全部按照老户逻辑计算)
+                    saveSalePerformanceDetail(advertiser, user, userRole, DateUtils.getYear(getDate), DateUtils.getQuarter(getDate),
+                            startDateStr, endDateStr, bytedanceFinishMediaTask, bytedanceFinishPersonnalTask, kuaishouFinishMediaTask,
+                            kuaishouFinishPersonnalTask, 0);
+                } else if (endOldDate.after(endSeasonDate)) {
+                    saveSalePerformanceDetail(advertiser, user, userRole, DateUtils.getYear(getDate), DateUtils.getQuarter(getDate),
+                            startDateStr, endDateStr, bytedanceFinishMediaTask, bytedanceFinishPersonnalTask, kuaishouFinishMediaTask,
+                            kuaishouFinishPersonnalTask, 1);
+                } else {
+                    //新户结束时间处于本季度中间
+                    String endduring1Date = DateUtils.formatDate(endOldDate);
+                    saveSalePerformanceDetail(advertiser, user, userRole, DateUtils.getYear(getDate), DateUtils.getQuarter(getDate),
+                            startDateStr, endduring1Date, bytedanceFinishMediaTask, bytedanceFinishPersonnalTask, kuaishouFinishMediaTask,
+                            kuaishouFinishPersonnalTask, 1);
+                    saveSalePerformanceDetail(advertiser, user, userRole, DateUtils.getYear(getDate), DateUtils.getQuarter(getDate),
+                            endduring1Date, endDateStr, bytedanceFinishMediaTask, bytedanceFinishPersonnalTask, kuaishouFinishMediaTask,
+                            kuaishouFinishPersonnalTask, 0);
+                }
+            }
+        }
+    }
+
+    private void saveSalePerformanceDetail(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.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 (user.getOrgCode().startsWith(CtopAdConstant.HB_BYTEDANCE_SALE_ORG_CODE)) {
+            detail.setMediaType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+            BigDecimal totalCost = performanceService.getSalesSeasonTotalCostByParams(startDate, endDate, null, advertiser.getId(), 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));
+            salePerformanceDetailService.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, advertiser.getId(), 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));
+            salePerformanceDetailService.save(detail);
+        } else {
+            return;
+        }
+    }
+
+    private BigDecimal getPercentagePercent(SalePerformanceDetail detail) {
+        BigDecimal percent = detail.getDoMediaTask().divide(detail.getMediaTask()).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");
+            }
+        }
+    }
+
+    @Autowired
+    private IAdvertiserService advertiserService;
+}

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

@@ -0,0 +1,19 @@
+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 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vo/SheetInfoVo.java

@@ -0,0 +1,29 @@
+package org.jeecg.modules.ctop.vo;
+
+import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
+
+import java.util.List;
+
+/**
+ * @author 宋英豪
+ */
+public class SheetInfoVo {
+    private String sheetName;
+    List<KuaishouXxlEntity> details;
+
+    public List<KuaishouXxlEntity> getDetails() {
+        return details;
+    }
+
+    public void setDetails(List<KuaishouXxlEntity> details) {
+        this.details = details;
+    }
+
+    public String getSheetName() {
+        return sheetName;
+    }
+
+    public void setSheetName(String sheetName) {
+        this.sheetName = sheetName;
+    }
+}

+ 110 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/KuaishouXxlEntity.java

@@ -0,0 +1,110 @@
+package org.jeecg.modules.excelutil.entity;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.metadata.BaseRowModel;
+
+import java.math.BigDecimal;
+
+/**
+ * @author 宋英豪
+ */
+public class KuaishouXxlEntity extends BaseRowModel {
+    /**
+     * 日期
+     */
+    @ExcelProperty(index = 1, value = "日期")
+    private String date;
+    /**
+     * 总花费
+     */
+    @ExcelProperty(index = 2, value = "总花费(元)")
+    private BigDecimal cost;
+    /**
+     * 双出价
+     */
+    @ExcelProperty(index = 3, value = "双出价(元)")
+    private BigDecimal doubleBid;
+    /**
+     * 非双出价
+     */
+    @ExcelProperty(index = 4, value = "非双出价(元)")
+    private BigDecimal singleBid;
+    /**
+     * 激活数
+     */
+    @ExcelProperty(index = 5, value = "激活数")
+    private int active;
+    /**
+     * 激活成本
+     */
+    @ExcelProperty(index = 6, value = "激活成本")
+    private BigDecimal activeCost;
+    @ExcelProperty(index = 7, value = "每日计划(组)")
+    private int planNum;
+    @ExcelProperty(index = 8, value = "每日素材安排")
+    private String mat;
+
+    public String getDate() {
+        return date;
+    }
+
+    public void setDate(String date) {
+        this.date = date;
+    }
+
+    public BigDecimal getCost() {
+        return cost;
+    }
+
+    public void setCost(BigDecimal cost) {
+        this.cost = cost;
+    }
+
+    public BigDecimal getDoubleBid() {
+        return doubleBid;
+    }
+
+    public void setDoubleBid(BigDecimal doubleBid) {
+        this.doubleBid = doubleBid;
+    }
+
+    public BigDecimal getSingleBid() {
+        return singleBid;
+    }
+
+    public void setSingleBid(BigDecimal singleBid) {
+        this.singleBid = singleBid;
+    }
+
+    public int getActive() {
+        return active;
+    }
+
+    public void setActive(int active) {
+        this.active = active;
+    }
+
+    public BigDecimal getActiveCost() {
+        return activeCost;
+    }
+
+    public void setActiveCost(BigDecimal activeCost) {
+        this.activeCost = activeCost;
+    }
+
+    public int getPlanNum() {
+        return planNum;
+    }
+
+    public void setPlanNum(int planNum) {
+        this.planNum = planNum;
+    }
+
+    public String getMat() {
+        return mat;
+    }
+
+    public void setMat(String mat) {
+        this.mat = mat;
+    }
+}

+ 14 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

@@ -137,12 +137,10 @@ public class SysUserController {
         return result;
     }
 
-
     @RequestMapping(value = "/getAllUserList", method = RequestMethod.GET)
     public Result<List<SysUserVo>> getAllList() {
         Result<List<SysUserVo>> result = new Result<>();
         try {
-
             List<SysUserVo> userList = sysUserService.getAllUser();
             result.setSuccess(true);
             result.setResult(userList);
@@ -150,9 +148,22 @@ public class SysUserController {
             e.printStackTrace();
             result.setSuccess(false);
             result.setMessage("请求失败");
-
         }
+        return result;
+    }
 
+    @RequestMapping(value = "/getAllSaleList", method = RequestMethod.GET)
+    public Result<List<SysUserVo>> getSaleList() {
+        Result<List<SysUserVo>> result = new Result<>();
+        try {
+            List<SysUserVo> userList = sysUserService.getAllSales();
+            result.setSuccess(true);
+            result.setResult(userList);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage("请求失败");
+        }
         return result;
     }
 

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java

@@ -78,4 +78,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
     List<SysUserVo> getAllUser();
 
     List<SysUserVo> getUserListByCompany(@Param("companyId") String companyId);
+
+    List<SysUserVo> getAllSale();
 }

+ 12 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml

@@ -93,6 +93,17 @@ SELECT
     LEFT JOIN sys_user_role t3 on t1.user_id = t3.user_id
     WHERE t1.company_id = #{companyId}
     </select>
+    <select id="getAllSale" resultType="org.jeecg.modules.system.entity.SysUserVo">
+        SELECT
+            t1.id userId,
+            t1.username userName,
+            t1.realname realName,
+            t3.role_name as  roleName
+        FROM sys_user t1
+        LEFT JOIN sys_user_role t2 on t1.id = t2.user_id
+        left join sys_role t3 on t3.id = t2.role_id
+        where t3.role_name like '销售%';
+    </select>
 
 
-</mapper>
+</mapper>

+ 5 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserRoleService.java

@@ -1,10 +1,9 @@
 package org.jeecg.modules.system.service;
 
-import java.util.Map;
-
+import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.system.entity.SysUserRole;
 
-import com.baomidou.mybatisplus.extension.service.IService;
+import java.util.Map;
 
 /**
  * <p>
@@ -15,10 +14,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2018-12-21
  */
 public interface ISysUserRoleService extends IService<SysUserRole> {
-	
+
 	/**
 	 * 查询所有的用户角色信息
 	 * @return
 	 */
 	Map<String,String> queryUserRole();
+
+	SysUserRole getUserRoleByUserId(String userId);
 }

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserService.java

@@ -131,4 +131,6 @@ public interface ISysUserService extends IService<SysUser> {
 	List<SysUserVo> getUserListByCompany(String companyId);
 
     List<SysUser> getUserListByRoleId(String roleId);
+
+    List<SysUserVo> getAllSales();
 }

+ 14 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserRoleServiceImpl.java

@@ -1,9 +1,7 @@
 package org.jeecg.modules.system.service.impl;
 
-import java.util.IdentityHashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.modules.system.entity.SysRole;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.entity.SysUserRole;
@@ -14,7 +12,9 @@ import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -31,7 +31,7 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
 	private ISysUserService userService;
 	@Autowired
 	private ISysRoleService roleService;
-	
+
 	/**
 	 * 查询所有用户对应的角色信息
 	 */
@@ -59,7 +59,14 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
 		}
 		return map;
 	}
-	
+
+	@Override
+	public SysUserRole getUserRoleByUserId(String userId) {
+		QueryWrapper<SysUserRole> queryWrapper = new QueryWrapper<>();
+		queryWrapper.eq("user_id", userId);
+		return getOne(queryWrapper);
+	}
+
 	/**
 	 * queryUserRole调用的方法
 	 * @param roleList

+ 9 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java

@@ -277,9 +277,15 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
     @Override
     public List<SysUser> getUserListByRoleId(String roleId) {
-        QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("role_id", roleId);
-        return this.list(queryWrapper);
+        Page<SysUser> page = new Page<>();
+        page.setSize(10000);
+        IPage<SysUser> userPage = this.getUserByRoleId(page, roleId, null);
+        return userPage.getRecords();
+    }
+
+    @Override
+    public List<SysUserVo> getAllSales() {
+        return userMapper.getAllSale();
     }
 
 

+ 43 - 12
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -2,7 +2,6 @@ package org.jeecg;
 
 import cn.com.ctop.bytedance.service.IReportService;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
@@ -11,11 +10,12 @@ import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.service.IPerformanceSaleService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -130,20 +130,44 @@ public class SampleTest {
 
     @Autowired
     private ICtopOauthTokenService tokenService;
-    private static ExecutorService executorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService executorService = Executors.newFixedThreadPool(10);
     private static CountDownLatch countDownLatch = null;
 
+    @Autowired
+    private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
     @Test
     public void testLoadJob() {
-        Date getDate = DateUtils.addDay(new Date(), -1);
-        //1:查询当日数据
-        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("project_id", 222);
-        List<UserAllocation> allocations = userAllocationService.list(queryWrapper);
-        allocations.forEach(allocation -> {
-            CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
-            reportService.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
-        });
+//        try {
+//            kuaishouWebInterfaceService.adkuaishouWebLogin("18606113995", "SsjX666!@");
+//            kuaishouWebInterfaceService.deleteAllComment(new HashMap<>());
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        }
+
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (null != tokens && tokens.size() > 0) {
+            countDownLatch = new CountDownLatch(tokens.size());
+            tokens.forEach(token -> {
+                //拉取往期数据
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            reportService.loadBytedanceHistoryData(token);
+                            countDownLatch.countDown();
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+            });
+            try {
+                countDownLatch.await();
+                System.out.println("数据获取完成");
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
     }
 
     @Autowired
@@ -212,6 +236,13 @@ public class SampleTest {
     @Autowired
     private IKuaiShouCreativeService creativeService;
 
+    @Test
+    public void testSalePerformance() {
+        performanceSaleService.loadSalsePerformance();
+    }
+
+    @Autowired
+    private IPerformanceSaleService performanceSaleService;
 
 
     @Test

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

@@ -32,4 +32,6 @@ public interface CtopOauthTokenMapper extends BaseMapper<CtopOauthToken> {
      * @return
      */
     CtopOauthToken selectByAccountId(Long accountId);
+
+    List<CtopOauthToken> selectKuaiShouToken();
 }

+ 10 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml

@@ -75,4 +75,14 @@
         limit 1
     </select>
 
+
+    <select id="selectKuaiShouToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
+        select  t1.*
+        from ctop_oauth_token t1
+        left join ctop_user_allocation t2
+        on t1.account_id = t2.account_id
+        where t2.account_status = 0
+        and t1.media_id = 2
+
+    </select>
 </mapper>

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java

@@ -23,4 +23,6 @@ public interface ICtopOauthTokenService extends IService<CtopOauthToken> {
     Map<String, Object> getKuaiShouRefreshToken(Long accountId, String refreshToken);
 
     List<CtopOauthToken> getTokenListByType(String platformTypeBytedance);
+
+    List<CtopOauthToken> selectKuaiShouToken();
 }

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -3,6 +3,8 @@ package cn.com.ctop.common.module.service;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * @Description: 用户分配
  * @Author: jeecg-boot
@@ -12,4 +14,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
 public interface IUserAllocationService extends IService<UserAllocation> {
 
     UserAllocation getByAccountId(Long accountId);
+
+    List<UserAllocation> getByProjectId(long projectId, String systemType);
 }

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -157,4 +157,15 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
         queryWrapper.eq("media_id", platformType).orderByDesc("account_id");
         return this.list(queryWrapper);
     }
+
+    /**
+     * 获取快手有效账户列表
+     *
+     * @return
+     */
+
+    @Override
+    public List<CtopOauthToken> selectKuaiShouToken() {
+        return cTopOauthTokenMapper.selectKuaiShouToken();
+    }
 }

+ 13 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @Description: 用户分配
  * @Author: jeecg-boot
@@ -22,4 +24,15 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
         queryWrapper.eq("account_id", accountId + "").orderByDesc("id").last("limit 1");
         return this.getOne(queryWrapper);
     }
+
+    @Override
+    public List<UserAllocation> getByProjectId(long projectId, String systemType) {
+        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("project_id", projectId);
+        if (null != systemType && !systemType.trim().equals("")) {
+            queryWrapper.eq("system_type", systemType);
+        }
+        queryWrapper.orderByDesc("id");
+        return this.list(queryWrapper);
+    }
 }

+ 27 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/CtopAdConstant.java

@@ -1,5 +1,7 @@
 package cn.com.ctop.common.module.utils;
 
+import java.math.BigDecimal;
+
 /**
  * 广告相关常量数据
  */
@@ -21,4 +23,29 @@ public class CtopAdConstant {
 
     public static final String KUAISHOU_LOAD_JOB_TYPE_HISTORY = "history";
     public static final String KUAISHOU_LOAD_JOB_TYPE_DAILY = "daily";
+
+    /**
+     * 销售角色Id
+     */
+    public static final String SYSTEM_SALE_CODE = "75ee837e6f3de29c0e3ed75d4629438e";
+
+    /**
+     * 销售AM角色Id
+     */
+    public static final String SYSTEM_SALE_AM_CODE = "f5a68aa2acf86e842100f0fa4b050d28";
+
+
+    public static final BigDecimal BYTEDANCE_MEDIA_TASK_COST = new BigDecimal("200000000");
+    public static final BigDecimal KUAISHOU_MEDIA_TASK_COST = new BigDecimal("200000000");
+    public static final BigDecimal BYTEDANCE_PERSONAL_TASK_COST = new BigDecimal("2400000");
+    public static final BigDecimal KUAISHOU_PERSONAL_TASK_COST = new BigDecimal("2400000");
+
+    /**
+     * 华北快手销售机构号
+     */
+    public static final String HB_KUAISHOU_SALE_ORG_CODE = "A01A11A01";
+    /**
+     * 华北头条销售机构号
+     */
+    public static final String HB_BYTEDANCE_SALE_ORG_CODE = "A01A11A02";
 }

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

@@ -340,7 +340,7 @@ public class BatchController {
                                                     HttpServletRequest req) {
         Result<IPage<KuaiShouGroup>> result = new Result<IPage<KuaiShouGroup>>();
         QueryWrapper<KuaiShouGroup> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouGroup, req.getParameterMap());
-        queryWrapper.orderByDesc("unit_id");
+        queryWrapper.orderByDesc("group_create_time");
         Page<KuaiShouGroup> page = new Page<KuaiShouGroup>(pageNo, pageSize);
         IPage<KuaiShouGroup> pageList = kuaiShouGroupService.page(page, queryWrapper);
         result.setSuccess(true);

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

@@ -212,4 +212,11 @@ public class KuaiShouCreative {
     private Date creativeCreateTime;
 
     private Date creativeUpdateTime;
+
+    private Long siteId;
+
+    private String programmedCreativeMaterial;
+
+
+    private String photoIds;
 }

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

@@ -157,6 +157,12 @@ public class KuaiShouGroup {
     @ApiModelProperty(value = "APP图标存储地址")
     private String appIconUrl;
 
+
+    private Long convertId; // 转化目标
+    private String groupCreateTime;
+    private String groupUpdateTime;
+
+
     /**
      * 创建时间
      */

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

@@ -30,6 +30,9 @@
         description,
         action_bar_text,
         first_frame_type,
+        site_id,
+        programmed_creative_material,
+        photo_ids,
         creative_create_time,
         creative_update_time,
         create_time,
@@ -64,6 +67,9 @@
             #{creative.description},
             #{creative.actionBarText},
             #{creative.firstFrameType},
+            #{creative.siteId},
+            #{creative.programmedCreativeMaterial},
+            #{creative.photoIds},
             #{creative.creativeCreateTime},
             #{creative.creativeUpdateTime},
             #{creative.createTime},

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

@@ -30,6 +30,9 @@
         url,
         app_id,
         app_icon_url,
+        convert_id,
+        group_create_time,
+        group_update_time,
         create_time,
         update_time)
         values
@@ -62,6 +65,9 @@
             #{getGroup.url},
             #{getGroup.appId},
             #{getGroup.appIconUrl},
+            #{getGroup.convertId},
+            #{getGroup.groupCreateTime},
+            #{getGroup.groupUpdateTime},
             #{getGroup.createTime},
             #{getGroup.updateTime})
         </foreach>

+ 3 - 8
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/AccountWarningServiceImpl.java

@@ -50,6 +50,9 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
             if (Check.isNull(userAllocation)) {
                 return;
             }
+            if (userAllocation.getAccountStatus() == 1) {
+                return;
+            }
             BigDecimal warningAmount = userAllocation.getWarningAmount();
             BigDecimal warningProportion = userAllocation.getWarningProportion();
             BigDecimal nowCost = hourlyAccountMapper.getCost(accountId, maxHour, statDate);
@@ -167,12 +170,4 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
     }
 
 
-
-
-
-
-
-
-
-
 }

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

@@ -1612,6 +1612,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     group.setUrl(detail.getString("url"));
                     group.setAppId(detail.getLong("app_id"));
                     group.setAppIconUrl(detail.getString("app_icon_url"));
+                    group.setGroupCreateTime(detail.getString("create_time"));
+                    group.setGroupUpdateTime(detail.getString("update_time"));
+                    group.setConvertId(detail.getLong("convert_id"));
                     group.setCreateTime(new Date());
                     group.setUpdateTime(new Date());
                     groups.add(group);
@@ -2012,31 +2015,29 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     }
                     creative.setCreateTime(new Date());
                     creative.setUpdateTime(new Date());
-
+                    creative.setSiteId(detailJson.getLong("site_id"));
+                    creative.setPhotoId(detailJson.getString("photo_id"));
                     if (detailJson.getLong("photo_id") == 0) {
+                        JSONArray photoIds = new JSONArray();
                         JSONObject programmed_creative_material = detailJson.getJSONObject("programmed_creative_material");
                         if (!Check.isNull(programmed_creative_material)) {
+                            creative.setProgrammedCreativeMaterial(programmed_creative_material.toJSONString());
                             JSONArray materials = programmed_creative_material.getJSONArray("materials");
                             if (!Check.isNull(materials)) {
                                 for (int j = 0; j < materials.size(); j++) {
                                     JSONObject materialJson = materials.getJSONObject(j);
                                     if (!Check.isNull(materialJson)) {
                                         Long photo_id = materialJson.getLong("photo_id");
-                                        creative.setPhotoId(String.valueOf(photo_id));
-                                        creatives.add(creative);
+                                        photoIds.add(String.valueOf(photo_id));
                                     }
                                 }
+                                creative.setPhotoIds(photoIds.toJSONString());
                             }
                         }
-
-
-                    } else {
-                        creative.setPhotoId(detailJson.getString("photo_id"));
-                        creatives.add(creative);
                     }
-
-
+                    creatives.add(creative);
                 }
+
             }
             creativeService.replaceBatch(creatives);
             getCreativeListByPage(accessToken, advertiserId, startDate, endDate, page + 1);
@@ -2123,6 +2124,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         try {
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
+            System.err.println(resultJson);
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {

+ 1 - 1
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/KuaiShouYiCheReportMapper.xml

@@ -446,7 +446,7 @@
             and t1.stat_date = #{statDate}
         </if>
         ) t2
-        WHERE t2.campaignName in(845,846,847,848,849,850,1071,1072)
+        WHERE t2.campaignName in(845,846,847,848,849,850,1071,1072,1066)
 
     </select>
 

+ 46 - 47
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/MaterialReportMapper.xml

@@ -92,31 +92,34 @@
         END
         ) conversionPrice, -- 转化单价
 
-        t2.url url, -- 视频url
+        --  t2.url url, -- 视频url
+
+        (SELECT  url
+        FROM ctop_kuaishou_video_get
+        WHERE signature = t2.signature
+        LIMIT 1
+        ) url,
         t2.signature signature -- 视频md5
         from
         ctop_user_allocation t1
         left join
-        ctop_kuaishou_report_hourly_creative_statistic t2
+        ctop_kuaishou_report_daily_creative t2
         on t1.account_id = t2.account_id
+
         <where>
             <if test="userId != null">
                 and t1.user_id = #{userId,jdbcType=VARCHAR}
             </if>
-            and t1.media_id = '2'
-            and t1.account_id != ''
-            and t2.signature != ''
+
             <if test="startDate != null">
                 and t2.stat_date = #{startDate}
             </if>
-            <if test="statHour != null">
-                and t2.stat_hour &lt;= #{statHour}
-            </if>
+            and t2.signature is not null
         </where>
-
         group by t2.signature
         order by sum(t2.charge) desc
-        limit 100
+        limit 100;
+
 
 
     </select>
@@ -207,8 +210,6 @@
 
     <select id="selectDailyByMap" parameterType="Map" resultType="com.alibaba.fastjson.JSONObject">
 
-
-
         SELECT
         sum(t2.charge) cost, -- 花费
         sum(t2.photo_show) photoShow, -- 封面曝光数
@@ -471,87 +472,85 @@
 
     <select id="selectDayMaterialList" parameterType="Map" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
-        sum(charge) cost, -- 花费
-        sum(photo_show) photoShow, -- 封面曝光数
-        sum(photo_click) photoClick, -- 封面点击数
-        sum(aclick) aclick, -- 素材曝光数
-        sum(bclick) bclick, -- 行为数
+        sum(t1.charge) cost, -- 花费
+        sum(t1.photo_show) photoShow, -- 封面曝光数
+        sum(t1.photo_click) photoClick, -- 封面点击数
+        sum(t1.aclick) aclick, -- 素材曝光数
+        sum(t1.bclick) bclick, -- 行为数
         (case
-        when sum(photo_show) != 0
-        then (sum(photo_click) / sum(photo_show))
+        when sum(t1.photo_show) != 0
+        then (sum(t1.photo_click) / sum(t1.photo_show))
         else 0
         end
         ) photoClickRatio, -- 封面点击率
 
         (case
-        when sum(aclick) != 0
-        then (sum(bclick) / sum(aclick))
+        when sum(t1.aclick) != 0
+        then (sum(t1.bclick) / sum(t1.aclick))
         else 0
         end
         ) actionRatio, -- 行为率
 
         (case
-        when sum(photo_show) != 0
-        then ((sum(charge) / sum(photo_show)) * 1000)
+        when sum(t1.photo_show) != 0
+        then ((sum(t1.charge) / sum(t1.photo_show)) * 1000)
         else 0
         end
         ) impression1kCost, -- 均千次封面曝光花费
 
         (case
-        when sum(photo_click) != 0
-        then (sum(charge) / sum(photo_click))
+        when sum(t1.photo_click) != 0
+        then (sum(t1.charge) / sum(t1.photo_click))
         else 0
         end
         ) photoClickCost, -- 平均封面点击单价
 
         (CASE
-        WHEN sum(photo_click) != 0
-        THEN (sum(charge) / sum(photo_click))
+        WHEN sum(t1.photo_click) != 0
+        THEN (sum(t1.charge) / sum(t1.photo_click))
         ELSE 0
         end
         ) actionCost, -- 平均行为单价
 
         (case
-        WHEN sum(form_count) != 0
-        THEN sum(form_count)
-        WHEN sum(activation) != 0
-        THEN sum(activation)
+        WHEN sum(t1.form_count) != 0
+        THEN sum(t1.form_count)
+        WHEN sum(t1.activation) != 0
+        THEN sum(t1.activation)
         ELSE 0
         END
         ) conversions, -- 转化数
 
         (
         CASE
-        WHEN sum(form_count) != 0
-        THEN (sum(charge) / sum(form_count))
-        WHEN sum(activation) != 0
-        THEN (sum(charge) / sum(activation))
+        WHEN sum(t1.form_count) != 0
+        THEN (sum(t1.charge) / sum(t1.form_count))
+        WHEN sum(t1.activation) != 0
+        THEN (sum(t1.charge) / sum(t1.activation))
         ELSE 0
         END
         ) conversionPrice, -- 转化单价
 
-        ( SELECT url from ctop_kuaishou_video_get WHERE signature = signature limit 1) url,
-        signature signature, -- 视频md5
-        account_id accountId
+        ( SELECT url from ctop_kuaishou_video_get WHERE signature = t1.signature limit 1) url,
+        t1.signature signature, -- 视频md5
+        t1.account_id accountId
         from
-        ctop_kuaishou_report_daily_creative
-        where  account_id in
+        ctop_kuaishou_report_daily_creative t1
+        where  t1.account_id in
         <foreach item="item" index="index" collection="accountIds"
                  open="(" separator="," close=")">
             #{item}
         </foreach>
-
-
         <if test="startDate != null">
-            and stat_date &gt;= #{startDate}
+            and t1.stat_date &gt;= #{startDate}
         </if>
 
         <if test="endDate != null">
-            and stat_date &lt;= #{endDate}
+            and t1.stat_date &lt;= #{endDate}
         </if>
-        and signature is not null
-        GROUP BY signature
-        order by sum(charge) desc
+        and t1.signature is not null
+        GROUP BY t1.signature
+        order by sum(t1.charge) desc
         limit 100
     </select>
 

+ 2 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/IReportService.java

@@ -31,4 +31,6 @@ public interface IReportService {
     void getAdvertiserPlanReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
 
     void getAdvertiserCreativeReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
+
+    void loadBytedanceHistoryData(CtopOauthToken token);
 }

+ 3 - 2
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/ByteDanceHourlyAccountWarningServiceImpl.java

@@ -6,7 +6,6 @@ import cn.com.ctop.common.module.entity.MailLog;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
-import cn.com.ctop.common.module.utils.BigDecimalUtil;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CorpWexinUtils;
 import cn.com.ctop.common.module.utils.SendMailUtil;
@@ -23,7 +22,6 @@ import java.util.List;
 public class ByteDanceHourlyAccountWarningServiceImpl implements IByteDanceHourlyAccountWarningService {
 
 
-
     @Autowired
     private BytedanceAdvertiserHourlyReportMapper bytedanceAdvertiserHourlyReportMapper;
     @Autowired
@@ -53,6 +51,9 @@ public class ByteDanceHourlyAccountWarningServiceImpl implements IByteDanceHourl
             if (Check.isNull(userAllocation)) {
                 return;
             }
+            if (userAllocation.getAccountStatus() == 1) {
+                return;
+            }
             BigDecimal warningAmount = userAllocation.getWarningAmount();
             BigDecimal warningProportion = userAllocation.getWarningProportion();
             BigDecimal nowCost = bytedanceAdvertiserHourlyReportMapper.getCost(accountId, maxHour, statDate);

+ 10 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/ReportServiceImpl.java

@@ -307,6 +307,16 @@ public class ReportServiceImpl implements IReportService {
         getCreativeReportByPage(token, conditions, 1);
     }
 
+    @Override
+    public void loadBytedanceHistoryData(CtopOauthToken token) {
+        for (int i = 1; i < 180; i++) {
+            Date getDate = DateUtils.addDay(new Date(), -i);
+            this.getAdvertiserCreativeReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            this.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            this.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        }
+    }
+
     private ByteDanceAdvertiserReportDTO getReportDTO(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl) {
         var conditions = new ByteDanceAdvertiserReportDTO();
         conditions.setAdvertiserId(token.getAccountId());

+ 2 - 2
performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/mapper/PerformanceMapper.java

@@ -42,7 +42,7 @@ public interface PerformanceMapper extends BaseMapper<Performance> {
 
     BigDecimal getKuaishouSeasonTotalCost(@Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate);
 
-    BigDecimal getKuaishouSalesSeasonTotalCost(@Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "saleId") String saleId);
+    BigDecimal getKuaishouSalesSeasonTotalCostByParams(@Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "saleId") String saleId, @Param(value = "advertiserId") String advertiserId);
 
-    BigDecimal getBytedanceSalesSeasonTotalCost(@Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "saleId") String saleId);
+    BigDecimal getBytedanceSalesSeasonTotalCostByParams(@Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "saleId") String saleId, @Param(value = "advertiserId") String advertiserId);
 }

+ 28 - 16
performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/mapper/xml/PerformanceMapper.xml

@@ -274,9 +274,9 @@
         FROM
             ctop_bytedance_report_advertiser_daily
         WHERE
-            stat_date &gt;= #{startDate}
+            stat_datetime &gt;= #{startDate}
         AND
-            stat_date &lt; #{endDate}
+            stat_datetime &lt; #{endDate}
     </select>
     <select id="getKuaishouSeasonTotalCost" resultType="java.math.BigDecimal">
         SELECT
@@ -330,36 +330,48 @@
         ORDER BY
             SUM(dailyAccount.cost) DESC
     </select>
-    <select id="getKuaishouSalesSeasonTotalCost" resultType="java.math.BigDecimal">
+    <select id="getBytedanceSalesSeasonTotalCostByParams" resultType="java.math.BigDecimal">
         SELECT
-            SUM(charge)
+        SUM(daily.cost)
         FROM
-            ctop_kuaishou_report_daily_account daily
+        ctop_bytedance_report_advertiser_daily daily
         LEFT JOIN
-            ctop_user_allocation allocation ON daily.account_id = allocation.account_id
+        ctop_user_allocation allocation ON daily.advertiser_id = allocation.account_id
         LEFT JOIN
-            ctop_advertiser advertiser ON advertiser.id = allocation.advertiser_id
+        ctop_advertiser advertiser ON advertiser.id = allocation.advertiser_id
         WHERE
-            advertiser.sale_id = #{saleId}
+        1=1
+        <if test="saleId != null">
+            and advertiser.sale_id = #{saleId}
+        </if>
+        <if test="advertiserId != null">
+            and advertiser.id = #{advertiserId}
+        </if>
         AND
-            daily.stat_date &gt;= #{startDate}
+        daily.stat_datetime &gt;= #{startDate}
         AND
-            daily.stat_date &lt; #{endDate}
+        daily.stat_datetime &lt; #{endDate}
     </select>
-    <select id="getBytedanceSalesSeasonTotalCost" resultType="java.math.BigDecimal">
+    <select id="getKuaishouSalesSeasonTotalCostByParams" resultType="java.math.BigDecimal">
         SELECT
             SUM(charge)
         FROM
-            ctop_bytedance_report_advertiser_daily daily
+        ctop_kuaishou_report_daily_account daily
         LEFT JOIN
-            ctop_user_allocation allocation ON daily.advertiser_id = allocation.account_id
+        ctop_user_allocation allocation ON daily.account_id = allocation.account_id
         LEFT JOIN
             ctop_advertiser advertiser ON advertiser.id = allocation.advertiser_id
         WHERE
-            advertiser.sale_id = #{saleId}
+        1=1
+        <if test="saleId != null">
+            and advertiser.sale_id = #{saleId}
+        </if>
+        <if test="advertiserId != null">
+            and advertiser.id = #{advertiserId}
+        </if>
         AND
-            daily.stat_datetime &gt;= #{startDate}
+        daily.stat_date &gt;= #{startDate}
         AND
-            daily.stat_datetime &lt; #{endDate}
+        daily.stat_date &lt; #{endDate}
     </select>
 </mapper>

+ 4 - 2
performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/service/IPerformanceService.java

@@ -40,7 +40,9 @@ public interface IPerformanceService extends IService<Performance> {
 
     BigDecimal getKuaishouSeasonTotalCost(String startDate, String endDate);
 
-    BigDecimal getKuaishouSalesSeasonTotalCost(String startDate, String endDate, String id);
+    BigDecimal getKuaishouSalesSeasonTotalCostByParams(String startDate, String endDate, String salesId, String advertiserId);
 
-    BigDecimal getBytedanceSalesSeasonTotalCost(String startDate, String endDate, String id);
+    BigDecimal getBytedanceSalesSeasonTotalCostByParams(String startDate, String endDate, String saledId, String advertiserId);
+
+    BigDecimal getSalesSeasonTotalCostByParams(String startDate, String endDate, String saledId, String advertiserId, String mediaType);
 }

+ 41 - 6
performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/service/impl/PerformanceServiceImpl.java

@@ -165,22 +165,57 @@ public class PerformanceServiceImpl extends ServiceImpl<PerformanceMapper, Perfo
 
     @Override
     public BigDecimal getBytedanceSeasonTotalCost(String startDate, String endDate) {
-        return performanceMapper.getBytedanceSeasonTotalCost(startDate, endDate);
+        BigDecimal cost = performanceMapper.getBytedanceSeasonTotalCost(startDate, endDate);
+        if (null == cost) {
+            return BigDecimal.ZERO;
+        } else {
+            return cost;
+        }
     }
 
     @Override
     public BigDecimal getKuaishouSeasonTotalCost(String startDate, String endDate) {
-        return performanceMapper.getKuaishouSeasonTotalCost(startDate, endDate);
+        BigDecimal cost = performanceMapper.getKuaishouSeasonTotalCost(startDate, endDate);
+        if (null == cost) {
+            return BigDecimal.ZERO;
+        } else {
+            return cost;
+        }
     }
 
     @Override
-    public BigDecimal getKuaishouSalesSeasonTotalCost(String startDate, String endDate, String salesId) {
-        return performanceMapper.getKuaishouSalesSeasonTotalCost(startDate, endDate, salesId);
+    public BigDecimal getKuaishouSalesSeasonTotalCostByParams(String startDate, String endDate, String salesId, String advertiserId) {
+        BigDecimal cost = performanceMapper.getKuaishouSalesSeasonTotalCostByParams(startDate, endDate, salesId, advertiserId);
+        if (null == cost) {
+            return BigDecimal.ZERO;
+        } else {
+            return cost;
+        }
     }
 
     @Override
-    public BigDecimal getBytedanceSalesSeasonTotalCost(String startDate, String endDate, String salesId) {
-        return performanceMapper.getBytedanceSalesSeasonTotalCost(startDate, endDate, salesId);
+    public BigDecimal getBytedanceSalesSeasonTotalCostByParams(String startDate, String endDate, String salesId, String advertiserId) {
+        BigDecimal cost = performanceMapper.getBytedanceSalesSeasonTotalCostByParams(startDate, endDate, salesId, advertiserId);
+        if (null == cost) {
+            return BigDecimal.ZERO;
+        } else {
+            return cost;
+        }
+    }
+
+    @Override
+    public BigDecimal getSalesSeasonTotalCostByParams(String startDate, String endDate, String saledId, String advertiserId, String mediaType) {
+        BigDecimal cost;
+        if (null != mediaType && mediaType.equals(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE)) {
+            cost = performanceMapper.getKuaishouSalesSeasonTotalCostByParams(startDate, endDate, saledId, advertiserId);
+        } else {
+            cost = performanceMapper.getBytedanceSalesSeasonTotalCostByParams(startDate, endDate, saledId, advertiserId);
+        }
+        if (null == cost) {
+            return BigDecimal.ZERO;
+        } else {
+            return cost;
+        }
     }
 
     private BigDecimal getTotalRoyalty(OptimizerConfig config, OptimizerCostDetailVO vo, OptimizerCostDetailVO quarterCost) {