Browse Source

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

xuzuoyun 5 years ago
parent
commit
acec6c4897
19 changed files with 254 additions and 48 deletions
  1. 12 0
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/LoadFileUtil.java
  2. 2 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/controller/FileController.java
  3. 1 1
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/entity/MaterialInfo.java
  4. 2 2
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/mapper/MaterialInfoMapper.java
  5. 1 1
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/mapper/xml/MaterialInfoMapper.xml
  6. 2 2
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/IMaterialInfoService.java
  7. 4 4
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialInfoServiceImpl.java
  8. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  9. 3 2
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/controller/MaterialInfoController.java
  10. 9 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoUpload.java
  11. 35 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  12. 37 0
      module-report/src/main/java/cn/com/ctop/bytedance/controller/MaterialReportController.java
  13. 4 5
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/AccountReportMapper.java
  14. 7 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/MaterialReportMapper.java
  15. 7 1
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/AccountReportMapper.xml
  16. 23 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/MaterialReportMapper.xml
  17. 7 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/IMaterialReportService.java
  18. 80 21
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/AccountReportServiceImpl.java
  19. 17 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/MaterialReportServiceImpl.java

+ 12 - 0
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/LoadFileUtil.java

@@ -1,5 +1,6 @@
 package org.jeecg.common.util;
 package org.jeecg.common.util;
 
 
+import org.apache.commons.codec.digest.DigestUtils;
 import org.jeecg.common.util.encryption.AesEncryptUtil;
 import org.jeecg.common.util.encryption.AesEncryptUtil;
 
 
 import java.io.*;
 import java.io.*;
@@ -94,5 +95,16 @@ public class LoadFileUtil {
         return flag;
         return flag;
     }
     }
 
 
+    /**
+     * 获取文件md5
+     *
+     * @param path
+     * @return
+     * @throws IOException
+     */
+    public static String getMD5(String path) throws IOException {
+        return DigestUtils.md5Hex(new FileInputStream(path));
+    }
+
 
 
 }
 }

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

@@ -1,6 +1,6 @@
 package org.jeecg.modules.fileupload.controller;
 package org.jeecg.modules.fileupload.controller;
 
 
-import cn.com.ctop.manage.modules.material.service.IMaterialInfoService;
+import cn.com.ctop.common.module.service.IMaterialInfoService;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.system.vo.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -12,6 +12,7 @@ import java.util.Map;
 
 
 /**
 /**
  * 素材库工具接口
  * 素材库工具接口
+ *
  * @author jeecg-boot
  * @author jeecg-boot
  */
  */
 @RestController
 @RestController

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

@@ -1,4 +1,4 @@
-package cn.com.ctop.manage.modules.material.entity;
+package cn.com.ctop.common.module.entity;
 
 
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;

+ 2 - 2
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/mapper/MaterialInfoMapper.java

@@ -1,6 +1,6 @@
-package cn.com.ctop.manage.modules.material.mapper;
+package cn.com.ctop.common.module.mapper;
 
 
-import cn.com.ctop.manage.modules.material.entity.MaterialInfo;
+import cn.com.ctop.common.module.entity.MaterialInfo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 
 /**
 /**

+ 1 - 1
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/mapper/xml/MaterialInfoMapper.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?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">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="cn.com.ctop.manage.modules.material.mapper.MaterialInfoMapper">
+<mapper namespace="cn.com.ctop.common.module.mapper.MaterialInfoMapper">
 
 
 </mapper>
 </mapper>

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

@@ -1,6 +1,6 @@
-package cn.com.ctop.manage.modules.material.service;
+package cn.com.ctop.common.module.service;
 
 
-import cn.com.ctop.manage.modules.material.entity.MaterialInfo;
+import cn.com.ctop.common.module.entity.MaterialInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 
 import java.util.Map;
 import java.util.Map;

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

@@ -1,10 +1,10 @@
-package cn.com.ctop.manage.modules.material.service.impl;
+package cn.com.ctop.common.module.service.impl;
 
 
+import cn.com.ctop.common.module.entity.MaterialInfo;
+import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
+import cn.com.ctop.common.module.service.IMaterialInfoService;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.common.module.utils.StatusCode;
-import cn.com.ctop.manage.modules.material.entity.MaterialInfo;
-import cn.com.ctop.manage.modules.material.mapper.MaterialInfoMapper;
-import cn.com.ctop.manage.modules.material.service.IMaterialInfoService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;

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

@@ -58,7 +58,7 @@ public class KuaishouInterfaceConstant {
     /**
     /**
      * 视频文件上传
      * 视频文件上传
      */
      */
-    public static final String VIDEO_UPLOAD = "/rest/openapi/v1/file/ad/video/upload";
+    public static final String VIDEO_UPLOAD = "/rest/openapi/v2/file/ad/video/upload";
     /**
     /**
      * 视频文件获取
      * 视频文件获取
      */
      */

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

@@ -1,7 +1,8 @@
 package cn.com.ctop.manage.modules.material.controller;
 package cn.com.ctop.manage.modules.material.controller;
 
 
-import cn.com.ctop.manage.modules.material.entity.MaterialInfo;
-import cn.com.ctop.manage.modules.material.service.IMaterialInfoService;
+
+import cn.com.ctop.common.module.entity.MaterialInfo;
+import cn.com.ctop.common.module.service.IMaterialInfoService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;

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

@@ -51,6 +51,15 @@ public class KuaiShouVideoUpload {
     @Excel(name = "本地保存地址", width = 15)
     @Excel(name = "本地保存地址", width = 15)
     @ApiModelProperty(value = "本地保存地址")
     @ApiModelProperty(value = "本地保存地址")
     private Object savaPath;
     private Object savaPath;
+
+    /**
+     * 本地保存地址
+     */
+    @Excel(name = "md5", width = 15)
+    @ApiModelProperty(value = "md5")
+    private Object signature;
+
+
     /**
     /**
      * 视频大小
      * 视频大小
      */
      */

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

@@ -1,7 +1,12 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.common.module.entity.MaterialInfo;
+import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.batch.entity.*;
 import cn.com.ctop.kuaishou.modules.batch.entity.*;
 import cn.com.ctop.kuaishou.modules.batch.mapper.*;
 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.IKuaiShouCreativeService;
@@ -854,9 +859,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     /**
     /**
      * 创建广告计划
      * 创建广告计划
      *
      *
-     * @param accessToken token信息
-     * @param advertiserId  广告主id
-     * @param requestJson 请求参数拼装
+     * @param accessToken  token信息
+     * @param advertiserId 广告主id
+     * @param requestJson  请求参数拼装
      */
      */
     @Override
     @Override
     public Map<String, Object> campaignCreate(String accessToken, Long advertiserId, JSONObject requestJson) {
     public Map<String, Object> campaignCreate(String accessToken, Long advertiserId, JSONObject requestJson) {
@@ -1580,6 +1585,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
 
     }
     }
 
 
+    @Autowired
+    private MaterialInfoMapper materialInfoMapper;
+
     @Override
     @Override
     public Map<String, Object> videoUpload(Long advertiserId, String accessToken, String videoUrl) {
     public Map<String, Object> videoUpload(Long advertiserId, String accessToken, String videoUrl) {
         Map<String, Object> returnMap = new HashMap<>();
         Map<String, Object> returnMap = new HashMap<>();
@@ -1600,11 +1608,25 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 log.error("下载文件到本地文件夹失败,filePath:{},accountId:{}", videoUrl, advertiserId);
                 log.error("下载文件到本地文件夹失败,filePath:{},accountId:{}", videoUrl, advertiserId);
                 throw new Exception("下载文件到本地失败");
                 throw new Exception("下载文件到本地失败");
             }
             }
+
+            QueryWrapper<MaterialInfo> materialInfoQueryWrapper = new QueryWrapper<>();
+            materialInfoQueryWrapper.eq("url", videoUrl);
+            materialInfoQueryWrapper.eq("status", 1);
+            materialInfoQueryWrapper.orderByDesc("create_time");
+            materialInfoQueryWrapper.last("limit 1");
+            MaterialInfo materialInfo = materialInfoMapper.selectOne(materialInfoQueryWrapper);
+            String signature;
+            if (Check.isNull(materialInfo) || Check.isNull(materialInfo.getCode())) {
+                signature = LoadFileUtil.getMD5(localUrl);
+            } else {
+                signature = materialInfo.getCode();
+            }
             Long startTime = System.currentTimeMillis();
             Long startTime = System.currentTimeMillis();
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_UPLOAD;
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_UPLOAD;
             JSONObject requestJson = new JSONObject();
             JSONObject requestJson = new JSONObject();
             requestJson.put("advertiser_id", advertiserId);
             requestJson.put("advertiser_id", advertiserId);
-            Map<String, String> headerMap = new HashMap<String, String>();
+            requestJson.put("signature", signature);
+            Map<String, String> headerMap = new HashMap<>();
             headerMap.put("Access-Token", accessToken);
             headerMap.put("Access-Token", accessToken);
             headerMap.put("Content-Type", "multipart/form-data");
             headerMap.put("Content-Type", "multipart/form-data");
             String result = exceptInfoForRestTemplate(url, requestJson, headerMap, localUrl);
             String result = exceptInfoForRestTemplate(url, requestJson, headerMap, localUrl);
@@ -1615,12 +1637,18 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     if (!Check.isNull(dataJson)) {
                     if (!Check.isNull(dataJson)) {
                         KuaiShouVideoUpload kuaiShouVideoUpload = new KuaiShouVideoUpload();
                         KuaiShouVideoUpload kuaiShouVideoUpload = new KuaiShouVideoUpload();
-                        kuaiShouVideoUpload.setPhotoId(dataJson.getString("photo_id"));
+                        String photoId = dataJson.getString("photo_id");
+                        kuaiShouVideoUpload.setPhotoId(photoId);
                         kuaiShouVideoUpload.setAccountId(advertiserId);
                         kuaiShouVideoUpload.setAccountId(advertiserId);
                         kuaiShouVideoUpload.setSavaPath(videoUrl);
                         kuaiShouVideoUpload.setSavaPath(videoUrl);
+                        kuaiShouVideoUpload.setSignature(dataJson.getString("signature"));
                         kuaiShouVideoUpload.setSize(null);
                         kuaiShouVideoUpload.setSize(null);
                         kuaiShouVideoUpload.setType(null);
                         kuaiShouVideoUpload.setType(null);
                         kuaiShouVideoUpload.setUploadTime(DateUtils.timeStamp2Date(System.currentTimeMillis()));
                         kuaiShouVideoUpload.setUploadTime(DateUtils.timeStamp2Date(System.currentTimeMillis()));
+                        Map<String, Object> deleteMap = new HashMap<>();
+                        deleteMap.put("photo_id", photoId);
+                        deleteMap.put("account_id", advertiserId);
+                        videoUploadMapper.deleteByMap(deleteMap);
                         int i = videoUploadMapper.insert(kuaiShouVideoUpload);
                         int i = videoUploadMapper.insert(kuaiShouVideoUpload);
                         if (i > 0) {
                         if (i > 0) {
                             log.info("上传快手视频完成");
                             log.info("上传快手视频完成");
@@ -1639,7 +1667,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         returnMap.put("code", 0);
                         returnMap.put("code", 0);
                         returnMap.put("message", "视频已上传文件");
                         returnMap.put("message", "视频已上传文件");
                         returnMap.put("success", true);
                         returnMap.put("success", true);
-                        returnMap.put("photoId", dataJson.getString("photo_id"));
+                        returnMap.put("photoId", photoId);
                         return returnMap;
                         return returnMap;
                     }
                     }
                 } else {
                 } else {

+ 37 - 0
module-report/src/main/java/cn/com/ctop/bytedance/controller/MaterialReportController.java

@@ -0,0 +1,37 @@
+package cn.com.ctop.bytedance.controller;
+
+
+import cn.com.ctop.bytedance.service.IMaterialReportService;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@RestController
+@RequestMapping("/materialReport")
+public class MaterialReportController {
+    @Autowired
+    private IMaterialReportService materialReportService;
+
+
+    @GetMapping(value = "/getKuaiShouMaterialReport")
+    public JSONObject getKuaiShouMaterialReport(@RequestBody String userId) {
+        String roleCode = materialReportService.getRoleCodeByUserId(userId);
+        if ("operator".equals(roleCode)) {
+            // 根据创建人查询accountId
+
+        } else {
+            // 查询所有
+        }
+
+
+        return null;
+
+    }
+
+
+}

+ 4 - 5
module-report/src/main/java/cn/com/ctop/bytedance/mapper/AccountReportMapper.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.List;
 
 
 public interface AccountReportMapper {
 public interface AccountReportMapper {
@@ -106,16 +107,15 @@ public interface AccountReportMapper {
      * @param accountIds
      * @param accountIds
      * @return
      * @return
      */
      */
-    List<JSONObject> selectAccountReportByDate(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("accountIds") JSONArray accountIds);
+    List<JSONObject> selectAccountReportByDate(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("accountIds") JSONArray accountIds, @Param("discount") BigDecimal discount);
 
 
 
 
     /**
     /**
-     *
      * @param accountIds
      * @param accountIds
      * @return
      * @return
      */
      */
 
 
-    List<JSONObject> selectAccountReport(@Param("accountIds") JSONArray accountIds);
+    List<JSONObject> selectAccountReport(@Param("accountIds") JSONArray accountIds, @Param("discount") BigDecimal discount);
 
 
 
 
     /**
     /**
@@ -126,10 +126,9 @@ public interface AccountReportMapper {
      * @param statHour
      * @param statHour
      * @return
      * @return
      */
      */
-    JSONObject selectSummaryByAccountId(@Param("date") String date, @Param("accountIds") JSONArray accountIds, @Param("statHour") Integer statHour);
+    JSONObject selectSummaryByAccountId(@Param("date") String date, @Param("accountIds") JSONArray accountIds, @Param("statHour") Integer statHour, @Param("discount") BigDecimal discount);
 
 
     /**
     /**
-     *
      * @param startDate
      * @param startDate
      * @param endDate
      * @param endDate
      * @param accountIds
      * @param accountIds

+ 7 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/MaterialReportMapper.java

@@ -0,0 +1,7 @@
+package cn.com.ctop.bytedance.mapper;
+
+import org.apache.ibatis.annotations.Param;
+
+public interface MaterialReportMapper {
+    String getRoleCodeByUserId(@Param("userId") String userId);
+}

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

@@ -15,8 +15,10 @@
         sum(bclick) bClick,-- 行为数
         sum(bclick) bClick,-- 行为数
         sum(form_count) formCount, -- 表单提交数
         sum(form_count) formCount, -- 表单提交数
         (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
         (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
+        ((sum(charge) / sum(form_count)) / #{discount}) afterFormPrice, -- 表单提交单价
         sum(activation) activationCount, -- 激活数
         sum(activation) activationCount, -- 激活数
-        (sum(charge) / sum(activation)) activationPrice -- 激活单价
+        (sum(charge) / sum(activation)) activationPrice, -- 激活单价
+        ((sum(charge) / sum(activation)) / #{discount}) afterActivationPrice -- 激活单价
         from
         from
         ctop_kuaishou_report_hourly_account
         ctop_kuaishou_report_hourly_account
         where stat_date = #{date}
         where stat_date = #{date}
@@ -41,8 +43,10 @@
         sum(bclick) bClick,-- 行为数
         sum(bclick) bClick,-- 行为数
         sum(form_count) formCount,
         sum(form_count) formCount,
         (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
         (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
+        ((sum(charge) / sum(form_count)) / #{discount}) afterFormPrice, -- 表单提交单价
         sum(activation) activationCount, -- 激活数
         sum(activation) activationCount, -- 激活数
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
+        ((sum(charge) / sum(activation)) / #{discount}) afterActivationPrice, -- 激活单价
         account_id accountId,
         account_id accountId,
         (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
         (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
         from
         from
@@ -68,8 +72,10 @@
         sum(bclick) bClick,-- 行为数
         sum(bclick) bClick,-- 行为数
         sum(form_count) formCount,
         sum(form_count) formCount,
         (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
         (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
+        ((sum(charge) / sum(form_count)) / #{discount}) afterFormPrice, -- 表单提交单价
         sum(activation) activationCount, -- 激活数
         sum(activation) activationCount, -- 激活数
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
+        ((sum(charge) / sum(activation)) / #{discount}) afterActivationPrice, -- 激活单价
         account_id accountId,
         account_id accountId,
         (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
         (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
         from
         from

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

@@ -0,0 +1,23 @@
+<?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.MaterialReportMapper">
+
+
+    <select id="getRoleCodeByUserId" parameterType="Object" resultType="java.lang.String">
+	SELECT
+    role_code
+    FROM
+    sys_role
+    WHERE
+    id = (
+    SELECT
+    t2.role_id
+    FROM
+    sys_user t1
+    LEFT JOIN sys_user_role t2 ON t1.id = t2.user_id
+    WHERE
+    t1.id = #{userId,jdbcType=VARCHAR}
+    )
+	</select>
+
+</mapper>

+ 7 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/IMaterialReportService.java

@@ -0,0 +1,7 @@
+package cn.com.ctop.bytedance.service;
+
+public interface IMaterialReportService {
+    String getRoleCodeByUserId(String userId);
+
+
+}

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

@@ -249,10 +249,10 @@ public class AccountReportServiceImpl implements IAccountReportService {
                 }
                 }
                 JSONObject chainRatioJson = new JSONObject();
                 JSONObject chainRatioJson = new JSONObject();
                 accountDetail = accountReportMapper.selectReportDetailGroupAccountId(nowDate, accountIds, hour);
                 accountDetail = accountReportMapper.selectReportDetailGroupAccountId(nowDate, accountIds, hour);
-                JSONObject nowAccountSummary = accountReportMapper.selectSummaryByAccountId(nowDate, accountIds, hour);
+                JSONObject nowAccountSummary = accountReportMapper.selectSummaryByAccountId(nowDate, accountIds, hour, discount);
                 if (!Check.isNull(nowAccountSummary)) {
                 if (!Check.isNull(nowAccountSummary)) {
                     returnJson.put("now", nowAccountSummary);
                     returnJson.put("now", nowAccountSummary);
-                    JSONObject yesterdayAccountSummary = accountReportMapper.selectSummaryByAccountId(anotherDay, accountIds, hour);
+                    JSONObject yesterdayAccountSummary = accountReportMapper.selectSummaryByAccountId(anotherDay, accountIds, hour, discount);
                     if (!Check.isNull(yesterdayAccountSummary)) {
                     if (!Check.isNull(yesterdayAccountSummary)) {
                         returnJson.put("yesterday", yesterdayAccountSummary);
                         returnJson.put("yesterday", yesterdayAccountSummary);
                         BigDecimal nowCost = nowAccountSummary.getBigDecimal("cost");
                         BigDecimal nowCost = nowAccountSummary.getBigDecimal("cost");
@@ -264,6 +264,8 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             } else {
                             } else {
                                 chainRatioJson.put("costProportion", 0); // 消耗环比
                                 chainRatioJson.put("costProportion", 0); // 消耗环比
                             }
                             }
+                        } else {
+                            chainRatioJson.put("costProportion", 0); // 消耗环比
                         }
                         }
 
 
                         Long photoShow = nowAccountSummary.getLong("photoShow");// 今日封面展示
                         Long photoShow = nowAccountSummary.getLong("photoShow");// 今日封面展示
@@ -275,6 +277,8 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             } else {
                             } else {
                                 chainRatioJson.put("showProportion", 0); // 展示环比
                                 chainRatioJson.put("showProportion", 0); // 展示环比
                             }
                             }
+                        } else {
+                            chainRatioJson.put("showProportion", 0); // 展示环比
                         }
                         }
 
 
                         Long photoClick = nowAccountSummary.getLong("photoClick");// 封面点击
                         Long photoClick = nowAccountSummary.getLong("photoClick");// 封面点击
@@ -286,6 +290,8 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             } else {
                             } else {
                                 chainRatioJson.put("photoClickProportion", 0); // 点击环比
                                 chainRatioJson.put("photoClickProportion", 0); // 点击环比
                             }
                             }
+                        } else {
+                            chainRatioJson.put("photoClickProportion", 0); // 点击环比
                         }
                         }
 
 
                         Long nowAClick = nowAccountSummary.getLong("aclick"); // 爆光
                         Long nowAClick = nowAccountSummary.getLong("aclick"); // 爆光
@@ -297,6 +303,8 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             } else {
                             } else {
                                 chainRatioJson.put("aClickProportion", 0); //爆光环比
                                 chainRatioJson.put("aClickProportion", 0); //爆光环比
                             }
                             }
+                        } else {
+                            chainRatioJson.put("aClickProportion", 0); //爆光环比
                         }
                         }
 
 
                         BigDecimal nowPhotoClickRatio = nowAccountSummary.getBigDecimal("photoClickRatio"); // 封面点击率
                         BigDecimal nowPhotoClickRatio = nowAccountSummary.getBigDecimal("photoClickRatio"); // 封面点击率
@@ -308,6 +316,8 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             } else {
                             } else {
                                 chainRatioJson.put("photoClickRatioProportion", 0); // 封面点击率环比
                                 chainRatioJson.put("photoClickRatioProportion", 0); // 封面点击率环比
                             }
                             }
+                        } else {
+                            chainRatioJson.put("photoClickRatioProportion", 0); // 封面点击率环比
                         }
                         }
 
 
                         BigDecimal nowCvr = nowAccountSummary.getBigDecimal("cvr"); // cvr
                         BigDecimal nowCvr = nowAccountSummary.getBigDecimal("cvr"); // cvr
@@ -319,6 +329,8 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             } else {
                             } else {
                                 chainRatioJson.put("cvrProportion", 0); // cvr环比
                                 chainRatioJson.put("cvrProportion", 0); // cvr环比
                             }
                             }
+                        } else {
+                            chainRatioJson.put("cvrProportion", 0); // cvr环比
                         }
                         }
 
 
                         BigDecimal nowCpm = nowAccountSummary.getBigDecimal("cpm"); // cpm
                         BigDecimal nowCpm = nowAccountSummary.getBigDecimal("cpm"); // cpm
@@ -330,6 +342,8 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             } else {
                             } else {
                                 chainRatioJson.put("cpmProportion", 0); // cpm环比
                                 chainRatioJson.put("cpmProportion", 0); // cpm环比
                             }
                             }
+                        } else {
+                            chainRatioJson.put("cpmProportion", 0); // cpm环比
                         }
                         }
 
 
                         Long nowBClick = nowAccountSummary.getLong("bClick"); // 行为数
                         Long nowBClick = nowAccountSummary.getLong("bClick"); // 行为数
@@ -341,6 +355,8 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             } else {
                             } else {
                                 chainRatioJson.put("bClickProportion", 0); //行为数环比
                                 chainRatioJson.put("bClickProportion", 0); //行为数环比
                             }
                             }
+                        } else {
+                            chainRatioJson.put("bClickProportion", 0); //行为数环比
                         }
                         }
 
 
                         Long nowFormCount = nowAccountSummary.getLong("formCount"); // 表单提交数
                         Long nowFormCount = nowAccountSummary.getLong("formCount"); // 表单提交数
@@ -353,6 +369,8 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             } else {
                             } else {
                                 chainRatioJson.put("formCountProportion", 0); //表单提交数环比
                                 chainRatioJson.put("formCountProportion", 0); //表单提交数环比
                             }
                             }
+                        } else {
+                            chainRatioJson.put("formCountProportion", 0); //表单提交数环比
                         }
                         }
 
 
 
 
@@ -365,6 +383,8 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             } else {
                             } else {
                                 chainRatioJson.put("activationCountProportion", 0); //表单提交数环比
                                 chainRatioJson.put("activationCountProportion", 0); //表单提交数环比
                             }
                             }
+                        } else {
+                            chainRatioJson.put("activationCountProportion", 0); //表单提交数环比
                         }
                         }
 
 
                         BigDecimal nowFormPrice = nowAccountSummary.getBigDecimal("formPrice"); // 表单提交单价
                         BigDecimal nowFormPrice = nowAccountSummary.getBigDecimal("formPrice"); // 表单提交单价
@@ -372,26 +392,60 @@ public class AccountReportServiceImpl implements IAccountReportService {
                         if (!Check.isNull(nowFormPrice) && !Check.isNull(yesterdayFormPrice)) {
                         if (!Check.isNull(nowFormPrice) && !Check.isNull(yesterdayFormPrice)) {
                             if (yesterdayFormPrice.compareTo(new BigDecimal(0)) != 0) {
                             if (yesterdayFormPrice.compareTo(new BigDecimal(0)) != 0) {
                                 BigDecimal formPriceProportion = (nowFormPrice.subtract(yesterdayFormPrice)).divide(yesterdayFormPrice, BigDecimal.ROUND_HALF_UP, 2);
                                 BigDecimal formPriceProportion = (nowFormPrice.subtract(yesterdayFormPrice)).divide(yesterdayFormPrice, BigDecimal.ROUND_HALF_UP, 2);
-                                chainRatioJson.put("formPriceProportion", formPriceProportion.divide(discount, BigDecimal.ROUND_HALF_UP, 2));
+                                chainRatioJson.put("beforeFormPriceProportion", formPriceProportion); // 折前消耗单价
                             } else {
                             } else {
-                                chainRatioJson.put("formPriceProportion", 0); // 表单提交单价环比
+                                chainRatioJson.put("beforeFormPriceProportion", 0); // 折前消耗单价
                             }
                             }
+                        } else {
+                            chainRatioJson.put("beforeFormPriceProportion", 0); // 折前消耗单价
+                        }
+
+
+                        BigDecimal nowAfterFormPrice = nowAccountSummary.getBigDecimal("afterFormPrice"); // 表单提交单价
+                        BigDecimal yesterdayAfterFormPrice = yesterdayAccountSummary.getBigDecimal("afterFormPrice");
+                        if (!Check.isNull(nowAfterFormPrice) && !Check.isNull(yesterdayAfterFormPrice)) {
+                            if (yesterdayAfterFormPrice.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal afterFormPriceProportion = (nowAfterFormPrice.subtract(yesterdayAfterFormPrice)).divide(yesterdayAfterFormPrice, BigDecimal.ROUND_HALF_UP, 2);
+                                chainRatioJson.put("afterFormPriceProportion", afterFormPriceProportion); // 折后提交单价
+                            } else {
+                                chainRatioJson.put("afterFormPriceProportion", 0); // 折后提交单价
+                            }
+                        } else {
+                            chainRatioJson.put("afterFormPriceProportion", 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); // 表单提交单价环比
-                                }
+                        BigDecimal nowActivationPrice = nowAccountSummary.getBigDecimal("activationPrice"); // 转化提交单价
+                        BigDecimal yesterdayActivationPrice = yesterdayAccountSummary.getBigDecimal("activationPrice");
+                        if (!Check.isNull(nowActivationPrice) && !Check.isNull(yesterdayActivationPrice)) {
+                            if (yesterdayActivationPrice.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal activationPriceProportion = (nowActivationPrice.subtract(yesterdayActivationPrice)).divide(yesterdayActivationPrice, BigDecimal.ROUND_HALF_UP, 2);
+                                chainRatioJson.put("beforeActivationPriceProportion", activationPriceProportion); // 折前转化单价
+                            } else {
+                                chainRatioJson.put("beforeActivationPriceProportion", 0); // 折前激活单价
                             }
                             }
+                        } else {
+                            chainRatioJson.put("beforeActivationPriceProportion", 0); // 折前激活单价
                         }
                         }
+
+
+                        BigDecimal nowAfterActivationPrice = nowAccountSummary.getBigDecimal("afterActivationPrice"); // 转化提交单价
+                        BigDecimal yesterdayAfterActivationPrice = yesterdayAccountSummary.getBigDecimal("afterActivationPrice");
+                        if (!Check.isNull(nowAfterActivationPrice) && !Check.isNull(yesterdayAfterActivationPrice)) {
+                            if (yesterdayAfterActivationPrice.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal activationPriceProportion = (nowAfterActivationPrice.subtract(yesterdayAfterActivationPrice)).divide(yesterdayAfterActivationPrice, BigDecimal.ROUND_HALF_UP, 2);
+                                chainRatioJson.put("afterActivationPriceProportion", activationPriceProportion); // 折后转化单价
+                            } else {
+                                chainRatioJson.put("afterActivationPriceProportion", 0); // 折后激活单价
+                            }
+                        } else {
+                            chainRatioJson.put("afterActivationPriceProportion", 0); // 折后激活单价
+                        }
+
+
+                        returnJson.put("chainRatio", chainRatioJson);
                     }
                     }
                 }
                 }
-                returnJson.put("chainRatio", chainRatioJson);
             } else if (type == 2) {
             } else if (type == 2) {
                 if (Check.isNull(statHour)) {
                 if (Check.isNull(statHour)) {
                     accountDetail = accountReportMapper.selectReportDetailGroupAccountId(anotherDay, accountIds, 23);
                     accountDetail = accountReportMapper.selectReportDetailGroupAccountId(anotherDay, accountIds, 23);
@@ -401,46 +455,51 @@ public class AccountReportServiceImpl implements IAccountReportService {
 
 
             } else if (type == 3) { // 近七天
             } else if (type == 3) { // 近七天
                 String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
                 String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
-                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds);
+                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
 
 
             } else if (type == 4) { // 近15天
             } else if (type == 4) { // 近15天
                 String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
                 String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
-                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds);
+                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
 
 
 
 
             } else if (type == 5) {// 近一个月
             } else if (type == 5) {// 近一个月
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
-                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds);
+                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
 
 
 
 
             } else if (type == 6) {// 近三个月
             } else if (type == 6) {// 近三个月
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
-                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds);
+                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
 
 
 
 
             } else if (type == 7) {// 近六个月
             } else if (type == 7) {// 近六个月
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
-                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds);
+                accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
 
 
 
 
             } else if (type == 8) {  // 所有
             } else if (type == 8) {  // 所有
-                accountDetail = accountReportMapper.selectAccountReport(accountIds);
+                accountDetail = accountReportMapper.selectAccountReport(accountIds, discount);
 
 
 
 
             } else if (type == 9) {  // 自定义查询日期
             } else if (type == 9) {  // 自定义查询日期
                 String startDate = json.getString("startDate");
                 String startDate = json.getString("startDate");
                 String endDate = json.getString("endDate");
                 String endDate = json.getString("endDate");
-                accountDetail = accountReportMapper.selectAccountReportByDate(startDate, endDate, accountIds);
+                accountDetail = accountReportMapper.selectAccountReportByDate(startDate, endDate, accountIds, discount);
 
 
             }
             }
 
 
+
             returnJson.put("accountDetail", accountDetail);
             returnJson.put("accountDetail", accountDetail);
+
+
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
 
 
         }
         }
 
 
+
         return returnJson;
         return returnJson;
     }
     }
 
 
+
 }
 }

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.bytedance.service.impl;
+
+import cn.com.ctop.bytedance.mapper.MaterialReportMapper;
+import cn.com.ctop.bytedance.service.IMaterialReportService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MaterialReportServiceImpl implements IMaterialReportService {
+    @Autowired
+    private MaterialReportMapper materialReportMapper;
+
+    @Override
+    public String getRoleCodeByUserId(String userId) {
+        return materialReportMapper.getRoleCodeByUserId(userId);
+    }
+}