소스 검색

内容合作平台 内容池增加 推荐指数

wangyunpeng 2 주 전
부모
커밋
843d3313a6
14개의 변경된 파일312개의 추가작업 그리고 32개의 파일을 삭제
  1. 8 0
      api-module/src/main/java/com/tzld/piaoquan/api/controller/contentplatform/ContentPlatformPlanController.java
  2. 4 1
      api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/contentplatform/ext/ContentPlatformPlanMapperExt.java
  3. 107 8
      api-module/src/main/java/com/tzld/piaoquan/api/job/contentplatform/ContentPlatformVideoJob.java
  4. 1 1
      api-module/src/main/java/com/tzld/piaoquan/api/job/wecom/thirdpart/WeComSendMsgJob.java
  5. 1 1
      api-module/src/main/java/com/tzld/piaoquan/api/model/param/contentplatform/VideoContentListParam.java
  6. 11 0
      api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformVideoDataStatAgg.java
  7. 70 0
      api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformVideoDataStatAggExample.java
  8. 3 0
      api-module/src/main/java/com/tzld/piaoquan/api/model/vo/contentplatform/VideoContentItemVO.java
  9. 6 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/ContentPlatformPlanService.java
  10. 2 1
      api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformApiServiceImpl.java
  11. 21 7
      api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImpl.java
  12. 23 7
      api-module/src/main/resources/mapper/contentplatform/ContentPlatformVideoDataStatAggMapper.xml
  13. 14 6
      api-module/src/main/resources/mapper/contentplatform/ext/ContentPlatformPlanMapperExt.xml
  14. 41 0
      api-module/src/test/java/com/tzld/piaoquan/api/ContentPlatformTest.java

+ 8 - 0
api-module/src/main/java/com/tzld/piaoquan/api/controller/contentplatform/ContentPlatformPlanController.java

@@ -139,4 +139,12 @@ public class ContentPlatformPlanController {
         videoJob.syncContentPlatformVideoDatastatJob(dateStr);
         return CommonResponse.success();
     }
+
+    @ApiOperation(value = "同步最近top1000视频统计数据-推荐指数", hidden = true)
+    @JwtIgnore
+    @GetMapping("/job/calContentPlatformVideoDatastatAggRecommendRateJob")
+    public CommonResponse<Void> calContentPlatformVideoDatastatAggRecommendRateJob(String dateStr) {
+        videoJob.calContentPlatformVideoDatastatAggRecommendRateJob(dateStr);
+        return CommonResponse.success();
+    }
 }

+ 4 - 1
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/contentplatform/ext/ContentPlatformPlanMapperExt.java

@@ -40,6 +40,7 @@ public interface ContentPlatformPlanMapperExt {
                                             @Param("datastatDt") String datastatDt,
                                             @Param("type") String type,
                                             @Param("channel") String channel,
+                                            @Param("strategy") String strategy,
                                             @Param("minScore") Double minScore,
                                             @Param("offset") int offset,
                                             @Param("pageSize") Integer pageSize,
@@ -56,6 +57,7 @@ public interface ContentPlatformPlanMapperExt {
                                                             @Param("datastatDt") String datastatDt,
                                                             @Param("type") String type,
                                                             @Param("channel") String channel,
+                                                            @Param("strategy") String strategy,
                                                             @Param("minScore") Double minScore,
                                                             @Param("excludeVideoIds") List<Long> excludeVideoIds,
                                                             @Param("offset") int offset,
@@ -100,7 +102,7 @@ public interface ContentPlatformPlanMapperExt {
 
     void deleteContentPlatformVideoAgg(@Param("dt") String dt);
 
-    void deleteContentPlatformVideoDatastatAgg(@Param("dt") String aggDt);
+    void deleteContentPlatformVideoDatastatAgg(@Param("dt") String aggDt, @Param("strategy") String strategy);
 
     void deleteContentPlatformVideoDatastat(@Param("dt") String aggDt);
 
@@ -121,6 +123,7 @@ public interface ContentPlatformPlanMapperExt {
                                                   @Param("datastatDt") String datastatDt,
                                                   @Param("type") String type,
                                                   @Param("channel") String channel,
+                                                  @Param("strategy") String strategy,
                                                   @Param("offset") int offset,
                                                   @Param("pageSize") Integer pageSize,
                                                   @Param("sort") String sort);

+ 107 - 8
api-module/src/main/java/com/tzld/piaoquan/api/job/contentplatform/ContentPlatformVideoJob.java

@@ -1,6 +1,7 @@
 package com.tzld.piaoquan.api.job.contentplatform;
 
 import com.aliyun.odps.data.Record;
+import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.google.common.collect.Lists;
 import com.tzld.piaoquan.api.common.enums.contentplatform.UploadVideoAuditStatusEnum;
 import com.tzld.piaoquan.api.dao.mapper.contentplatform.*;
@@ -31,28 +32,29 @@ public class ContentPlatformVideoJob {
 
     @Autowired
     private ContentPlatformPlanMapperExt planMapperExt;
-
     @Autowired
     private ContentPlatformVideoMapper videoMapper;
-
     @Autowired
     private ContentPlatformVideoAggMapper videoAggMapper;
-
     @Autowired
     private ContentPlatformVideoDataStatMapper videoDataStatMapper;
-
+    @Autowired
+    private ContentPlatformVideoDataStatAggMapper videoDataStatAggMapper;
     @Autowired
     private ContentPlatformIllegalVideoMapper illegalVideoMapper;
-
     @Autowired
     private MessageAttachmentService messageAttachmentService;
-
     @Autowired
-    ContentPlatformUploadVideoMapper uploadVideoMapper;
+    private ContentPlatformUploadVideoMapper uploadVideoMapper;
+    @Autowired
+    private ContentPlatformAccountMapper accountMapper;
 
     @Value("${video.agg.days:3}")
     private Integer videoAggDays;
 
+    @ApolloJsonValue("${video.recommend.score.config:{}}")
+    private Map<String, Double> recommendScoreConfig;
+
     @XxlJob("syncContentPlatformVideoJob")
     public ReturnT<String> syncContentPlatformVideoJob(String param) {
         String aggDt = DateUtil.getBeforeDayDateString("yyyyMMdd");
@@ -233,6 +235,12 @@ public class ContentPlatformVideoJob {
         return videoAggMapper.selectByExample(example);
     }
 
+    private List<ContentPlatformVideoDataStatAgg> getVideoDatastatAggList(String dt, String strategy) {
+        ContentPlatformVideoDataStatAggExample example = new ContentPlatformVideoDataStatAggExample();
+        example.createCriteria().andDtEqualTo(dt).andStrategyEqualTo(strategy);
+        return videoDataStatAggMapper.selectByExample(example);
+    }
+
     @XxlJob("syncContentPlatformVideoDatastatJob")
     public ReturnT<String> syncContentPlatformVideoDatastatJob(String param) {
         String aggDt = DateUtil.getBeforeDayDateString("yyyyMMdd");
@@ -276,9 +284,10 @@ public class ContentPlatformVideoJob {
         // 聚合最近14天视频
         List<ContentPlatformVideoDataStatAgg> saveAggList = buildVideoDataStatAggList(aggDt, dtList);
         if (CollectionUtils.isNotEmpty(saveAggList)) {
-            planMapperExt.deleteContentPlatformVideoDatastatAgg(aggDt);
+            planMapperExt.deleteContentPlatformVideoDatastatAgg(aggDt, null);
             planMapperExt.batchInsertContentPlatformVideoDatastatAgg(saveAggList);
         }
+        calContentPlatformVideoDatastatAggRecommendRateJob(param);
         return ReturnT.SUCCESS;
     }
 
@@ -314,6 +323,7 @@ public class ContentPlatformVideoJob {
                     item.setVideoId(videoId);
                     item.setType(type);
                     item.setChannel(channel);
+                    item.setStrategy("normal");
                     item.setFirstLevel(sumFirstLevel);
                     item.setFission0(sumFission0);
                     if (sumFirstLevel > 0) {
@@ -334,6 +344,95 @@ public class ContentPlatformVideoJob {
         return videoDataStatMapper.selectByExample(example);
     }
 
+    @XxlJob("calContentPlatformVideoDatastatAggRecommendRateJob")
+    public ReturnT<String> calContentPlatformVideoDatastatAggRecommendRateJob(String param) {
+        String dt = planMapperExt.getVideoMaxDt();
+        String datastatDt = planMapperExt.getVideoDatastatMaxDt();
+        if (StringUtils.hasText(param)) {
+            dt = param;
+            datastatDt = param;
+        }
+        List<ContentPlatformVideoAgg> videoList = getVideoListByDt(dt);
+        List<ContentPlatformVideoDataStatAgg> aggList = getVideoDatastatAggList(datastatDt, "normal");
+        Map<String, Map<String, Map<Long, Double>>> videoIdTypeChannelScoreMap = aggList.stream()
+                .filter(o -> "normal".equals(o.getStrategy()))
+                .collect(Collectors.groupingBy(
+                        ContentPlatformVideoDataStatAgg::getType,
+                        Collectors.groupingBy(ContentPlatformVideoDataStatAgg::getChannel,
+                                Collectors.toMap(ContentPlatformVideoDataStatAgg::getVideoId, ContentPlatformVideoDataStatAgg::getFissionRate))));
+        List<String> typeList = Arrays.asList("自动回复", "服务号推送", "公众号推送", "企微-社群", "企微-自动回复");
+        List<ContentPlatformAccount> accountList = getAllContentPlatformAccount();
+        List<String> channelList = accountList.stream().map(ContentPlatformAccount::getChannel).collect(Collectors.toList());
+        List<ContentPlatformVideoDataStatAgg> saveList = new ArrayList<>();
+        Long now = System.currentTimeMillis();
+        String strategy = "recommend";
+        for (String type : typeList) {
+            for (String channel : channelList) {
+                for (ContentPlatformVideoAgg video : videoList) {
+                    if (!videoIdTypeChannelScoreMap.containsKey(type)) {
+                        continue;
+                    }
+                    Map<Long, Double> typeVideoScoreMap = videoIdTypeChannelScoreMap.get(type).getOrDefault("sum", new HashMap<>());
+                    Map<Long, Double> channelVideoScoreMap = videoIdTypeChannelScoreMap.get(type).getOrDefault(channel, new HashMap<>());
+                    Double platformScore = video.getScore();
+                    Double channelRate = channelVideoScoreMap.get(video.getVideoId());
+                    Double typeRate = typeVideoScoreMap.get(video.getVideoId());
+                    Double recommendScore = calRecommendScore(platformScore, channelRate, typeRate);
+                    ContentPlatformVideoDataStatAgg agg = new ContentPlatformVideoDataStatAgg();
+                    agg.setDt(datastatDt);
+                    agg.setVideoId(video.getVideoId());
+                    agg.setType(type);
+                    agg.setChannel(channel);
+                    agg.setStrategy(strategy);
+                    agg.setFissionRate(recommendScore);
+                    agg.setCreateTimestamp(now);
+                    saveList.add(agg);
+                }
+            }
+        }
+        if (CollectionUtils.isNotEmpty(saveList)) {
+            planMapperExt.deleteContentPlatformVideoDatastatAgg(datastatDt, strategy);
+            for (List<ContentPlatformVideoDataStatAgg> partition : Lists.partition(saveList, 1000)) {
+                planMapperExt.batchInsertContentPlatformVideoDatastatAgg(partition);
+            }
+        }
+
+        return ReturnT.SUCCESS;
+    }
+
+    private Double calRecommendScore(Double platformScore, Double channelRate, Double typeRate) {
+        // channelRate 本渠道传播率,不存在的为0
+        if (Objects.isNull(channelRate)) {
+            channelRate = 0.0;
+        }
+        // typeRate 行业裂变率, 不存在的为0
+        if (Objects.isNull(typeRate)) {
+            typeRate = 0.0;
+        }
+        Double platformWeight = recommendScoreConfig.getOrDefault("platformWeight", 0.5);
+        Double channelWeight = recommendScoreConfig.getOrDefault("channelWeight", 0.5);
+        Double typeWeight = recommendScoreConfig.getOrDefault("typeWeight", 0.1);
+        Double scalingWeight = recommendScoreConfig.getOrDefault("scalingWeight", 1.5);
+        Double maxScore = recommendScoreConfig.getOrDefault("maxScore", 10.0);
+
+        Double score = platformWeight * platformScore + channelWeight * channelRate;
+        score += typeWeight * (10 - Math.min(10, typeRate));
+        score *= scalingWeight;
+
+        if (score > maxScore) {
+            score = maxScore + (score - maxScore) / 10;
+        }
+        BigDecimal bdScore = new BigDecimal(score);
+        return bdScore.setScale(2, RoundingMode.HALF_UP).doubleValue();
+    }
+
+
+    private List<ContentPlatformAccount> getAllContentPlatformAccount() {
+        ContentPlatformAccountExample example = new ContentPlatformAccountExample();
+        example.createCriteria().andStatusEqualTo(1);
+        return accountMapper.selectByExample(example);
+    }
+
     @XxlJob("syncContentPlatformUploadVideoScoreJob")
     public ReturnT<String> syncContentPlatformUploadVideoScoreJob(String param) {
         String aggDt = DateUtil.getBeforeDayDateString("yyyyMMdd");

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/job/wecom/thirdpart/WeComSendMsgJob.java

@@ -143,7 +143,7 @@ public class WeComSendMsgJob {
         String type = "企微-社群";
         String channel = "sum";
         List<ContentPlatformVideo> videoList = planMapperExt.getVideoMinDatastatScoreList(dt, datastatDt,
-                type, channel, videoMinScore, sentVideoIds, 0, 100, sort);
+                type, channel, "normal", videoMinScore, sentVideoIds, 0, 100, sort);
         // 行业数量不足,按平台推荐top选取视频
         sort = "video.score desc";
         videoList.addAll(planMapperExt.getVideoMinScoreList(dt, videoMinScore, sentVideoIds, 0, 100, sort));

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/model/param/contentplatform/VideoContentListParam.java

@@ -16,6 +16,6 @@ public class VideoContentListParam extends PageParam {
     @ApiModelProperty(value = "行业 0-自动回复、1-服务号推送、2-企微-社群、3-企微-自动回复、4-公众号推送")
     private Integer type = 999;
 
-    @ApiModelProperty(value = "排序 0-平台推荐 1-行业裂变率 2-本渠道裂变率")
+    @ApiModelProperty(value = "排序 0-平台推荐 1-行业裂变率 2-本渠道裂变率 3-推荐指数")
     private Integer sort = 0;
 }

+ 11 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformVideoDataStatAgg.java

@@ -11,6 +11,8 @@ public class ContentPlatformVideoDataStatAgg {
 
     private String channel;
 
+    private String strategy;
+
     private Long firstLevel;
 
     private Long fission0;
@@ -59,6 +61,14 @@ public class ContentPlatformVideoDataStatAgg {
         this.channel = channel;
     }
 
+    public String getStrategy() {
+        return strategy;
+    }
+
+    public void setStrategy(String strategy) {
+        this.strategy = strategy;
+    }
+
     public Long getFirstLevel() {
         return firstLevel;
     }
@@ -102,6 +112,7 @@ public class ContentPlatformVideoDataStatAgg {
         sb.append(", videoId=").append(videoId);
         sb.append(", type=").append(type);
         sb.append(", channel=").append(channel);
+        sb.append(", strategy=").append(strategy);
         sb.append(", firstLevel=").append(firstLevel);
         sb.append(", fission0=").append(fission0);
         sb.append(", fissionRate=").append(fissionRate);

+ 70 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformVideoDataStatAggExample.java

@@ -445,6 +445,76 @@ public class ContentPlatformVideoDataStatAggExample {
             return (Criteria) this;
         }
 
+        public Criteria andStrategyIsNull() {
+            addCriterion("strategy is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyIsNotNull() {
+            addCriterion("strategy is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyEqualTo(String value) {
+            addCriterion("strategy =", value, "strategy");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyNotEqualTo(String value) {
+            addCriterion("strategy <>", value, "strategy");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyGreaterThan(String value) {
+            addCriterion("strategy >", value, "strategy");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyGreaterThanOrEqualTo(String value) {
+            addCriterion("strategy >=", value, "strategy");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyLessThan(String value) {
+            addCriterion("strategy <", value, "strategy");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyLessThanOrEqualTo(String value) {
+            addCriterion("strategy <=", value, "strategy");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyLike(String value) {
+            addCriterion("strategy like", value, "strategy");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyNotLike(String value) {
+            addCriterion("strategy not like", value, "strategy");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyIn(List<String> values) {
+            addCriterion("strategy in", values, "strategy");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyNotIn(List<String> values) {
+            addCriterion("strategy not in", values, "strategy");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyBetween(String value1, String value2) {
+            addCriterion("strategy between", value1, value2, "strategy");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyNotBetween(String value1, String value2) {
+            addCriterion("strategy not between", value1, value2, "strategy");
+            return (Criteria) this;
+        }
+
         public Criteria andFirstLevelIsNull() {
             addCriterion("first_level is null");
             return (Criteria) this;

+ 3 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/vo/contentplatform/VideoContentItemVO.java

@@ -26,4 +26,7 @@ public class VideoContentItemVO {
 
     @ApiModelProperty(value = "本渠道裂变率")
     private Double channelFissionRate;
+
+    @ApiModelProperty(value = "推荐指数")
+    private Double recommendScore;
 }

+ 6 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/ContentPlatformPlanService.java

@@ -35,6 +35,12 @@ public interface ContentPlatformPlanService {
 
     Page<VideoContentItemVO> getVideoContentList(VideoContentListParam param);
 
+    List<ContentPlatformVideoDataStatAgg> getTypeChannelVideoDataStatAggList(String datastatDt,
+                                                                             String type,
+                                                                             String channel,
+                                                                             String strategy,
+                                                                             List<Long> videoIds);
+
     Page<VideoContentItemVO> getUploadVideoContentList(VideoContentListParam param);
 
     List<String> getVideoContentCategoryList();

+ 2 - 1
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformApiServiceImpl.java

@@ -98,7 +98,8 @@ public class ContentPlatformApiServiceImpl implements ContentPlatformApiService
         if (count == 0) {
             return result;
         }
-        List<ContentPlatformVideo> videoList = planMapperExt.getVideoList(listParam, dt, datastatDt, "", "sum", videoMinScore,
+        List<ContentPlatformVideo> videoList = planMapperExt.getVideoList(listParam, dt, datastatDt,
+                "", "sum", "normal", videoMinScore,
                 offset, param.getPageSize(), "video.score desc");
         List<VideoIdTitleVO> list = videoList.stream().map(video -> {
             VideoIdTitleVO vo = new VideoIdTitleVO();

+ 21 - 7
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImpl.java

@@ -485,7 +485,9 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         String sort = getVideoContentListSort(param.getSort());
         String type = getVideoContentListType(param.getType());
         String channel = getVideoContentListChannel(param.getSort(), user.getChannel());
-        List<ContentPlatformVideo> videoList = planMapperExt.getVideoList(param, dt, datastatDt, type, channel, videoMinScore, offset, param.getPageSize(), sort);
+        String strategy = param.getSort() == 3 ? "recommend" : "normal";
+        List<ContentPlatformVideo> videoList = planMapperExt.getVideoList(param, dt, datastatDt, type, channel, strategy,
+                videoMinScore, offset, param.getPageSize(), sort);
         List<VideoContentItemVO> list = buildVideoContentItemVOList(videoList, type, channel, user.getChannel(), datastatDt);
         result.setObjs(list);
         return result;
@@ -509,7 +511,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
     }
 
     private String getVideoContentListChannel(Integer sort, String channel) {
-        if (sort == 2) {
+        if (sort == 2 || sort == 3) {
             return channel;
         }
         return "sum";
@@ -523,6 +525,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
                 return "datastat.fission_rate desc, video.score desc";
             case 2:
                 return "datastat.fission_rate desc, video.score desc";
+            case 3:
+                return "datastat.fission_rate desc, video.score desc";
             default:
                 return "video.score desc";
         }
@@ -543,12 +547,15 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
             Set<Long> ids = new HashSet<>(partition);
             coverMap.putAll(messageAttachmentService.getVideoDetail(ids));
         }
-        List<ContentPlatformVideoDataStatAgg> typeVideoDataStatAggList = getTypeChannelVideoDataStatAggList(datastatDt, type, channel, videoIds);
+        List<ContentPlatformVideoDataStatAgg> typeVideoDataStatAggList = getTypeChannelVideoDataStatAggList(datastatDt, type, channel, "normal", videoIds);
         Map<Long, Double> typeVideoScoreMap = typeVideoDataStatAggList.stream().collect(Collectors.toMap(
                 ContentPlatformVideoDataStatAgg::getVideoId, ContentPlatformVideoDataStatAgg::getFissionRate));
-        List<ContentPlatformVideoDataStatAgg> channelVideoDataStatAggList = getTypeChannelVideoDataStatAggList(datastatDt, type, userChannel, videoIds);
+        List<ContentPlatformVideoDataStatAgg> channelVideoDataStatAggList = getTypeChannelVideoDataStatAggList(datastatDt, type, userChannel, "normal", videoIds);
         Map<Long, Double> channelVideoScoreMap = channelVideoDataStatAggList.stream().collect(Collectors.toMap(
                 ContentPlatformVideoDataStatAgg::getVideoId, ContentPlatformVideoDataStatAgg::getFissionRate));
+        List<ContentPlatformVideoDataStatAgg> recommendVideoDataStatAggList = getTypeChannelVideoDataStatAggList(datastatDt, type, userChannel, "recommend", videoIds);
+        Map<Long, Double> recommendVideoScoreMap = recommendVideoDataStatAggList.stream().collect(Collectors.toMap(
+                ContentPlatformVideoDataStatAgg::getVideoId, ContentPlatformVideoDataStatAgg::getFissionRate));
         List<VideoContentItemVO> result = new ArrayList<>();
         for (ContentPlatformVideo video : videoList) {
             VideoContentItemVO item = new VideoContentItemVO();
@@ -564,14 +571,21 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
             item.setScore(video.getScore());
             item.setIndustryFissionRate(typeVideoScoreMap.get(video.getVideoId()));
             item.setChannelFissionRate(channelVideoScoreMap.get(video.getVideoId()));
+            item.setRecommendScore(recommendVideoScoreMap.get(video.getVideoId()));
             result.add(item);
         }
         return result;
     }
 
-    private List<ContentPlatformVideoDataStatAgg> getTypeChannelVideoDataStatAggList(String datastatDt, String type, String channel, List<Long> videoIds) {
+    @Override
+    public List<ContentPlatformVideoDataStatAgg> getTypeChannelVideoDataStatAggList(String datastatDt,
+                                                                                     String type,
+                                                                                     String channel,
+                                                                                     String strategy,
+                                                                                     List<Long> videoIds) {
         ContentPlatformVideoDataStatAggExample example = new ContentPlatformVideoDataStatAggExample();
-        example.createCriteria().andVideoIdIn(videoIds).andDtEqualTo(datastatDt).andTypeEqualTo(type).andChannelEqualTo(channel);
+        example.createCriteria().andVideoIdIn(videoIds).andDtEqualTo(datastatDt).andTypeEqualTo(type)
+                .andChannelEqualTo(channel).andStrategyEqualTo(strategy);
         return videoDataStatAggMapper.selectByExample(example);
     }
 
@@ -591,7 +605,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         String type = getVideoContentListType(param.getType());
         String channel = getVideoContentListChannel(param.getSort(), user.getChannel());
         List<ContentPlatformVideo> videoList = planMapperExt.getUploadVideoList(param, user.getId(), datastatDt,
-                type, channel, offset, param.getPageSize(), sort);
+                type, channel, "normal", offset, param.getPageSize(), sort);
         List<VideoContentItemVO> list = buildVideoContentItemVOList(videoList, type, channel, user.getChannel(), datastatDt);
         result.setObjs(list);
         return result;

+ 23 - 7
api-module/src/main/resources/mapper/contentplatform/ContentPlatformVideoDataStatAggMapper.xml

@@ -7,6 +7,7 @@
     <result column="video_id" jdbcType="BIGINT" property="videoId" />
     <result column="type" jdbcType="VARCHAR" property="type" />
     <result column="channel" jdbcType="VARCHAR" property="channel" />
+    <result column="strategy" jdbcType="VARCHAR" property="strategy" />
     <result column="first_level" jdbcType="BIGINT" property="firstLevel" />
     <result column="fission0" jdbcType="BIGINT" property="fission0" />
     <result column="fission_rate" jdbcType="DOUBLE" property="fissionRate" />
@@ -71,7 +72,8 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, dt, video_id, `type`, channel, first_level, fission0, fission_rate, create_timestamp
+    id, dt, video_id, `type`, channel, strategy, first_level, fission0, fission_rate, 
+    create_timestamp
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideoDataStatAggExample" resultMap="BaseResultMap">
     select
@@ -108,13 +110,13 @@
   </delete>
   <insert id="insert" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideoDataStatAgg">
     insert into content_platform_video_datastat_agg (id, dt, video_id, 
-      `type`, channel, first_level, 
-      fission0, fission_rate, create_timestamp
-      )
+      `type`, channel, strategy, 
+      first_level, fission0, fission_rate, 
+      create_timestamp)
     values (#{id,jdbcType=BIGINT}, #{dt,jdbcType=VARCHAR}, #{videoId,jdbcType=BIGINT}, 
-      #{type,jdbcType=VARCHAR}, #{channel,jdbcType=VARCHAR}, #{firstLevel,jdbcType=BIGINT}, 
-      #{fission0,jdbcType=BIGINT}, #{fissionRate,jdbcType=DOUBLE}, #{createTimestamp,jdbcType=BIGINT}
-      )
+      #{type,jdbcType=VARCHAR}, #{channel,jdbcType=VARCHAR}, #{strategy,jdbcType=VARCHAR}, 
+      #{firstLevel,jdbcType=BIGINT}, #{fission0,jdbcType=BIGINT}, #{fissionRate,jdbcType=DOUBLE}, 
+      #{createTimestamp,jdbcType=BIGINT})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideoDataStatAgg">
     insert into content_platform_video_datastat_agg
@@ -134,6 +136,9 @@
       <if test="channel != null">
         channel,
       </if>
+      <if test="strategy != null">
+        strategy,
+      </if>
       <if test="firstLevel != null">
         first_level,
       </if>
@@ -163,6 +168,9 @@
       <if test="channel != null">
         #{channel,jdbcType=VARCHAR},
       </if>
+      <if test="strategy != null">
+        #{strategy,jdbcType=VARCHAR},
+      </if>
       <if test="firstLevel != null">
         #{firstLevel,jdbcType=BIGINT},
       </if>
@@ -201,6 +209,9 @@
       <if test="record.channel != null">
         channel = #{record.channel,jdbcType=VARCHAR},
       </if>
+      <if test="record.strategy != null">
+        strategy = #{record.strategy,jdbcType=VARCHAR},
+      </if>
       <if test="record.firstLevel != null">
         first_level = #{record.firstLevel,jdbcType=BIGINT},
       </if>
@@ -225,6 +236,7 @@
       video_id = #{record.videoId,jdbcType=BIGINT},
       `type` = #{record.type,jdbcType=VARCHAR},
       channel = #{record.channel,jdbcType=VARCHAR},
+      strategy = #{record.strategy,jdbcType=VARCHAR},
       first_level = #{record.firstLevel,jdbcType=BIGINT},
       fission0 = #{record.fission0,jdbcType=BIGINT},
       fission_rate = #{record.fissionRate,jdbcType=DOUBLE},
@@ -248,6 +260,9 @@
       <if test="channel != null">
         channel = #{channel,jdbcType=VARCHAR},
       </if>
+      <if test="strategy != null">
+        strategy = #{strategy,jdbcType=VARCHAR},
+      </if>
       <if test="firstLevel != null">
         first_level = #{firstLevel,jdbcType=BIGINT},
       </if>
@@ -269,6 +284,7 @@
       video_id = #{videoId,jdbcType=BIGINT},
       `type` = #{type,jdbcType=VARCHAR},
       channel = #{channel,jdbcType=VARCHAR},
+      strategy = #{strategy,jdbcType=VARCHAR},
       first_level = #{firstLevel,jdbcType=BIGINT},
       fission0 = #{fission0,jdbcType=BIGINT},
       fission_rate = #{fissionRate,jdbcType=DOUBLE},

+ 14 - 6
api-module/src/main/resources/mapper/contentplatform/ext/ContentPlatformPlanMapperExt.xml

@@ -114,7 +114,8 @@
         select video.*
         from content_platform_video_agg video
         left join content_platform_video_datastat_agg datastat
-            on datastat.dt = #{datastatDt} and datastat.type = #{type} and datastat.channel = #{channel} and datastat.video_id = video.video_id
+            on datastat.dt = #{datastatDt} and datastat.type = #{type} and datastat.channel = #{channel}
+                   and datastat.strategy = #{strategy} and datastat.video_id = video.video_id
         where video.dt = #{dt} and video.status = 1 and video.score > #{minScore}
         <if test="param.title!= null and param.title!= ''">
             and video.title like concat('%', #{param.title}, '%')
@@ -144,7 +145,8 @@
         select video.*
         from content_platform_video_agg video
         left join content_platform_video_datastat_agg datastat
-            on datastat.dt = #{datastatDt} and datastat.type = #{type} and datastat.channel = #{channel} and datastat.video_id = video.video_id
+            on datastat.dt = #{datastatDt} and datastat.type = #{type} and datastat.channel = #{channel}
+                   and datastat.strategy = #{strategy} and datastat.video_id = video.video_id
         where video.dt = #{dt} and video.status = 1 and datastat.fission_rate > #{minScore}
         <if test="excludeVideoIds != null and excludeVideoIds.size() > 0">
             and video.video_id not in
@@ -316,7 +318,12 @@
     </delete>
 
     <delete id="deleteContentPlatformVideoDatastatAgg">
-        delete from content_platform_video_datastat_agg where dt = #{dt}
+        delete
+        from content_platform_video_datastat_agg
+        where dt = #{dt}
+        <if test="strategy != null and strategy != ''">
+            and strategy = #{strategy}
+        </if>
     </delete>
 
     <delete id="deleteContentPlatformVideoDatastat">
@@ -334,11 +341,11 @@
     </insert>
 
     <insert id="batchInsertContentPlatformVideoDatastatAgg">
-        insert into content_platform_video_datastat_agg (dt, video_id, `type`, channel, first_level, fission0,
+        insert into content_platform_video_datastat_agg (dt, video_id, `type`, channel, strategy, first_level, fission0,
                                                          fission_rate, create_timestamp)
         values
         <foreach collection="records" item="item" separator=",">
-            (#{item.dt}, #{item.videoId}, #{item.type}, #{item.channel}, #{item.firstLevel},
+            (#{item.dt}, #{item.videoId}, #{item.type}, #{item.channel}, #{item.strategy}, #{item.firstLevel},
             #{item.fission0}, #{item.fissionRate}, #{item.createTimestamp})
         </foreach>
     </insert>
@@ -384,7 +391,8 @@
         select video.*
         from content_platform_upload_video video
         left join content_platform_video_datastat_agg datastat
-        on datastat.dt = #{datastatDt} and datastat.type = #{type} and datastat.channel = #{channel} and datastat.video_id = video.video_id
+        on datastat.dt = #{datastatDt} and datastat.type = #{type} and datastat.channel = #{channel}
+               and datastat.strategy = #{strategy} and datastat.video_id = video.video_id
         where video.audit_status = 2 and video.create_account_id = #{createAccountId} and video.is_delete = 0
         <if test="param.title!= null and param.title!= ''">
             and video.title like concat('%', #{param.title}, '%')

+ 41 - 0
api-module/src/test/java/com/tzld/piaoquan/api/ContentPlatformTest.java

@@ -1,7 +1,10 @@
 package com.tzld.piaoquan.api;
 
 import com.aliyun.openservices.shade.com.google.common.collect.Sets;
+import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformAccountMapper;
 import com.tzld.piaoquan.api.job.contentplatform.ContentPlatformDatastatJob;
+import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformAccount;
+import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformAccountExample;
 import com.tzld.piaoquan.growth.common.model.bo.VideoDetail;
 import com.tzld.piaoquan.growth.common.service.MessageAttachmentService;
 import com.tzld.piaoquan.growth.common.utils.DateUtil;
@@ -10,9 +13,12 @@ import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 @SpringBootTest(classes = GrowthServerApplication.class)
 @Slf4j
@@ -22,6 +28,8 @@ public class ContentPlatformTest {
     ContentPlatformDatastatJob datastatJob;
     @Autowired
     MessageAttachmentService messageAttachmentService;
+    @Autowired
+    ContentPlatformAccountMapper accountMapper;
 
     @Test
     public void testSyncContentPlatformQwDatastatReplyTotalJob() {
@@ -48,4 +56,37 @@ public class ContentPlatformTest {
         log.info("videoDetailMap:{}", videoDetailMap);
     }
 
+    @Test
+    public void changeAccountPrice() {
+        List<String> channelList = Arrays.asList("gzh", "fwh", "qw");
+        ContentPlatformAccountExample example = new ContentPlatformAccountExample();
+        example.createCriteria().andChannelIn(channelList);
+        List<ContentPlatformAccount> accountList = accountMapper.selectByExample(example);
+        accountList.forEach(account -> {
+            String price = updateJsonValue(account.getPrice(), "qiweihezuo_static_price", "0.25");
+            account.setPrice(price);
+            //accountMapper.updateByPrimaryKeySelective(account);
+        });
+    }
+
+    /**
+     * 仅通过字符串匹配方式修改指定 key 的 value
+     *
+     * @param jsonStr 原始 JSON 字符串
+     * @param key     要修改的字段名,例如 "qiweihezuo_static_price"
+     * @param newValue 新的值,例如 "0.25"
+     * @return 修改后的 JSON 字符串
+     */
+    public String updateJsonValue(String jsonStr, String key, String newValue) {
+        // 匹配规则: "qiweihezuo_static_price": 任意数值
+        // 支持整数、小数,并允许空格
+        String regex = "(\"" + Pattern.quote(key) + "\"\\s*:\\s*)([0-9]+(?:\\.[0-9]+)?)";
+
+        Pattern pattern = Pattern.compile(regex);
+        Matcher matcher = pattern.matcher(jsonStr);
+
+        // 替换为新的值
+        return matcher.replaceAll("$1" + newValue);
+    }
+
 }