yumeng 1 viikko sitten
vanhempi
commit
7e59656521

+ 3 - 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -120,6 +120,9 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/material/report/getProjectAccountByUserId", "anon");
         filterChainDefinitionMap.put("/material/report/kuaishou/list", "anon");
         filterChainDefinitionMap.put("/material/report/kuaishou/detail", "anon");
+        filterChainDefinitionMap.put("/material/report/tencent/list", "anon");
+        filterChainDefinitionMap.put("/material/report/tencent/detail", "anon");
+        filterChainDefinitionMap.put("/material/report/tencent/excelV2", "anon");
 
         filterChainDefinitionMap.put("/v1/**", "anon");
 

+ 2 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -61,10 +61,11 @@
         select
         t1.project_id as 'projectId',
         t1.account_id as 'accountId',
-        (select realname from sys_user where id = t1.user_id ) as 'userName',
+        t2.realname as 'userName',
         t1.auth_name as 'authName',
         t1.account_status as 'accountStatus'
         from ctop_user_allocation t1
+        left join sys_user t2 on t2.id = t1.user_id
         where t1.project_id in
         <foreach collection="list" item="item" separator=","
                  open="(" close=")">

+ 41 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java

@@ -769,12 +769,51 @@ public class ProjectMemberController {
     public Result<List<Map<String, Object>>> getProjectAccountBy(String mediaType, String userId) {
         Result<List<Map<String, Object>>> resultBody = new Result<>();
         try {
-            List<Map<String, Object>> result = projectMemberService.getProjectAccountByUserId(userId, mediaType);
+            List<Integer> mediaIds = new ArrayList<>();
+            if ("1".equals(mediaType)) {
+                mediaIds.add(1);
+                mediaIds.add(3);
+            } else if ("2".equals(mediaType)) {
+                mediaIds.add(2);
+                mediaIds.add(4);
+            } else if ("16".equals(mediaType) || "tencent".equals(mediaType)) {
+                mediaIds.add(16);
+            }
+
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            List<String> userIds = new ArrayList<>();
+            if ("CompanyManager".equals(roleCode) || "bytedanceDirector".equals(roleCode) || "kuaishouDirector".equals(roleCode)) {
+                userIds = roleService.getCompanyUsers(roleCode, userId);
+            } else if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
+                userIds = null;
+            } else {
+                userIds.add(userId);
+            }
+
+            List<Map<String, Object>> result = new ArrayList<>();
+            List<JSONObject> projectList = projectMemberService.getProjectByUserIdAndMediaIds(userIds, mediaIds);
+            if (!Check.isNull(projectList)) {
+                Map<Long, List<JSONObject>> accountMap = userAllocationService.getAccountListByProjectList(projectList);
+                for (JSONObject project : projectList) {
+                    if (Check.isNull(project)) {
+                        continue;
+                    }
+                    List<JSONObject> accountList = accountMap.get(project.getLong("projectId"));
+                    if (Check.isNull(accountList)) {
+                        continue;
+                    }
+                    Map<String, Object> temp = new HashMap<>();
+                    temp.put("project", project);
+                    temp.put("account", accountList);
+                    result.add(temp);
+                }
+            }
             resultBody.setSuccess(true);
             resultBody.setResult(result);
         } catch (Exception e) {
+            log.error("getProjectAccountByUserId error, userId={}, mediaType={}", userId, mediaType, e);
             resultBody.setSuccess(false);
-            resultBody.success("查询失败");
+            resultBody.setMessage("查询失败");
         }
         return resultBody;
     }

+ 123 - 0
jeecg-boot-report/src/main/java/cn/com/ctop/common/constant/AccountReportConstants.java

@@ -759,6 +759,124 @@ public class AccountReportConstants {
             "    \"comment\": \"投放场景\"\n" +
             "  }\n" +
             "}";
+    public static final String TENCENT_VIDEO_REPORT_FILED_MAPPING_JSON = "{\n" +
+            "  \"cost\": {\n" +
+            "    \"filed\": \"IFNULL(sum(cost),0) as cost \",\n" +
+            "    \"comment\": \"消耗\"\n" +
+            "  },\n" +
+            "  \"photoShow\": {\n" +
+            "    \"filed\": \"IFNULL(sum(view_count),0) as photoShow \",\n" +
+            "    \"comment\": \"曝光数\"\n" +
+            "  },\n" +
+            "  \"photoClick\": {\n" +
+            "    \"filed\": \"IFNULL(sum(valid_click_count),0) as photoClick \",\n" +
+            "    \"comment\": \"点击数\"\n" +
+            "  },\n" +
+            "  \"aClick\": {\n" +
+            "    \"filed\": \"IFNULL(sum(view_count),0) as aClick \",\n" +
+            "    \"comment\": \"素材曝光数\"\n" +
+            "  },\n" +
+            "  \"bClick\": {\n" +
+            "    \"filed\": \"IFNULL(sum(conversions_count),0) as bClick \",\n" +
+            "    \"comment\": \"转化数\"\n" +
+            "  },\n" +
+            "  \"clickRate\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(view_count) != 0 THEN ROUND(sum(valid_click_count) / sum(view_count),4) ELSE 0 END AS clickRate \",\n" +
+            "    \"comment\": \"点击率\"\n" +
+            "  },\n" +
+            "  \"bClickRate\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(view_count) != 0 THEN ROUND(sum(conversions_count) / sum(view_count),4) ELSE 0 END AS bClickRate \",\n" +
+            "    \"comment\": \"转化率\"\n" +
+            "  },\n" +
+            "  \"cpm\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(view_count) != 0 THEN ROUND(sum(cost) / sum(view_count) * 1000,3) ELSE 0 END AS cpm \",\n" +
+            "    \"comment\": \"平均千次曝光花费\"\n" +
+            "  },\n" +
+            "  \"cpc\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(valid_click_count) != 0 THEN ROUND(sum(cost) / sum(valid_click_count),3) ELSE 0 END AS cpc \",\n" +
+            "    \"comment\": \"平均点击单价\"\n" +
+            "  },\n" +
+            "  \"cpb\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(conversions_count) != 0 THEN ROUND(sum(cost) / sum(conversions_count),3) ELSE 0 END AS cpb \",\n" +
+            "    \"comment\": \"平均转化成本\"\n" +
+            "  },\n" +
+            "  \"active\": {\n" +
+            "    \"filed\": \"IFNULL(sum(activated_count),0) as active \",\n" +
+            "    \"comment\": \"激活数\"\n" +
+            "  },\n" +
+            "  \"activeCost\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(activated_count) != 0 THEN ROUND(sum(cost) / sum(activated_count),3) ELSE 0 END AS activeCost \",\n" +
+            "    \"comment\": \"激活成本\"\n" +
+            "  },\n" +
+            "  \"activeRate\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(valid_click_count) != 0 THEN ROUND(sum(activated_count) / sum(valid_click_count),4) ELSE 0 END AS activeRate \",\n" +
+            "    \"comment\": \"激活率\"\n" +
+            "  },\n" +
+            "  \"register\": {\n" +
+            "    \"filed\": \"IFNULL(sum(reg_pv),0) as register \",\n" +
+            "    \"comment\": \"注册数\"\n" +
+            "  },\n" +
+            "  \"activeRegisterCost\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(reg_pv) != 0 THEN ROUND(sum(cost) / sum(reg_pv),3) ELSE 0 END AS activeRegisterCost \",\n" +
+            "    \"comment\": \"注册成本\"\n" +
+            "  },\n" +
+            "  \"activeRegisterRate\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(activated_count) != 0 THEN ROUND(sum(reg_pv) / sum(activated_count),4) ELSE 0 END AS activeRegisterRate \",\n" +
+            "    \"comment\": \"注册率\"\n" +
+            "  },\n" +
+            "  \"nextDayOpen\": {\n" +
+            "    \"filed\": \"IFNULL(sum(retention_count),0) as nextDayOpen \",\n" +
+            "    \"comment\": \"次留数\"\n" +
+            "  },\n" +
+            "  \"nextDayOpenCost\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(retention_count) != 0 THEN ROUND(sum(cost) / sum(retention_count),3) ELSE 0 END AS nextDayOpenCost \",\n" +
+            "    \"comment\": \"次留成本\"\n" +
+            "  },\n" +
+            "  \"nextDayOpenRate\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(activated_count) != 0 THEN ROUND(sum(retention_count) / sum(activated_count),4) ELSE 0 END AS nextDayOpenRate \",\n" +
+            "    \"comment\": \"次留率\"\n" +
+            "  },\n" +
+            "  \"play3sCount\": {\n" +
+            "    \"filed\": \"IFNULL(sum(play_3s_count),0) as play3sCount \",\n" +
+            "    \"comment\": \"3s播放数\"\n" +
+            "  },\n" +
+            "  \"play3sRate\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(view_count) != 0 THEN ROUND(sum(play_3s_count) / sum(view_count),4) ELSE 0 END AS play3sRate \",\n" +
+            "    \"comment\": \"3s播放率\"\n" +
+            "  },\n" +
+            "  \"convertMaterial\": {\n" +
+            "    \"filed\": \"IFNULL(sum(conversions_count),0) as convertMaterial \",\n" +
+            "    \"comment\": \"转化数\"\n" +
+            "  },\n" +
+            "  \"convertRate\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(valid_click_count) != 0 THEN ROUND(sum(conversions_count) / sum(valid_click_count),4) ELSE 0 END AS convertRate \",\n" +
+            "    \"comment\": \"转化率\"\n" +
+            "  },\n" +
+            "  \"convertCost\": {\n" +
+            "    \"filed\": \"CASE WHEN sum(conversions_count) != 0 THEN ROUND(sum(cost) / sum(conversions_count),3) ELSE 0 END AS convertCost \",\n" +
+            "    \"comment\": \"转化成本\"\n" +
+            "  },\n" +
+            "  \"deepConvert\": {\n" +
+            "    \"filed\": \"IFNULL(sum(deep_conversions_count),0) as deepConvert \",\n" +
+            "    \"comment\": \"深度转化数\"\n" +
+            "  },\n" +
+            "  \"purchasePv\": {\n" +
+            "    \"filed\": \"IFNULL(sum(purchase_pv),0) as purchasePv \",\n" +
+            "    \"comment\": \"付费次数\"\n" +
+            "  },\n" +
+            "  \"purchaseAmount\": {\n" +
+            "    \"filed\": \"IFNULL(sum(purchase_amount),0) as purchaseAmount \",\n" +
+            "    \"comment\": \"付费金额\"\n" +
+            "  },\n" +
+            "  \"firstDayPay\": {\n" +
+            "    \"filed\": \"IFNULL(sum(first_pay_count),0) as firstDayPay \",\n" +
+            "    \"comment\": \"首日付费次数\"\n" +
+            "  },\n" +
+            "  \"videoPlay100Count\": {\n" +
+            "    \"filed\": \"IFNULL(sum(video_outer_play100_count),0) as videoPlay100Count \",\n" +
+            "    \"comment\": \"100%播放数\"\n" +
+            "  }\n" +
+            "}";
 
     public static final String BYTEDANCE_VIDEO_REPORT_FILED = "{\n" +
             "  \"materialName\": {\n" +
@@ -1401,6 +1519,11 @@ public class AccountReportConstants {
 
     }
 
+    public static Map<String, Map<String, Object>> getTencentVideoReportMap() {
+        Object tencentVideoJson = JSON.parseObject(TENCENT_VIDEO_REPORT_FILED_MAPPING_JSON);
+        return JsonResourceUtil.jsonToMap(tencentVideoJson);
+    }
+
     public static Map<String, Map<String, Object>> getBytedanceVideoFiled() {
         Object bytedanceVideoJson = JSON.parseObject(BYTEDANCE_VIDEO_REPORT_FILED);
         return JsonResourceUtil.jsonToMap(bytedanceVideoJson);

+ 31 - 22
jeecg-boot-report/src/main/java/cn/com/ctop/report/controller/TencentMaterialReportDailyDwController.java

@@ -28,6 +28,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 @RestController
 @RequestMapping("material/report")
@@ -57,7 +58,7 @@ public class TencentMaterialReportDailyDwController {
                 throw new Exception("开始和结束时间的时间跨度,不能超过60天,请重新选择");
             }
 
-            String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.getKuaishouVideoReportMap());
+            String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.getTencentVideoReportMap());
             if (Check.isNull(filedAll)) {
                 throw new Exception("初始化查询 字段返回为空");
             }
@@ -96,7 +97,13 @@ public class TencentMaterialReportDailyDwController {
         String materialType = requestBody.getString("materialType");
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
-        String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.getDicMapKs());
+        if (!Check.isNull(startDate)) {
+            startDate = startDate.replace("-", "");
+        }
+        if (!Check.isNull(endDate)) {
+            endDate = endDate.replace("-", "");
+        }
+        String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.getTencentVideoReportMap());
         try {
             if (accountIds != null && accountIds.isEmpty()) {
                 accountIds = null;
@@ -126,7 +133,7 @@ public class TencentMaterialReportDailyDwController {
                 throw new Exception("请输入查询结束时间");
             }
 
-            String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.getKuaishouVideoReportMap());
+            String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.getTencentVideoReportMap());
             if (Check.isNull(filedAll)) {
                 throw new Exception("初始化查询 字段返回为空");
             }
@@ -201,12 +208,8 @@ public class TencentMaterialReportDailyDwController {
         if (!Check.isNull(requestBody.getJSONArray("accountIds"))) {
             requestMap.put("accountIds", requestBody.getJSONArray("accountIds"));
         }
-        if (!Check.isNull(requestBody.getString("target"))) {
-            requestMap.put("target", requestBody.getString("target"));
-        }
-        if (!Check.isNull(requestBody.getString("order"))) {
-            requestMap.put("order", requestBody.getString("order"));
-        }
+        requestMap.put("target", getSortTarget(requestBody.getString("target")));
+        requestMap.put("order", getSortOrder(requestBody.getString("order")));
         if (!Check.isNull(requestBody.getInteger("channelType"))) {
             requestMap.put("channelType", requestBody.getInteger("channelType"));
         }
@@ -214,33 +217,39 @@ public class TencentMaterialReportDailyDwController {
             requestMap.put("materialType", requestBody.getString("materialType"));
         }
 
-        String roleCode = sysRoleMapper.getRoleCodeByUserId(userId);
-        if ("clip".equals(roleCode)) {
-            requestMap.put("clipId", userId);
-        } else if (!Check.isNull(requestBody.getString("clipId"))) {
+        if (!Check.isNull(requestBody.getString("clipId"))) {
             requestMap.put("clipId", requestBody.getString("clipId"));
         }
 
-        if ("shot".equals(roleCode)) {
-            requestMap.put("shotId", userId);
-        } else if (!Check.isNull(requestBody.getString("shotId"))) {
+        if (!Check.isNull(requestBody.getString("shotId"))) {
             requestMap.put("shotId", requestBody.getString("shotId"));
         }
 
-        if ("plan".equals(roleCode)) {
-            requestMap.put("planId", userId);
-        } else if (!Check.isNull(requestBody.getString("planId"))) {
+        if (!Check.isNull(requestBody.getString("planId"))) {
             requestMap.put("planId", requestBody.getString("planId"));
         }
 
-        if ("designTeamLeader".equals(roleCode)) {
-            requestMap.put("leaderId", userId);
-        } else if (!Check.isNull(requestBody.getString("leaderId"))) {
+        if (!Check.isNull(requestBody.getString("leaderId"))) {
             requestMap.put("leaderId", requestBody.getString("leaderId"));
         }
         return requestMap;
     }
 
+    private String getSortTarget(String target) {
+        Set<String> fieldNames = AccountReportConstants.getTencentVideoReportMap().keySet();
+        if (!Check.isNull(target) && fieldNames.contains(target)) {
+            return target;
+        }
+        return "cost";
+    }
+
+    private String getSortOrder(String order) {
+        if ("asc".equalsIgnoreCase(order)) {
+            return "asc";
+        }
+        return "desc";
+    }
+
     private List<String> getFieldTitles(Map<String, Map<String, Object>> fieldMap, List<String> columns) {
         List<String> titles = new ArrayList<>();
         for (String column : columns) {

+ 16 - 16
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/TencentMaterialVideoReportDailyDwMapper.xml

@@ -42,10 +42,10 @@
     <select id="getTotalByMap" resultType="java.lang.Long">
         select count(1)
         from (
-            select signature, material_type
+            select ifnull(nullif(signature, ''), material_id) as signature, material_type
             from application.adq_material_report_daily_dw
             <include refid="baseWhere"/>
-            group by signature, material_type
+            group by ifnull(nullif(signature, ''), material_id), material_type
         ) t
     </select>
 
@@ -57,23 +57,23 @@
                 ifnull(plan_name, '-') as plan,
                 ifnull(shot_name, '-') as shot,
                 ifnull(leader_name, '-') as designLeader,
-                ifnull(video_name, '-') as materialName,
-                ifnull(cover_url, '-') as coverUrl,
-                ifnull(video_url, '-') as url,
+                ifnull(video_name, material_id) as materialName,
+                ifnull(key_frame_image_url, '-') as coverUrl,
+                ifnull(photo_url, '-') as url,
                 ifnull(channel_name, '-') as channel,
                 ifnull(stat_date, '-') as createTime,
                 ifnull(material_type, '-') as materialType,
                 case material_type
-                    when 'IMAGE' then 'IMAGE'
-                    when 'VIDEO' then 'VIDEO'
+                    when 'IMAGE' then '图片'
+                    when 'VIDEO' then '视频'
                     else ifnull(material_type, '-')
                 end as materialTypeName,
-                signature,
+                ifnull(nullif(signature, ''), material_id) as signature,
                 ifnull(project_name, '-') as projectName,
                 ${filed}
             from application.adq_material_report_daily_dw
             <include refid="baseWhere"/>
-            group by signature, material_type
+            group by ifnull(nullif(signature, ''), material_id), material_type
             order by ${target} ${order}
         ) t1
     </select>
@@ -82,21 +82,21 @@
         select
             t1.stat_date as statDate,
             t1.signature,
-            t1.video_url as url,
-            t1.cover_url as converUrl,
+            t1.photo_url as url,
+            t1.key_frame_image_url as coverUrl,
             ifnull(t1.material_type, '-') as materialType,
             case t1.material_type
-                when 'IMAGE' then 'IMAGE'
-                when 'VIDEO' then 'VIDEO'
+                when 'IMAGE' then '图片'
+                when 'VIDEO' then '视频'
                 else ifnull(t1.material_type, '-')
             end as materialTypeName,
-            ifnull(t1.video_name, '-') as materialName,
+            ifnull(t1.video_name, t1.material_id) as materialName,
             t1.project_name as projectName,
             t1.advertiser_name as advertiserName,
             t1.stat_date as createTime,
             ${filed}
         from application.adq_material_report_daily_dw t1
-        where t1.signature = #{signature}
+        where ifnull(nullif(t1.signature, ''), t1.material_id) = #{signature}
           and t1.stat_date >= #{startDate}
           and t1.stat_date &lt;= #{endDate}
         <if test="materialType != null and materialType != ''">
@@ -108,7 +108,7 @@
                 #{item}
             </foreach>
         </if>
-        group by t1.signature, t1.material_type, t1.stat_date
+        group by ifnull(nullif(t1.signature, ''), t1.material_id), t1.material_type, t1.stat_date
         order by t1.stat_date desc
     </select>
 </mapper>