瀏覽代碼

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

xuzuoyun 5 年之前
父節點
當前提交
83350e11dd
共有 36 個文件被更改,包括 1780 次插入290 次删除
  1. 9 5
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 0 2
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  3. 7 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java
  4. 9 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyReportLoadJob.java
  5. 4 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/controller/FileController.java
  6. 1 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/IpPoolServiceImpl.java
  7. 4 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  8. 11 5
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/controller/MaterialInfoController.java
  9. 15 9
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/entity/MaterialInfo.java
  10. 1 1
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/IMaterialInfoService.java
  11. 4 2
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialInfoServiceImpl.java
  12. 0 10
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouReportController.java
  13. 1 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCreative.java
  14. 2 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouImageGet.java
  15. 13 10
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java
  16. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  17. 163 22
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  18. 0 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/IKuaishouWebInterfaceService.java
  19. 7 198
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/impl/KuaishouWebInterfaceServiceImpl.java
  20. 64 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAccount.java
  21. 64 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCampaign.java
  22. 64 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCreative.java
  23. 64 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyGroup.java
  24. 64 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyAccount.java
  25. 63 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyCampaign.java
  26. 63 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyCreative.java
  27. 63 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyGroup.java
  28. 70 0
      module-report/src/main/java/cn/com/ctop/bytedance/controller/AccountReportController.java
  29. 139 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/AccountReportMapper.java
  30. 11 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/BytedanceReportMapper.java
  31. 295 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/AccountReportMapper.xml
  32. 19 6
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/BytedanceReportMapper.xml
  33. 21 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/IAccountReportService.java
  34. 446 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/AccountReportServiceImpl.java
  35. 12 2
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportServiceImpl.java
  36. 3 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertiserDataServiceImpl.java

+ 9 - 5
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -785,10 +785,14 @@ public class DateUtils extends PropertyEditorSupport {
         SimpleDateFormat dateFormat = new SimpleDateFormat(format);
         Date date = dateFormat.parse(nowTime);
 
-        Calendar calendar = Calendar.getInstance(); //得到日历
-        calendar.setTime(date);//把当前时间赋给日历
-        calendar.add(calendar.MONTH, amount); //设置为前2月,可根据需求进行修改
-        date = calendar.getTime();//获取2个月前的时间
+        //得到日历
+        Calendar calendar = Calendar.getInstance();
+        //把当前时间赋给日历
+        calendar.setTime(date);
+        //设置为前2月,可根据需求进行修改
+        calendar.add(Calendar.MONTH, amount);
+        //获取2个月前的时间
+        date = calendar.getTime();
 
         return dateFormat.format(date);
     }
@@ -865,4 +869,4 @@ public class DateUtils extends PropertyEditorSupport {
     }
 
 
-}
+}

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

@@ -103,8 +103,6 @@ public class ShiroConfig {
         //模板测试
         filterChainDefinitionMap.put("/test/**", "anon");
         //报表测试
-        filterChainDefinitionMap.put("/report/**", "anon");
-
 		//oauth接口
         filterChainDefinitionMap.put("/auth/**", "anon");
 		filterChainDefinitionMap.put("/ctop/syncdata/**", "anon");

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

@@ -125,7 +125,13 @@ public class CallbackController {
                     topOauthToken.setUpdateTime(new Date());
                     cTopOauthTokenMapper.insert(topOauthToken);
                     bindAccountAuthService.addBindAccount(accountId, KuaishouInterfaceConstant.LOGIN_TYPE_KUAISHOU, advertiserId); //账号绑定
-                    kuaishouInterfaceService.loadKuaishouDataSingle(topOauthToken);
+                    Thread t = new Thread() {
+                        @Override
+                        public void run() {
+                            kuaishouInterfaceService.loadKuaishouDataSingle(topOauthToken);
+                        }
+                    };
+                    t.start();
                 }
                 return "授权绑定成功";
             }

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

@@ -5,11 +5,13 @@ import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 
@@ -26,6 +28,11 @@ public class KuaishouHourlyReportLoadJob implements Job {
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
         Date getDate = new Date();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
+        String hour = simpleDateFormat.format(getDate);
+        if (null != hour && hour.equals("00")) {
+            getDate = DateUtils.addDay(getDate, -1);
+        }
         //1:查询当日数据
         List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
         if (null == tokens || tokens.size() <= 0) {
@@ -33,8 +40,7 @@ public class KuaishouHourlyReportLoadJob implements Job {
             return;
         }
 
-        tokens.forEach(token -> {
-            //1: 获取广告主信息数据
+        for (CtopOauthToken token : tokens) {
             kuaishouInterfaceService.getAdvertiserReportHourly(token, getDate, getDate);
             //2:获取广告计划信息数据
             kuaishouInterfaceService.getAdvertiserCampaignReportHourly(token, getDate, getDate);
@@ -42,6 +48,6 @@ public class KuaishouHourlyReportLoadJob implements Job {
             kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, getDate, getDate);
             //4: 获取广告创意信息数据
             kuaishouInterfaceService.getAdvertiserCreativeReportHourly(token, getDate, getDate);
-        });
+        }
     }
 }

+ 4 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/controller/FileController.java

@@ -1,6 +1,8 @@
 package org.jeecg.modules.fileupload.controller;
 
 import cn.com.ctop.manage.modules.material.service.IMaterialInfoService;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,6 +26,7 @@ public class FileController {
 
     @PostMapping("file/insert")
     public Map<String, Object> insertFile(String code, String url) {
-        return materialInfoService.insert(code, url);
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        return materialInfoService.insert(user.getId(), code, url);
     }
 }

+ 1 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/IpPoolServiceImpl.java

@@ -20,6 +20,7 @@ import java.util.List;
 @Service
 public class IpPoolServiceImpl extends ServiceImpl<IpPoolMapper, IpPool> implements IIpPoolService {
 
+    @Override
     public IpPool getAvaliableIp() {
         QueryWrapper<IpPool> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("status", 1);

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

@@ -12,6 +12,10 @@ public class KuaishouInterfaceConstant {
      */
     public static final String ACCOUNT_REPORT = "/rest/openapi/v1/report/account_report";
     /**
+     * 广告主报表数据
+     */
+    public static final String VIDEO_LIST = "rest/openapi/v1/file/ad/video/list";
+    /**
      * 广告计划报表数据
      */
     public static final String CAMPAIGN_REPORT = "/rest/openapi/v1/report/campaign_report";

+ 11 - 5
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/controller/MaterialInfoController.java

@@ -9,9 +9,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -64,9 +66,13 @@ public class MaterialInfoController {
                                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                      HttpServletRequest req) {
-        Result<IPage<MaterialInfo>> result = new Result<IPage<MaterialInfo>>();
+        Result<IPage<MaterialInfo>> result = new Result<>();
         QueryWrapper<MaterialInfo> queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
-        Page<MaterialInfo> page = new Page<MaterialInfo>(pageNo, pageSize);
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        if (null != user.getUsername() && !user.getUsername().contains("admin")) {
+            queryWrapper.eq("user_id", user.getId());
+        }
+        Page<MaterialInfo> page = new Page<>(pageNo, pageSize);
         IPage<MaterialInfo> pageList = materialInfoService.page(page, queryWrapper);
         result.setSuccess(true);
         result.setResult(pageList);
@@ -83,7 +89,7 @@ public class MaterialInfoController {
     @ApiOperation(value = "素材信息-添加", notes = "素材信息-添加")
     @PostMapping(value = "/add")
     public Result<MaterialInfo> add(@RequestBody MaterialInfo materialInfo) {
-        Result<MaterialInfo> result = new Result<MaterialInfo>();
+        Result<MaterialInfo> result = new Result<>();
         try {
             materialInfoService.save(materialInfo);
             result.success("添加成功!");
@@ -104,7 +110,7 @@ public class MaterialInfoController {
     @ApiOperation(value = "素材信息-编辑", notes = "素材信息-编辑")
     @PutMapping(value = "/edit")
     public Result<MaterialInfo> edit(@RequestBody MaterialInfo materialInfo) {
-        Result<MaterialInfo> result = new Result<MaterialInfo>();
+        Result<MaterialInfo> result = new Result<>();
         MaterialInfo materialInfoEntity = materialInfoService.getById(materialInfo.getId());
         if (materialInfoEntity == null) {
             result.error500("未找到对应实体");
@@ -147,7 +153,7 @@ public class MaterialInfoController {
     @ApiOperation(value = "素材信息-批量删除", notes = "素材信息-批量删除")
     @DeleteMapping(value = "/deleteBatch")
     public Result<MaterialInfo> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
-        Result<MaterialInfo> result = new Result<MaterialInfo>();
+        Result<MaterialInfo> result = new Result<>();
         if (ids == null || "".equals(ids.trim())) {
             result.error500("参数不识别!");
         } else {

+ 15 - 9
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/entity/MaterialInfo.java

@@ -1,6 +1,5 @@
 package cn.com.ctop.manage.modules.material.entity;
 
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -29,9 +28,9 @@ public class MaterialInfo {
     /**
      * id
      */
-    @TableId(type = IdType.UUID)
+    @TableId
     @ApiModelProperty(value = "id")
-    private Integer id;
+    private String id;
     /**
      * code
      */
@@ -45,6 +44,19 @@ public class MaterialInfo {
     @ApiModelProperty(value = "url")
     private String url;
     /**
+     * status
+     */
+    @Excel(name = "status", width = 15)
+    @ApiModelProperty(value = "status")
+    private Integer status;
+    /**
+     * userId
+     */
+    @Excel(name = "status", width = 15)
+    @ApiModelProperty(value = "status")
+    private String userId;
+
+    /**
      * createTime
      */
     @ApiModelProperty(value = "createTime")
@@ -54,10 +66,4 @@ public class MaterialInfo {
      */
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
-    /**
-     * status
-     */
-    @Excel(name = "status", width = 15)
-    @ApiModelProperty(value = "status")
-    private Integer status;
 }

+ 1 - 1
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/IMaterialInfoService.java

@@ -17,5 +17,5 @@ public interface IMaterialInfoService extends IService<MaterialInfo> {
 
     Map<String, Object> checkMaterialInfo(String code);
 
-    Map<String, Object> insert(String code, String url);
+    Map<String, Object> insert(String userId, String code, String url);
 }

+ 4 - 2
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialInfoServiceImpl.java

@@ -47,12 +47,14 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     }
 
     @Override
-    public Map<String, Object> insert(String code, String url) {
+    public Map<String, Object> insert(String userId, String code, String url) {
         Map<String, Object> resultMap = new HashMap<>();
         MaterialInfo info = new MaterialInfo();
+        info.setId(code);
         info.setCode(code);
-        info.setUrl(url);
+        info.setUrl("https:" + url);
         info.setStatus(1);
+        info.setUserId(userId);
         info.setCreateTime(new Date());
         info.setUpdateTime(new Date());
         this.save(info);

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

@@ -82,11 +82,9 @@ public class KuaiShouReportController {
                             if (i == 0) {
                                 kuaishouInterfaceService.getAccountHourlyReport(accessToken, advertiserId, nowDate, nowDate, 500, 1);
                                 hourDate = nowDate;
-                                System.err.println(nowDate);
                             } else if (i > 0) {
                                 String hourAnotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", hourDate, -1);
                                 kuaishouInterfaceService.getAccountHourlyReport(accessToken, advertiserId, hourAnotherDay, hourAnotherDay, 500, 1);
-                                System.err.println(hourAnotherDay);
                                 hourDate = hourAnotherDay;
                             }
 
@@ -107,12 +105,4 @@ public class KuaiShouReportController {
 
     }
 
-
-    public static void main(String[] args) throws ParseException {
-        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-        String anotherDay1 = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
-        String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay1, -180);
-
-        System.err.println(anotherDay);
-    }
 }

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

@@ -1,6 +1,5 @@
 package cn.com.ctop.kuaishou.modules.batch.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;
@@ -30,7 +29,7 @@ public class KuaiShouCreative {
     /**
      * id
      */
-    @TableId(type = IdType.AUTO)
+    @TableId
     @ApiModelProperty(value = "id")
     private Long id;
     /**

+ 2 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouImageGet.java

@@ -1,6 +1,5 @@
 package cn.com.ctop.kuaishou.modules.batch.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;
@@ -30,9 +29,9 @@ public class KuaiShouImageGet {
     /**
      * id
      */
-    @TableId(type = IdType.AUTO)
+    @TableId
     @ApiModelProperty(value = "id")
-    private Long id;
+    private String id;
     /**
      * 账户ID
      */

+ 13 - 10
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java

@@ -1,20 +1,17 @@
 package cn.com.ctop.kuaishou.modules.batch.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;
 
 /**
  * @Description: 快手-获取视频接口
@@ -32,9 +29,9 @@ public class KuaiShouVideoGet {
     /**
      * id
      */
-    @TableId(type = IdType.AUTO)
+    @TableId
     @ApiModelProperty(value = "id")
-    private Long id;
+    private String id;
     /**
      * 账户ID
      */
@@ -70,7 +67,13 @@ public class KuaiShouVideoGet {
      */
     @Excel(name = "视频首帧图片链接", width = 15)
     @ApiModelProperty(value = "视频首帧图片链接")
-    private Object coverUrl;
+    private String coverUrl;
+    /**
+     * 视频首帧图片链接
+     */
+    @Excel(name = "视频MD5值", width = 15)
+    @ApiModelProperty(value = "视频MD5值")
+    private String signature;
     /**
      * 创建时间
      */

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

@@ -92,6 +92,8 @@ public interface IKuaishouInterfaceService {
     void getGroup(String accessToken, Long advertiserId, Long unitId);
 
 
+    void getVideoInfo(String accessToken, Long advertiserId, String photoId);
+
     /**
      * 获取创意信息
      *
@@ -231,6 +233,8 @@ public interface IKuaishouInterfaceService {
      */
     Map<String, Object> advertiserInfo(Long accountId, String accessToken);
 
+    void getVideoList(CtopOauthToken token);
+
     void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate);
 
     void getAdvertiserCampaignReportDaily(CtopOauthToken token, Date startDate, Date endDate);

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

@@ -4,6 +4,8 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.kuaishou.modules.batch.entity.*;
 import cn.com.ctop.kuaishou.modules.batch.mapper.*;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
@@ -66,7 +68,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     @Autowired
     private KuaiShouScheduleMapper shouScheduleMapper;
     @Autowired
-    private KuaiShouCreativeMapper creativeMapper;
+    private IKuaiShouCreativeService creativeService;
     @Autowired
     private KuaiShouConversionInfosMapper conversionInfosMapper;
     @Autowired
@@ -167,11 +169,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         param.put("page", pageNum);
         KuaishouResult<KuaishouReportHourlyAccount> kuaishouResult = null;
         try {
-
             String result = HttpUtils.httpPostRequest(url, param, headers);
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(resultJson)) {
-                System.err.println(resultJson);
                 if (resultJson.getInteger("code") == 0) {
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     if (!Check.isNull(dataJson)) {
@@ -183,7 +183,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                             Long like = detailJson.getLong("like");
                             detailJson.put("photo_like", like);
                             KuaishouReportHourlyAccount kuaishouReportHourlyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportHourlyAccount.class);
-//                            System.err.println(kuaishouReportHourlyAccount);
                             kuaishouReportHourlyAccount.setAccountId(advertiserId);
                             kuaishouReportHourlyAccount.setId("" + advertiserId + kuaishouReportHourlyAccount.getStatDate() + kuaishouReportHourlyAccount.getStatHour());
                             hourlyAccountService.saveOrUpdate(kuaishouReportHourlyAccount);
@@ -201,6 +200,47 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
+    public void getVideoList(CtopOauthToken token) {
+        getVideoListByPage(token, 1);
+    }
+
+    private void getVideoListByPage(CtopOauthToken token, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+        Map<String, Object> param = new HashMap<>();
+        param.put("advertiser_id", token.getAccountId());
+        param.put("page_size", 500);
+        param.put("page", page);
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手视频列表数据异常:{},accountId:{}", message, token.getAccountId());
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+
+        for (int i = 0; i < details.size(); i++) {
+            var detailJson = details.getJSONObject(i);
+            var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
+            kuaiShouVideoGet.setAccountId(token.getAccountId());
+            kuaiShouVideoGet.setId("" + token.getAccountId() + kuaiShouVideoGet.getPhotoId());
+            kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
+        }
+        getVideoListByPage(token, page + 1);
+    }
+
+    @Autowired
+    private IKuaiShouVideoGetService kuaiShouVideoGetService;
+
+    @Override
     public void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate) {
         getAccountDailyReportByPage(token, startDate, endDate, 1);
     }
@@ -264,7 +304,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(resultJson)) {
-                System.err.println(resultJson);
                 if (resultJson.getInteger("code") == 0) {
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     if (!Check.isNull(dataJson)) {
@@ -282,7 +321,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         }
                     }
                 }
-
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -1190,8 +1228,115 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
             }
         }
+    }
 
+    public void getCreativeListByPage(String accessToken, Long advertiserId, Integer page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", " application/json");
+        headers.put("Access-Token", accessToken);
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", advertiserId);
+        param.put("page_size", 200);
+        param.put("page", page);
 
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (Check.isNull(resultJson)) {
+            log.error("获取广告创意返回结果为空,advertiserId:{}", advertiserId);
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取广告创意返回结果异常,advertiserId:{},message:{}", advertiserId, message);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.error("获取广告创意返回结果数据为空,advertiserId:{}", advertiserId);
+            return;
+        }
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject detailJson = JSONObject.parseObject(details.get(i).toString());
+            if (!Check.isNull(detailJson)) {
+                KuaiShouCreative creative = new KuaiShouCreative();
+                creative.setId(detailJson.getLong("creative_id"));
+                creative.setAccountId(advertiserId);
+                creative.setStatus(detailJson.getInteger("status"));
+                creative.setCampaignId(detailJson.getLong("campaign_id"));
+                creative.setUnitId(detailJson.getLong("unit_id"));
+                creative.setCreativeId(detailJson.getLong("creative_id"));
+                creative.setCreativeName(detailJson.getString("creative_name"));
+                creative.setPhotoId(detailJson.getString("photo_id"));
+                creative.setReviewDetail(detailJson.getString("review_detail"));
+                creative.setCoverUrl(detailJson.getString("cover_url"));
+                creative.setCoverHeight(detailJson.getString("cover_height"));
+                creative.setCoverWidth(detailJson.getString("cover_width"));
+                creative.setClickTrackUrl(detailJson.getString("click_track_url"));
+                JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
+                if (!Check.isNull(displayInfoJson)) {
+                    creative.setDescription(displayInfoJson.getString("description"));
+                    creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
+                }
+                creativeService.saveOrUpdate(creative);
+            }
+        }
+        getCreativeList(accessToken, advertiserId, page + 1);
+    }
+
+    /**
+     * 获取视频信息数据
+     *
+     * @param accessToken
+     * @param advertiserId
+     * @param photoId
+     */
+    @Override
+    public void getVideoInfo(String accessToken, Long advertiserId, String photoId) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_GET;
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Content-Type", " application/json");
+        headers.put("Access-Token", accessToken);
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", advertiserId);
+        JSONArray photosArray = new JSONArray();
+        photosArray.add(photoId);
+        param.put("photo_ids", photosArray);
+        try {
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONArray dataArray = resultJson.getJSONArray("data");
+                    if (!Check.isNull(dataArray)) {
+                        for (int i = 0; i < dataArray.size(); i++) {
+                            JSONObject detailJson = dataArray.getJSONObject(i);
+                            if (!Check.isNull(detailJson)) {
+                                KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
+                                videoGet.setId(detailJson.getString("photo_id"));
+                                videoGet.setAccountId(advertiserId);
+                                videoGet.setWidth(detailJson.getInteger("width"));
+                                videoGet.setHeight(detailJson.getInteger("height"));
+                                videoGet.setUrl(detailJson.getLong("unit_id"));
+                                videoGet.setCoverUrl(detailJson.getString("creative_name"));
+                                videoGet.setPhotoId(detailJson.getString("photo_id"));
+                                //videoGet.setSignature(UUID.randomUUID().toString());
+                                kuaiShouVideoGetService.saveOrUpdate(videoGet);
+                            }
+                        }
+                    }
+                } else {
+                    log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
+                }
+
+            } else {
+                log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     /**
@@ -1202,11 +1347,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      */
     @Override
     public void getCreativeList(String accessToken, Long advertiserId, Integer page) {
-        if (page == 1) { // 第一次请求删除历史数据
-            Map<String, Object> map = new HashMap<>();
-            map.put("account_id", advertiserId);
-            creativeMapper.deleteByMap(map);
-        }
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
         Map<String, String> headers = new HashMap<String, String>();
         headers.put("Content-Type", " application/json");
@@ -1229,24 +1369,25 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                 JSONObject detailJson = JSONObject.parseObject(details.get(i).toString());
                                 if (!Check.isNull(detailJson)) {
                                     KuaiShouCreative creative = new KuaiShouCreative();
+                                    creative.setId(detailJson.getLong("creative_id"));
                                     creative.setAccountId(advertiserId);
                                     creative.setStatus(detailJson.getInteger("status"));
-                                    creative.setCampaignId(dataJson.getLong("campaign_id"));
-                                    creative.setUnitId(dataJson.getLong("unit_id"));
-                                    creative.setCreativeId(dataJson.getLong("creative_id"));
-                                    creative.setCreativeName(dataJson.getString("creative_name"));
-                                    creative.setPhotoId(dataJson.getString("photo_id"));
-                                    creative.setReviewDetail(dataJson.getString("review_detail"));
-                                    creative.setCoverUrl(dataJson.getString("cover_url"));
-                                    creative.setCoverHeight(dataJson.getString("cover_height"));
-                                    creative.setCoverWidth(dataJson.getString("cover_width"));
-                                    creative.setClickTrackUrl(dataJson.getString("click_track_url"));
+                                    creative.setCampaignId(detailJson.getLong("campaign_id"));
+                                    creative.setUnitId(detailJson.getLong("unit_id"));
+                                    creative.setCreativeId(detailJson.getLong("creative_id"));
+                                    creative.setCreativeName(detailJson.getString("creative_name"));
+                                    creative.setPhotoId(detailJson.getString("photo_id"));
+                                    creative.setReviewDetail(detailJson.getString("review_detail"));
+                                    creative.setCoverUrl(detailJson.getString("cover_url"));
+                                    creative.setCoverHeight(detailJson.getString("cover_height"));
+                                    creative.setCoverWidth(detailJson.getString("cover_width"));
+                                    creative.setClickTrackUrl(detailJson.getString("click_track_url"));
                                     JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
                                     if (!Check.isNull(displayInfoJson)) {
                                         creative.setDescription(displayInfoJson.getString("description"));
                                         creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
                                     }
-                                    creativeMapper.insert(creative);
+                                    creativeService.saveOrUpdate(creative);
                                 }
 
                             }

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

@@ -1,9 +1,5 @@
 package cn.com.ctop.kuaishou.modules.graphql.service;
 
-import cn.com.ctop.kuaishou.modules.graphql.vo.KuaishouAcceptVO;
-import cn.com.ctop.kuaishou.modules.graphql.vo.KuaishouQrStartVO;
-import cn.com.ctop.kuaishou.modules.graphql.vo.KuaishouUserVO;
-
 import java.io.IOException;
 import java.util.Map;
 
@@ -16,8 +12,6 @@ public interface IKuaishouWebInterfaceService {
 
     public void deleteAllComment(Map<String, String> pcursorMap);
 
-    public void test();
-
     public String qrLogin(String taskId) throws Exception;
 
     public Map<String, Object> loginStatus(String taskId);

文件差異過大導致無法顯示
+ 7 - 198
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/impl/KuaishouWebInterfaceServiceImpl.java


+ 64 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAccount.java

@@ -8,6 +8,7 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Date;
 
 @Data
 @TableName("ctop_kuaishou_report_daily_account")
@@ -50,12 +51,74 @@ public class KuaishouReportDailyAccount implements Serializable {
     private Long block;
     @JsonProperty
     private Long negative;
+    @JsonProperty
+    private Long submit;
     @JsonProperty("download_started")
     private Long downloadStarted;
     @JsonProperty("download_completed")
     private Long downloadCompleted;
     @JsonProperty
     private Long activation;
+
     @JsonProperty
-    private Long submit;
+    private BigDecimal photoClickRatio;
+    @JsonProperty
+    private BigDecimal actionRatio;
+    @JsonProperty("impression_1k_cost")
+    @TableField("impression_1k_cost")
+    private BigDecimal impression1kCost;
+    @JsonProperty
+    private BigDecimal photoClickCost;
+    @JsonProperty
+    private BigDecimal actionCost;
+    @JsonProperty
+    private Long eventPayFirstDay;
+    @JsonProperty
+    private BigDecimal eventPayFirstDayRoi;
+    @JsonProperty
+    private BigDecimal eventPay;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventPayRoi;
+    @JsonProperty
+    private Long eventRegister;
+    @JsonProperty
+    private BigDecimal eventRegisterCost;
+    @JsonProperty
+    private Long eventJinJianApp;
+    @JsonProperty
+    private BigDecimal eventJinJianAppCost;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmountFirstDay;
+    @JsonProperty
+    private Long eventCreditGrantApp;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppCost;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppRatio;
+    @JsonProperty
+    private BigDecimal eventOrderPaid;
+    @JsonProperty
+    private BigDecimal eventOrderPaidPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventOrderPaidCost;
+    @JsonProperty
+    private Long formCount;
+    @JsonProperty
+    private BigDecimal formCost;
+    @JsonProperty
+    private BigDecimal formActionRatio;
+    @JsonProperty
+    private Long eventJinJianLandingPage;
+    @JsonProperty
+    private BigDecimal eventJinJianLandingPageCost;
+    @JsonProperty
+    private Long eventCreditGrantLandingPage;
+    @JsonProperty
+    private BigDecimal eventCreditGrantLandingPageCost;
+    @JsonProperty
+    private Date createTime;
+    @JsonProperty
+    private Date updateTime;
 }

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

@@ -8,6 +8,8 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Date;
+
 @Data
 @TableName("ctop_kuaishou_report_daily_campaign")
 public class KuaishouReportDailyCampaign implements Serializable {
@@ -54,4 +56,66 @@ public class KuaishouReportDailyCampaign implements Serializable {
     private Long activation;
     @JsonProperty
     private Long submit;
+
+    @JsonProperty
+    private BigDecimal photoClickRatio;
+    @JsonProperty
+    private BigDecimal actionRatio;
+    @JsonProperty("impression_1k_cost")
+    @TableField("impression_1k_cost")
+    private BigDecimal impression1kCost;
+    @JsonProperty
+    private BigDecimal photoClickCost;
+    @JsonProperty
+    private BigDecimal actionCost;
+    @JsonProperty
+    private Long eventPayFirstDay;
+    @JsonProperty
+    private BigDecimal eventPayFirstDayRoi;
+    @JsonProperty
+    private BigDecimal eventPay;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventPayRoi;
+    @JsonProperty
+    private Long eventRegister;
+    @JsonProperty
+    private BigDecimal eventRegisterCost;
+    @JsonProperty
+    private Long eventJinJianApp;
+    @JsonProperty
+    private BigDecimal eventJinJianAppCost;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmountFirstDay;
+    @JsonProperty
+    private Long eventCreditGrantApp;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppCost;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppRatio;
+    @JsonProperty
+    private BigDecimal eventOrderPaid;
+    @JsonProperty
+    private BigDecimal eventOrderPaidPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventOrderPaidCost;
+    @JsonProperty
+    private Long formCount;
+    @JsonProperty
+    private BigDecimal formCost;
+    @JsonProperty
+    private BigDecimal formActionRatio;
+    @JsonProperty
+    private Long eventJinJianLandingPage;
+    @JsonProperty
+    private BigDecimal eventJinJianLandingPageCost;
+    @JsonProperty
+    private Long eventCreditGrantLandingPage;
+    @JsonProperty
+    private BigDecimal eventCreditGrantLandingPageCost;
+    @JsonProperty
+    private Date createTime;
+    @JsonProperty
+    private Date updateTime;
 }

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

@@ -8,6 +8,8 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Date;
+
 @Data
 @TableName("ctop_kuaishou_report_daily_creative")
 public class KuaishouReportDailyCreative implements Serializable {
@@ -57,4 +59,66 @@ public class KuaishouReportDailyCreative implements Serializable {
     private Long activation;
     @JsonProperty
     private Long submit;
+
+    @JsonProperty
+    private BigDecimal photoClickRatio;
+    @JsonProperty
+    private BigDecimal actionRatio;
+    @JsonProperty("impression_1k_cost")
+    @TableField("impression_1k_cost")
+    private BigDecimal impression1kCost;
+    @JsonProperty
+    private BigDecimal photoClickCost;
+    @JsonProperty
+    private BigDecimal actionCost;
+    @JsonProperty
+    private Long eventPayFirstDay;
+    @JsonProperty
+    private BigDecimal eventPayFirstDayRoi;
+    @JsonProperty
+    private BigDecimal eventPay;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventPayRoi;
+    @JsonProperty
+    private Long eventRegister;
+    @JsonProperty
+    private BigDecimal eventRegisterCost;
+    @JsonProperty
+    private Long eventJinJianApp;
+    @JsonProperty
+    private BigDecimal eventJinJianAppCost;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmountFirstDay;
+    @JsonProperty
+    private Long eventCreditGrantApp;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppCost;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppRatio;
+    @JsonProperty
+    private BigDecimal eventOrderPaid;
+    @JsonProperty
+    private BigDecimal eventOrderPaidPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventOrderPaidCost;
+    @JsonProperty
+    private Long formCount;
+    @JsonProperty
+    private BigDecimal formCost;
+    @JsonProperty
+    private BigDecimal formActionRatio;
+    @JsonProperty
+    private Long eventJinJianLandingPage;
+    @JsonProperty
+    private BigDecimal eventJinJianLandingPageCost;
+    @JsonProperty
+    private Long eventCreditGrantLandingPage;
+    @JsonProperty
+    private BigDecimal eventCreditGrantLandingPageCost;
+    @JsonProperty
+    private Date createTime;
+    @JsonProperty
+    private Date updateTime;
 }

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

@@ -8,6 +8,8 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Date;
+
 @Data
 @TableName("ctop_kuaishou_report_daily_group")
 public class KuaishouReportDailyGroup implements Serializable {
@@ -58,4 +60,66 @@ public class KuaishouReportDailyGroup implements Serializable {
     private Long activation;
     @JsonProperty
     private Long submit;
+
+    @JsonProperty
+    private BigDecimal photoClickRatio;
+    @JsonProperty
+    private BigDecimal actionRatio;
+    @JsonProperty("impression_1k_cost")
+    @TableField("impression_1k_cost")
+    private BigDecimal impression1kCost;
+    @JsonProperty
+    private BigDecimal photoClickCost;
+    @JsonProperty
+    private BigDecimal actionCost;
+    @JsonProperty
+    private Long eventPayFirstDay;
+    @JsonProperty
+    private BigDecimal eventPayFirstDayRoi;
+    @JsonProperty
+    private BigDecimal eventPay;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventPayRoi;
+    @JsonProperty
+    private Long eventRegister;
+    @JsonProperty
+    private BigDecimal eventRegisterCost;
+    @JsonProperty
+    private Long eventJinJianApp;
+    @JsonProperty
+    private BigDecimal eventJinJianAppCost;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmountFirstDay;
+    @JsonProperty
+    private Long eventCreditGrantApp;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppCost;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppRatio;
+    @JsonProperty
+    private BigDecimal eventOrderPaid;
+    @JsonProperty
+    private BigDecimal eventOrderPaidPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventOrderPaidCost;
+    @JsonProperty
+    private Long formCount;
+    @JsonProperty
+    private BigDecimal formCost;
+    @JsonProperty
+    private BigDecimal formActionRatio;
+    @JsonProperty
+    private Long eventJinJianLandingPage;
+    @JsonProperty
+    private BigDecimal eventJinJianLandingPageCost;
+    @JsonProperty
+    private Long eventCreditGrantLandingPage;
+    @JsonProperty
+    private BigDecimal eventCreditGrantLandingPageCost;
+    @JsonProperty
+    private Date createTime;
+    @JsonProperty
+    private Date updateTime;
 }

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.report.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -7,6 +8,7 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Date;
 
 @Data
 @TableName("ctop_kuaishou_report_hourly_account")
@@ -57,4 +59,66 @@ public class KuaishouReportHourlyAccount implements Serializable {
     private Long activation;
     @JsonProperty
     private Long submit;
+
+    @JsonProperty
+    private BigDecimal photoClickRatio;
+    @JsonProperty
+    private BigDecimal actionRatio;
+    @JsonProperty("impression_1k_cost")
+    @TableField("impression_1k_cost")
+    private BigDecimal impression1kCost;
+    @JsonProperty
+    private BigDecimal photoClickCost;
+    @JsonProperty
+    private BigDecimal actionCost;
+    @JsonProperty
+    private Long eventPayFirstDay;
+    @JsonProperty
+    private BigDecimal eventPayFirstDayRoi;
+    @JsonProperty
+    private BigDecimal eventPay;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventPayRoi;
+    @JsonProperty
+    private Long eventRegister;
+    @JsonProperty
+    private BigDecimal eventRegisterCost;
+    @JsonProperty
+    private Long eventJinJianApp;
+    @JsonProperty
+    private BigDecimal eventJinJianAppCost;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmountFirstDay;
+    @JsonProperty
+    private Long eventCreditGrantApp;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppCost;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppRatio;
+    @JsonProperty
+    private BigDecimal eventOrderPaid;
+    @JsonProperty
+    private BigDecimal eventOrderPaidPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventOrderPaidCost;
+    @JsonProperty
+    private Long formCount;
+    @JsonProperty
+    private BigDecimal formCost;
+    @JsonProperty
+    private BigDecimal formActionRatio;
+    @JsonProperty
+    private Long eventJinJianLandingPage;
+    @JsonProperty
+    private BigDecimal eventJinJianLandingPageCost;
+    @JsonProperty
+    private Long eventCreditGrantLandingPage;
+    @JsonProperty
+    private BigDecimal eventCreditGrantLandingPageCost;
+    @JsonProperty
+    private Date createTime;
+    @JsonProperty
+    private Date updateTime;
 }

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

@@ -8,6 +8,7 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Date;
 
 @Data
 @TableName("ctop_kuaishou_report_hourly_campaign")
@@ -62,4 +63,66 @@ public class KuaishouReportHourlyCampaign implements Serializable {
     private Long activation;
     @JsonProperty
     private Long submit;
+
+    @JsonProperty
+    private BigDecimal photoClickRatio;
+    @JsonProperty
+    private BigDecimal actionRatio;
+    @JsonProperty("impression_1k_cost")
+    @TableField("impression_1k_cost")
+    private BigDecimal impression1kCost;
+    @JsonProperty
+    private BigDecimal photoClickCost;
+    @JsonProperty
+    private BigDecimal actionCost;
+    @JsonProperty
+    private Long eventPayFirstDay;
+    @JsonProperty
+    private BigDecimal eventPayFirstDayRoi;
+    @JsonProperty
+    private BigDecimal eventPay;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventPayRoi;
+    @JsonProperty
+    private Long eventRegister;
+    @JsonProperty
+    private BigDecimal eventRegisterCost;
+    @JsonProperty
+    private Long eventJinJianApp;
+    @JsonProperty
+    private BigDecimal eventJinJianAppCost;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmountFirstDay;
+    @JsonProperty
+    private Long eventCreditGrantApp;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppCost;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppRatio;
+    @JsonProperty
+    private BigDecimal eventOrderPaid;
+    @JsonProperty
+    private BigDecimal eventOrderPaidPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventOrderPaidCost;
+    @JsonProperty
+    private Long formCount;
+    @JsonProperty
+    private BigDecimal formCost;
+    @JsonProperty
+    private BigDecimal formActionRatio;
+    @JsonProperty
+    private Long eventJinJianLandingPage;
+    @JsonProperty
+    private BigDecimal eventJinJianLandingPageCost;
+    @JsonProperty
+    private Long eventCreditGrantLandingPage;
+    @JsonProperty
+    private BigDecimal eventCreditGrantLandingPageCost;
+    @JsonProperty
+    private Date createTime;
+    @JsonProperty
+    private Date updateTime;
 }

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

@@ -8,6 +8,7 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Date;
 
 @Data
 @TableName("ctop_kuaishou_report_hourly_creative")
@@ -57,4 +58,66 @@ public class KuaishouReportHourlyCreative implements Serializable {
     private Long activation;
     @JsonProperty
     private Long submit;
+
+    @JsonProperty
+    private BigDecimal photoClickRatio;
+    @JsonProperty
+    private BigDecimal actionRatio;
+    @JsonProperty("impression_1k_cost")
+    @TableField("impression_1k_cost")
+    private BigDecimal impression1kCost;
+    @JsonProperty
+    private BigDecimal photoClickCost;
+    @JsonProperty
+    private BigDecimal actionCost;
+    @JsonProperty
+    private Long eventPayFirstDay;
+    @JsonProperty
+    private BigDecimal eventPayFirstDayRoi;
+    @JsonProperty
+    private BigDecimal eventPay;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventPayRoi;
+    @JsonProperty
+    private Long eventRegister;
+    @JsonProperty
+    private BigDecimal eventRegisterCost;
+    @JsonProperty
+    private Long eventJinJianApp;
+    @JsonProperty
+    private BigDecimal eventJinJianAppCost;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmountFirstDay;
+    @JsonProperty
+    private Long eventCreditGrantApp;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppCost;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppRatio;
+    @JsonProperty
+    private BigDecimal eventOrderPaid;
+    @JsonProperty
+    private BigDecimal eventOrderPaidPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventOrderPaidCost;
+    @JsonProperty
+    private Long formCount;
+    @JsonProperty
+    private BigDecimal formCost;
+    @JsonProperty
+    private BigDecimal formActionRatio;
+    @JsonProperty
+    private Long eventJinJianLandingPage;
+    @JsonProperty
+    private BigDecimal eventJinJianLandingPageCost;
+    @JsonProperty
+    private Long eventCreditGrantLandingPage;
+    @JsonProperty
+    private BigDecimal eventCreditGrantLandingPageCost;
+    @JsonProperty
+    private Date createTime;
+    @JsonProperty
+    private Date updateTime;
 }

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

@@ -8,6 +8,7 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Date;
 
 @Data
 @TableName("ctop_kuaishou_report_hourly_group")
@@ -57,4 +58,66 @@ public class KuaishouReportHourlyGroup implements Serializable {
     private Long activation;
     @JsonProperty
     private Long submit;
+
+    @JsonProperty
+    private BigDecimal photoClickRatio;
+    @JsonProperty
+    private BigDecimal actionRatio;
+    @JsonProperty("impression_1k_cost")
+    @TableField("impression_1k_cost")
+    private BigDecimal impression1kCost;
+    @JsonProperty
+    private BigDecimal photoClickCost;
+    @JsonProperty
+    private BigDecimal actionCost;
+    @JsonProperty
+    private Long eventPayFirstDay;
+    @JsonProperty
+    private BigDecimal eventPayFirstDayRoi;
+    @JsonProperty
+    private BigDecimal eventPay;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventPayRoi;
+    @JsonProperty
+    private Long eventRegister;
+    @JsonProperty
+    private BigDecimal eventRegisterCost;
+    @JsonProperty
+    private Long eventJinJianApp;
+    @JsonProperty
+    private BigDecimal eventJinJianAppCost;
+    @JsonProperty
+    private BigDecimal eventPayPurchaseAmountFirstDay;
+    @JsonProperty
+    private Long eventCreditGrantApp;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppCost;
+    @JsonProperty
+    private BigDecimal eventCreditGrantAppRatio;
+    @JsonProperty
+    private BigDecimal eventOrderPaid;
+    @JsonProperty
+    private BigDecimal eventOrderPaidPurchaseAmount;
+    @JsonProperty
+    private BigDecimal eventOrderPaidCost;
+    @JsonProperty
+    private Long formCount;
+    @JsonProperty
+    private BigDecimal formCost;
+    @JsonProperty
+    private BigDecimal formActionRatio;
+    @JsonProperty
+    private Long eventJinJianLandingPage;
+    @JsonProperty
+    private BigDecimal eventJinJianLandingPageCost;
+    @JsonProperty
+    private Long eventCreditGrantLandingPage;
+    @JsonProperty
+    private BigDecimal eventCreditGrantLandingPageCost;
+    @JsonProperty
+    private Date createTime;
+    @JsonProperty
+    private Date updateTime;
 }

+ 70 - 0
module-report/src/main/java/cn/com/ctop/bytedance/controller/AccountReportController.java

@@ -0,0 +1,70 @@
+package cn.com.ctop.bytedance.controller;
+
+import cn.com.ctop.bytedance.service.IAccountReportService;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@Slf4j
+@Api(tags = "广告主日报表")
+@RestController
+@RequestMapping("/ctop/accountReport")
+public class AccountReportController {
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
+    @Autowired
+    private IAccountReportService accountReportService;
+
+
+    @PostMapping(value = "/getAdvertiserList")
+    public Result<List<UserAllocation>> queryPageList() {
+        Result<List<UserAllocation>> result = new Result();
+
+        try {
+            QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+            userAllocationQueryWrapper.eq("media_id", 2);
+            userAllocationQueryWrapper.isNotNull("account_id");
+            userAllocationQueryWrapper.groupBy("account_id");
+            userAllocationQueryWrapper.orderByAsc("advertiser_name");
+            List<UserAllocation> userAllocations = userAllocationMapper.selectList(userAllocationQueryWrapper);
+            result.setSuccess(true);
+            result.setMessage("查询成功");
+            result.setResult(userAllocations);
+        } catch (Exception e) {
+            result.setSuccess(true);
+            result.setMessage("查询失败");
+            e.printStackTrace();
+
+        }
+
+        return result;
+    }
+
+    @PostMapping("/getReportList")
+    public JSONObject getReportList(@RequestBody JSONObject json) {
+        JSONObject summaryJson = accountReportService.getSummaryReport(json);
+        return summaryJson;
+
+    }
+
+
+    @PostMapping("/getStatistics")
+    public JSONObject getStatistics(@RequestBody JSONObject json) {
+        JSONObject statisticsJson = accountReportService.getStatistics(json);
+        return statisticsJson;
+
+    }
+
+
+}

+ 139 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/AccountReportMapper.java

@@ -0,0 +1,139 @@
+package cn.com.ctop.bytedance.mapper;
+
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface AccountReportMapper {
+
+
+    /**
+     * 查询 当日最大小时
+     *
+     * @param nowDate
+     * @return
+     */
+    Integer selectMaxHourByDate(String nowDate);
+
+    /**
+     * 今日消耗
+     *
+     * @param date
+     * @return
+     */
+    JSONObject selectDayReport(@Param("date") String date, @Param("accountIds") JSONArray accountIds);
+
+
+    /**
+     * 查询明细
+     *
+     * @param date
+     * @return
+     */
+    List<JSONObject> selectReportDetail(@Param("date") String date, @Param("accountIds") JSONArray accountIds);
+
+    /**
+     * 根据开始、结束日期查询消耗
+     *
+     * @param anotherDay
+     * @param endDate
+     * @return
+     */
+    JSONObject selectByDate(@Param("startDate") String anotherDay, @Param("endDate") String endDate, @Param("accountIds") JSONArray accountIds);
+
+    /**
+     * 查询全部消耗 包括今日消耗
+     *
+     * @return
+     */
+    JSONObject selectAllAccount(@Param("accountIds") JSONArray accountIds);
+
+
+    /**
+     * 根据日期 小时 查询信息
+     *
+     * @param date
+     * @param statHour
+     * @return
+     */
+    JSONObject selectDayHourlyByHourAndDate(@Param("date") String date, @Param("statHour") String statHour, @Param("accountIds") JSONArray accountIds);
+
+    /**
+     * 根据日期 最大小时小时 查询信息
+     *
+     * @param date
+     * @param statHour
+     * @return
+     */
+    JSONObject selectSumDayHourlyByHourAndDate(@Param("date") String date, @Param("statHour") String statHour, @Param("accountIds") JSONArray accountIds);
+
+
+    /**
+     * 查询 七天汇总数据
+     *
+     * @param anotherDay
+     * @param endDate
+     * @return
+     */
+    List<JSONObject> selectDayDetailByDate(@Param("startDate") String anotherDay, @Param("endDate") String endDate, @Param("accountIds") JSONArray accountIds);
+
+
+    /**
+     * 查询所有按月统计数据
+     *
+     * @return
+     */
+    List<JSONObject> selectAllByAccounts(@Param("accountIds") JSONArray accountId);
+
+
+    /**
+     * 查询账号维度 分组数据
+     *
+     * @param date
+     * @param accountIds
+     * @return
+     */
+    List<JSONObject> selectReportDetailGroupAccountId(@Param("date") String date, @Param("accountIds") JSONArray accountIds, @Param("statHour") Integer statHour);
+
+    /**
+     * 根据开始结束时间查询明细
+     *
+     * @param startDate
+     * @param endDate
+     * @param accountIds
+     * @return
+     */
+    List<JSONObject> selectAccountReportByDate(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("accountIds") JSONArray accountIds);
+
+
+    /**
+     *
+     * @param accountIds
+     * @return
+     */
+
+    List<JSONObject> selectAccountReport(@Param("accountIds") JSONArray accountIds);
+
+
+    /**
+     * 查询 根据日期查询汇总数据
+     *
+     * @param date
+     * @param accountIds
+     * @param statHour
+     * @return
+     */
+    JSONObject selectSummaryByAccountId(@Param("date") String date, @Param("accountIds") JSONArray accountIds, @Param("statHour") Integer statHour);
+
+    /**
+     *
+     * @param startDate
+     * @param endDate
+     * @param accountIds
+     * @return
+     */
+    List<JSONObject> selectDayDetailByMonth(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("accountIds") JSONArray accountIds);
+}

+ 11 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/BytedanceReportMapper.java

@@ -52,6 +52,16 @@ public interface BytedanceReportMapper {
     JSONObject selectDayHourlyByHourAndDate(@Param("date") String date, @Param("statHour") String statHour);
 
     /**
+     * 根据日期 最大小时小时 查询信息
+     *
+     * @param date
+     * @param statHour
+     * @return
+     */
+    JSONObject selectSumDayHourlyByHourAndDate(@Param("date") String date, @Param("statHour") String statHour);
+
+
+    /**
      * 查询 七天汇总数据
      *
      * @param anotherDay
@@ -113,6 +123,7 @@ public interface BytedanceReportMapper {
 
     /**
      * 根据日期获取 分时详情数据
+     *
      * @param date
      * @return
      */

+ 295 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/AccountReportMapper.xml

@@ -0,0 +1,295 @@
+<?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.bytedance.mapper.AccountReportMapper">
+
+
+    <select id="selectSummaryByAccountId" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost, -- 消耗
+        sum(photo_show) photoShow, -- 封面展示
+        sum(photo_click) photoClick, -- 封面点击
+        sum(aclick) aclick, -- 素材曝光数
+        (sum(photo_click) / sum(photo_show)) photoClickRatio, -- 封面点击率
+        (sum(form_count) / sum(bclick)) cvr,
+        ((sum(charge) / (sum(photo_show)) * 1000)) cpm,
+        sum(bclick) bClick,-- 行为数
+        sum(form_count) formCount, -- 表单提交数
+        (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
+        sum(activation) activationCount, -- 激活数
+        (sum(charge) / sum(activation)) activationPrice -- 激活单价
+        from
+        ctop_kuaishou_report_hourly_account
+        where stat_date = #{date}
+        and account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        and stat_hour &lt;= #{statHour}
+    </select>
+
+
+    <select id="selectAccountReport" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost, -- 消耗
+        sum(photo_show) photoShow, -- 封面展示
+        sum(photo_click) photoClick, -- 封面点击
+        sum(aclick) aclick, -- 素材曝光数
+        (sum(photo_click) / sum(photo_show)) photoClickRatio, -- 封面点击率
+        (sum(form_count) / sum(bclick)) cvr,
+        ((sum(charge) / (sum(photo_show)) * 1000)) cpm,
+        sum(bclick) bClick,-- 行为数
+        sum(form_count) formCount,
+        (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
+        sum(activation) activationCount, -- 激活数
+        (sum(charge) / sum(activation)) activationPrice, -- 激活单价
+        account_id accountId,
+        (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
+        from
+        ctop_kuaishou_report_daily_account
+        where account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        group by account_id;
+    </select>
+
+
+    <select id="selectAccountReportByDate" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost, -- 消耗
+        sum(photo_show) photoShow, -- 封面展示
+        sum(photo_click) photoClick, -- 封面点击
+        sum(aclick) aclick, -- 素材曝光数
+        (sum(photo_click) / sum(photo_show)) photoClickRatio, -- 封面点击率
+        (sum(form_count) / sum(bclick)) cvr,
+        ((sum(charge) / (sum(photo_show)) * 1000)) cpm,
+        sum(bclick) bClick,-- 行为数
+        sum(form_count) formCount,
+        (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
+        sum(activation) activationCount, -- 激活数
+        (sum(charge) / sum(activation)) activationPrice, -- 激活单价
+        account_id accountId,
+        (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
+        from
+        ctop_kuaishou_report_daily_account
+        where stat_date &lt;= #{startDate}
+        and stat_date &gt;= #{endDate}
+        and account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        group by account_id;
+    </select>
+
+
+    <select id="selectReportDetailGroupAccountId" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost, -- 消耗
+        sum(photo_show) photoShow, -- 封面展示
+        sum(photo_click) photoClick, -- 封面点击
+        sum(aclick) aclick, -- 素材曝光数
+        (sum(photo_click) / sum(photo_show)) photoClickRatio, -- 封面点击率
+        (sum(form_count) / sum(bclick)) cvr,
+        ((sum(charge) / (sum(photo_show)) * 1000)) cpm,
+        sum(bclick) bClick,-- 行为数
+        sum(form_count) formCount,
+        (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
+        sum(activation) activationCount, -- 激活数
+        (sum(charge) / sum(activation)) activationPrice, -- 激活单价
+        account_id accountId,
+        (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
+        from
+        ctop_kuaishou_report_hourly_account
+        where stat_date = #{date}
+        and stat_hour &lt;= #{statHour}
+        and account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        group by account_id;
+    </select>
+
+
+    <select id="selectMaxHourByDate" resultType="java.lang.Integer">
+        select
+        max(stat_hour)
+       from
+        ctop_kuaishou_report_hourly_account
+        where stat_date = #{date}
+
+      </select>
+
+
+    <select id="selectDayReport" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost,
+        sum(photo_show) photoShow,
+        sum(photo_click) photoClick,
+        sum(aclick) aclick,
+        max(stat_hour) maxHour
+        from
+        ctop_kuaishou_report_hourly_account
+        where stat_date = #{date}
+        and account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
+
+
+    <select id="selectByDate" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost,
+        sum(photo_show) photoShow,
+        sum(photo_click) photoClick,
+        sum(aclick) aclick
+        from
+        ctop_kuaishou_report_daily_account
+        where stat_date &lt;= #{startDate}
+        and stat_date &gt;= #{endDate}
+        and account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="selectAllAccount" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost,
+        sum(photo_show) photoShow,
+        sum(photo_click) photoClick,
+        sum(aclick) aclick
+        from
+        ctop_kuaishou_report_daily_account
+        where account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
+
+
+    <select id="selectReportDetail" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost,
+        sum(photo_show) photoShow,
+        sum(photo_click) photoClick,
+        sum(aclick) aclick,
+        stat_hour statHour,
+        stat_date statDate
+        from
+        ctop_kuaishou_report_hourly_account
+        where stat_date = #{date}
+        and account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        group by stat_hour
+        order by stat_hour asc
+    </select>
+
+
+    <select id="selectDayHourlyByHourAndDate" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost,
+        sum(photo_show) photoShow,
+        sum(photo_click) photoClick,
+        sum(aclick) aclick
+        from
+        ctop_kuaishou_report_hourly_account
+        where stat_date = #{date}
+        and stat_hour = #{statHour}
+        and account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="selectSumDayHourlyByHourAndDate" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost,
+        sum(photo_show) photoShow,
+        sum(photo_click) photoClick,
+        sum(aclick) aclick
+        from
+        ctop_kuaishou_report_hourly_account
+        where stat_date = #{date}
+        and stat_hour &lt;= #{statHour}
+        and account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
+
+
+    <select id="selectDayDetailByDate" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost,
+        sum(photo_show) photoShow,
+        sum(photo_click) photoClick,
+        sum(aclick) aclick,
+        stat_date statDate
+        from
+        ctop_kuaishou_report_daily_account
+        where stat_date &lt;= #{startDate}
+        and stat_date &gt;= #{endDate}
+        and account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        group by stat_date
+        order by stat_date asc
+    </select>
+
+
+    <select id="selectAllByAccounts" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost,
+        sum(photo_show) photoShow,
+        sum(photo_click) photoClick,
+        sum(aclick) aclick,
+        DATE_FORMAT(stat_date,'%Y-%m') statDate
+        from
+        ctop_kuaishou_report_daily_account
+        where account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        group by DATE_FORMAT(stat_date,'%Y-%m')
+        order by stat_date asc
+    </select>
+
+
+    <select id="selectDayDetailByMonth" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost,
+        sum(photo_show) photoShow,
+        sum(photo_click) photoClick,
+        sum(aclick) aclick,
+        DATE_FORMAT(stat_date,'%Y-%m') statDate
+        from
+        ctop_kuaishou_report_daily_account
+        where stat_date &lt;= #{startDate}
+        and stat_date &gt;= #{endDate}
+        and account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        group by DATE_FORMAT(stat_date,'%Y-%m')
+        order by stat_date asc
+    </select>
+
+
+</mapper>

+ 19 - 6
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/BytedanceReportMapper.xml

@@ -8,7 +8,8 @@
          sum(charge) cost,
          sum(photo_show) photoShow,
          sum(photo_click) photoClick,
-         sum(aclick) aclick
+         sum(aclick) aclick,
+         max(stat_hour) maxHour
        from
         ctop_kuaishou_report_hourly_account
         where stat_date = #{date}
@@ -66,6 +67,18 @@
       and stat_hour = #{statHour}
     </select>
 
+    <select id="selectSumDayHourlyByHourAndDate" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick
+     from
+      ctop_kuaishou_report_hourly_account
+      where stat_date = #{date}
+      and stat_hour &lt;= #{statHour}
+    </select>
+
 
     <select id="selectDayDetailByDate" resultType="com.alibaba.fastjson.JSONObject">
       select
@@ -79,7 +92,7 @@
       where stat_date &lt;= #{startDate}
       and  stat_date &gt;= #{endDate}
       group by stat_date
-      order by stat_date desc
+      order by stat_date asc
     </select>
 
 
@@ -95,7 +108,7 @@
       where stat_date &lt;= #{startDate}
       and  stat_date &gt;= #{endDate}
       group by DATE_FORMAT(stat_date,'%Y-%m')
-      order by stat_date desc
+      order by stat_date asc
     </select>
 
     <select id="selectAllDayDetailByMonth" resultType="com.alibaba.fastjson.JSONObject">
@@ -108,7 +121,7 @@
      from
       ctop_kuaishou_report_daily_account
       group by DATE_FORMAT(stat_date,'%Y-%m')
-      order by stat_date desc
+      order by stat_date asc
     </select>
 
 
@@ -136,7 +149,7 @@
       ctop_kuaishou_report_daily_account
       where DATE_FORMAT(stat_date,'%Y-%m') = #{date}
       group by stat_date
-      order by stat_date desc
+      order by stat_date asc
     </select>
 
 
@@ -180,7 +193,7 @@
       ctop_kuaishou_report_hourly_account
       where stat_date = #{date}
       group by stat_hour
-      order by stat_hour desc
+      order by stat_hour asc
     </select>
 
 

+ 21 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/IAccountReportService.java

@@ -0,0 +1,21 @@
+package cn.com.ctop.bytedance.service;
+
+import com.alibaba.fastjson.JSONObject;
+
+public interface IAccountReportService {
+    /**
+     * 获取汇总报表
+     *
+     * @param json
+     * @return
+     */
+    JSONObject getSummaryReport(JSONObject json);
+
+    /**
+     * 获取 统计报表数据
+     *
+     * @param json
+     * @return
+     */
+    JSONObject getStatistics(JSONObject json);
+}

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

@@ -0,0 +1,446 @@
+package cn.com.ctop.bytedance.service.impl;
+
+import cn.com.ctop.bytedance.mapper.AccountReportMapper;
+import cn.com.ctop.bytedance.service.IAccountReportService;
+import cn.com.ctop.common.module.utils.Check;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class AccountReportServiceImpl implements IAccountReportService {
+    @Autowired
+    private AccountReportMapper accountReportMapper;
+
+    /**
+     * 获取 汇总
+     *
+     * @param json
+     * @return
+     */
+    @Override
+    public JSONObject getSummaryReport(JSONObject json) {
+        JSONObject returnJson = new JSONObject();
+        if (Check.isNull(json)) {
+            return null;
+        }
+        JSONArray accountIds = json.getJSONArray("accountIds");
+        if (Check.isNull(accountIds)) {
+            return null;
+        }
+        try {
+            JSONObject accountJson = new JSONObject();
+            List<JSONObject> detail = new ArrayList<>();
+
+            Integer type = json.getInteger("type");
+            BigDecimal discount = json.getBigDecimal("discount");
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd"); // 当前日期
+            String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1); // 当前日期-1
+            if (type == 1) { // 今日汇总
+                Integer maxHour = accountReportMapper.selectMaxHourByDate(nowDate);
+                if (Check.isNull(maxHour) || maxHour == 0) {
+                    return null;
+                }
+                String maxHourStr = String.valueOf(maxHour - 1);
+                accountJson = accountReportMapper.selectSumDayHourlyByHourAndDate(nowDate, maxHourStr, accountIds); // 今日 小时汇总数据
+                JSONObject yesterdayJson = accountReportMapper.selectSumDayHourlyByHourAndDate(anotherDay, maxHourStr, accountIds); // 昨日 小时汇总数据
+                accountJson.put("maxHour", maxHour);
+                if (!Check.isNull(accountJson)) {
+                    BigDecimal cost = accountJson.getBigDecimal("cost"); // 今日消耗
+                    BigDecimal yesterdayCost = yesterdayJson.getBigDecimal("cost");// 昨日消耗
+                    BigDecimal compareBigDecimal = new BigDecimal(0);
+                    if (yesterdayCost.compareTo(compareBigDecimal) != 0) {
+                        BigDecimal costProportion = (cost.subtract(yesterdayCost)).divide(yesterdayCost, BigDecimal.ROUND_HALF_UP, 2);
+                        accountJson.put("costProportion", costProportion); // 较昨日增加比例
+                    } else {
+                        accountJson.put("costProportion", 0); // 较昨日增加比例
+                    }
+
+                    BigDecimal discountCost = cost.divide(discount, BigDecimal.ROUND_HALF_UP, 2);
+                    accountJson.put("discountCost", discountCost); // 折后消耗
+                    BigDecimal yesterdayDiscountCost = yesterdayCost.divide(discount, BigDecimal.ROUND_HALF_UP, 2);
+                    if (yesterdayDiscountCost.compareTo(compareBigDecimal) != 0) {
+                        BigDecimal discountCostProportion = (discountCost.subtract(yesterdayDiscountCost)).divide(yesterdayDiscountCost, BigDecimal.ROUND_HALF_UP, 2);
+                        accountJson.put("discountCostProportion", discountCostProportion); // 较昨日折后上涨
+                    } else {
+                        accountJson.put("discountCostProportion", 0); // 较昨日折后上涨
+                    }
+
+                    Long photoShow = accountJson.getLong("photoShow");// 今日封面展示
+                    Long yesterdayPhotoShow = yesterdayJson.getLong("photoShow");// 昨日封面展示
+                    if (yesterdayPhotoShow != 0L) {
+                        double showProportion = (photoShow.doubleValue() - yesterdayPhotoShow.doubleValue()) / yesterdayPhotoShow.doubleValue();
+                        accountJson.put("showProportion", showProportion); // 较昨日增加比例
+                    } else {
+                        accountJson.put("showProportion", 0); // 较昨日增加比例
+                    }
+
+                    Long photoClick = accountJson.getLong("photoClick");// 今日封面展示
+                    Long yesterdayPhotoClick = yesterdayJson.getLong("photoClick");// 昨日封面展示
+                    if (yesterdayPhotoClick != 0L) {
+                        double photoClickProportion = (photoClick.doubleValue() - yesterdayPhotoClick.doubleValue()) / yesterdayPhotoClick.doubleValue();
+                        accountJson.put("photoClickProportion", photoClickProportion); // 较昨日增加比例
+                    } else {
+                        accountJson.put("photoClickProportion", 0); // 较昨日增加比例
+                    }
+
+                    Long aClick = accountJson.getLong("aclick");
+                    Long yesterdayAClick = yesterdayJson.getLong("aclick");
+                    if (yesterdayAClick != 0L) {
+                        double aClickProportion = (aClick.doubleValue() - yesterdayAClick.doubleValue()) / yesterdayAClick.doubleValue();
+                        accountJson.put("aClickProportion", aClickProportion); // 较昨日增加比例
+                    } else {
+                        accountJson.put("aClickProportion", 0); // 较昨日增加比例
+                    }
+                }
+
+
+                // 折线图
+                List<JSONObject> yesterdayDetailArr = accountReportMapper.selectReportDetail(anotherDay, accountIds);
+                for (int i = 0; i < yesterdayDetailArr.size(); i++) {
+
+                    JSONObject yesterdayDetail = yesterdayDetailArr.get(i);
+                    if (!Check.isNull(yesterdayDetail)) {
+                        String yesterdayStatHour = yesterdayDetail.getString("statHour");
+                        JSONObject nowJson = accountReportMapper.selectDayHourlyByHourAndDate(nowDate, yesterdayStatHour, accountIds);
+                        if (!Check.isNull(nowJson)) {
+                            nowJson.put("statDate", nowDate);
+                            BigDecimal cost = nowJson.getBigDecimal("cost"); // 今日消耗
+                            BigDecimal yesterdayCost = yesterdayDetail.getBigDecimal("cost");// 昨日消耗
+                            BigDecimal compareBigDecimal = new BigDecimal(0);
+                            if (yesterdayCost.compareTo(compareBigDecimal) != 0) {
+                                BigDecimal costProportion = ((cost.subtract(yesterdayCost))).divide(yesterdayCost, BigDecimal.ROUND_HALF_UP, 2);
+                                nowJson.put("costProportion", costProportion); // 较昨日增加比例
+                            } else {
+                                nowJson.put("costProportion", 0); // 较昨日增加比例
+                            }
+
+                            Long photoShow = nowJson.getLong("photoShow");// 今日封面展示
+                            Long yesterdayPhotoShow = yesterdayDetail.getLong("photoShow");// 昨日封面展示
+                            if (yesterdayPhotoShow != 0L) {
+                                double showProportion = (photoShow.doubleValue() - yesterdayPhotoShow.doubleValue()) / yesterdayPhotoShow.doubleValue();
+                                nowJson.put("showProportion", showProportion); // 较昨日增加比例
+                            } else {
+                                nowJson.put("showProportion", 0); // 较昨日增加比例
+                            }
+
+                            Long photoClick = nowJson.getLong("photoClick");// 今日封面展示
+                            Long yesterdayPhotoClick = yesterdayDetail.getLong("photoClick");// 昨日封面展示
+                            if (yesterdayPhotoClick != 0L) {
+                                double photoClickProportion = (photoClick.doubleValue() - yesterdayPhotoClick.doubleValue()) / yesterdayPhotoClick.doubleValue();
+                                nowJson.put("photoClickProportion", photoClickProportion); // 较昨日增加比例
+                            } else {
+                                nowJson.put("photoClickProportion", 0); // 较昨日增加比例
+                            }
+
+                            Long aClick = nowJson.getLong("aclick");// 今日封面展示
+                            Long yesterdayAClick = yesterdayDetail.getLong("aclick");// 昨日封面展示
+                            if (yesterdayAClick != 0L) {
+                                double aClickProportion = (aClick.doubleValue() - yesterdayAClick.doubleValue()) / yesterdayAClick.doubleValue();
+                                nowJson.put("aClickProportion", aClickProportion); // 较昨日增加比例
+                            } else {
+                                nowJson.put("aClickProportion", 0); // 较昨日增加比例
+                            }
+
+                            BigDecimal discountCost = cost.divide(discount, BigDecimal.ROUND_HALF_UP, 2);
+                            nowJson.put("discountCost", discountCost); // 折后消耗
+                            BigDecimal yesterdayDiscountCost = yesterdayCost.divide(discount, BigDecimal.ROUND_HALF_UP, 2);
+                            if (yesterdayDiscountCost.compareTo(compareBigDecimal) != 0) {
+                                BigDecimal discountCostProportion = (discountCost.subtract(yesterdayDiscountCost)).divide(yesterdayDiscountCost, BigDecimal.ROUND_HALF_UP, 2);
+                                nowJson.put("discountCostProportion", discountCostProportion); // 较昨日折后上涨
+                            } else {
+                                nowJson.put("discountCostProportion", 0); // 较昨日折后上涨
+                            }
+
+
+                            yesterdayDetail.put("now", nowJson);
+                        }
+                    }
+
+                    detail.add(yesterdayDetail);
+                }
+
+            } else if (type == 2) {
+                accountJson = accountReportMapper.selectDayReport(anotherDay, accountIds);
+                detail = accountReportMapper.selectReportDetail(anotherDay, accountIds);
+            } else if (type == 3) { // 近七天
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                accountJson = accountReportMapper.selectByDate(anotherDay, endDate, accountIds);
+
+                detail = accountReportMapper.selectDayDetailByDate(anotherDay, endDate, accountIds);
+
+            } else if (type == 4) { // 近15天
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                accountJson = accountReportMapper.selectByDate(anotherDay, endDate, accountIds);
+                detail = accountReportMapper.selectDayDetailByDate(anotherDay, endDate, accountIds);
+
+            } else if (type == 5) {// 近一个月
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
+                accountJson = accountReportMapper.selectByDate(anotherDay, endDate, accountIds);
+                detail = accountReportMapper.selectDayDetailByDate(anotherDay, endDate, accountIds);
+
+            } else if (type == 6) {// 近三个月
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
+                accountJson = accountReportMapper.selectByDate(anotherDay, endDate, accountIds);
+                detail = accountReportMapper.selectDayDetailByDate(anotherDay, endDate, accountIds);
+
+            } else if (type == 7) {// 近六个月
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
+                accountJson = accountReportMapper.selectByDate(anotherDay, endDate, accountIds);
+                detail = accountReportMapper.selectDayDetailByMonth(anotherDay, endDate, accountIds);
+
+            } else if (type == 8) {  // 所有
+                accountJson = accountReportMapper.selectAllAccount(accountIds);
+                detail = accountReportMapper.selectAllByAccounts(accountIds);
+
+
+            } else if (type == 9) {  // 自定义查询日期
+                String startDate = json.getString("startDate");
+                String endDate = json.getString("endDate");
+                accountJson = accountReportMapper.selectByDate(startDate, endDate, accountIds);
+                detail = accountReportMapper.selectDayDetailByDate(startDate, endDate, accountIds);
+
+            }
+
+            if (type != 1) {
+                if (!Check.isNull(accountJson)) {
+                    BigDecimal cost = accountJson.getBigDecimal("cost");
+                    BigDecimal discountCost = cost.divide(discount, BigDecimal.ROUND_HALF_UP, 2);
+                    accountJson.put("discountCost", discountCost); // 折后消耗
+                }
+            }
+            returnJson.put("summary", accountJson);
+            returnJson.put("trend", detail);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return returnJson;
+    }
+
+    @Override
+    public JSONObject getStatistics(JSONObject json) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            Integer type = json.getInteger("type");
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd"); // 当前日期
+            String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1); // 当前日期-1
+            JSONArray accountIds = json.getJSONArray("accountIds");
+            BigDecimal discount = json.getBigDecimal("discount");
+            if (Check.isNull(accountIds)) {
+                return null;
+            }
+
+            List<JSONObject> accountDetail = new ArrayList<>();
+            Integer statHour = json.getInteger("statHour");
+            Integer hour;
+            if (type == 1) { // 今日汇总
+                if (Check.isNull(statHour)) {
+                    Integer maxHour = accountReportMapper.selectMaxHourByDate(nowDate);
+                    hour = maxHour - 1;
+                } else {
+                    hour = statHour;
+                }
+                JSONObject chainRatioJson = new JSONObject();
+                accountDetail = accountReportMapper.selectReportDetailGroupAccountId(nowDate, accountIds, hour);
+                JSONObject nowAccountSummary = accountReportMapper.selectSummaryByAccountId(nowDate, accountIds, hour);
+                if (!Check.isNull(nowAccountSummary)) {
+                    returnJson.put("now", nowAccountSummary);
+                    JSONObject yesterdayAccountSummary = accountReportMapper.selectSummaryByAccountId(anotherDay, accountIds, hour);
+                    if (!Check.isNull(yesterdayAccountSummary)) {
+                        returnJson.put("yesterday", yesterdayAccountSummary);
+                        BigDecimal nowCost = nowAccountSummary.getBigDecimal("cost");
+                        BigDecimal yesterdayCost = yesterdayAccountSummary.getBigDecimal("cost");
+                        if (!Check.isNull(nowCost) && !Check.isNull(yesterdayCost)) {
+                            if (yesterdayCost.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal costProportion = (nowCost.subtract(yesterdayCost)).divide(yesterdayCost, BigDecimal.ROUND_HALF_UP, 2);
+                                chainRatioJson.put("costProportion", costProportion);
+                            } else {
+                                chainRatioJson.put("costProportion", 0); // 消耗环比
+                            }
+                        }
+
+                        Long photoShow = nowAccountSummary.getLong("photoShow");// 今日封面展示
+                        Long yesterdayPhotoShow = yesterdayAccountSummary.getLong("photoShow");// 昨日封面展示
+                        if (!Check.isNull(photoShow) && !Check.isNull(yesterdayPhotoShow)) {
+                            if (yesterdayPhotoShow != 0L) {
+                                double showProportion = (photoShow.doubleValue() - yesterdayPhotoShow.doubleValue()) / yesterdayPhotoShow.doubleValue();
+                                chainRatioJson.put("showProportion", showProportion); // 较昨日增加比例
+                            } else {
+                                chainRatioJson.put("showProportion", 0); // 展示环比
+                            }
+                        }
+
+                        Long photoClick = nowAccountSummary.getLong("photoClick");// 封面点击
+                        Long yesterdayPhotoClick = yesterdayAccountSummary.getLong("photoClick");
+                        if (!Check.isNull(photoClick) && !Check.isNull(yesterdayPhotoClick)) {
+                            if (yesterdayPhotoClick != 0L) {
+                                double photoClickProportion = (photoClick.doubleValue() - yesterdayPhotoClick.doubleValue()) / yesterdayPhotoClick.doubleValue();
+                                chainRatioJson.put("photoClickProportion", photoClickProportion);
+                            } else {
+                                chainRatioJson.put("photoClickProportion", 0); // 点击环比
+                            }
+                        }
+
+                        Long nowAClick = nowAccountSummary.getLong("aclick"); // 爆光
+                        Long yesterdayAClick = yesterdayAccountSummary.getLong("aclick");
+                        if (!Check.isNull(nowAClick) && !Check.isNull(nowAClick)) {
+                            if (yesterdayAClick != 0L) {
+                                double aClickProportion = (nowAClick.doubleValue() - yesterdayAClick.doubleValue()) / yesterdayAClick.doubleValue();
+                                chainRatioJson.put("aClickProportion", aClickProportion);
+                            } else {
+                                chainRatioJson.put("aClickProportion", 0); //爆光环比
+                            }
+                        }
+
+                        BigDecimal nowPhotoClickRatio = nowAccountSummary.getBigDecimal("photoClickRatio"); // 封面点击率
+                        BigDecimal yesterdayPhotoClickRatio = yesterdayAccountSummary.getBigDecimal("photoClickRatio");
+                        if (!Check.isNull(nowPhotoClickRatio) && !Check.isNull(yesterdayPhotoClickRatio)) {
+                            if (yesterdayPhotoClickRatio.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal photoClickRatioProportion = (nowPhotoClickRatio.subtract(yesterdayPhotoClickRatio)).divide(yesterdayPhotoClickRatio, BigDecimal.ROUND_HALF_UP, 2);
+                                chainRatioJson.put("photoClickRatioProportion", photoClickRatioProportion);
+                            } else {
+                                chainRatioJson.put("photoClickRatioProportion", 0); // 封面点击率环比
+                            }
+                        }
+
+                        BigDecimal nowCvr = nowAccountSummary.getBigDecimal("cvr"); // cvr
+                        BigDecimal yesterdayCvr = yesterdayAccountSummary.getBigDecimal("cvr");
+                        if (!Check.isNull(nowCvr) && !Check.isNull(yesterdayCvr)) {
+                            if (yesterdayCvr.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal cvrProportion = (nowCvr.subtract(yesterdayCvr)).divide(yesterdayCvr, BigDecimal.ROUND_HALF_UP, 2);
+                                chainRatioJson.put("cvrProportion", cvrProportion);
+                            } else {
+                                chainRatioJson.put("cvrProportion", 0); // cvr环比
+                            }
+                        }
+
+                        BigDecimal nowCpm = nowAccountSummary.getBigDecimal("cpm"); // cpm
+                        BigDecimal yesterdayCpm = yesterdayAccountSummary.getBigDecimal("cpm");
+                        if (!Check.isNull(nowCpm) && !Check.isNull(yesterdayCpm)) {
+                            if (yesterdayCpm.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal cpmProportion = (nowCpm.subtract(yesterdayCpm)).divide(yesterdayCpm, BigDecimal.ROUND_HALF_UP, 2);
+                                chainRatioJson.put("cpmProportion", cpmProportion);
+                            } else {
+                                chainRatioJson.put("cpmProportion", 0); // cpm环比
+                            }
+                        }
+
+                        Long nowBClick = nowAccountSummary.getLong("bClick"); // 行为数
+                        Long yesterdayBClick = yesterdayAccountSummary.getLong("bClick");
+                        if (!Check.isNull(nowBClick) && !Check.isNull(yesterdayBClick)) {
+                            if (yesterdayAClick != 0L) {
+                                double bClickProportion = (nowBClick.doubleValue() - yesterdayBClick.doubleValue()) / yesterdayBClick.doubleValue();
+                                chainRatioJson.put("bClickProportion", bClickProportion);
+                            } else {
+                                chainRatioJson.put("bClickProportion", 0); //行为数环比
+                            }
+                        }
+
+                        Long nowFormCount = nowAccountSummary.getLong("formCount"); // 表单提交数
+                        Long yesterdayFormCount = yesterdayAccountSummary.getLong("formCount");
+
+                        if (!Check.isNull(nowFormCount) && !Check.isNull(yesterdayFormCount)) {
+                            if (yesterdayAClick != 0L) {
+                                double formCountProportion = (nowFormCount.doubleValue() - yesterdayFormCount.doubleValue()) / yesterdayFormCount.doubleValue();
+                                chainRatioJson.put("formCountProportion", formCountProportion);
+                            } else {
+                                chainRatioJson.put("formCountProportion", 0); //表单提交数环比
+                            }
+                        }
+
+
+                        Long nowActivationCount = nowAccountSummary.getLong("activationCount"); // 激活数
+                        Long yesterdayActivationCount = yesterdayAccountSummary.getLong("activationCount");
+                        if (!Check.isNull(nowActivationCount) && !Check.isNull(yesterdayActivationCount)) {
+                            if (yesterdayAClick != 0L) {
+                                double activationCountProportion = (nowActivationCount.doubleValue() - yesterdayActivationCount.doubleValue()) / yesterdayActivationCount.doubleValue();
+                                chainRatioJson.put("activationCountProportion", activationCountProportion);
+                            } else {
+                                chainRatioJson.put("activationCountProportion", 0); //表单提交数环比
+                            }
+                        }
+
+                        BigDecimal nowFormPrice = nowAccountSummary.getBigDecimal("formPrice"); // 表单提交单价
+                        BigDecimal yesterdayFormPrice = yesterdayAccountSummary.getBigDecimal("formPrice");
+                        if (!Check.isNull(nowFormPrice) && !Check.isNull(yesterdayFormPrice)) {
+                            if (yesterdayFormPrice.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal formPriceProportion = (nowFormPrice.subtract(yesterdayFormPrice)).divide(yesterdayFormPrice, BigDecimal.ROUND_HALF_UP, 2);
+                                chainRatioJson.put("formPriceProportion", formPriceProportion.divide(discount, BigDecimal.ROUND_HALF_UP, 2));
+                            } else {
+                                chainRatioJson.put("formPriceProportion", 0); // 表单提交单价环比
+                            }
+
+
+                            BigDecimal nowActivationPrice = nowAccountSummary.getBigDecimal("activationPrice"); // 表单提交单价
+                            BigDecimal yesterdayActivationPrice = yesterdayAccountSummary.getBigDecimal("activationPrice");
+                            if (!Check.isNull(nowActivationPrice) && !Check.isNull(yesterdayActivationPrice)) {
+                                if (yesterdayFormPrice.compareTo(new BigDecimal(0)) != 0) {
+                                    BigDecimal activationPriceProportion = (nowActivationPrice.subtract(yesterdayActivationPrice)).divide(yesterdayActivationPrice, BigDecimal.ROUND_HALF_UP, 2);
+                                    chainRatioJson.put("activationPriceProportion", activationPriceProportion.divide(discount, BigDecimal.ROUND_HALF_UP, 2));
+                                } else {
+                                    chainRatioJson.put("activationPriceProportion", 0); // 表单提交单价环比
+                                }
+                            }
+                        }
+                    }
+                }
+                returnJson.put("chainRatio", chainRatioJson);
+            } else if (type == 2) {
+                if (Check.isNull(statHour)) {
+                    accountDetail = accountReportMapper.selectReportDetailGroupAccountId(anotherDay, accountIds, 23);
+                } else {
+                    accountDetail = accountReportMapper.selectReportDetailGroupAccountId(anotherDay, accountIds, statHour);
+                }
+
+            } else if (type == 3) { // 近七天
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds);
+
+            } else if (type == 4) { // 近15天
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds);
+
+
+            } else if (type == 5) {// 近一个月
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
+                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds);
+
+
+            } else if (type == 6) {// 近三个月
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
+                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds);
+
+
+            } else if (type == 7) {// 近六个月
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
+                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds);
+
+
+            } else if (type == 8) {  // 所有
+                accountDetail = accountReportMapper.selectAccountReport(accountIds);
+
+
+            } else if (type == 9) {  // 自定义查询日期
+                String startDate = json.getString("startDate");
+                String endDate = json.getString("endDate");
+                accountDetail = accountReportMapper.selectAccountReportByDate(startDate, endDate, accountIds);
+
+            }
+
+            returnJson.put("accountDetail", accountDetail);
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+
+        return returnJson;
+    }
+
+}

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

@@ -203,9 +203,19 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd"); // 当前日期
             String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1); // 当前日期-1
             if (type == 1) { // 今日总消耗
-                accountJson = reportMapper.selectDayReport(nowDate);
+                JSONObject nowJson = reportMapper.selectDayReport(nowDate);
+                if (Check.isNull(nowJson)) {
+                    return accountJson;
+                }
+                int maxHour = nowJson.getInteger("maxHour");
+                if (maxHour == 0 || Check.isNull(maxHour)) {
+                    return accountJson;
+                }
+                String maxHourStr = String.valueOf(maxHour - 1);
+                accountJson = reportMapper.selectSumDayHourlyByHourAndDate(nowDate, maxHourStr);
+                accountJson.put("maxHour", maxHour);
                 if (!Check.isNull(accountJson)) {
-                    JSONObject yesterdayJson = reportMapper.selectDayReport(anotherDay);
+                    JSONObject yesterdayJson = reportMapper.selectSumDayHourlyByHourAndDate(anotherDay, maxHourStr);
                     if (!Check.isNull(yesterdayJson)) {
                         BigDecimal cost = accountJson.getBigDecimal("cost"); // 今日消耗
                         BigDecimal yesterdayCost = yesterdayJson.getBigDecimal("cost");// 昨日消耗

+ 3 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -215,7 +215,9 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
 
         TreeMap<String, Object> params = new TreeMap<>();
         params.put("advertiser_id", cTopOauthToken.getAccountId());
-        params.put("creative_ids", "[" + creativeIds + "]");
+        if (null != creativeIds && !"".equals(creativeIds.trim())) {
+            params.put("creative_ids", "[" + creativeIds + "]");
+        }
         String result = HttpUtils.httpGetRequest(url, headers, params);
         JSONObject jsonObject = JSONObject.parseObject(result);
         Integer code = jsonObject.getInteger("code");