Ver código fonte

Merge branch 'performance-branch' into test

syh 5 anos atrás
pai
commit
09dfe63ccb
49 arquivos alterados com 1563 adições e 9 exclusões
  1. 2 1
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/TransferAccountMapper.java
  3. 16 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/TransferAccountMapper.xml
  4. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ITransferAccountService.java
  5. 21 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/TransferAccountServiceImpl.java
  6. 25 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/PeriodConstant.java
  7. 36 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/RateConstant.java
  8. 23 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/StandardValue.java
  9. 111 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/controller/PerformanceShowCtrl.java
  10. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/DesignDetail.java
  11. 75 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/OperateDetail.java
  12. 146 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/PerformanceQuarter.java
  13. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/CalculatePerformanceMapper.java
  14. 11 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/DesignDetailMapper.java
  15. 25 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/OperateDetailMapper.java
  16. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/PerformanceQuarterMapper.java
  17. 27 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/CalculatePerformanceMapper.xml
  18. 52 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/DesignDetailMapper.xml
  19. 78 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/OperateDetailMapper.xml
  20. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/PerformanceQuarterMapper.xml
  21. 28 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/DesignDetailServiceImpl.java
  22. 12 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/ICalculatePerformanceService.java
  23. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IDesignDetailService.java
  24. 27 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IOperateDetailService.java
  25. 8 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IPerformanceInfoService.java
  26. 20 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IPerformanceQuarterService.java
  27. 75 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/CalculatePerformanceServiceImpl.java
  28. 189 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/OperateDetailServiceImpl.java
  29. 81 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/PerformanceInfoInfoServiceImpl.java
  30. 109 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/PerformanceQuarterServiceImpl.java
  31. 35 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/testCtrl.java
  32. 32 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/vo/TransferDetailVO.java
  33. 26 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysUserRoleMapper.java
  34. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserRoleService.java
  35. 15 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserRoleServiceImpl.java
  36. 5 5
      jeecg-boot-module-system/src/main/resources/application-test.yml
  37. 56 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/SysCompany.java
  38. 8 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/SysCompanyMapper.java
  39. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysCompanyMapper.xml
  40. 7 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ISysCompanyService.java
  41. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  42. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysCompanyServiceImpl.java
  43. 9 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  44. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/CtopAdConstant.java
  45. 42 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/CtopMediaTypeUtil.java
  46. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java
  47. 12 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml
  48. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAccountService.java
  49. 12 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAccountServiceImpl.java

+ 2 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -143,7 +143,8 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/graphql/video", "anon");
         filterChainDefinitionMap.put("/ks/web/test", "anon");
         filterChainDefinitionMap.put("/ureport/**", "anon");
-        filterChainDefinitionMap.put("/ctop/advertiser/**", "anon");
+        //filterChainDefinitionMap.put("/ctop/performance/show/**", "anon");
+        filterChainDefinitionMap.put("/job/test/*", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

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

@@ -1,8 +1,11 @@
 package org.jeecg.modules.ctop.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.lettuce.core.dynamic.annotation.Param;
 import org.jeecg.modules.ctop.entity.TransferAccount;
 
+import java.util.List;
+
 /**
  * 转户记录表
  *
@@ -12,4 +15,6 @@ import org.jeecg.modules.ctop.entity.TransferAccount;
  */
 public interface TransferAccountMapper extends BaseMapper<TransferAccount> {
 
+    List<TransferAccount> getAccountQuarterDetail(@Param(value = "accountId") Long accountId, @Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate);
+
 }

+ 16 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/TransferAccountMapper.xml

@@ -2,4 +2,20 @@
 <!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.TransferAccountMapper">
 
+    <select id="getAccountQuarterDetail" resultType="org.jeecg.modules.ctop.entity.TransferAccount">
+        select
+            *
+        from
+            ctop_transfer_account
+        where
+            status = 1
+          and
+            account_id =#{accountId}
+          and
+            transferor_date &gt;= #{startDate}
+          and
+            transferor_date &lt; #{endDate}
+        order by transferor_date asc
+    </select>
+
 </mapper>

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

@@ -1,8 +1,11 @@
 package org.jeecg.modules.ctop.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.ctop.entity.TransferAccount;
 
+import java.util.List;
+
 /**
  * 转户记录表
  *
@@ -12,4 +15,8 @@ import org.jeecg.modules.ctop.entity.TransferAccount;
  */
 public interface ITransferAccountService extends IService<TransferAccount> {
 
+    List<JSONObject> selectCost(Long accountId, String startDate, String endDate);
+
+    List<TransferAccount> getAccountQuarterDetail(Long accountId, String startDate, String endDate);
+
 }

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

@@ -1,11 +1,16 @@
 package org.jeecg.modules.ctop.service.impl;
 
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.modules.ctop.entity.TransferAccount;
 import org.jeecg.modules.ctop.mapper.TransferAccountMapper;
 import org.jeecg.modules.ctop.service.ITransferAccountService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 转户记录表
  *
@@ -16,4 +21,20 @@ import org.springframework.stereotype.Service;
 @Service
 public class TransferAccountServiceImpl extends ServiceImpl<TransferAccountMapper, TransferAccount> implements ITransferAccountService {
 
+    @Autowired
+    private KuaishouReportDailyAccountMapper dailyAccountMapper;
+    @Autowired
+    private TransferAccountMapper transferAccountMapper;
+
+    @Override
+    public List<JSONObject> selectCost(Long accountId, String startDate, String endDate) {
+        return dailyAccountMapper.selectCost(accountId, startDate, endDate);
+    }
+
+
+    @Override
+    public List<TransferAccount> getAccountQuarterDetail(Long accountId, String startDate, String endDate) {
+        return transferAccountMapper.getAccountQuarterDetail(accountId, startDate, endDate);
+    }
+
 }

+ 25 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/PeriodConstant.java

@@ -0,0 +1,25 @@
+package org.jeecg.modules.performance.constants;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * Created by JQ.bi on 2020.5.26
+ */
+@Getter
+public enum PeriodConstant {
+
+    Q1("01-01","03-31"),
+    Q2("04-01","06-30"),
+    Q3("07-01","09-30"),
+    Q4("10-01","12-31");
+
+    PeriodConstant(String start, String end) {
+        this.start = start;
+        this.end = end;
+    }
+
+    private final String start;
+    private final String end;
+
+}

+ 36 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/RateConstant.java

@@ -0,0 +1,36 @@
+package org.jeecg.modules.performance.constants;
+
+import java.math.BigDecimal;
+
+/**
+ * Created by JQ.bi on 2020.5.26
+ */
+public class RateConstant {
+
+    private RateConstant() {
+    }
+
+    // Percentage constant
+    public static final BigDecimal PERCENT_0 = BigDecimal.valueOf(0.00);
+    public static final BigDecimal PERCENT_5 = BigDecimal.valueOf(0.05);
+    public static final BigDecimal PERCENT_10 = BigDecimal.valueOf(0.1);
+    public static final BigDecimal PERCENT_15 = BigDecimal.valueOf(0.15);
+    public static final BigDecimal PERCENT_20 = BigDecimal.valueOf(0.2);
+    public static final BigDecimal PERCENT_30 = BigDecimal.valueOf(0.3);
+    public static final BigDecimal PERCENT_40 = BigDecimal.valueOf(0.4);
+    public static final BigDecimal PERCENT_50 = BigDecimal.valueOf(0.5);
+    public static final BigDecimal PERCENT_60 = BigDecimal.valueOf(0.6);
+    public static final BigDecimal PERCENT_70 = BigDecimal.valueOf(0.7);
+    public static final BigDecimal PERCENT_80 = BigDecimal.valueOf(0.8);
+    public static final BigDecimal PERCENT_90 = BigDecimal.valueOf(0.9);
+
+
+    // Thousand constant
+    public static final BigDecimal THOUSAND_0 = BigDecimal.valueOf(0.000);
+    public static final BigDecimal THOUSAND_1 = BigDecimal.valueOf(0.001);
+    public static final BigDecimal THOUSAND_2 = BigDecimal.valueOf(0.002);
+    public static final BigDecimal THOUSAND_3 = BigDecimal.valueOf(0.003);
+    public static final BigDecimal THOUSAND_4 = BigDecimal.valueOf(0.004);
+    public static final BigDecimal THOUSAND_5 = BigDecimal.valueOf(0.005);
+
+}

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

@@ -0,0 +1,23 @@
+package org.jeecg.modules.performance.constants;
+
+import java.math.BigDecimal;
+
+/**
+ * Created by JQ.bi on 2020.5.26
+ */
+public class StandardValue {
+
+    private StandardValue() {
+    }
+
+    // 季度消耗门槛值
+    public static final BigDecimal QUARTER_CONSUMPTION=new BigDecimal(2400000);
+
+    // 视频有效门槛值
+    public static final BigDecimal VIDEO_CLICK=new BigDecimal(5000);
+
+    // 零绩效
+    public static final BigDecimal PERFORMANCE_ZERO=new BigDecimal(0);
+
+
+}

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

@@ -0,0 +1,111 @@
+package org.jeecg.modules.performance.controller;
+
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.performance.entity.PerformanceQuarter;
+import org.jeecg.modules.performance.service.IOperateDetailService;
+import org.jeecg.modules.performance.service.IPerformanceInfoService;
+import org.jeecg.modules.performance.service.IPerformanceQuarterService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by JQ.bi on 2020.6.9
+ */
+@Slf4j
+@RestController
+@RequestMapping("/ctop/performance/show")
+public class PerformanceShowCtrl {
+
+    @Autowired
+    IPerformanceInfoService performanceService;
+    @Autowired
+    IPerformanceQuarterService performanceQuarterService;
+    @Autowired
+    IOperateDetailService operateDetailService;
+
+    @GetMapping("/getPerformanceInfo")
+    public Result<Map<String, Object>> getPerformanceInfo() {
+        Result<Map<String, Object>> result = new Result<>();
+        result.setResult(performanceService.getPerformanceInfo());
+        result.setSuccess(true);
+        return result;
+    }
+
+    @PostMapping("/{pageNo}/{pageSize}/{order}")
+    public Result<PageInfo<PerformanceQuarter>> showPerformance(@PathVariable int pageNo,
+                                                               @PathVariable int pageSize,
+                                                               @PathVariable String order,
+                                                               @RequestBody JSONObject requestBody) {
+        Result<PageInfo<PerformanceQuarter>> result = new Result<>();
+        PageInfo<PerformanceQuarter> pageInfo = performanceQuarterService.getPerformanceByConditionsPage(pageNo, pageSize, order, requestBody);
+        result.setSuccess(true);
+        result.setResult(pageInfo);
+        return result;
+    }
+
+    /**
+     * 导出数据
+     *
+     * @param requestBody
+     * @param response
+     */
+    @PostMapping("/excel")
+    public void getExcelReport(@RequestBody JSONObject requestBody,
+                               HttpServletResponse response) {
+        List<PerformanceQuarter> excelData= performanceQuarterService.getPerformanceByConditions(requestBody);
+        if (excelData.isEmpty()) {
+            return;
+        }
+        String[] titles={"姓名","公司","职位","媒体类型","年份","季度","消耗","提成比例","绩效","管理岗绩效"};
+
+        List<List<Object>> excelList = new ArrayList<>();
+        excelData.forEach(data -> {
+            List<Object> temp = new ArrayList<>();
+            temp.add(data.getUserName());
+            temp.add(data.getCompanyName());
+            temp.add(data.getRoleName());
+            temp.add(data.getMediaType()==1?"头条":"快手");
+            temp.add(data.getYear());
+            temp.add(data.getQuarter());
+            temp.add(data.getCost());
+            temp.add(data.getPoint());
+            temp.add(data.getPerformance());
+            temp.add(data.getAdditionalFees());
+            excelList.add(temp);
+        });
+        try {
+            OutputStream os = response.getOutputStream();
+            ExportExcelUtils eeu = new ExportExcelUtils();
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            eeu.exportExcel(workbook, 0, "绩效", titles, excelList);
+            HttpUtils.setResponseHeader(response, "绩效.xlsx");
+            workbook.write(os);
+            os.flush();
+            os.close();
+        } catch (IOException e) {
+            log.error(e.getMessage());
+        }
+    }
+
+    @PostMapping("/operateDetail")
+    public Result<List<JSONObject>> getOperateDetail(@RequestBody JSONObject requestBody){
+        Result<List<JSONObject>> result = new Result<>();
+        result.setResult(operateDetailService.getOperateGroupAccountByUser(requestBody));
+        result.setSuccess(true);
+        return result;
+    }
+
+}

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

@@ -0,0 +1,13 @@
+package org.jeecg.modules.performance.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * 设计消耗详细
+ */
+@Data
+@TableName("ctop_performance_design_detail")
+public class DesignDetail {
+
+}

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

@@ -0,0 +1,75 @@
+package org.jeecg.modules.performance.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import 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.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 运营消耗详细
+ */
+@Data
+@TableName("ctop_performance_operate_detail")
+public class OperateDetail {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    /**
+     * 用户id
+     */
+    private String userId;
+    /**
+     * 媒体类型 1:头条 2:快手
+     */
+    private Integer mediaType;
+    /**
+     * 账户id
+     */
+    private Long accountId;
+    /**
+     * 统计开始时间
+     */
+    private String statDate;
+
+    /**
+     * 账户消耗
+     */
+    private BigDecimal cost;
+    /**
+     * leaderId
+     */
+    private String leaderId;
+    /**
+     * createTime
+     */
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    private Date updateTime;
+
+    /**
+     * 是否节假日
+     */
+    private Date isHoliday;
+
+    /**
+     * 预留字段
+     */
+    private BigDecimal cost1;
+    private BigDecimal cost2;
+    private BigDecimal cost3;
+    private BigDecimal cost4;
+
+}

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

@@ -0,0 +1,146 @@
+package org.jeecg.modules.performance.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Objects;
+
+@Data
+@TableName("ctop_performance_quarter")
+public class PerformanceQuarter {
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    /**
+     * 用户id
+     */
+    private String userId;
+    /**
+     * 用户姓名
+     */
+    private String userName;
+    /**
+     * 公司ID
+     */
+    private String companyId;
+    /**
+     * 公司名称
+     */
+    private String companyName;
+    /**
+     * 公司名称
+     */
+    private String department;
+    /**
+     * 职位code
+     */
+    private String roleCode;
+    /**
+     * 职位名称
+     */
+    private String roleName;
+    /**
+     * 负责人
+     */
+    private String leader;
+    /**
+     * 用户id
+     */
+    private Integer year;
+    /**
+     * 季度
+     */
+    private String quarter;
+    /**
+     * 消耗
+     */
+    private BigDecimal cost;
+    /**
+     * 绩效
+     */
+    private BigDecimal performance;
+    /**
+     * 提成点
+     */
+    private BigDecimal point;
+    /**
+     * 额外提成
+     */
+    private BigDecimal additionalFees;
+    /**
+     * 原因
+     */
+    private String reason;
+    /**
+     * 媒体类型
+     */
+    private Integer mediaType;
+    /**
+     * createTime
+     */
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    private Date updateTime;
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        PerformanceQuarter that = (PerformanceQuarter) o;
+        return Objects.equals(id, that.id) &&
+                Objects.equals(userId, that.userId) &&
+                Objects.equals(userName, that.userName) &&
+                Objects.equals(companyId, that.companyId) &&
+                Objects.equals(companyName, that.companyName) &&
+                Objects.equals(roleCode, that.roleCode) &&
+                Objects.equals(roleName, that.roleName) &&
+                Objects.equals(leader, that.leader) &&
+                Objects.equals(year, that.year) &&
+                Objects.equals(quarter, that.quarter) &&
+                Objects.equals(cost, that.cost) &&
+                Objects.equals(performance, that.performance) &&
+                Objects.equals(point, that.point) &&
+                Objects.equals(additionalFees, that.additionalFees) &&
+                Objects.equals(reason, that.reason) &&
+                Objects.equals(mediaType, that.mediaType) &&
+                Objects.equals(createTime, that.createTime) &&
+                Objects.equals(updateTime, that.updateTime);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, userId, userName, companyId, companyName, roleCode, roleName, leader, year, quarter, cost, performance, point, additionalFees, reason, mediaType, createTime, updateTime);
+    }
+
+    @Override
+    public String toString() {
+        return "PerformanceQuarter{" +
+                "id=" + id +
+                ", userId='" + userId + '\'' +
+                ", userName='" + userName + '\'' +
+                ", companyId='" + companyId + '\'' +
+                ", companyName='" + companyName + '\'' +
+                ", roleCode='" + roleCode + '\'' +
+                ", roleName='" + roleName + '\'' +
+                ", leader='" + leader + '\'' +
+                ", year=" + year +
+                ", quarter='" + quarter + '\'' +
+                ", cost=" + cost +
+                ", performance=" + performance +
+                ", point=" + point +
+                ", additionalFees=" + additionalFees +
+                ", reason='" + reason + '\'' +
+                ", mediaType=" + mediaType +
+                ", createTime=" + createTime +
+                ", updateTime=" + updateTime +
+                '}';
+    }
+}

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

@@ -0,0 +1,13 @@
+package org.jeecg.modules.performance.mapper;
+
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface CalculatePerformanceMapper {
+
+    List<JSONObject> queryOperateCostGroupByUser(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("mediaType")int mediaType);
+
+}

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

@@ -0,0 +1,11 @@
+package org.jeecg.modules.performance.mapper;
+
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+
+public interface DesignDetailMapper {
+
+    List<JSONObject> queryMaterialDetailByDate(String startDate,String endDate, int mediaType);
+}

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

@@ -0,0 +1,25 @@
+package org.jeecg.modules.performance.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.lettuce.core.dynamic.annotation.Param;
+import org.jeecg.modules.performance.entity.OperateDetail;
+
+import java.util.List;
+
+/**
+ * 运营消耗详细
+ *
+ * @author: jeecg-boot
+ * @date: 2020-04-23
+ * @cersion: V1.0
+ */
+public interface OperateDetailMapper extends BaseMapper<OperateDetail> {
+
+    List<OperateDetail> selectBytedanceByParams(@Param(value = "accountId") Long accountId, @Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "userId") String userId, @Param(value = "orgCode") String orgCode);
+
+    List<JSONObject> ByteDanceOperateDetailGroupAccountByDate(@Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "userId") String userId);
+
+    List<JSONObject> kuaiShouOperateDetailGroupAccountByDate(@Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "userId") String userId);
+
+}

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

@@ -0,0 +1,14 @@
+package org.jeecg.modules.performance.mapper;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.performance.entity.PerformanceQuarter;
+
+import java.util.List;
+
+public interface PerformanceQuarterMapper extends BaseMapper<PerformanceQuarter> {
+
+    List<JSONObject> queryYearAndQuarter();
+
+}

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

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.performance.mapper.CalculatePerformanceMapper">
+
+    <select id="queryOperateCostGroupByUser" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT res.*,
+        (SELECT realname from sys_user user where user.id=res.userId limit 1) as userName,
+        (SELECT company_id from user_company company where company.user_id=res.userId limit 1) as 'companyId',
+        (SELECT company_name from user_company company where company.user_id=res.userId limit 1) as 'companyName',
+        (SELECT role_code from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleCode',
+        (SELECT role_name from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleName'
+        from (
+        SELECT
+        user_id as userId,
+        leader_id as leaderId,
+        sum(cost) as cost
+        FROM
+        ctop_performance_operate_detail
+        WHERE
+        media_type= #{mediaType}
+        AND	stat_date &gt;= #{startDate}
+        AND stat_date &lt;= #{endDate}
+        GROUP BY user_id
+        ) res
+    </select>
+
+</mapper>

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

@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.performance.mapper.DesignDetailMapper">
+
+    <select id="queryMaterialDetailByDate" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        res.*,
+        (
+        SELECT
+        USER.id
+        FROM
+        sys_user USER
+        LEFT JOIN sys_user_role userRole ON USER .id = userRole.user_id
+        LEFT JOIN sys_role role ON userRole.role_id = role.id
+        WHERE
+        USER .org_code = (
+        SELECT
+        user1.org_code
+        FROM
+        sys_user user1
+        WHERE
+        user1.id = res.clipId
+        LIMIT 1
+        )
+        AND role.role_code = 'designTeamLeader'
+        ) AS 'leaderId'
+        FROM
+        (
+        SELECT
+        report.CODE,
+        sum(report.cost) AS cost,
+        ascription.clip_id as clipID,
+        ascription.plane_id as planeId,
+        ascription.plan_id as planID,
+        ascription.shot_id as shotID,
+        ascription.material_id as materialId
+        FROM
+        ctop_material_report_total_result report
+        LEFT JOIN ctop_material_info info on report.code=info.code
+        LEFT JOIN ctop_material_ascription ascription ON info. CODE = ascription.material_id
+        WHERE
+        report.media_type = #{param3}
+        AND report.stat_date &gt;= #{param1}
+        AND report.stat_date &lt;= #{param2}
+        GROUP BY
+        report.CODE
+        ) res
+        WHERE
+        res.cost > 0
+    </select>
+
+</mapper>

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

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.performance.mapper.OperateDetailMapper">
+
+    <select id="selectBytedanceByParams" resultType="org.jeecg.modules.performance.entity.OperateDetail">
+        select
+            #{userId} as user_id,
+            1 as media_type,
+            #{accountId} as account_id,
+            left(stat_datetime,10) as stat_date,
+            sum(cost) as cost,
+            (select
+                user.id
+            from
+                sys_user_role userRole
+            left join sys_user user on userRole.user_id = user.id
+            left join sys_role role on userRole.role_id = role.id
+            where
+                org_code = #{orgCode}
+            and
+                role.role_name = '头条运营经理'
+            ) as leader_id
+        from
+            ctop_bytedance_report_advertiser_daily
+        where
+            advertiser_id = #{accountId}
+        and
+            stat_datetime &gt;=#{startDate}
+        and
+            stat_datetime &lt;=#{endDate}
+        group by stat_datetime
+    </select>
+
+    <select id="ByteDanceOperateDetailGroupAccountByDate" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t2.project_name AS projectName,
+        t2.auth_name AS authName,
+        ROUND(sum(t1.cost), 2) cost
+        FROM
+        ctop_bytedance_report_advertiser_daily t1
+        LEFT JOIN ctop_user_allocation t2 on t1.advertiser_id=t2.account_id
+        WHERE
+        t1.stat_datetime &gt;= #{startDate} '00:00:00'
+        AND t1.stat_datetime &lt;= #{endDate}
+        AND t1.advertiser_id IN (
+        SELECT
+        account_id
+        FROM
+        ctop_user_allocation
+        WHERE
+        user_id = #{userId}
+        AND media_id = 1
+        ) GROUP BY t2.account_id
+    </select>
+
+    <select id="kuaiShouOperateDetailGroupAccountByDate" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t2.project_name AS projectName,
+        t2.auth_name AS authName,
+        ROUND(sum(t1.charge), 2) cost
+        FROM
+        ctop_kuaishou_report_daily_account t1
+        LEFT JOIN ctop_user_allocation t2 on t1.account_id=t2.account_id
+        WHERE
+        t1.stat_date &gt;=#{startDate}
+        AND t1.stat_date &lt;=#{endDate}
+        AND t1.account_id IN (
+        SELECT
+        account_id
+        FROM
+        ctop_user_allocation
+        WHERE
+        user_id = #{userId}
+        AND media_id = 2
+        ) GROUP BY t2.account_id
+    </select>
+
+</mapper>

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

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.performance.mapper.PerformanceQuarterMapper">
+
+    <select  id="queryYearAndQuarter" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT DISTINCT
+            year,
+            quarter
+        FROM
+            ctop_performance_quarter
+    </select>
+
+</mapper>

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

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

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

@@ -0,0 +1,12 @@
+package org.jeecg.modules.performance.service;
+
+public interface ICalculatePerformanceService {
+
+    //运营绩效计算
+    void CalculateOperatePerformance(int year, String quarter, int mediaType);
+    //设计绩效计算
+    void CalculateDesignPerformance();
+    //销售绩效计算
+    void CalculateSalePerformance();
+
+}

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

@@ -0,0 +1,7 @@
+package org.jeecg.modules.performance.service;
+
+public interface IDesignDetailService {
+
+    void UserCostCalculateByMaterial(String startDate, String endDate, int mediaType);
+
+}

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

@@ -0,0 +1,27 @@
+package org.jeecg.modules.performance.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.performance.entity.OperateDetail;
+import org.jeecg.modules.performance.vo.TransferDetailVO;
+
+import java.text.ParseException;
+import java.util.List;
+
+/**
+ * 运营消耗详细
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-04-23
+ */
+public interface IOperateDetailService extends IService<OperateDetail> {
+
+    void KsCostCalculateByAccount(String startDate, String endDate);
+
+    void BtCostCalculateByAccount(String startDate, String endDate);
+
+    List<TransferDetailVO> loadTransferDetail(Long accountId, String userId, String startDate, String endDate) throws ParseException;
+
+    List<JSONObject> getOperateGroupAccountByUser(JSONObject requestBody);
+}

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

@@ -0,0 +1,8 @@
+package org.jeecg.modules.performance.service;
+
+import java.util.Map;
+
+public interface IPerformanceInfoService {
+
+    Map<String,Object> getPerformanceInfo();
+}

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

@@ -0,0 +1,20 @@
+package org.jeecg.modules.performance.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.modules.performance.entity.PerformanceQuarter;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public interface IPerformanceQuarterService extends IService<PerformanceQuarter> {
+
+    Map<String, Set<String>> getYearQuarter();
+
+    List<PerformanceQuarter> getPerformanceByConditions(JSONObject requestBody);
+
+    PageInfo<PerformanceQuarter> getPerformanceByConditionsPage(int pageNo, int pageSize, String order,JSONObject requestBody);
+
+}

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

@@ -0,0 +1,75 @@
+package org.jeecg.modules.performance.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.modules.performance.constants.PeriodConstant;
+import org.jeecg.modules.performance.constants.RateConstant;
+import org.jeecg.modules.performance.constants.StandardValue;
+import org.jeecg.modules.performance.entity.PerformanceQuarter;
+import org.jeecg.modules.performance.mapper.CalculatePerformanceMapper;
+import org.jeecg.modules.performance.service.ICalculatePerformanceService;
+import org.jeecg.modules.performance.service.IPerformanceQuarterService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *  Created by JQ.bi
+ */
+@Service
+public class CalculatePerformanceServiceImpl implements ICalculatePerformanceService {
+
+    @Autowired
+    CalculatePerformanceMapper calculatePerformanceMapper;
+    @Autowired
+    IPerformanceQuarterService performanceQuarterService;
+
+    @Override
+    public void CalculateOperatePerformance(int year, String quarter, int mediaType) {
+        //TODO 查询配置的提成点
+        BigDecimal point =new BigDecimal(0);
+        if (mediaType == 1) point = RateConstant.THOUSAND_2;
+        if (mediaType == 2) point = RateConstant.THOUSAND_3;
+        String startDate= year+"-"+ PeriodConstant.valueOf(quarter).getStart();
+        String endDate= year+"-"+PeriodConstant.valueOf(quarter).getEnd();
+        List<JSONObject> operateCost = calculatePerformanceMapper.queryOperateCostGroupByUser(startDate, endDate, mediaType);
+        List<PerformanceQuarter> performanceQuarters = new ArrayList<>();
+        PerformanceQuarter performanceQuarter;
+        for(JSONObject op:operateCost){
+            performanceQuarter = new PerformanceQuarter();
+            performanceQuarter.setUserId(op.getString("userId"));
+            performanceQuarter.setUserName(op.getString("userName"));
+            performanceQuarter.setCompanyId(op.getString("companyId"));
+            performanceQuarter.setCompanyName(op.getString("companyName"));
+            performanceQuarter.setDepartment("运营部");
+            performanceQuarter.setRoleCode(op.getString("roleCode"));
+            performanceQuarter.setRoleName(op.getString("roleName"));
+            performanceQuarter.setLeader(op.getString("leaderId"));
+            performanceQuarter.setYear(year);
+            performanceQuarter.setQuarter(quarter);
+            BigDecimal cost=op.getBigDecimal("cost");
+            performanceQuarter.setCost(cost);
+            if(cost.compareTo(StandardValue.QUARTER_CONSUMPTION)>=0){
+                performanceQuarter.setPerformance(cost.multiply(point));
+            }else {
+                performanceQuarter.setPerformance(StandardValue.PERFORMANCE_ZERO);
+            }
+            performanceQuarter.setPoint(point);
+            performanceQuarter.setMediaType(mediaType);
+            performanceQuarters.add(performanceQuarter);
+        }
+        performanceQuarterService.saveBatch(performanceQuarters);
+    }
+
+    @Override
+    public void CalculateDesignPerformance() {
+
+    }
+
+    @Override
+    public void CalculateSalePerformance() {
+
+    }
+}

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

@@ -0,0 +1,189 @@
+package org.jeecg.modules.performance.service.impl;
+
+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.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAccountService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.entity.TransferAccount;
+import org.jeecg.modules.ctop.service.ITransferAccountService;
+import org.jeecg.modules.performance.constants.PeriodConstant;
+import org.jeecg.modules.performance.entity.OperateDetail;
+import org.jeecg.modules.performance.mapper.OperateDetailMapper;
+import org.jeecg.modules.performance.service.IOperateDetailService;
+import org.jeecg.modules.performance.vo.TransferDetailVO;
+import org.jeecg.modules.system.entity.SysUser;
+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.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 运营消耗详细
+ */
+@Service
+@Slf4j
+public class OperateDetailServiceImpl extends ServiceImpl<OperateDetailMapper, OperateDetail> implements IOperateDetailService {
+
+    @Autowired
+    private OperateDetailMapper operateDetailMapper;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private ITransferAccountService transferAccountService;
+    @Autowired
+    private IKuaishouReportDailyAccountService dailyAccountService;
+    @Autowired
+    private ISysUserRoleService roleService;
+    @Autowired
+    private ISysUserService sysUserService;
+
+
+    /**
+     * 快手账户消耗计算
+     */
+    @Override
+    public void KsCostCalculateByAccount(String startStatDate, String endStatDate) {
+
+        List<UserAllocation> list = userAllocationService.getByMediaId(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+        for (UserAllocation allocation : list) {
+            List<TransferDetailVO> transferDetailVOS = loadTransferDetail(allocation.getAccountId(), allocation.getUserId(), startStatDate, endStatDate);
+            if (Check.isNull(transferDetailVOS)) {
+                log.error("错误,未返回转户信息,accountId:{}", allocation.getAccountId());
+                continue;
+            }
+            for (TransferDetailVO transferDetail : transferDetailVOS) {
+                String userId = transferDetail.getUserId();
+                Long accountId = transferDetail.getAccountId();
+                String startDate = transferDetail.getStartDate();
+                String endDate = transferDetail.getEndDate();
+                String leaderId = roleService.getLeaderId(userId, "kuaishouOperationManager");
+                List<JSONObject> costJsonArr = dailyAccountService.selectCost(accountId, startDate, endDate);
+                if (!Check.isNull(costJsonArr)) {
+                    costJsonArr.stream().filter(costJson -> !Check.isNull(costJson)).forEach(costJson -> {
+                        BigDecimal cost = costJson.getBigDecimal("cost");
+                        if (Check.isNull(cost)) {
+                            return;
+                        }
+                        OperateDetail detail = new OperateDetail();
+                        detail.setCost(cost);
+                        detail.setAccountId(accountId);
+                        detail.setStatDate(costJson.getString("statDate"));
+                        detail.setLeaderId(leaderId);
+                        detail.setUserId(userId);
+                        detail.setMediaType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT);
+                        //TODO 判断是否为节假日
+                        operateDetailMapper.insert(detail);
+                    });
+
+                }
+            }
+        }
+
+    }
+
+
+    /**
+     * 头条账户消耗计算
+     */
+    @Override
+    public void BtCostCalculateByAccount(String startStatDate, String endStatDate) {
+
+        //1:获取头条账户
+        List<UserAllocation> allocations = userAllocationService.getByMediaId(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (allocations.isEmpty()) {
+            log.info("获取头条用户失败");
+            return;
+        }
+        allocations.forEach(allocation->{
+            List<TransferDetailVO> transferDetailVOS = loadTransferDetail(allocation.getAccountId(), allocation.getUserId(), startStatDate, endStatDate);
+            if (null != transferDetailVOS && transferDetailVOS.size() > 0) {
+                transferDetailVOS.forEach(vo->{
+                    SysUser user = sysUserService.getById(vo.getUserId());
+                    List<OperateDetail> details = operateDetailMapper.selectBytedanceByParams(allocation.getAccountId(), vo.getStartDate() + " 00:00:00", vo.getEndDate() + "00:00:00", vo.getUserId(), user.getOrgCode());
+                    if (!details.isEmpty()) {
+                        details.forEach(detail->{
+                            if (null != detail && null != detail.getCost()) {
+                                if (detail.getUserId().equals(detail.getLeaderId())) {
+                                    detail.setLeaderId(null);
+                                }
+                                //TODO 判断是否为节假日
+                                this.save(detail);
+                            }
+                        });
+                    }
+                });
+            }
+        });
+    }
+
+    @Override
+    public List<TransferDetailVO> loadTransferDetail(Long accountId, String userId, String startDate, String endDate) {
+        List<TransferDetailVO> vos = new ArrayList<>();
+        String realEndDate = DateUtils.addDay(endDate, -1);
+        List<TransferAccount> transferAccounts = transferAccountService.getAccountQuarterDetail(accountId, startDate, endDate);
+        if (Check.isNull(transferAccounts)) {
+            vos.add(new TransferDetailVO(startDate, endDate, userId, accountId));
+            return vos;
+        } else if (transferAccounts.size() == 1) {
+            TransferAccount account = transferAccounts.get(0);
+            if (account.getTransferorDate().equals(startDate)) {
+                //极限情况 季度末最后一天转让
+                vos.add(new TransferDetailVO(startDate, endDate, userId, accountId));
+                return vos;
+            } else {
+                vos.add(new TransferDetailVO(startDate, account.getAssigneeDate(), userId, accountId));
+                vos.add(new TransferDetailVO(account.getAssigneeDate(), endDate, userId, accountId));
+                return vos;
+            }
+        } else {
+            TransferAccount firstAccount = transferAccounts.get(0);
+            TransferAccount lastAccout = transferAccounts.get(transferAccounts.size() - 1);
+            vos.add(new TransferDetailVO(startDate, firstAccount.getAssigneeDate(), firstAccount.getTransferor(), accountId));
+            String lastTwoAssigneeDate = "";
+            for (int i = 1; i <= transferAccounts.size() - 1; i++) {
+                TransferAccount account = transferAccounts.get(i);
+                TransferAccount preAccount = transferAccounts.get(i - 1);
+                vos.add(new TransferDetailVO(preAccount.getAssigneeDate(), account.getAssigneeDate(), account.getTransferor(), accountId));
+                lastTwoAssigneeDate = account.getAssigneeDate();
+            }
+            if (lastAccout.getTransferorDate().equals(realEndDate)) {
+                //最后一条数据的转让时间为季度末尾
+                vos.add(new TransferDetailVO(lastTwoAssigneeDate, endDate, lastAccout.getTransferor(), accountId));
+            } else {
+                vos.add(new TransferDetailVO(lastTwoAssigneeDate, lastAccout.getAssigneeDate(), lastAccout.getTransferor(), accountId));
+                vos.add(new TransferDetailVO(lastAccout.getAssigneeDate(), endDate, lastAccout.getAssignee(), accountId));
+            }
+            vos = vos.parallelStream().filter(
+                    vo -> !vo.getStartDate().equals(vo.getEndDate())
+            ).collect(Collectors.toList());
+        }
+        return vos;
+    }
+
+    @Override
+    public List<JSONObject> getOperateGroupAccountByUser(JSONObject requestBody) {
+        String userId=requestBody.getString("userId");
+        int year= requestBody.getInteger("year");
+        String quarter=requestBody.getString("quarter");
+        int mediaType=requestBody.getInteger("mediaType");
+        String startDate= year+"-"+ PeriodConstant.valueOf(quarter).getStart();
+        String endDate= year+"-"+PeriodConstant.valueOf(quarter).getEnd();
+        List<JSONObject> result=new ArrayList<>();
+        if(mediaType==CtopAdConstant.PLATFORM_TYPE_BYTEDANCE_INT){
+            result=operateDetailMapper.ByteDanceOperateDetailGroupAccountByDate(startDate,endDate,userId);
+        }else if(mediaType==CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT){
+            result=operateDetailMapper.kuaiShouOperateDetailGroupAccountByDate(startDate,endDate,userId);
+        }
+        return result;
+    }
+}

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

@@ -0,0 +1,81 @@
+package org.jeecg.modules.performance.service.impl;
+
+import cn.com.ctop.common.module.entity.SysCompany;
+import cn.com.ctop.common.module.service.ISysCompanyService;
+import cn.com.ctop.common.module.service.ISysRoleService;
+import cn.com.ctop.common.module.utils.CtopMediaTypeUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
+import org.jeecg.modules.performance.service.IPerformanceInfoService;
+import org.jeecg.modules.performance.service.IPerformanceQuarterService;
+import org.jeecg.modules.system.service.ISysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *  Created by JQ.bi on 2020.6.10
+ */
+@Service
+public class PerformanceInfoInfoServiceImpl implements IPerformanceInfoService {
+
+    @Autowired
+    ISysCompanyService sysCompanyService;
+    @Autowired
+    ISysRoleService sysRoleService;
+    @Autowired
+    ISysUserService sysUserService;
+    @Autowired
+    ProjectMemberMapper projectMemberMapper;
+    @Autowired
+    IPerformanceQuarterService performanceQuarterService;
+
+    @Override
+    public Map<String, Object> getPerformanceInfo() {
+
+        Map<String,Object> result= new HashMap<>();
+        //获取公司名称
+        result.put("company",this.getCompany());
+        //部门
+        result.put("depart",this.getDepart());
+        //获取媒体类型
+        result.put("mediaType", CtopMediaTypeUtil.getMediaTypeAll());
+        //获取年份,季度
+        result.put("data",performanceQuarterService.getYearQuarter());
+        //获取职位
+        result.put("post",sysRoleService.list());
+
+        return result;
+    }
+
+    //根据权限查看绩效
+    private List<SysCompany> getCompany(){
+        List<SysCompany> result;
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = sysUser.getId();
+        Map<String,Object> role=sysUserService.queryRoleCode(userId);
+        if(role.get("roleName").equals("管理员")){
+            result=sysCompanyService.list();
+        }else {
+            String companyId=projectMemberMapper.getCompanyIdByUserId(userId);
+            QueryWrapper<SysCompany> queryWrapper= new QueryWrapper<>();
+            queryWrapper.eq("company_id",companyId);
+            result= sysCompanyService.list(queryWrapper);
+        }
+        return result;
+    }
+    //TODO 部门暂时写死
+    private List<String> getDepart(){
+        List<String> depart=new ArrayList<>();
+        depart.add("运营部");
+        depart.add("设计部");
+        depart.add("销售部");
+        return depart;
+    }
+}

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

@@ -0,0 +1,109 @@
+package org.jeecg.modules.performance.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.modules.performance.entity.PerformanceQuarter;
+import org.jeecg.modules.performance.mapper.PerformanceQuarterMapper;
+import org.jeecg.modules.performance.service.IPerformanceQuarterService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+@Service
+public class PerformanceQuarterServiceImpl extends ServiceImpl<PerformanceQuarterMapper, PerformanceQuarter> implements IPerformanceQuarterService {
+
+    @Autowired
+    PerformanceQuarterMapper performanceQuarterMapper;
+
+    /**
+     *  获取绩效表里有的年份季度
+     *
+     */
+    @Override
+    public Map<String, Set<String>> getYearQuarter() {
+        Map<String, Set<String>> result= new HashMap<>();
+        List<JSONObject> jsonObjectList=performanceQuarterMapper.queryYearAndQuarter();
+        if(jsonObjectList.isEmpty()){
+            return result;
+        }
+        jsonObjectList.forEach(it->{
+            if(result.get(it.getInteger("year").toString())==null){
+                Set<String> quarter= new HashSet<>();
+                quarter.add(it.getString("quarter"));
+                result.put(it.getInteger("year").toString(),quarter);
+            }else {
+                result.get(it.getInteger("year").toString()).add(it.getString("quarter"));
+            }
+        });
+        return result;
+    }
+
+    @Override
+    public List<PerformanceQuarter> getPerformanceByConditions(JSONObject requestBody) {
+        QueryWrapper<PerformanceQuarter> quarterWrapper=new QueryWrapper<>();
+        String[] columns={"user_id","user_name","company_name","role_name","media_type","year","quarter","cost","point","performance","additional_fees"};
+        quarterWrapper.select(columns);
+        Map<String,Object> map = new HashMap<>(10);
+        if(!requestBody.getString("company").equals("")) {
+            map.put("company_id",requestBody.getString("company"));
+        }
+        if(!requestBody.getString("department").equals("")) {
+            map.put("department",requestBody.getString("department"));
+        }
+        if(requestBody.getInteger("mediaType")!=0) {
+            map.put("media_type",requestBody.getInteger("mediaType"));
+        }
+        if(requestBody.getInteger("year")!=0) {
+            map.put("year",requestBody.getInteger("year"));
+        }
+        if(!requestBody.getString("quarter").equals("")) {
+            map.put("quarter",requestBody.getString("quarter"));
+        }
+        if(!requestBody.getString("roleCode").equals("")) {
+            map.put("role_code",requestBody.getString("roleCode"));
+        }
+        quarterWrapper.allEq(map);
+        quarterWrapper.like("user_name",requestBody.getString("userName"));
+        return performanceQuarterMapper.selectList(quarterWrapper);
+    }
+
+    @Override
+    public PageInfo<PerformanceQuarter> getPerformanceByConditionsPage(int pageNo, int pageSize, String order,JSONObject requestBody) {
+        QueryWrapper<PerformanceQuarter> quarterWrapper=new QueryWrapper<>();
+        String[] columns={"user_id","user_name","company_name","department","role_name","media_type","year","quarter","cost","point","performance","additional_fees"};
+        quarterWrapper.select(columns);
+        Map<String,Object> map = new HashMap<>(16);
+        if(!requestBody.getString("company").equals("")) {
+            map.put("company_id",requestBody.getString("company"));
+        }
+        if(!requestBody.getString("department").equals("")) {
+            map.put("department",requestBody.getString("department"));
+        }
+        if(requestBody.getInteger("mediaType")!=0) {
+            map.put("media_type",requestBody.getInteger("mediaType"));
+        }
+        if(requestBody.getInteger("year")!=0) {
+            map.put("year",requestBody.getInteger("year"));
+        }
+        if(!requestBody.getString("quarter").equals("")) {
+            map.put("quarter",requestBody.getString("quarter"));
+        }
+        if(!requestBody.getString("roleCode").equals("")) {
+            map.put("role_code",requestBody.getString("roleCode"));
+        }
+        quarterWrapper.allEq(map);
+        quarterWrapper.like("user_name",requestBody.getString("userName"));
+        if(order.equals("asc"))
+            quarterWrapper.orderByAsc("cost");
+        else
+            quarterWrapper.orderByDesc("cost");
+        PageHelper.startPage(pageNo,pageSize);
+        List<PerformanceQuarter> maps = performanceQuarterMapper.selectList(quarterWrapper);
+        return (PageInfo<PerformanceQuarter>) new PageInfo(maps);
+    }
+
+}

+ 35 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/testCtrl.java

@@ -0,0 +1,35 @@
+package org.jeecg.modules.performance;
+
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.performance.service.ICalculatePerformanceService;
+import org.jeecg.modules.performance.service.IOperateDetailService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+
+@RestController
+public class testCtrl {
+
+    @Autowired
+    IOperateDetailService operateDetailService;
+
+    @Autowired
+    ICalculatePerformanceService  calculatePerformanceService;
+
+    @GetMapping("/job/test/operator")
+    public String testOperator(){
+/*
+        Date nowDate= new Date();
+
+        String startStatDate = DateUtils.getQuarterStartDate(nowDate);
+        String endStatDate = DateUtils.getQuarterEndDate(nowDate);
+
+        operateDetailService.KsCostCalculateByAccount(startStatDate,endStatDate);
+        operateDetailService.BtCostCalculateByAccount(startStatDate,endStatDate);*/
+        calculatePerformanceService.CalculateOperatePerformance(2020,"Q2",2);
+        return "success";
+    }
+
+}

+ 32 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/vo/TransferDetailVO.java

@@ -0,0 +1,32 @@
+package org.jeecg.modules.performance.vo;
+
+import lombok.Data;
+
+@Data
+public class TransferDetailVO {
+    private String startDate;
+    private String endDate;
+    private String userId;
+    private Long accountId;
+
+    public TransferDetailVO() {
+
+    }
+
+    public TransferDetailVO(String startDate, String endDate, String userId, Long accountId) {
+        this.startDate = startDate;
+        this.endDate = endDate;
+        this.userId = userId;
+        this.accountId = accountId;
+    }
+
+    @Override
+    public String toString() {
+        return "TransferDetailVO{" +
+                "startDate='" + startDate + '\'' +
+                ", endDate='" + endDate + '\'' +
+                ", userId='" + userId + '\'' +
+                ", accountId=" + accountId +
+                '}';
+    }
+}

+ 26 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysUserRoleMapper.java

@@ -18,4 +18,30 @@ public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
 
 	@Select("select role_code from sys_role where id in (select role_id from sys_user_role where user_id = (select id from sys_user where username=#{username}))")
 	List<String> getRoleByUserName(@Param("username") String username);
+
+	@Select("SELECT\n" +
+			"\tt3.user_id\n" +
+			"FROM\n" +
+			"\t(\n" +
+			"\t\tSELECT\n" +
+			"\t\t\tt2.user_id,\n" +
+			"\t\t\tt2.role_id\n" +
+			"\t\tFROM\n" +
+			"\t\t\tsys_user_depart t1\n" +
+			"\t\tLEFT JOIN sys_user_role t2 ON t1.user_id = t2.user_id\n" +
+			"\t\tWHERE\n" +
+			"\t\t\tt1.dep_id = (\n" +
+			"\t\t\t\tSELECT\n" +
+			"\t\t\t\t\tdep_id\n" +
+			"\t\t\t\tFROM\n" +
+			"\t\t\t\t\tsys_user_depart\n" +
+			"\t\t\t\tWHERE\n" +
+			"\t\t\t\t\tuser_id = #{userId}\n" +
+			"\t\t\t)\n" +
+			"\t) t3\n" +
+			"LEFT JOIN sys_role t4 ON t3.role_id = t4.id\n" +
+			"WHERE\n" +
+			"\tt4.role_code =  #{roleCode}\n")
+	String getLeaderIdByUser(@Param("userId") String userId, @Param("roleCode") String roleCode);
+
 }

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserRoleService.java

@@ -22,4 +22,7 @@ public interface ISysUserRoleService extends IService<SysUserRole> {
 	Map<String,String> queryUserRole();
 
 	SysUserRole getUserRoleByUserId(String userId);
+
+	String getLeaderId(String userId, String roleCode);
+
 }

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

@@ -1,6 +1,7 @@
 package org.jeecg.modules.system.service.impl;
 
 import cn.com.ctop.common.module.entity.SysRole;
+import cn.com.ctop.common.module.mapper.SysRoleMapper;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -31,7 +32,10 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
 	private ISysUserService userService;
 	@Autowired
 	private ISysRoleService roleService;
-
+	@Autowired
+	private SysUserRoleMapper roleMapper;
+	@Autowired
+	private SysRoleMapper sysRoleMapper;
 	/**
 	 * 查询所有用户对应的角色信息
 	 */
@@ -83,4 +87,14 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
 		}
 	}
 
+	@Override
+	public String getLeaderId(String userId, String roleCode) {
+		String roleCodeStr = sysRoleMapper.getRoleCodeByUserId(userId);
+		if ("kuaishouOperationManager".equals(roleCodeStr) || "touTiaoOperationManager".equals(roleCodeStr)) {
+			return null;
+		}
+		String leaderId = roleMapper.getLeaderIdByUser(userId, roleCode);
+		return leaderId;
+	}
+
 }

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

@@ -94,16 +94,16 @@ spring:
         filters: stat,slf4j
         # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
-      #      datasource:
-      #        master:
-      #          url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
-      #          username: hcst
-      #          password: test@20190531
       datasource:
         master:
           url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
           username: hcst
           password: test@20190531
+#      datasource:
+#        master:
+#          url: jdbc:mysql://39.97.120.42:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+#          username: hcst
+#          password: test@20190531
           driver-class-name: com.mysql.jdbc.Driver
   #redis 配置
   redis:

+ 56 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/SysCompany.java

@@ -0,0 +1,56 @@
+package cn.com.ctop.common.module.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Objects;
+
+@Data
+@TableName("sys_company")
+public class SysCompany {
+
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    private String companyId;
+
+    private String companyCode;
+
+    private String companyName;
+
+    private String area;
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        SysCompany that = (SysCompany) o;
+        return id.equals(that.id) &&
+                companyId.equals(that.companyId) &&
+                companyCode.equals(that.companyCode) &&
+                companyName.equals(that.companyName) &&
+                area.equals(that.area);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, companyId, companyCode, companyName, area);
+    }
+
+    @Override
+    public String toString() {
+        return "SysCompany{" +
+                "id=" + id +
+                ", companyId='" + companyId + '\'' +
+                ", companyCode='" + companyCode + '\'' +
+                ", companyName='" + companyName + '\'' +
+                ", area='" + area + '\'' +
+                '}';
+    }
+
+}

+ 8 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/SysCompanyMapper.java

@@ -0,0 +1,8 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.SysCompany;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+public interface SysCompanyMapper extends BaseMapper<SysCompany> {
+
+}

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysCompanyMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.common.module.mapper.SysCompanyMapper">
+
+</mapper>

+ 7 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/ISysCompanyService.java

@@ -0,0 +1,7 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.SysCompany;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+public interface ISysCompanyService  extends IService<SysCompany> {
+}

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

@@ -24,4 +24,6 @@ public interface IUserAllocationService extends IService<UserAllocation> {
     Map<String, Object> getPangolinProjectListByParams(String userId);
 
     List<UserAllocation> selectAccountListByProjectId(Long projectId);
+
+    List<UserAllocation> getByMediaId(String mediaId);
 }

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

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.SysCompany;
+import cn.com.ctop.common.module.mapper.SysCompanyMapper;
+import cn.com.ctop.common.module.service.ISysCompanyService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SysCompanyServiceImpl extends ServiceImpl<SysCompanyMapper, SysCompany> implements ISysCompanyService {
+}

+ 9 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -88,5 +88,13 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
         return list;
     }
 
-
+    @Override
+    public List<UserAllocation> getByMediaId(String mediaId) {
+        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
+        if ("".equals(mediaId)) {
+            queryWrapper.eq("media_id", mediaId);
+        }
+        queryWrapper.orderByDesc("id");
+        return this.list(queryWrapper);
+    }
 }

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

@@ -11,7 +11,7 @@ public class CtopAdConstant {
     public static final  int PLATFORM_TYPE_BYTEDANCE_INT = 1;
     //快手
     public static final String PLATFORM_TYPE_KUAISHOU = "2";
-    public static final  int PLATFORM_TYPE_KUAISHOU_INT = 2;
+    public static final  int   PLATFORM_TYPE_KUAISHOU_INT = 2;
     //头条内广
     public static final String PLATFORM_TYPE_BYTEDANCE_INSIDE = "3";
     public static final  int PLATFORM_TYPE_BYTEDANCE_INSIDE_INT = 3;

+ 42 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/CtopMediaTypeUtil.java

@@ -0,0 +1,42 @@
+package cn.com.ctop.common.module.utils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *  Created by JQ.bi on 2020.6.10
+ */
+public class CtopMediaTypeUtil {
+
+    /**
+     *  获取全部媒体类型
+     */
+    public static List<Map<String,Object>>  getMediaTypeAll(){
+
+        List<Map<String,Object>> mediaType= new ArrayList<>();
+        Map<String,Object> byteDance= new HashMap<>();
+        byteDance.put("code","PLATFORM_TYPE_BYTEDANCE");
+        byteDance.put("num",1);
+        byteDance.put("name","头条");
+        Map<String,Object> kuaiShou= new HashMap<>();
+        kuaiShou.put("code","PLATFORM_TYPE_KUAISHOU");
+        kuaiShou.put("num",2);
+        kuaiShou.put("name","快手");
+        Map<String,Object> byteDanceInside= new HashMap<>();
+        byteDanceInside.put("code","PLATFORM_TYPE_BYTEDANCE_INSIDE");
+        byteDanceInside.put("num",3);
+        byteDanceInside.put("name","头条内广");
+        Map<String,Object> kuaiShouInside= new HashMap<>();
+        kuaiShouInside.put("code","PLATFORM_TYPE_KUAISHOU_INSIDE");
+        kuaiShouInside.put("num",4);
+        kuaiShouInside.put("name","快手内广");
+        mediaType.add(byteDance);
+        mediaType.add(byteDanceInside);
+        mediaType.add(kuaiShou);
+        mediaType.add(kuaiShouInside);
+
+        return mediaType;
+    }
+}

+ 7 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java

@@ -1,11 +1,18 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouReportDailyAccount> {
+
     void loadAccountDailyReport(@Param("accountId") Long accountId, @Param("localPath") String localPath);
 
     void insertSelective(KuaishouReportDailyAccount dailyAccount);
+
+    List<JSONObject> selectCost(@Param("accountId") Long accountId, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
 }

+ 12 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml

@@ -491,4 +491,16 @@
         )
           set account_id = #{accountId}
     </insert>
+
+    <select id="selectCost" resultType="com.alibaba.fastjson.JSONObject">
+        select
+            sum(charge) cost,
+            stat_date statDate
+        from ctop_kuaishou_report_daily_account
+        where account_id = #{accountId}
+          and stat_date &gt;= #{startDate}
+          and stat_date &lt; #{endDate}
+        group by stat_date
+    </select>
+
 </mapper>

+ 6 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAccountService.java

@@ -1,7 +1,13 @@
 package cn.com.ctop.kuaishou.modules.report.service;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 public interface IKuaishouReportDailyAccountService extends IService<KuaishouReportDailyAccount> {
+
+    List<JSONObject> selectCost(Long accountId, String startDate, String endDate);
+
 }

+ 12 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAccountServiceImpl.java

@@ -3,9 +3,21 @@ package cn.com.ctop.kuaishou.modules.report.service.impl;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAccountService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouReportDailyAccountMapper, KuaishouReportDailyAccount> implements IKuaishouReportDailyAccountService {
+
+    @Autowired
+    private KuaishouReportDailyAccountMapper dailyAccountMapper;
+
+    @Override
+    public List<JSONObject> selectCost(Long accountId, String startDate, String endDate) {
+        return dailyAccountMapper.selectCost(accountId, startDate, endDate);
+    }
 }