Ver Fonte

Merge remote-tracking branch 'origin/test' into test

syh há 4 anos atrás
pai
commit
3e650022a9
38 ficheiros alterados com 1856 adições e 265 exclusões
  1. 11 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialAscriptionController.java
  2. 3 31
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MediaReportCtrl.java
  3. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/MediaReportMapper.java
  4. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MaterialTopMapper.xml
  5. 20 8
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MediaReportMapper.xml
  6. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IMediaReportService.java
  7. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MediaReportServiceImpl.java
  8. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vo/MaterialTopVO.java
  9. 6 6
      module-check/src/main/java/cn/com/ctop/check/component/execute/GroovyScriptExecutor.java
  10. 16 0
      module-check/src/main/java/cn/com/ctop/notice/handler/SendWeChatHandle.java
  11. 95 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/OauthAgentToken.java
  12. 15 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/OauthAgentTokenMapper.java
  13. 0 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialAscriptionMapper.xml
  14. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/OauthAgentTokenMapper.xml
  15. 3 1
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java
  16. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialAscriptionService.java
  17. 14 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IOauthAgentTokenService.java
  18. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IRefreshTokenService.java
  19. 63 3
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  20. 8 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialAscriptionServiceImpl.java
  21. 19 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/OauthAgentTokenServiceImpl.java
  22. 25 4
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RefreshTokenServiceImpl.java
  23. 120 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java
  24. 1 1
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/CheckDataStateJob.java
  25. 1 1
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/CheckExecuteStateJob.java
  26. 25 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouRefreshAgentTokenJob.java
  27. 28 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouTodayAgentReportJob.java
  28. 29 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouYesterdayAgentReportJob.java
  29. 386 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaiShouDailyAgentController.java
  30. 204 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaiShouDailyAgent.java
  31. 146 139
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAgent.java
  32. 93 61
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAgentSum.java
  33. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/ParamsDTO.java
  34. 26 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaiShouDailyAgentMapper.java
  35. 301 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouDailyAgentMapper.xml
  36. 26 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaiShouDailyAgentService.java
  37. 150 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaiShouDailyAgentServiceImpl.java
  38. 5 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAgentServiceImpl.java

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

@@ -3,6 +3,7 @@ package org.jeecg.modules.ctop.controller;
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.entity.MaterialAscription;
 import cn.com.ctop.common.module.service.IMaterialAscriptionService;
+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;
@@ -57,6 +58,16 @@ public class MaterialAscriptionController {
         return result;
     }
 
+
+    @GetMapping(value = "/getDetail")
+    public Result<JSONObject> getDetail(String code) {
+        Result<JSONObject> result = new Result<>();
+        JSONObject json = materialAscriptionService.getDetailByCode(code);
+        result.setSuccess(true);
+        result.setResult(json);
+        return result;
+    }
+
     /**
      * 添加
      *

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

@@ -82,7 +82,7 @@ public class MediaReportCtrl {
         Result<List<Product>> result = new Result();
 
         try {
-            List<Product> allProductList = mediaReportService.getAllProductList(requestBody.getInteger("mediaType"));
+            List<Product> allProductList = mediaReportService.getAllProductList(requestBody.getInteger("mediaType"), requestBody.getString("advertiserId"));
             result.setResult(allProductList);
         }catch (Exception e){
             log.error(e.getMessage());
@@ -190,24 +190,6 @@ public class MediaReportCtrl {
         return result;
     }
 
-
-    //@PostMapping("/{pageNum}/{pageSize}")
-    //public Result<PageInfo<JSONObject>> toutiaoMediaReport(@PathVariable int pageNum,
-    //                                              @PathVariable int pageSize,
-    //                                              @RequestBody JSONObject requestBody){
-    //    Result<PageInfo<JSONObject>> result = new Result<>();
-    //    if(requestBody.isEmpty()){
-    //        log.error("requestBody is null");
-    //        result.setSuccess(false);
-    //        return result;
-    //    }
-    //    PageInfo<JSONObject> pageInfo =mediaReportService.toutiaoMediaReport(pageNum ,pageSize,requestBody);
-    //
-    //    result.setResult(pageInfo);
-    //    result.setSuccess(true);
-    //    return result;
-    //}
-
     /**
      *  导出数据
      * @param requestBody
@@ -215,15 +197,9 @@ public class MediaReportCtrl {
      * @param response
      */
     @PostMapping("/exportMediaReportExcel")
-    public Result exportMediaReportExcel(@RequestBody JSONObject requestBody,
+    public void exportMediaReportExcel(@RequestBody JSONObject requestBody,
                                HttpServletRequest request,
                                HttpServletResponse response) {
-        Result result = new Result();
-        if(StringUtils.isBlank(requestBody.getString("todayDate")) || requestBody.getInteger("mediaType") ==null){
-            result.setSuccess(false);
-            result.setMessage("参数有误");
-        }
-
         String today = requestBody.getString("todayDate");
         Date todayDate = DateUtils.parseDate(today, "yyyy-MM-dd");
         Date yesterdayDate = DateUtils.addDay(todayDate, -1);
@@ -235,10 +211,8 @@ public class MediaReportCtrl {
         excelData.forEach(data->{
             List<Object> temp= new ArrayList<>();
             temp.add(data.get("mediaType")==null?"-":(data.getInteger("mediaType")==1?"头条":"快手"));
-            //temp.add(data.get("advertiserId")==null?"-":data.get("advertiserId"));
             temp.add(data.get("advertiserName")==null?"-":data.get("advertiserName"));
             temp.add(data.get("productName")==null?"-":data.get("productName"));
-            //temp.add(data.get("operatorManger")==null?"-":data.get("operatorManger"));
             temp.add(data.get("operator")==null?"-":data.get("operator"));
             temp.add(data.get("sale")==null?"-":data.get("sale"));
             temp.add(data.get("todayCost"));
@@ -252,17 +226,15 @@ public class MediaReportCtrl {
             OutputStream os = response.getOutputStream();
             ExportExcelUtils eeu = new ExportExcelUtils();
             XSSFWorkbook workbook = new XSSFWorkbook();
-            eeu.exportExcel(workbook, 0, "媒介报表", headers, excelList);
+            eeu.exportExcelForMediaReport(workbook, 0, "媒介报表", headers, excelList);
             HttpUtils.setResponseHeader(response, "媒介报表.xlsx");
             workbook.write(os);
             os.flush();
             os.close();
         }catch (IOException e){
             log.error(e.getMessage());
-            result.setSuccess(false);
         }
 
-        return result;
     }
 
 

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

@@ -23,6 +23,6 @@ public interface MediaReportMapper {
     //头条媒介报表
     List<JSONObject> toutiaoMediaReport(@Param("today") String today ,@Param("yesterday") String yesterday, @Param("advertiserId") String advertiserId, @Param("companyId")String companyId, @Param("productId")Long productId);
 
-    List<Product> getAllProductList(@Param("mediaType")Integer mediaType);
+    List<Product> getAllProductList(@Param("mediaType")Integer mediaType, @Param("advertiserId")String advertiserId);
 
 }

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

@@ -3,6 +3,7 @@
 <mapper namespace="org.jeecg.modules.ctop.mapper.MaterialTopMapper">
     <select id="selectMapsPage" resultType="org.jeecg.modules.ctop.vo.MaterialTopVO">
         SELECT
+            code,
             url,
             cover_url,
             name,

+ 20 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MediaReportMapper.xml

@@ -273,9 +273,9 @@
         productName,
         sale,
         operator,
-        todayCost,
-        yesterdayCost,
-        ( todayCost - yesterdayCost ) AS diffCost,
+        format(todayCost,3) as todayCost,
+        format(yesterdayCost,3) as yesterdayCost,
+        format(( todayCost - yesterdayCost ),3) AS diffCost,
         companyName
         FROM
                 (
@@ -343,7 +343,11 @@
                                     AND report.stat_date = #{yesterday}
                              )
                         ,0) AS yesterdayCost,
-                    d.company_name AS companyName
+                        case
+                            when d.company_id = 'd57fecdcf7a94d009736d9c850731582' then '华北'
+                            when d.company_id = '6608ed13c0dd42de93c790dbdf124234' then '华南'
+                            when d.company_id = '4b10089775c040119e139087517aed88' then '华东'
+                            else '-' end AS companyName
                     FROM
                         ctop_product a
                         LEFT JOIN ctop_product_project_map b ON a.id = b.product_id
@@ -351,6 +355,7 @@
                         LEFT JOIN user_company d ON c.user_id = d.user_id
                     WHERE
                         d.company_id IS NOT NULL
+                        AND a.product_status = 1
                         AND a.media_id = 2
                         <if test="advertiserId != null and advertiserId != ''">
                         AND a.advertiser_id = #{advertiserId}
@@ -376,9 +381,9 @@
         productName,
         sale,
         operator,
-        todayCost,
-        yesterdayCost,
-        ( todayCost - yesterdayCost ) AS diffCost,
+        format(todayCost,2) as todayCost,
+        format(yesterdayCost,2) as yesterdayCost,
+        format(( todayCost - yesterdayCost ),2) AS diffCost,
         companyName
         FROM
             (
@@ -446,7 +451,10 @@
                             )
                             AND date_format( report.stat_datetime, '%Y-%m-%d' ) = #{yesterday}
                             ),0) AS yesterdayCost,
-                    d.company_name AS companyName
+                    case when d.company_id = 'd57fecdcf7a94d009736d9c850731582' then '华北'
+                         when d.company_id = '6608ed13c0dd42de93c790dbdf124234' then '华南'
+                         when d.company_id = '4b10089775c040119e139087517aed88' then '华东'
+                         else '-' end AS companyName
                 FROM
                     ctop_product a
                     LEFT JOIN ctop_product_project_map b ON a.id = b.product_id
@@ -455,6 +463,7 @@
                 WHERE
                     d.company_id IS NOT NULL
                     AND a.media_id = 1
+                    AND a.product_status = 1
                     <if test="advertiserId != null and advertiserId != ''">
                         AND a.advertiser_id = #{advertiserId}
                     </if>
@@ -484,6 +493,9 @@
         <if test="mediaType != null">
             and media_id = #{mediaType}
         </if>
+        <if test="advertiserId != null">
+            and advertiser_id = #{advertiserId}
+        </if>
     </select>
 
 </mapper>

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

@@ -12,7 +12,7 @@ public interface IMediaReportService {
 
     List<JSONObject> queryProjectNameByAdvertiserId(String advertiserId);
 
-    List<Product> getAllProductList(Integer mediaType);
+    List<Product> getAllProductList(Integer mediaType, String advertiserId);
 
     PageInfo<JSONObject> queryReportByCondition(int pageNo,int pageSize,JSONObject requestBody);
 

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

@@ -30,8 +30,8 @@ public class MediaReportServiceImpl implements IMediaReportService {
     }
 
     @Override
-    public List<Product> getAllProductList(Integer mediaType){
-        return mediaReportMapper.getAllProductList(mediaType);
+    public List<Product> getAllProductList(Integer mediaType, String advertiserId){
+        return mediaReportMapper.getAllProductList(mediaType, advertiserId);
     }
 
 

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vo/MaterialTopVO.java

@@ -6,6 +6,7 @@ import java.math.BigDecimal;
 
 @Data
 public class MaterialTopVO {
+    private String code;
     private String url;
     private String coverUrl;
     private String name ;

+ 6 - 6
module-check/src/main/java/cn/com/ctop/check/component/execute/GroovyScriptExecutor.java

@@ -53,7 +53,7 @@ public class GroovyScriptExecutor {
         if(script.getIsDelete()||!script.getExeState()){
             return Result.error(String.format("groovy script is invalid. api_name=%s", script.getApiName()));
         }else {
-            return executescriptScript(script);
+            return executeScript(script);
         }
     }
 
@@ -62,11 +62,11 @@ public class GroovyScriptExecutor {
         if (script == null) {
             return Result.error(String.format("groovy script not found. api_name=%s", apiName));
         }else {
-            return executescriptScript(script);
+            return executeScript(script);
         }
     }
 
-    private Result<Object> executescriptScript(CtopCheckTaskList taskList){
+    private Result<Object> executeScript(CtopCheckTaskList taskList){
         ClearCache();
         GroovyCodeSource groovyCodeSource = getGroovyCodeSource(taskList);
         Result<Object> response = null;
@@ -81,9 +81,9 @@ public class GroovyScriptExecutor {
                 scriptInstance.setCtopCheckTaskList(taskList);
                 response = scriptInstance.exec();
             } else {
-                scriptProcessLogExecutor.insertLogExecute(taskList,0L,0L,false,false);
-                log.error("script script should extends Abstractscript.");
-                response=Result.error("script script should extends Abstractscript.");
+                scriptProcessLogExecutor.insertLogExecute(taskList,start,0L,false,false);
+                log.error("script script should extends AbstractScript.");
+                response=Result.error("script script should extends AbstractScript.");
             }
             long end=System.currentTimeMillis();
             scriptProcessLogExecutor.insertLogExecute(taskList,start,end);

+ 16 - 0
module-check/src/main/java/cn/com/ctop/notice/handler/SendWeChatHandle.java

@@ -6,6 +6,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Arrays;
+import java.util.List;
+
 @Slf4j
 @Service
 public class SendWeChatHandle {
@@ -25,4 +28,17 @@ public class SendWeChatHandle {
         }
         return result;
     }
+
+    public void SendWeChatByMails(String mails,String message){
+        List<String> mail= Arrays.asList(mails.split(","));
+        mail.forEach(m->{
+            String weChatId=mailLogMapper.getWeChatByMail(m);
+            if(weChatId.isEmpty()){
+                log.error(String.format("mail's WeChat not found. mail =%s", m));
+                //TODO 通知管理员添加邮箱
+            }else{
+                CorpWexinUtils.sendMessageByWeChatId(weChatId,message);
+            }
+        });
+    }
 }

+ 95 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/OauthAgentToken.java

@@ -0,0 +1,95 @@
+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 com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 代理商token
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-08-18
+ */
+@Data
+@TableName("ctop_oauth_agent_token")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_oauth_agent_token对象", description = "代理商token")
+public class OauthAgentToken {
+
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "主键ID")
+    private String id;
+    /**
+     * 媒体ID(外部广告平台类型,快手/头条/抖音等)
+     */
+    @Excel(name = "媒体ID(外部广告平台类型,快手/头条/抖音等)", width = 15)
+    @ApiModelProperty(value = "媒体ID(外部广告平台类型,快手/头条/抖音等)")
+    private String mediaId;
+
+    private Long agentId;
+    /**
+     * 访问令牌
+     */
+    @Excel(name = "访问令牌", width = 15)
+    @ApiModelProperty(value = "访问令牌")
+    private String accessToken;
+    /**
+     * 访问令牌有效期
+     */
+    @Excel(name = "访问令牌有效期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "访问令牌有效期")
+    private Date accessTokenExpiresIn;
+    /**
+     * 刷新令牌
+     */
+    @Excel(name = "刷新令牌", width = 15)
+    @ApiModelProperty(value = "刷新令牌")
+    private String refreshToken;
+    /**
+     * 刷新令牌有效期
+     */
+    @Excel(name = "刷新令牌有效期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "刷新令牌有效期")
+    private Date refreshTokenExpiresIn;
+    /**
+     * 代理商类型 0:三方代理商 1:本代理商
+     */
+    @Excel(name = "代理商类型 0:三方代理商 1:本代理商", width = 15)
+    @ApiModelProperty(value = "代理商类型 0:三方代理商 1:本代理商")
+    private Integer agentType;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.OauthAgentToken;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 代理商token
+ *
+ * @author: jeecg-boot
+ * @date: 2020-08-18
+ * @cersion: V1.0
+ */
+public interface OauthAgentTokenMapper extends BaseMapper<OauthAgentToken> {
+
+}

+ 0 - 1
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialAscriptionMapper.xml

@@ -3,7 +3,6 @@
 <mapper namespace="cn.com.ctop.common.module.mapper.MaterialAscriptionMapper">
 
     <select id="selectByMaterialId" resultType="com.alibaba.fastjson.JSONObject">
-
     select
       (case
         when clip_id != ""

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

+ 3 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java

@@ -20,7 +20,7 @@ public interface ICtopOauthTokenService extends IService<CtopOauthToken> {
 
     Map<String, Object> getByteDanceAccessToken(CtopOauthToken token);
 
-    void getKuaiShouRefreshToken(Long accountId,String token, String refreshToken, Integer agentType);
+    void getKuaiShouRefreshToken(Long accountId, String token, String refreshToken, Integer agentType);
 
     List<CtopOauthToken> getTokenListByType(String platformTypeBytedance);
 
@@ -37,4 +37,6 @@ public interface ICtopOauthTokenService extends IService<CtopOauthToken> {
     List<CtopOauthToken> getByProjectId(long projectId);
 
     CtopOauthToken selectOneByMediaId(String platformTypeKuaishou);
+
+    void getKuaiShouAgentRefreshToken(Long agentId, String accessToken, String refreshToken);
 }

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

@@ -1,6 +1,7 @@
 package cn.com.ctop.common.module.service;
 
 import cn.com.ctop.common.module.entity.MaterialAscription;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 /**
@@ -11,5 +12,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @date 2019-11-23
  */
 public interface IMaterialAscriptionService extends IService<MaterialAscription> {
+    JSONObject getDetailByCode(String code);
 
 }

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.OauthAgentToken;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 代理商token
+ * @Author: jeecg-boot
+ * @Date: 2020-08-18
+ * @Version: V1.0
+ */
+public interface IOauthAgentTokenService extends IService<OauthAgentToken> {
+
+}

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

@@ -4,4 +4,6 @@ public interface IRefreshTokenService {
     void getKuaiShouRefresh();
 
     void byteDanceRefresh(String accountId);
+
+    void getKuaiShouAgentRefresh();
 }

+ 63 - 3
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -1,7 +1,9 @@
 package cn.com.ctop.common.module.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.OauthAgentToken;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.common.module.mapper.OauthAgentTokenMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
@@ -27,6 +29,8 @@ import java.util.*;
 public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper, CtopOauthToken> implements ICtopOauthTokenService {
     @Autowired
     private CtopOauthTokenMapper ctopOauthTokenMapper;
+    @Autowired
+    private OauthAgentTokenMapper agentTokenMapper;
 
     @Override
     public CtopOauthToken getOauthTokenByAccountId(String accountId) {
@@ -62,7 +66,7 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
         String result = HttpUtils.httpPostRequest(url, param, new HashMap<>());
         System.err.println(JSONObject.parseObject(result));
         XxlJobLogger.log("头条刷新token;accountId:{},返回信息:{}", token.getAccountId(), result);
-        if(null == result||result.trim().equals("")||result.equalsIgnoreCase("null")){
+        if (null == result || result.trim().equals("") || result.equalsIgnoreCase("null")) {
             XxlJobLogger.log("头条刷新token失败;accountId:{},返回信息:{}", token.getAccountId(), result);
             resultMap.put("message", "token刷新失败");
             resultMap.put("token", token);
@@ -217,10 +221,11 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
     public List<CtopOauthToken> getToutiaoTokenByCreateTime(String createTime) {
         return ctopOauthTokenMapper.getToutiaoTokenByCreateTime(createTime);
     }
+
     @Override
     public List<CtopOauthToken> getByProjectId(long projectId) {
-        QueryWrapper<CtopOauthToken>queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("project_id",projectId).eq("account_status",0);
+        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("project_id", projectId).eq("account_status", 0);
         return this.list(queryWrapper);
     }
 
@@ -233,6 +238,61 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
         return this.getOne(tokenQueryWrapper);
     }
 
+    @Override
+    public void getKuaiShouAgentRefreshToken(Long agentId, String accessToken, String refreshToken) {
+        log.info("快手刷新token入参,token:{},refreshToken:{}", accessToken, refreshToken);
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + "/rest/openapi/oauth2/authorize/refresh_token";
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", " application/json");
+        Map<String, Object> param = new HashMap<>();
+
+        param.put("app_id", PropertiesUtils.getConfig("kuaishou_appid"));
+        param.put("secret", PropertiesUtils.getConfig("kuaishou_secret"));
+        param.put("refresh_token", refreshToken);
+        try {
+            String result = HttpUtils.httpPostRequest(url, param, headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            log.info("快手刷新代理商token返回结果:{}", refreshToken);
+            if (Check.isNull(resultJson)) {
+                log.error("快手刷新代理商token返回结果为空,token:{}", accessToken);
+                return;
+            }
+            Integer code = resultJson.getInteger("code");
+            if (null == code || code != 0) {
+                log.error("快手刷新代理商token失败,token:{},result:{}", accessToken, resultJson);
+                return;
+            }
+            JSONObject dataJson = resultJson.getJSONObject("data");
+            if (null == dataJson) {
+                log.error("快手刷新代理商token失败,token:{},result:{}", accessToken, resultJson);
+                return;
+            }
+
+            QueryWrapper<OauthAgentToken> agentTokenQueryWrapper = new QueryWrapper<>();
+            agentTokenQueryWrapper.eq("agent_id", agentId);
+            OauthAgentToken updateAgentToken = new OauthAgentToken();
+            updateAgentToken.setAccessToken(dataJson.getString("access_token"));
+            updateAgentToken.setRefreshToken(dataJson.getString("refresh_token"));
+            long accessTokenExpireIn = dataJson.getLong("access_token_expires_in") * 1000L;
+            long now = System.currentTimeMillis();
+            Date accessTokenExpireInDate = new Date(now + accessTokenExpireIn);
+            updateAgentToken.setAccessTokenExpiresIn(accessTokenExpireInDate);
+            long refreshTokenExpireIn = dataJson.getLong("refresh_token_expires_in") * 1000L;
+            Date refreshTokenExpireInDate = new Date(now + refreshTokenExpireIn);
+            updateAgentToken.setRefreshTokenExpiresIn(refreshTokenExpireInDate);
+            updateAgentToken.setUpdateTime(new Date());
+            int update = agentTokenMapper.update(updateAgentToken, agentTokenQueryWrapper);
+            if (update > 0) {
+                log.info("刷新代理商token完成");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            log.error("快手刷新代理商token失败,token{}", accessToken);
+        }
+
+
+    }
+
     private Date addSecond(Date date, int seconds) {
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(date);

+ 8 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialAscriptionServiceImpl.java

@@ -3,7 +3,9 @@ package cn.com.ctop.common.module.service.impl;
 import cn.com.ctop.common.module.entity.MaterialAscription;
 import cn.com.ctop.common.module.mapper.MaterialAscriptionMapper;
 import cn.com.ctop.common.module.service.IMaterialAscriptionService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
 
@@ -17,5 +19,11 @@ import org.springframework.stereotype.Service;
 @Service
 @Primary
 public class MaterialAscriptionServiceImpl extends ServiceImpl<MaterialAscriptionMapper, MaterialAscription> implements IMaterialAscriptionService {
+    @Autowired
+    private MaterialAscriptionMapper ascriptionMapper;
 
+    @Override
+    public JSONObject getDetailByCode(String code) {
+        return ascriptionMapper.selectByMaterialId(code);
+    }
 }

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

@@ -0,0 +1,19 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.OauthAgentToken;
+import cn.com.ctop.common.module.mapper.OauthAgentTokenMapper;
+import cn.com.ctop.common.module.service.IOauthAgentTokenService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 代理商token
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-08-18
+ */
+@Service
+public class OauthAgentTokenServiceImpl extends ServiceImpl<OauthAgentTokenMapper, OauthAgentToken> implements IOauthAgentTokenService {
+
+}

+ 25 - 4
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RefreshTokenServiceImpl.java

@@ -1,11 +1,14 @@
 package cn.com.ctop.common.module.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.OauthAgentToken;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IOauthAgentTokenService;
 import cn.com.ctop.common.module.service.IRefreshTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.xxl.job.core.log.XxlJobLogger;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +23,8 @@ public class RefreshTokenServiceImpl implements IRefreshTokenService {
     private CtopOauthTokenMapper oauthTokenMapper;
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    private IOauthAgentTokenService agentTokenService;
 
     /**
      * 获取所有token
@@ -44,20 +49,36 @@ public class RefreshTokenServiceImpl implements IRefreshTokenService {
 
     @Override
     public void byteDanceRefresh(String accountId) {
-        if(null==accountId||"".equals(accountId.trim())||accountId.equalsIgnoreCase("null")){
+        if (null == accountId || "".equals(accountId.trim()) || accountId.equalsIgnoreCase("null")) {
             List<CtopOauthToken> byteDanceOauthTokens = oauthTokenMapper.selectByteDanceTokens(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
             if (!Check.isNull(byteDanceOauthTokens)) {
                 for (CtopOauthToken oauthToken : byteDanceOauthTokens) {
                     oauthTokenService.getByteDanceAccessToken(oauthToken);
                 }
             }
-        }else{
+        } else {
             CtopOauthToken token = oauthTokenMapper.selectByAccountId(Long.parseLong(accountId));
-            if(token == null){
-                XxlJobLogger.log("未获取到账户数据,accountId:{}",accountId);
+            if (token == null) {
+                XxlJobLogger.log("未获取到账户数据,accountId:{}", accountId);
                 return;
             }
             oauthTokenService.getByteDanceAccessToken(token);
         }
     }
+
+    @Override
+    public void getKuaiShouAgentRefresh() {
+        QueryWrapper<OauthAgentToken> agentTokenQueryWrapper = new QueryWrapper<>();
+        agentTokenQueryWrapper.eq("media_id", 2);
+        List<OauthAgentToken> list = agentTokenService.list(agentTokenQueryWrapper);
+        if (!Check.isNull(list)) {
+            for (OauthAgentToken agentToken : list) {
+                oauthTokenService.getKuaiShouAgentRefreshToken(agentToken.getAgentId(), agentToken.getAccessToken(), agentToken.getRefreshToken());
+
+            }
+
+        }
+
+
+    }
 }

+ 120 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java

@@ -91,4 +91,124 @@ public class ExportExcelUtils {
             }
         }
     }
+
+    public void exportExcelForMediaReport(XSSFWorkbook workbook, int sheetNum,
+                            String sheetTitle, String[] headers, List<List<Object>> result) {
+        // 生成一个表格
+        XSSFSheet sheet = workbook.createSheet();
+        workbook.setSheetName(sheetNum, sheetTitle);
+        // 设置表格默认列宽度为20个字节
+        sheet.setDefaultColumnWidth((short) 20);
+        sheet.setColumnWidth(0, 15 * 256);
+        sheet.setColumnWidth(1, 40 * 256);
+        sheet.setColumnWidth(2, 30 * 256);
+        sheet.setColumnWidth(3, 35 * 256);
+        sheet.setColumnWidth(4, 20 * 256);
+        sheet.setColumnWidth(5, 20 * 256);
+        sheet.setColumnWidth(6, 20 * 256);
+        sheet.setColumnWidth(7, 20 * 256);
+        sheet.setColumnWidth(8, 15 * 256);
+        // 生成一个样式
+        XSSFCellStyle style = workbook.createCellStyle();
+        // 设置这些样式
+        style.setFillForegroundColor(IndexedColors.PALE_BLUE.index);
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        style.setBorderTop(BorderStyle.THIN);
+        // style.setAlignment(HorizontalAlignment.CENTER);
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
+        // 生成一个字体
+        XSSFFont font = workbook.createFont();
+        font.setColor(IndexedColors.BLACK.index);
+        font.setFontHeightInPoints((short) 12);
+        font.setBold(true);
+        // 把字体应用到当前的样式
+        style.setFont(font);
+
+        // 指定当单元格内容显示不下时自动换行
+        style.setWrapText(true);
+
+        //同一行第一个cell
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        cellStyle.setAlignment(HorizontalAlignment.CENTER);
+        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        cellStyle.setWrapText(true);
+
+        // 产生表格标题行
+        XSSFRow row = sheet.createRow(0);
+        for (int i = 0; i < headers.length; i++) {
+            XSSFCell cell = row.createCell((short) i);
+            cell.setCellStyle(style);
+            XSSFRichTextString text = new XSSFRichTextString(headers[i]);
+            cell.setCellValue(text.toString());
+        }
+        // 遍历集合数据,产生数据行
+        if (result != null) {
+            int index = 1;
+            for (List<Object> m : result) {
+                row = sheet.createRow(index);
+                int cellIndex = 0;
+
+                for (Object obj : m) {
+                    XSSFCell cell = row.createCell((short) cellIndex);
+                    if (!Check.isNull(obj)) {
+                        if (obj instanceof String) {
+                            cell.setCellValue((String) obj);
+                        } else if (obj instanceof Double) {
+                            cell.setCellValue((Double) obj);
+                        } else if (obj instanceof BigDecimal) {
+                            BigDecimal bigDecimal = (BigDecimal) obj;
+                            cell.setCellValue(bigDecimal.doubleValue());
+                        } else if (obj instanceof Long) {
+                            cell.setCellValue(String.valueOf(obj));
+                        } else {
+                            cell.setCellValue(obj.toString());
+                        }
+                    } else {
+                        cell.setCellValue(0);
+                    }
+                    cell.setCellStyle(cellStyle);
+
+                    cellIndex++;
+                }
+                index++;
+            }
+        }
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 }

+ 1 - 1
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/CheckDataStateJob.java

@@ -28,7 +28,7 @@ public class CheckDataStateJob {
     public ReturnT<String> execute(String param) throws Exception {
         //查询需要检查的任务列表
         List<CtopCheckTaskList> ctopCheckTaskList= checkTaskListService.queryExecuteList(jobName);
-        if(!ctopCheckTaskList.isEmpty()){
+        if(ctopCheckTaskList!=null){
             ctopCheckTaskList.forEach(it-> groovyScriptExecutor.execute(it));
         }
         return ReturnT.SUCCESS;

+ 1 - 1
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/CheckExecuteStateJob.java

@@ -28,7 +28,7 @@ public class CheckExecuteStateJob {
     public ReturnT<String> execute(String param) throws Exception {
         //查询需要检查的任务列表
         List<CtopCheckTaskList> ctopCheckTaskList= checkTaskListService.queryExecuteList(jobName);
-        if(!ctopCheckTaskList.isEmpty()){
+        if(ctopCheckTaskList!=null){
             ctopCheckTaskList.forEach(it-> groovyScriptExecutor.execute(it));
         }
         return ReturnT.SUCCESS;

+ 25 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouRefreshAgentTokenJob.java

@@ -0,0 +1,25 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.service.IRefreshTokenService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class KuaiShouRefreshAgentTokenJob {
+    @Autowired
+    private IRefreshTokenService refreshTokenService;
+
+    /**
+     * 刷新token
+     * @throws JobExecutionException
+     */
+    @XxlJob("kuaiShouRefreshAgentTokenJob")
+    public ReturnT<String> execute(String param) throws Exception {
+        refreshTokenService.getKuaiShouAgentRefresh();
+        return ReturnT.SUCCESS;
+    }
+}
+

+ 28 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouTodayAgentReportJob.java

@@ -0,0 +1,28 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class KuaiShouTodayAgentReportJob {
+    @Autowired
+    private IKuaiShouDailyAgentService kuaiShouDailyAgentService;
+
+    /**
+     * 快手今日日代理商报表
+     *
+     * @throws JobExecutionException
+     */
+    @XxlJob("kuaiShouTodayAgentReportJob")
+    public ReturnT<String> execute(String param) throws Exception {
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        kuaiShouDailyAgentService.getAgentReportByPage(nowDate, nowDate);
+        return ReturnT.SUCCESS;
+    }
+}
+

+ 29 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouYesterdayAgentReportJob.java

@@ -0,0 +1,29 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class KuaiShouYesterdayAgentReportJob {
+    @Autowired
+    private IKuaiShouDailyAgentService kuaiShouDailyAgentService;
+
+    /**
+     * 快手昨日代理商报表
+     *
+     * @throws JobExecutionException
+     */
+    @XxlJob("kuaiShouYesterdayAgentReportJob")
+    public ReturnT<String> execute(String param) throws Exception {
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+        kuaiShouDailyAgentService.getAgentReportByPage(yesterday, yesterday);
+        return ReturnT.SUCCESS;
+    }
+}
+

+ 386 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaiShouDailyAgentController.java

@@ -0,0 +1,386 @@
+package cn.com.ctop.kuaishou.modules.report.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouDailyAgent;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum;
+import cn.com.ctop.kuaishou.modules.report.entity.ParamsDTO;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
+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 com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * 代理商报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-08-18
+ */
+@Slf4j
+@Api(tags = "代理商报表")
+@RestController
+@RequestMapping("/agent/kuaiShouDailyAgent")
+public class KuaiShouDailyAgentController {
+    @Autowired
+    private IKuaiShouDailyAgentService kuaiShouDailyAgentService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaiShouDailyAgent
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "代理商报表-分页列表查询")
+    @ApiOperation(value = "代理商报表-分页列表查询", notes = "代理商报表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaiShouDailyAgent>> queryPageList(KuaiShouDailyAgent kuaiShouDailyAgent,
+                                                           @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                           @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                           HttpServletRequest req) {
+        Result<IPage<KuaiShouDailyAgent>> result = new Result<>();
+
+        String accountName = kuaiShouDailyAgent.getAccountName();
+        kuaiShouDailyAgent.setAccountName(null);
+
+        String corporationName = kuaiShouDailyAgent.getCorporationName();
+        kuaiShouDailyAgent.setCorporationName(null);
+
+        QueryWrapper<KuaiShouDailyAgent> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouDailyAgent, req.getParameterMap());
+        if (!Check.isNull(accountName)) {
+            queryWrapper.like("account_name", accountName);
+        }
+
+        if (!Check.isNull(corporationName)) {
+            queryWrapper.like("corporation_name", corporationName);
+        }
+
+        Page<KuaiShouDailyAgent> page = new Page<KuaiShouDailyAgent>(pageNo, pageSize);
+        IPage<KuaiShouDailyAgent> pageList = kuaiShouDailyAgentService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+
+    /**
+     * 代理商报表
+     *
+     * @param dto
+     * @return
+     */
+
+    @AutoLog(value = "公司报表")
+    @ApiOperation(value = "公司报表", notes = "公司报表")
+    @PostMapping(value = "/companyReport")
+    public Result<PageInfo<KuaishouReportDailyAgentSum>> companyReport(@RequestBody ParamsDTO dto) {
+        Result<PageInfo<KuaishouReportDailyAgentSum>> result = new Result<>();
+        String startDate = dto.getStartDate();
+        String endDate = dto.getEndDate();
+        if (StringUtils.isBlank(startDate) || StringUtils.isBlank(endDate)) {
+            result.setSuccess(false);
+            result.setMessage("时间不能为空");
+        }
+        PageHelper.startPage(dto.getPage(), dto.getPageSize());
+        List<KuaishouReportDailyAgentSum> kuaishouReportDailyAgentSumList = kuaiShouDailyAgentService.companyReport(startDate, endDate);
+        PageInfo<KuaishouReportDailyAgentSum> pageInfo = new PageInfo<>(kuaishouReportDailyAgentSumList);
+        result.setResult(pageInfo);
+        result.setSuccess(true);
+        result.setMessage("success");
+
+        return result;
+    }
+
+
+    /**
+     * @param dto
+     * @return
+     */
+    @AutoLog(value = "公司报表按时间汇总")
+    @ApiOperation(value = "公司报表按时间汇总", notes = "公司报表按时间汇总")
+    @PostMapping(value = "/companyReportSum")
+    public Result<KuaishouReportDailyAgentSum> companyReportSum(@RequestBody ParamsDTO dto) {
+        Result<KuaishouReportDailyAgentSum> result = new Result<>();
+        String startDate = dto.getStartDate();
+        String endDate = dto.getEndDate();
+        if (StringUtils.isBlank(startDate) || StringUtils.isBlank(endDate)) {
+            result.setSuccess(false);
+            result.setMessage("时间不能为空");
+            return result;
+        }
+        KuaishouReportDailyAgentSum kuaishouReportDailyAgentSum = kuaiShouDailyAgentService.companyReportSum(startDate, endDate);
+        result.setResult(kuaishouReportDailyAgentSum);
+        result.setSuccess(true);
+        result.setMessage("success");
+
+        return result;
+    }
+
+
+    /**
+     * 按天查看明细
+     *
+     * @param dto
+     * @return
+     */
+    @PostMapping(value = "/companyReportAccountDetailList")
+    public Result<PageInfo<KuaishouReportDailyAgent>> companyReportAccountDetailList(@RequestBody ParamsDTO dto) {
+        Result<PageInfo<KuaishouReportDailyAgent>> result = new Result<>();
+        String advertiserName = dto.getAdvertiserName();
+        String date = dto.getDate();
+        if (StringUtils.isBlank(date)) {
+            result.setSuccess(false);
+            result.setMessage("时间不能为空");
+            return result;
+        }
+        PageHelper.startPage(dto.getPage(), dto.getPageSize());
+        List<KuaishouReportDailyAgent> kuaishouReportDailyAgentList = kuaiShouDailyAgentService.companyReportAccountDetailList(date, advertiserName, dto.getIsExportNullData());
+        PageInfo<KuaishouReportDailyAgent> pageInfo = new PageInfo<>(kuaishouReportDailyAgentList);
+
+        result.setResult(pageInfo);
+        result.setSuccess(true);
+        result.setMessage("success");
+
+        return result;
+    }
+
+
+    @PostMapping(value = "/companyReportExportExcel")
+    public void companyReportExportExcel(@RequestBody ParamsDTO dto,
+                                         HttpServletRequest request,
+                                         HttpServletResponse response) throws Exception {
+        Result result = new Result<>();
+        result.setSuccess(true);
+        result.setMessage("success");
+
+        //公司报表
+        List<KuaishouReportDailyAgentSum> kuaishouReportDailyAgentSumList = kuaiShouDailyAgentService.companyReport(dto.getStartDate(), dto.getEndDate());
+
+        //导出excel
+        List<List<Object>> group = new ArrayList<>();
+        if (!Check.isNull(kuaishouReportDailyAgentSumList)) {
+            for (KuaishouReportDailyAgentSum sum : kuaishouReportDailyAgentSumList) {
+                List<Object> kuaishouReportDailyAgentSum = new ArrayList();
+                kuaishouReportDailyAgentSum.add(sum.getDate());  //日期
+                kuaishouReportDailyAgentSum.add(sum.getCostCampaignCount());  //有消费计划数
+                kuaishouReportDailyAgentSum.add(sum.getBalance());  //总余额
+                kuaishouReportDailyAgentSum.add(sum.getCost());  //总消耗
+                kuaishouReportDailyAgentSum.add(sum.getXianjinCost());  //现金消耗
+                kuaishouReportDailyAgentSum.add(sum.getFandianCost());  //后返消耗
+                kuaishouReportDailyAgentSum.add(sum.getKuangfanCost());  //框返消耗
+                kuaishouReportDailyAgentSum.add(sum.getJiliCost());  //激励账户消耗
+                kuaishouReportDailyAgentSum.add(sum.getXinyongCost());  //信用账户消耗
+                kuaishouReportDailyAgentSum.add(sum.getFengmianShowCount());  //封面曝光数
+                kuaishouReportDailyAgentSum.add(sum.getFengmianClickCount());  //封面点击数
+                kuaishouReportDailyAgentSum.add(sum.getSucaiShowCount());  //素材曝光数
+                kuaishouReportDailyAgentSum.add(sum.getConvertCount());  //行为数
+                BigDecimal fengmianClickRate = sum.getFengmianClickRate();
+                if (!Check.isNull(fengmianClickRate) && fengmianClickRate.compareTo(new BigDecimal(0)) != 0) {
+                    BigDecimal bigDecimal = fengmianClickRate.multiply(new BigDecimal(100)).setScale(3, BigDecimal.ROUND_HALF_UP);
+                    kuaishouReportDailyAgentSum.add(bigDecimal + "%");
+                }
+
+
+                BigDecimal convertClickRate = sum.getConvertClickRate();
+                if (!Check.isNull(convertClickRate) && convertClickRate.compareTo(new BigDecimal(0)) != 0) {
+                    BigDecimal bigDecimal2 = convertClickRate.multiply(new BigDecimal(100)).setScale(3, BigDecimal.ROUND_HALF_UP);
+                    kuaishouReportDailyAgentSum.add(bigDecimal2 + "%"); //转化点击率
+                }
+                group.add(kuaishouReportDailyAgentSum);
+            }
+        }
+
+        String[] groupHeaders = {"日期", "有消费计划数", "总余额", "总消耗", "现金消耗", "返点消耗", "框返消耗", "激励消耗", "信用消耗", "封面曝光数", "封面点击数", "素材曝光数", "行为数", "封面点击率", "转化点击率"};
+        OutputStream os = response.getOutputStream();
+        ExportExcelUtils eeu = new ExportExcelUtils();
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        eeu.exportExcel(workbook, 0, "公司日报表", groupHeaders, group);
+        this.setResponseHeader(response, "公司日报表.xlsx");
+        workbook.write(os);
+        os.flush();
+        os.close();
+
+    }
+
+    @AutoLog(value = "公司日报明细表按天导出Excel")
+    @ApiOperation(value = "公司日报明细表按天导出Excel", notes = "公司报表按天导出Excel")
+    @PostMapping(value = "/companyReportAccountDetailListExportExcel")
+    public void companyReportAccountDetailListExportExcel(@RequestBody ParamsDTO dto,
+                                                          //@RequestParam("date")String date,
+                                                          HttpServletRequest request,
+                                                          HttpServletResponse response) throws Exception {
+        Result result = new Result<>();
+        result.setSuccess(true);
+        result.setMessage("success");
+
+        //公司报表按天明细
+        List<KuaishouReportDailyAgent> kuaishouReportDailyAgentList = kuaiShouDailyAgentService.companyReportAccountDetailList(dto.getDate(), dto.getAdvertiserName(), dto.getIsExportNullData());
+
+        //导出excel
+        List<List<Object>> group = new ArrayList<>();
+        if (!Check.isNull(kuaishouReportDailyAgentList)) {
+            for (KuaishouReportDailyAgent agent : kuaishouReportDailyAgentList) {
+                List<Object> kuaishouReportDailyAgentSum = new ArrayList();
+                kuaishouReportDailyAgentSum.add(agent.getDate());  //日期
+                kuaishouReportDailyAgentSum.add(agent.getKid());  //快手id
+                kuaishouReportDailyAgentSum.add(agent.getAdvertiserName());  //广告主名称
+                kuaishouReportDailyAgentSum.add(agent.getAccountName());  //账户名称
+                // kuaishouReportDailyAgentSum.add(DateUtils.formatDate(agent.getAdvertiserCreateTime()));  //广告主创建时间
+                kuaishouReportDailyAgentSum.add(agent.getCostCampaignCount());  //有消费计划数量
+                kuaishouReportDailyAgentSum.add(agent.getBalance());  //总余额
+                kuaishouReportDailyAgentSum.add(agent.getCost());  //总消耗
+                kuaishouReportDailyAgentSum.add(agent.getChargeDayOnDayPercent());  //消耗环比
+
+                kuaishouReportDailyAgentSum.add(agent.getXianjinCost());  //现金消耗
+                kuaishouReportDailyAgentSum.add(agent.getFandianCost());  //后返消耗
+                kuaishouReportDailyAgentSum.add(agent.getKuangfanCost());  //框返消耗
+                kuaishouReportDailyAgentSum.add(agent.getJiliCost());  //激励账户消耗
+                kuaishouReportDailyAgentSum.add(agent.getXinyongCost());  //信用账户消耗
+                kuaishouReportDailyAgentSum.add(agent.getFengmianShowCount());  //封面曝光数
+                kuaishouReportDailyAgentSum.add(agent.getFengmianClickCount());  //封面点击数
+                kuaishouReportDailyAgentSum.add(agent.getSucaiShowCount());  //素材曝光数
+                kuaishouReportDailyAgentSum.add(agent.getConvertCount());  //行为数
+                kuaishouReportDailyAgentSum.add(agent.getFengmianClickRate());  //封面点击率
+                kuaishouReportDailyAgentSum.add(agent.getConvertClickRate());  //转化点击率
+                kuaishouReportDailyAgentSum.add(agent.getIndustry()); // 一级行业
+                kuaishouReportDailyAgentSum.add(agent.getSecondIndustry()); // 二级行业
+                group.add(kuaishouReportDailyAgentSum);
+            }
+        }
+
+        String[] groupHeaders = {"日期", "快手id", "广告主名称", "账户名称", "有消费计划数量", "总余额", "总消耗", "消耗环比", "现金消耗", "返点消耗", "框返消耗", "激励消耗", "信用消耗", "封面曝光数", "封面点击数", "素材曝光数", "行为数", "封面点击率", "转化点击率", "一级行业", "二级行业"};
+        OutputStream os = response.getOutputStream();
+        ExportExcelUtils eeu = new ExportExcelUtils();
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        eeu.exportExcel(workbook, 0, "公司日报明细表", groupHeaders, group);
+        this.setResponseHeader(response, "公司日报明细表.xlsx");
+        workbook.write(os);
+        os.flush();
+        os.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();
+        }
+    }
+
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaiShouDailyAgent> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaiShouDailyAgent kuaiShouDailyAgent = JSON.parseObject(deString, KuaiShouDailyAgent.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouDailyAgent, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaiShouDailyAgent> pageList = kuaiShouDailyAgentService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "代理商报表列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaiShouDailyAgent.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<KuaiShouDailyAgent> listKuaiShouDailyAgents = ExcelImportUtil.importExcel(file.getInputStream(), KuaiShouDailyAgent.class, params);
+                kuaiShouDailyAgentService.saveBatch(listKuaiShouDailyAgents);
+                return Result.ok("文件导入成功!数据行数:" + listKuaiShouDailyAgents.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("文件导入失败!");
+    }
+
+}

+ 204 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaiShouDailyAgent.java

@@ -0,0 +1,204 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+
+/**
+ * 代理商报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-08-18
+ */
+@Data
+@TableName("ctop_kuaishou_daily_agent")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_daily_agent对象", description = "代理商报表")
+public class KuaiShouDailyAgent {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 代理商id
+     */
+    @Excel(name = "代理商id", width = 15)
+    @ApiModelProperty(value = "代理商id")
+    private Long agentId;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 日期
+     */
+    @Excel(name = "日期", width = 15)
+    @ApiModelProperty(value = "日期")
+    private String dateTime;
+    /**
+     * user_id
+     */
+    @Excel(name = "user_id", width = 15)
+    @ApiModelProperty(value = "user_id")
+    private Long userId;
+    /**
+     * 广告主名称
+     */
+    @Excel(name = "广告主名称", width = 15)
+    @ApiModelProperty(value = "广告主名称")
+    private String accountName;
+    /**
+     * 总消耗(元)
+     */
+    @Excel(name = "总消耗(元)", width = 15)
+    @ApiModelProperty(value = "总消耗(元)")
+    private java.math.BigDecimal totalChargedInYuan;
+    /**
+     * 总余额(元)
+     */
+    @Excel(name = "总余额(元)", width = 15)
+    @ApiModelProperty(value = "总余额(元)")
+    private java.math.BigDecimal totalBalanceInYuan;
+    /**
+     * 现金消耗(元)
+     */
+    @Excel(name = "现金消耗(元)", width = 15)
+    @ApiModelProperty(value = "现金消耗(元)")
+    private java.math.BigDecimal realChargedInYuan;
+    /**
+     * 返点消耗(元)
+     */
+    @Excel(name = "返点消耗(元)", width = 15)
+    @ApiModelProperty(value = "返点消耗(元)")
+    private java.math.BigDecimal totalRebateRealChargedInYuan;
+    /**
+     * 框返消耗(元)
+     */
+    @Excel(name = "框返消耗(元)", width = 15)
+    @ApiModelProperty(value = "框返消耗(元)")
+    private java.math.BigDecimal contractRebateRealChargedInYuan;
+    /**
+     * 激励消耗(元)
+     */
+    @Excel(name = "激励消耗(元)", width = 15)
+    @ApiModelProperty(value = "激励消耗(元)")
+    private java.math.BigDecimal directRebateRealChargedInYuan;
+    /**
+     * 信用消耗(元)
+     */
+    @Excel(name = "信用消耗(元)", width = 15)
+    @ApiModelProperty(value = "信用消耗(元)")
+    private java.math.BigDecimal creditRealChargedInYuan;
+    /**
+     * 消耗环比
+     */
+    @Excel(name = "消耗环比", width = 15)
+    @ApiModelProperty(value = "消耗环比")
+    private String chargeDayOnDayPercent;
+    /**
+     * 封面曝光数
+     */
+    @Excel(name = "封面曝光数", width = 15)
+    @ApiModelProperty(value = "封面曝光数")
+    private Long adPhotoImpression;
+    /**
+     * 封面点击数
+     */
+    @Excel(name = "封面点击数", width = 15)
+    @ApiModelProperty(value = "封面点击数")
+    private Long adPhotoClick;
+    /**
+     * 素材曝光数
+     */
+    @Excel(name = "素材曝光数", width = 15)
+    @ApiModelProperty(value = "素材曝光数")
+    private Long adItemImpression;
+    /**
+     * 行为数
+     */
+    @Excel(name = "行为数", width = 15)
+    @ApiModelProperty(value = "行为数")
+    private Long adItemClick;
+    /**
+     * 封面点击率
+     */
+    @Excel(name = "封面点击率", width = 15)
+    @ApiModelProperty(value = "封面点击率")
+    private String photoClickRatio;
+    /**
+     * 行为点击率
+     */
+    @Excel(name = "行为点击率", width = 15)
+    @ApiModelProperty(value = "行为点击率")
+    private String itemClickRatio;
+    /**
+     * 有消费计划数
+     */
+    @Excel(name = "有消费计划数", width = 15)
+    @ApiModelProperty(value = "有消费计划数")
+    private Long chargedCampaignCount;
+    /**
+     * 产品名
+     */
+    @Excel(name = "产品名", width = 15)
+    @ApiModelProperty(value = "产品名")
+    private String productName;
+    /**
+     * 企业名称
+     */
+    @Excel(name = "企业名称", width = 15)
+    @ApiModelProperty(value = "企业名称")
+    private String corporationName;
+    /**
+     * 首次消耗日期
+     */
+    @Excel(name = "首次消耗日期", width = 15)
+    @ApiModelProperty(value = "首次消耗日期")
+    private String firstCostDay;
+    /**
+     * 一级行业
+     */
+    @Excel(name = "一级行业", width = 15)
+    @ApiModelProperty(value = "一级行业")
+    private String industry;
+    /**
+     * 二级行业
+     */
+    @Excel(name = "二级行业", width = 15)
+    @ApiModelProperty(value = "二级行业")
+    private String secondIndustry;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 146 - 139
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAgent.java

@@ -1,165 +1,172 @@
 package cn.com.ctop.kuaishou.modules.report.entity;
 
-import java.io.Serializable;
-import java.util.Date;
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
 
 /**
  * 代理商报表
+ *
  * @author jeecg-boot
- * @date   2019-12-13
  * @version V1.0
+ * @date 2019-12-13
  */
 @Data
 @TableName("ctop_kuaishou_report_daily_agent")
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
-@ApiModel(value="ctop_kuaishou_report_daily_agent对象", description="代理商报表")
+@ApiModel(value = "ctop_kuaishou_report_daily_agent对象", description = "代理商报表")
 public class KuaishouReportDailyAgent {
 
-	/**
-	 * 日期
-	 */
-	@Excel(name = "日期", width = 15, format = "yyyy-MM-dd")
-	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
-	@DateTimeFormat(pattern = "yyyy-MM-dd")
-	@ApiModelProperty(value = "日期")
-	@TableId(type = IdType.INPUT)
-	private java.util.Date date;
-	/**
-	 * 账户ID
-	 */
-	@Excel(name = "账户ID", width = 15)
-	@ApiModelProperty(value = "账户ID")
-	@TableId(type = IdType.INPUT)
-	private java.lang.Integer accountId;
-	/**
-	 * 快手ID
-	 */
-	@Excel(name = "快手ID", width = 15)
-	@ApiModelProperty(value = "快手ID")
-	private java.lang.Integer kid;
-	/**
-	 * 广告主名称
-	 */
-	@Excel(name = "广告主名称", width = 15)
-	@ApiModelProperty(value = "广告主名称")
-	private java.lang.String advertiserName;
-	/**
-	 * 广告主创建时间
-	 */
-	@Excel(name = "广告主创建时间", width = 15, format = "yyyy-MM-dd")
-	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
-	@DateTimeFormat(pattern = "yyyy-MM-dd")
-	@ApiModelProperty(value = "广告主创建时间")
-	private java.util.Date advertiserCreateTime;
-	/**
-	 * 有消费计划数
-	 */
-	@Excel(name = "有消费计划数", width = 15)
-	@ApiModelProperty(value = "有消费计划数")
-	private java.lang.Integer costCampaignCount;
-	/**
-	 * 总余额
-	 */
-	@Excel(name = "总余额", width = 15)
-	@ApiModelProperty(value = "总余额")
-	private java.math.BigDecimal balance;
-	/**
-	 * 总消耗
-	 */
-	@Excel(name = "总消耗", width = 15)
-	@ApiModelProperty(value = "总消耗")
-	private java.math.BigDecimal cost;
-	/**
-	 * 现金消耗
-	 */
-	@Excel(name = "现金消耗", width = 15)
-	@ApiModelProperty(value = "现金消耗")
-	private java.math.BigDecimal xianjinCost;
-	/**
-	 * 后返消耗
-	 */
-	@Excel(name = "后返消耗", width = 15)
-	@ApiModelProperty(value = "后返消耗")
-	private java.math.BigDecimal fandianCost;
-	/**
-	 * 框返消耗
-	 */
-	@Excel(name = "框返消耗", width = 15)
-	@ApiModelProperty(value = "框返消耗")
-	private java.math.BigDecimal kuangfanCost;
-	/**
-	 * 激励账户消耗
-	 */
-	@Excel(name = "激励账户消耗", width = 15)
-	@ApiModelProperty(value = "激励账户消耗")
-	private java.math.BigDecimal jiliCost;
-	/**
-	 * 信用账户消耗
-	 */
-	@Excel(name = "信用账户消耗", width = 15)
-	@ApiModelProperty(value = "信用账户消耗")
-	private java.math.BigDecimal xinyongCost;
-	/**
-	 * 封面曝光数
-	 */
-	@Excel(name = "封面曝光数", width = 15)
-	@ApiModelProperty(value = "封面曝光数")
-	private java.lang.Integer fengmianShowCount;
-	/**
-	 * 封面点击数
-	 */
-	@Excel(name = "封面点击数", width = 15)
-	@ApiModelProperty(value = "封面点击数")
-	private java.lang.Integer fengmianClickCount;
-	/**
-	 * 素材曝光数
-	 */
-	@Excel(name = "素材曝光数", width = 15)
-	@ApiModelProperty(value = "素材曝光数")
-	private java.lang.Integer sucaiShowCount;
-	/**
-	 * 行为数
-	 */
-	@Excel(name = "行为数", width = 15)
-	@ApiModelProperty(value = "行为数")
-	private java.lang.Integer convertCount;
-	/**
-	 * 封面点击率
-	 */
-	@Excel(name = "封面点击率", width = 15)
-	@ApiModelProperty(value = "封面点击率")
-	private java.math.BigDecimal fengmianClickRate;
-	/**
-	 * 转化点击率
-	 */
-	@Excel(name = "转化点击率", width = 15)
-	@ApiModelProperty(value = "转化点击率")
-	private java.math.BigDecimal convertClickRate;
-	/**
-	 * 创建时间
-	 */
-	@ApiModelProperty(value = "创建时间")
-	private java.util.Date createTime;
-	/**
-	 * 修改时间
-	 */
-	@ApiModelProperty(value = "修改时间")
-	private java.util.Date updateTime;
+    /**
+     * 日期
+     */
+    @Excel(name = "日期", width = 15, format = "yyyy-MM-dd")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @ApiModelProperty(value = "日期")
+    private String date;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    @TableId(type = IdType.INPUT)
+    private java.lang.Integer accountId;
+    /**
+     * 快手ID
+     */
+    @Excel(name = "快手ID", width = 15)
+    @ApiModelProperty(value = "快手ID")
+    private java.lang.Integer kid;
+    /**
+     * 广告主名称
+     */
+    @Excel(name = "广告主名称", width = 15)
+    @ApiModelProperty(value = "广告主名称")
+    private java.lang.String advertiserName;
+    /**
+     * 广告主创建时间
+     */
+    @Excel(name = "广告主创建时间", width = 15, format = "yyyy-MM-dd")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @ApiModelProperty(value = "广告主创建时间")
+    private java.util.Date advertiserCreateTime;
+    /**
+     * 有消费计划数
+     */
+    @Excel(name = "有消费计划数", width = 15)
+    @ApiModelProperty(value = "有消费计划数")
+    private java.lang.Integer costCampaignCount;
+    /**
+     * 总余额
+     */
+    @Excel(name = "总余额", width = 15)
+    @ApiModelProperty(value = "总余额")
+    private java.math.BigDecimal balance;
+    /**
+     * 总消耗
+     */
+    @Excel(name = "总消耗", width = 15)
+    @ApiModelProperty(value = "总消耗")
+    private java.math.BigDecimal cost;
+    /**
+     * 现金消耗
+     */
+    @Excel(name = "现金消耗", width = 15)
+    @ApiModelProperty(value = "现金消耗")
+    private java.math.BigDecimal xianjinCost;
+    /**
+     * 后返消耗
+     */
+    @Excel(name = "后返消耗", width = 15)
+    @ApiModelProperty(value = "后返消耗")
+    private java.math.BigDecimal fandianCost;
+    /**
+     * 框返消耗
+     */
+    @Excel(name = "框返消耗", width = 15)
+    @ApiModelProperty(value = "框返消耗")
+    private java.math.BigDecimal kuangfanCost;
+    /**
+     * 激励账户消耗
+     */
+    @Excel(name = "激励账户消耗", width = 15)
+    @ApiModelProperty(value = "激励账户消耗")
+    private java.math.BigDecimal jiliCost;
+    /**
+     * 信用账户消耗
+     */
+    @Excel(name = "信用账户消耗", width = 15)
+    @ApiModelProperty(value = "信用账户消耗")
+    private java.math.BigDecimal xinyongCost;
+    /**
+     * 封面曝光数
+     */
+    @Excel(name = "封面曝光数", width = 15)
+    @ApiModelProperty(value = "封面曝光数")
+    private java.lang.Integer fengmianShowCount;
+    /**
+     * 封面点击数
+     */
+    @Excel(name = "封面点击数", width = 15)
+    @ApiModelProperty(value = "封面点击数")
+    private java.lang.Integer fengmianClickCount;
+    /**
+     * 素材曝光数
+     */
+    @Excel(name = "素材曝光数", width = 15)
+    @ApiModelProperty(value = "素材曝光数")
+    private java.lang.Integer sucaiShowCount;
+    /**
+     * 行为数
+     */
+    @Excel(name = "行为数", width = 15)
+    @ApiModelProperty(value = "行为数")
+    private java.lang.Integer convertCount;
+    /**
+     * 封面点击率
+     */
+    @Excel(name = "封面点击率", width = 15)
+    @ApiModelProperty(value = "封面点击率")
+    private String fengmianClickRate;
+    /**
+     * 转化点击率
+     */
+    @Excel(name = "转化点击率", width = 15)
+    @ApiModelProperty(value = "转化点击率")
+    private String convertClickRate;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private java.util.Date createTime;
+    /**
+     * 修改时间
+     */
+    @ApiModelProperty(value = "修改时间")
+    private java.util.Date updateTime;
+
+    @TableField(exist = false)
+    private Integer isHasData;
+    @TableField(exist = false)
+    private String accountName;
+    @TableField(exist = false)
+    private String industry;
+    @TableField(exist = false)
+    private String secondIndustry;
+    @TableField(exist = false)
+    private String chargeDayOnDayPercent;
 
-	@TableField(exist = false)
-	private Integer isHasData;
 
 }

+ 93 - 61
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAgentSum.java

@@ -1,100 +1,132 @@
 package cn.com.ctop.kuaishou.modules.report.entity;
 
-import java.io.Serializable;
-import java.util.Date;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
 
 /**
  * 代理商日汇总表
+ *
  * @author jeecg-boot
- * @date   2019-12-13
  * @version V1.0
+ * @date 2019-12-13
  */
 @Data
 @TableName("ctop_kuaishou_report_daily_agent_sum")
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
-@ApiModel(value="ctop_kuaishou_report_daily_agent对象", description="代理商日汇总表")
+@ApiModel(value = "ctop_kuaishou_report_daily_agent对象", description = "代理商日汇总表")
 public class KuaishouReportDailyAgentSum {
 
-	/**日期*/
-	@Excel(name = "日期", width = 15, format = "yyyy-MM-dd")
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
-    @DateTimeFormat(pattern="yyyy-MM-dd")
+    /**
+     * 日期
+     */
+    @Excel(name = "日期", width = 15, format = "yyyy-MM-dd")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
     @ApiModelProperty(value = "日期")
-	@TableId(type = IdType.INPUT)
-	private Date date;
-	/**有消费计划数*/
-	@Excel(name = "有消费计划数", width = 15)
+
+    private String date;
+    /**
+     * 有消费计划数
+     */
+    @Excel(name = "有消费计划数", width = 15)
     @ApiModelProperty(value = "有消费计划数")
-	private Long costCampaignCount;
-	/**总余额*/
-	@Excel(name = "总余额", width = 15)
+    private Long costCampaignCount;
+    /**
+     * 总余额
+     */
+    @Excel(name = "总余额", width = 15)
     @ApiModelProperty(value = "总余额")
-	private java.math.BigDecimal balance;
-	/**总消耗*/
-	@Excel(name = "总消耗", width = 15)
+    private java.math.BigDecimal balance;
+    /**
+     * 总消耗
+     */
+    @Excel(name = "总消耗", width = 15)
     @ApiModelProperty(value = "总消耗")
-	private java.math.BigDecimal cost;
-	/**现金消耗*/
-	@Excel(name = "现金消耗", width = 15)
+    private java.math.BigDecimal cost;
+    /**
+     * 现金消耗
+     */
+    @Excel(name = "现金消耗", width = 15)
     @ApiModelProperty(value = "现金消耗")
-	private java.math.BigDecimal xianjinCost;
-	/**后返消耗*/
-	@Excel(name = "后返消耗", width = 15)
+    private java.math.BigDecimal xianjinCost;
+    /**
+     * 后返消耗
+     */
+    @Excel(name = "后返消耗", width = 15)
     @ApiModelProperty(value = "后返消耗")
-	private java.math.BigDecimal fandianCost;
-	/**框返消耗*/
-	@Excel(name = "框返消耗", width = 15)
+    private java.math.BigDecimal fandianCost;
+    /**
+     * 框返消耗
+     */
+    @Excel(name = "框返消耗", width = 15)
     @ApiModelProperty(value = "框返消耗")
-	private java.math.BigDecimal kuangfanCost;
-	/**激励账户消耗*/
-	@Excel(name = "激励账户消耗", width = 15)
+    private java.math.BigDecimal kuangfanCost;
+    /**
+     * 激励账户消耗
+     */
+    @Excel(name = "激励账户消耗", width = 15)
     @ApiModelProperty(value = "激励账户消耗")
-	private java.math.BigDecimal jiliCost;
-	/**信用账户消耗*/
-	@Excel(name = "信用账户消耗", width = 15)
+    private java.math.BigDecimal jiliCost;
+    /**
+     * 信用账户消耗
+     */
+    @Excel(name = "信用账户消耗", width = 15)
     @ApiModelProperty(value = "信用账户消耗")
-	private java.math.BigDecimal xinyongCost;
-	/**封面曝光数*/
-	@Excel(name = "封面曝光数", width = 15)
+    private java.math.BigDecimal xinyongCost;
+    /**
+     * 封面曝光数
+     */
+    @Excel(name = "封面曝光数", width = 15)
     @ApiModelProperty(value = "封面曝光数")
-	private Long fengmianShowCount;
-	/**封面点击数*/
-	@Excel(name = "封面点击数", width = 15)
+    private Long fengmianShowCount;
+    /**
+     * 封面点击数
+     */
+    @Excel(name = "封面点击数", width = 15)
     @ApiModelProperty(value = "封面点击数")
-	private Long fengmianClickCount;
-	/**素材曝光数*/
-	@Excel(name = "素材曝光数", width = 15)
+    private Long fengmianClickCount;
+    /**
+     * 素材曝光数
+     */
+    @Excel(name = "素材曝光数", width = 15)
     @ApiModelProperty(value = "素材曝光数")
-	private Long sucaiShowCount;
-	/**行为数*/
-	@Excel(name = "行为数", width = 15)
+    private Long sucaiShowCount;
+    /**
+     * 行为数
+     */
+    @Excel(name = "行为数", width = 15)
     @ApiModelProperty(value = "行为数")
-	private Long convertCount;
-	/**封面点击率*/
-	@Excel(name = "封面点击率", width = 15)
+    private Long convertCount;
+    /**
+     * 封面点击率
+     */
+    @Excel(name = "封面点击率", width = 15)
     @ApiModelProperty(value = "封面点击率")
-	private java.math.BigDecimal fengmianClickRate;
-	/**转化点击率*/
-	@Excel(name = "转化点击率", width = 15)
+    private java.math.BigDecimal fengmianClickRate;
+    /**
+     * 转化点击率
+     */
+    @Excel(name = "转化点击率", width = 15)
     @ApiModelProperty(value = "转化点击率")
-	private java.math.BigDecimal convertClickRate;
-	/**创建时间*/
+    private java.math.BigDecimal convertClickRate;
+    /**
+     * 创建时间
+     */
     @ApiModelProperty(value = "创建时间")
-	private Date createTime;
-	/**修改时间*/
+    private Date createTime;
+    /**
+     * 修改时间
+     */
     @ApiModelProperty(value = "修改时间")
-	private Date updateTime;
+    private Date updateTime;
 }

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/ParamsDTO.java

@@ -12,4 +12,6 @@ public class ParamsDTO implements Serializable {
     private String date;
     private String advertiserName;  //广告主名称
     private Integer isExportNullData; //是否导出为0数据
+    private Integer page;
+    private Integer pageSize;
 }

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

@@ -0,0 +1,26 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouDailyAgent;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 代理商报表
+ *
+ * @author: jeecg-boot
+ * @date: 2020-08-18
+ * @cersion: V1.0
+ */
+public interface KuaiShouDailyAgentMapper extends BaseMapper<KuaiShouDailyAgent> {
+    int insertSelective(KuaiShouDailyAgent record);
+
+    List<KuaishouReportDailyAgentSum> companyReport(@Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    KuaishouReportDailyAgentSum companyReportSum(@Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<KuaishouReportDailyAgent> companyReportAccountDetailList(@Param("date") String date, @Param("advertiserName") String advertiserName, @Param("isExportNullData") Integer o);
+}

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

@@ -0,0 +1,301 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaiShouDailyAgentMapper">
+
+
+    <!-- 代理商列表-->
+    <select id="companyReport" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum">
+        select
+        date_time as date,  <!-- 日期 -->
+        sum(charged_campaign_count) as costCampaignCount,  <!-- 有消费计划数 -->
+        sum(total_balance_in_yuan) as balance,  <!-- 总余额 -->
+        sum(total_charged_in_yuan) as cost,  <!-- 总消耗 -->
+        sum(real_charged_in_yuan) as xianjinCost,  <!-- 现金消耗 -->
+        sum(total_rebate_real_charged_in_yuan) as fandianCost,  <!-- 后返消耗 -->
+        sum(contract_rebate_real_charged_in_yuan) as kuangfanCost,  <!-- 框返消耗 -->
+        sum(direct_rebate_real_charged_in_yuan) as jiliCost,  <!-- 激励账户消耗 -->
+        sum(credit_real_charged_in_yuan) as xinyongCost,  <!-- 信用账户消耗 -->
+        sum(ad_photo_impression) as fengmianShowCount,  <!-- 封面曝光数 -->
+        sum(ad_photo_click) as fengmianClickCount,  <!-- 封面点击数 -->
+        sum(ad_item_impression) as sucaiShowCount,  <!-- 素材曝光数 -->
+        sum(ad_item_click) as convertCount,  <!-- 行为数 -->
+        (case when sum(ad_photo_impression) != 0
+        then sum(ad_photo_click) / sum(ad_photo_impression)
+        else 0
+        end
+        ) as fengmianClickRate,  <!-- 封面点击率 -->
+        (
+        case when sum(ad_photo_click) != 0
+        THEN sum(ad_item_click) / sum(ad_photo_click)
+        else 0
+        end
+        ) as convertClickRate  <!-- 转化点击率 -->
+
+        from
+        ctop_kuaishou_daily_agent
+        where
+
+        date_time &gt;= #{startDate}
+        and
+        date_time &lt;= #{endDate}
+        group by date_time
+        order by date_time desc
+    </select>
+
+
+    <select id="companyReportSum" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum">
+        select
+        sum(charged_campaign_count) as costCampaignCount,  <!-- 有消费计划数 -->
+        sum(total_balance_in_yuan) as balance,  <!-- 总余额 -->
+        sum(total_charged_in_yuan) as cost,  <!-- 总消耗 -->
+        sum(real_charged_in_yuan) as xianjinCost,  <!-- 现金消耗 -->
+        sum(total_rebate_real_charged_in_yuan) as fandianCost,  <!-- 后返消耗 -->
+        sum(contract_rebate_real_charged_in_yuan) as kuangfanCost,  <!-- 框返消耗 -->
+        sum(direct_rebate_real_charged_in_yuan) as jiliCost,  <!-- 激励账户消耗 -->
+        sum(credit_real_charged_in_yuan) as xinyongCost,  <!-- 信用账户消耗 -->
+        sum(ad_photo_impression) as fengmianShowCount,  <!-- 封面曝光数 -->
+        sum(ad_photo_click) as fengmianClickCount,  <!-- 封面点击数 -->
+        sum(ad_item_impression) as sucaiShowCount,  <!-- 素材曝光数 -->
+        sum(ad_item_click) as convertCount,  <!-- 行为数 -->
+        (case when sum(ad_photo_impression) != 0
+        then sum(ad_photo_click) / sum(ad_photo_impression)
+        else 0
+        end
+        ) as fengmianClickRate,  <!-- 封面点击率 -->
+        (
+        case when sum(ad_photo_click) != 0
+        then sum(ad_item_click) / sum(ad_photo_click)
+        else 0
+        end
+        ) as convertClickRate  <!-- 转化点击率 -->
+        from
+        ctop_kuaishou_daily_agent
+        where
+        date_time &lt;= #{endDate} and
+        date_time &gt;= #{startDate}
+    </select>
+
+
+    <select id="companyReportAccountDetailList"
+            resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent">
+        select
+        date_time as date,  <!-- 日期 -->
+        account_id as accountId,  <!-- 账户id -->
+        user_id as kid, <!-- 快手id -->
+        corporation_name as advertiserName, <!-- 广告主名称 -->
+        account_name as accountName, <!-- 账户名称 -->
+        industry as industry, <!-- 一级行业 -->
+        second_industry as secondIndustry, <!-- 二级行业 -->
+        charge_day_on_day_percent as chargeDayOnDayPercent, <!-- 消耗环比 -->
+        -- advertiser_create_time as advertiserCreateTime, <!-- 广告主创建时间 -->
+        charged_campaign_count as costCampaignCount, <!-- 有消费计划数 -->
+        total_balance_in_yuan as balance, <!-- 总余额 -->
+        total_charged_in_yuan as cost, <!-- 总消耗 -->
+        real_charged_in_yuan as xianjinCost, <!-- 现金消耗 -->
+        total_rebate_real_charged_in_yuan as fandianCost, <!-- 后返消耗 -->
+        contract_rebate_real_charged_in_yuan as kuangfanCost, <!-- 框返消耗 -->
+        direct_rebate_real_charged_in_yuan as jiliCost, <!-- 激励账户消耗 -->
+        credit_real_charged_in_yuan as xinyongCost, <!-- 信用账户消耗 -->
+        ad_photo_impression as fengmianShowCount, <!-- 封面曝光数 -->
+        ad_photo_click as fengmianClickCount, <!-- 封面点击数 -->
+        ad_item_impression as sucaiShowCount, <!-- 素材曝光数 -->
+        ad_item_click as convertCount, <!-- 行为数 -->
+        photo_click_ratio as fengmianClickRate, <!-- 封面点击率 -->
+        item_click_ratio as convertClickRate, <!-- 转化点击率 -->
+        case
+        when
+        total_charged_in_yuan = 0
+        then 0
+        else 1
+        end as isHasData
+        from
+        ctop_kuaishou_daily_agent
+        where
+        date_time = #{date}
+        <if test="advertiserName != null and advertiserName != ''">
+            and corporation_name like concat('%',#{advertiserName},'%')
+        </if>
+        <if test="isExportNullData == 0 or isExportNullData == '0'">  <!-- 判断是否导出公司明细中各字段总合为0的数据  1-导出 0-不导出 -->
+            and
+            total_charged_in_yuan > 0
+        </if>
+    </select>
+
+
+    <insert id="insertSelective" parameterType="cn.com.ctop.kuaishou.modules.report.entity.KuaiShouDailyAgent">
+        replace into ctop_kuaishou_daily_agent
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="agentId != null">
+                agent_id,
+            </if>
+            <if test="accountId != null">
+                account_id,
+            </if>
+            <if test="dateTime != null">
+                date_time,
+            </if>
+            <if test="userId != null">
+                user_id,
+            </if>
+            <if test="accountName != null">
+                account_name,
+            </if>
+            <if test="totalChargedInYuan != null">
+                total_charged_in_yuan,
+            </if>
+            <if test="totalBalanceInYuan != null">
+                total_balance_in_yuan,
+            </if>
+            <if test="realChargedInYuan != null">
+                real_charged_in_yuan,
+            </if>
+            <if test="totalRebateRealChargedInYuan != null">
+                total_rebate_real_charged_in_yuan,
+            </if>
+            <if test="contractRebateRealChargedInYuan != null">
+                contract_rebate_real_charged_in_yuan,
+            </if>
+            <if test="directRebateRealChargedInYuan != null">
+                direct_rebate_real_charged_in_yuan,
+            </if>
+            <if test="creditRealChargedInYuan != null">
+                credit_real_charged_in_yuan,
+            </if>
+            <if test="chargeDayOnDayPercent != null">
+                charge_day_on_day_percent,
+            </if>
+            <if test="adPhotoImpression != null">
+                ad_photo_impression,
+            </if>
+            <if test="adPhotoClick != null">
+                ad_photo_click,
+            </if>
+            <if test="adItemImpression != null">
+                ad_item_impression,
+            </if>
+            <if test="adItemClick != null">
+                ad_item_click,
+            </if>
+            <if test="photoClickRatio != null">
+                photo_click_ratio,
+            </if>
+            <if test="itemClickRatio != null">
+                item_click_ratio,
+            </if>
+            <if test="chargedCampaignCount != null">
+                charged_campaign_count,
+            </if>
+            <if test="productName != null">
+                product_name,
+            </if>
+            <if test="corporationName != null">
+                corporation_name,
+            </if>
+            <if test="firstCostDay != null">
+                first_cost_day,
+            </if>
+            <if test="industry != null">
+                industry,
+            </if>
+            <if test="secondIndustry != null">
+                second_industry,
+            </if>
+            <if test="createTime != null">
+                create_time,
+            </if>
+            <if test="updateTime != null">
+                update_time,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id,jdbcType=BIGINT},
+            </if>
+            <if test="agentId != null">
+                #{agentId,jdbcType=BIGINT},
+            </if>
+            <if test="accountId != null">
+                #{accountId,jdbcType=BIGINT},
+            </if>
+            <if test="dateTime != null">
+                #{dateTime,jdbcType=VARCHAR},
+            </if>
+            <if test="userId != null">
+                #{userId,jdbcType=BIGINT},
+            </if>
+            <if test="accountName != null">
+                #{accountName,jdbcType=VARCHAR},
+            </if>
+            <if test="totalChargedInYuan != null">
+                #{totalChargedInYuan,jdbcType=DECIMAL},
+            </if>
+            <if test="totalBalanceInYuan != null">
+                #{totalBalanceInYuan,jdbcType=DECIMAL},
+            </if>
+            <if test="realChargedInYuan != null">
+                #{realChargedInYuan,jdbcType=DECIMAL},
+            </if>
+            <if test="totalRebateRealChargedInYuan != null">
+                #{totalRebateRealChargedInYuan,jdbcType=DECIMAL},
+            </if>
+            <if test="contractRebateRealChargedInYuan != null">
+                #{contractRebateRealChargedInYuan,jdbcType=DECIMAL},
+            </if>
+            <if test="directRebateRealChargedInYuan != null">
+                #{directRebateRealChargedInYuan,jdbcType=DECIMAL},
+            </if>
+            <if test="creditRealChargedInYuan != null">
+                #{creditRealChargedInYuan,jdbcType=DECIMAL},
+            </if>
+            <if test="chargeDayOnDayPercent != null">
+                #{chargeDayOnDayPercent,jdbcType=VARCHAR},
+            </if>
+            <if test="adPhotoImpression != null">
+                #{adPhotoImpression,jdbcType=BIGINT},
+            </if>
+            <if test="adPhotoClick != null">
+                #{adPhotoClick,jdbcType=BIGINT},
+            </if>
+            <if test="adItemImpression != null">
+                #{adItemImpression,jdbcType=BIGINT},
+            </if>
+            <if test="adItemClick != null">
+                #{adItemClick,jdbcType=BIGINT},
+            </if>
+            <if test="photoClickRatio != null">
+                #{photoClickRatio,jdbcType=VARCHAR},
+            </if>
+            <if test="itemClickRatio != null">
+                #{itemClickRatio,jdbcType=VARCHAR},
+            </if>
+            <if test="chargedCampaignCount != null">
+                #{chargedCampaignCount,jdbcType=BIGINT},
+            </if>
+            <if test="productName != null">
+                #{productName,jdbcType=VARCHAR},
+            </if>
+            <if test="corporationName != null">
+                #{corporationName,jdbcType=VARCHAR},
+            </if>
+            <if test="firstCostDay != null">
+                #{firstCostDay,jdbcType=VARCHAR},
+            </if>
+            <if test="industry != null">
+                #{industry,jdbcType=VARCHAR},
+            </if>
+            <if test="secondIndustry != null">
+                #{secondIndustry,jdbcType=VARCHAR},
+            </if>
+            <if test="createTime != null">
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </trim>
+    </insert>
+
+</mapper>

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

@@ -0,0 +1,26 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouDailyAgent;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+
+/**
+ * @Description: 代理商报表
+ * @Author: jeecg-boot
+ * @Date: 2020-08-18
+ * @Version: V1.0
+ */
+public interface IKuaiShouDailyAgentService extends IService<KuaiShouDailyAgent> {
+    void getAgentReportByPage(String startDate, String endDate);
+
+    List<KuaishouReportDailyAgentSum> companyReport(String startDate, String endDate);
+
+    KuaishouReportDailyAgentSum companyReportSum(String startDate, String endDate);
+
+
+    List<KuaishouReportDailyAgent> companyReportAccountDetailList(String date, String advertiserName, Integer o);
+}

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

@@ -0,0 +1,150 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.common.module.entity.OauthAgentToken;
+import cn.com.ctop.common.module.service.IOauthAgentTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouDailyAgent;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaiShouDailyAgentMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * 代理商报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-08-18
+ */
+@Slf4j
+@Service
+public class KuaiShouDailyAgentServiceImpl extends ServiceImpl<KuaiShouDailyAgentMapper, KuaiShouDailyAgent> implements IKuaiShouDailyAgentService {
+    @Autowired
+    private IOauthAgentTokenService agentTokenService;
+    @Autowired
+    private KuaiShouDailyAgentMapper agentMapper;
+
+    @Override
+    public void getAgentReportByPage(String startDate, String endDate) {
+        QueryWrapper<OauthAgentToken> agentTokenQueryWrapper = new QueryWrapper<>();
+        agentTokenQueryWrapper.eq("media_id", 2);
+        List<OauthAgentToken> list = agentTokenService.list(agentTokenQueryWrapper);
+        if (!Check.isNull(list)) {
+            for (OauthAgentToken agentToken : list) {
+                getAgentReport(agentToken.getAccessToken(), agentToken.getAgentId(), startDate, endDate, 1);
+            }
+        }
+    }
+
+
+    private void getAgentReport(String token, Long agentId, String startDate, String endDate, int page) {
+        try {
+            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/agent/report";
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Content-Type", " application/json");
+            headers.put("Access-Token", token);
+            JSONObject param = new JSONObject();
+            param.put("start_date", startDate);
+            param.put("end_date", endDate);
+            param.put("agent_id", agentId);
+            param.put("page_size", 1000);
+            param.put("page", page);
+
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            System.err.println(resultJson);
+            if (Check.isNull(resultJson)) {
+                log.info("代理商数据返回为空");
+                return;
+            }
+            Integer code = resultJson.getInteger("code");
+            if (code != 0) {
+                log.error("代理商报表返回code错误,返回:{}", resultJson);
+                return;
+            }
+            JSONObject data = resultJson.getJSONObject("data");
+            if (Check.isNull(data)) {
+                log.error("代理商报表返回data节点为空");
+                return;
+            }
+            JSONArray details = data.getJSONArray("details");
+            if (Check.isNull(details)) {
+                log.error("代理商报表返回details节点为空");
+                return;
+            }
+            for (int i = 0; i < details.size(); i++) {
+                JSONObject detailJson = details.getJSONObject(i);
+                if (!Check.isNull(detailJson)) {
+                    KuaiShouDailyAgent agent = new KuaiShouDailyAgent();
+                    agent.setAgentId(agentId);
+                    agent.setAccountId(detailJson.getLong("account_id"));
+                    agent.setDateTime(detailJson.getString("date_time"));
+                    agent.setUserId(detailJson.getLong("user_id"));
+                    agent.setAccountName(detailJson.getString("account_name"));
+                    agent.setTotalChargedInYuan(detailJson.getBigDecimal("total_charged_in_yuan"));
+                    agent.setTotalBalanceInYuan(detailJson.getBigDecimal("total_balance_in_yuan"));
+                    agent.setRealChargedInYuan(detailJson.getBigDecimal("real_charged_in_yuan"));
+                    agent.setTotalRebateRealChargedInYuan(detailJson.getBigDecimal("total_rebate_real_charged_in_yuan"));
+                    agent.setContractRebateRealChargedInYuan(detailJson.getBigDecimal("contract_rebate_real_charged_in_yuan"));
+                    agent.setDirectRebateRealChargedInYuan(detailJson.getBigDecimal("direct_rebate_real_charged_in_yuan"));
+                    agent.setCreditRealChargedInYuan(detailJson.getBigDecimal("credit_real_charged_in_yuan"));
+                    agent.setChargeDayOnDayPercent(detailJson.getString("charge_day_on_day_percent"));
+                    agent.setAdPhotoImpression(detailJson.getLong("ad_photo_impression"));
+                    agent.setAdPhotoClick(detailJson.getLong("ad_photo_click"));
+                    agent.setAdItemImpression(detailJson.getLong("ad_item_impression"));
+                    agent.setAdItemClick(detailJson.getLong("ad_item_click"));
+                    agent.setPhotoClickRatio(detailJson.getString("photo_click_ratio"));
+                    agent.setItemClickRatio(detailJson.getString("item_click_ratio"));
+                    agent.setChargedCampaignCount(detailJson.getLong("charged_campaign_count"));
+                    agent.setProductName(detailJson.getString("product_name"));
+                    agent.setCorporationName(detailJson.getString("corporation_name"));
+                    agent.setFirstCostDay(detailJson.getString("first_cost_day"));
+                    agent.setIndustry(detailJson.getString("industry"));
+                    agent.setSecondIndustry(detailJson.getString("second_industry"));
+                    agentMapper.insertSelective(agent);
+                }
+            }
+            getAgentReport(token, agentId, startDate, endDate, page + 1);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+
+    }
+
+
+    /**
+     * 汇总
+     *
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    @Override
+    public List<KuaishouReportDailyAgentSum> companyReport(String startDate, String endDate) {
+        return agentMapper.companyReport(startDate, endDate);
+    }
+
+    @Override
+    public KuaishouReportDailyAgentSum companyReportSum(String startDate, String endDate) {
+        return agentMapper.companyReportSum(startDate, endDate);
+    }
+
+    @Override
+    public List<KuaishouReportDailyAgent> companyReportAccountDetailList(String date, String advertiserName, Integer o) {
+        return agentMapper.companyReportAccountDetailList(date, advertiserName, o);
+    }
+}

+ 5 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAgentServiceImpl.java

@@ -120,7 +120,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
     public boolean getAccount(int currentPage) {
         boolean hasNextPage = false;
         try {
-            if (currentPage == 1&&!loginAgent()) {
+            if (currentPage == 1 && !loginAgent()) {
                 return hasNextPage;
             }
             Map<String, String> headerMap = new HashMap<>();
@@ -209,7 +209,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
                             kuaishouReportDailyAgentSum.setConvertCount(dataNode.get("actionbarClick").asLong());
                             kuaishouReportDailyAgentSum.setCost(dataNode.get("totalChargedInYuan").decimalValue());
                             kuaishouReportDailyAgentSum.setCostCampaignCount(dataNode.get("chargedCampaignCount").asLong());
-                            kuaishouReportDailyAgentSum.setDate(sdf.parse(currentDate));
+                            //-   kuaishouReportDailyAgentSum.setDate(sdf.parse(currentDate));
                             kuaishouReportDailyAgentSum.setFengmianClickCount(dataNode.get("adPhotoClick").asLong());
                             kuaishouReportDailyAgentSum.setFengmianClickRate(dataNode.get("clickRatio").decimalValue());
                             kuaishouReportDailyAgentSum.setFengmianShowCount(dataNode.get("impression").asLong());
@@ -229,13 +229,13 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
                             kuaishouReportDailyAgent.setAdvertiserCreateTime(new Date(dataNode.get("createTime").asLong()));
                             kuaishouReportDailyAgent.setAdvertiserName(dataNode.get("accountName").asText());
                             kuaishouReportDailyAgent.setBalance(dataNode.get("totalBalanceDouble").decimalValue());
-                            kuaishouReportDailyAgent.setConvertClickRate(dataNode.get("actionbarClickRatio").decimalValue());
+                            // kuaishouReportDailyAgent.setConvertClickRate(dataNode.get("actionbarClickRatio").decimalValue());
                             kuaishouReportDailyAgent.setConvertCount(dataNode.get("actionbarClick").asInt());
                             kuaishouReportDailyAgent.setCost(dataNode.get("totalChargedInYuan").decimalValue());
                             kuaishouReportDailyAgent.setCostCampaignCount(dataNode.get("chargedCampaignCount").asInt());
-                            kuaishouReportDailyAgent.setDate(sdf.parse(dataNode.get("dateTime").asText()));
+                            //      kuaishouReportDailyAgent.setDate(sdf.parse(dataNode.get("dateTime").asText()));
                             kuaishouReportDailyAgent.setFengmianClickCount(dataNode.get("adPhotoClick").asInt());
-                            kuaishouReportDailyAgent.setFengmianClickRate(dataNode.get("clickRatio").decimalValue());
+                            // kuaishouReportDailyAgent.setFengmianClickRate(dataNode.get("clickRatio").decimalValue());
                             kuaishouReportDailyAgent.setFengmianShowCount(dataNode.get("impression").asInt());
                             kuaishouReportDailyAgent.setFandianCost(dataNode.get("rebateRealChargedInYuan").decimalValue());
                             kuaishouReportDailyAgent.setJiliCost(dataNode.get("directRebateRealChargedInYuan").decimalValue());