Bläddra i källkod

Merge branch '20260105-wyp-videoPath' of Server/growth-manager into master

wangyunpeng 1 vecka sedan
förälder
incheckning
4efe34e911
19 ändrade filer med 644 tillägg och 42 borttagningar
  1. 2 0
      api-module/src/main/java/com/tzld/piaoquan/api/common/enums/ExceptionEnum.java
  2. 52 0
      api-module/src/main/java/com/tzld/piaoquan/api/component/ManagerApiService.java
  3. 2 0
      api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/GhDetailMapperExt.java
  4. 7 1
      api-module/src/main/java/com/tzld/piaoquan/api/job/wecom/WeComMessageDataJob.java
  5. 4 0
      api-module/src/main/java/com/tzld/piaoquan/api/job/wecom/thirdpart/WeComSendMsgJob.java
  6. 22 0
      api-module/src/main/java/com/tzld/piaoquan/api/model/po/GhDetailExt.java
  7. 120 0
      api-module/src/main/java/com/tzld/piaoquan/api/model/po/GhDetailExtExample.java
  8. 3 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/GhDetailService.java
  9. 85 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/VideoMultiService.java
  10. 9 4
      api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImpl.java
  11. 56 5
      api-module/src/main/java/com/tzld/piaoquan/api/service/impl/GhDetailServiceImpl.java
  12. 43 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/BuckStrategyV1.java
  13. 42 18
      api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/ThirdPartyPushMessageStrategyV1.java
  14. 27 4
      api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/WeComPushMessageStrategyV1.java
  15. 40 7
      api-module/src/main/resources/mapper/GhDetailExtMapper.xml
  16. 14 3
      api-module/src/main/resources/mapper/GhDetailMapperExt.xml
  17. 106 0
      api-module/src/test/java/com/tzld/piaoquan/api/GhDetailTest.java
  18. 3 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/ext/CgiReplyBucketDataMapperExt.java
  19. 7 0
      common-module/src/main/resources/mapper/ext/CgiReplyBucketDataMapperExt.xml

+ 2 - 0
api-module/src/main/java/com/tzld/piaoquan/api/common/enums/ExceptionEnum.java

@@ -64,6 +64,8 @@ public enum ExceptionEnum {
     VIDEO_GET_FAILED(6008, "视频获取失败"),
     VIDEO_MULTI_TITLE_SAVE_FAILED(6009, "视频多标题保存失败"),
     VIDEO_MULTI_COVER_SAVE_FAILED(6010, "视频多封面保存失败"),
+    VIDEO_MULTI_COVER_LIST_FAILED(6011, "视频多封面列表获取失败"),
+    VIDEO_MULTI_TITLE_LIST_FAILED(6012, "视频多标题列表获取失败"),
 
     // 自动回复
     CGI_REPLY_BUCKET_DATA_NOT_FOUND(10000, "自动回复数据不存在"),

+ 52 - 0
api-module/src/main/java/com/tzld/piaoquan/api/component/ManagerApiService.java

@@ -1,5 +1,6 @@
 package com.tzld.piaoquan.api.component;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.api.common.enums.ExceptionEnum;
 import com.tzld.piaoquan.api.common.exception.CommonException;
@@ -73,4 +74,55 @@ public class ManagerApiService {
         return res.getJSONObject("content");
     }
 
+    public JSONArray videoMultiCoverListV2(Long videoId) {
+        String url = managerApiHost + "/video/multiCover/listV2";
+        JSONObject res = null;
+        try {
+            JSONObject param = new JSONObject();
+            param.put("videoId", videoId);
+            param.put("range", "2h");
+            String post = httpPoolClient.post(url, param.toJSONString());
+            res = JSONObject.parseObject(post);
+        } catch (Exception e) {
+            log.error("ManagerApiService videoMultiCoverListV2 error, videoId={} range={}",
+                    videoId, "2h", e);
+        }
+        if (Objects.isNull(res)) {
+            throw new CommonException(ExceptionEnum.VIDEO_MULTI_COVER_LIST_FAILED);
+        }
+        if (res.getInteger("code") != 0) {
+            log.error("ManagerApiService videoMultiCoverListV2 error, videoId={} range={} res={}",
+                    videoId, "2h", res);
+            throw new CommonException(ExceptionEnum.VIDEO_MULTI_COVER_LIST_FAILED.getCode(),
+                    ExceptionEnum.VIDEO_MULTI_COVER_LIST_FAILED.getMsg() + "," + res.getString("msg"));
+        }
+        return res.getJSONArray("content");
+    }
+
+    public JSONArray videoMultiTitleListV2(Long videoId) {
+        String url = managerApiHost + "/video/multiTitleV2/listV2";
+        JSONObject res = null;
+        try {
+            JSONObject param = new JSONObject();
+            param.put("videoId", videoId);
+            param.put("range", "4h");
+            String post = httpPoolClient.post(url, param.toJSONString());
+            res = JSONObject.parseObject(post);
+        } catch (Exception e) {
+            log.error("ManagerApiService videoMultiCoverListV2 error, videoId={} range={}",
+                    videoId, "4h", e);
+        }
+        if (Objects.isNull(res)) {
+            throw new CommonException(ExceptionEnum.VIDEO_MULTI_TITLE_LIST_FAILED);
+        }
+        if (res.getInteger("code") != 0) {
+            log.error("ManagerApiService videoMultiCoverListV2 error, videoId={} range={} res={}",
+                    videoId, "4h", res);
+            throw new CommonException(ExceptionEnum.VIDEO_MULTI_TITLE_LIST_FAILED.getCode(),
+                    ExceptionEnum.VIDEO_MULTI_TITLE_LIST_FAILED.getMsg() + "," + res.getString("msg"));
+        }
+        return res.getJSONArray("content");
+    }
+
+
 }

+ 2 - 0
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/GhDetailMapperExt.java

@@ -14,4 +14,6 @@ public interface GhDetailMapperExt {
     void deleteOldGhDetailExt(@Param("ghId") String ghId, @Param("type") Integer type);
 
     void batchInsertGhDetailExt(@Param("records") List<GhDetailExt> records);
+
+    List<GhDetailExt> getGhDetailExtList(@Param("ghId") String ghId, @Param("type") Integer type);
 }

+ 7 - 1
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComMessageDataJob.java → api-module/src/main/java/com/tzld/piaoquan/api/job/wecom/WeComMessageDataJob.java

@@ -1,10 +1,11 @@
-package com.tzld.piaoquan.offline.job;
+package com.tzld.piaoquan.api.job.wecom;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.aliyun.odps.data.Record;
 import com.google.common.collect.Lists;
+import com.tzld.piaoquan.api.service.VideoMultiService;
 import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
 import com.tzld.piaoquan.growth.common.common.constant.MessageConstant;
 import com.tzld.piaoquan.growth.common.dao.mapper.*;
@@ -67,6 +68,9 @@ public class WeComMessageDataJob {
     @Autowired
     private WeComUserService weComUserService;
 
+    @Autowired
+    private VideoMultiService videoMultiService;
+
     //发送小程序标题限制字节数
     private static final int MAX_BYTES = 64;
 
@@ -551,8 +555,10 @@ public class WeComMessageDataJob {
             String key = staff.getCarrierId() + "_" + videoId;
             if (pageMap.containsKey(key)) {
                 page = pageMap.get(key);
+                page = videoMultiService.setVideoMultiTitleCoverPagePath(videoId, page, title, messageAttachment.getCover());
             } else {
                 page = messageAttachmentService.getPage("touliu", "tencentqw", staff, videoId, "企微", "日常推送");
+                page = videoMultiService.setVideoMultiTitleCoverPagePath(videoId, page, title, messageAttachment.getCover());
                 pageMap.put(key, page);
             }
             if (StringUtils.isEmpty(page)) {

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

@@ -14,6 +14,7 @@ import com.tzld.piaoquan.api.model.param.wecom.thirdpart.*;
 import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo;
 import com.tzld.piaoquan.api.model.po.wecom.thirdpart.*;
 import com.tzld.piaoquan.api.model.vo.contentplatform.WxVideoV2VO;
+import com.tzld.piaoquan.api.service.VideoMultiService;
 import com.tzld.piaoquan.api.service.wecom.thirdparty.WeComThirdPartyAccountService;
 import com.tzld.piaoquan.api.service.wecom.thirdparty.WeComThirdPartyRoomService;
 import com.tzld.piaoquan.api.service.wecom.thirdparty.WeComThirdPartyService;
@@ -64,6 +65,8 @@ public class WeComSendMsgJob {
     ThirdPartWeComRoomMapper roomMapper;
     @Autowired
     ThirdPartWeComMsgMapper msgMapper;
+    @Autowired
+    private VideoMultiService videoMultiService;
 
     @Autowired
     RedisUtils redisUtils;
@@ -297,6 +300,7 @@ public class WeComSendMsgJob {
         String putScene = StringUtils.isNotBlank(roomConfig.getPutScene()) ? roomConfig.getPutScene() : "touliu";
         String pageChannel = StringUtils.isNotBlank(roomConfig.getChannel()) ? roomConfig.getChannel() : "tencentqw";
         String page = messageAttachmentService.getPageNoCache(putScene, pageChannel, staff, video.getVideoId(), "企微", "社群");
+        page = videoMultiService.setVideoMultiTitleCoverPagePath(video.getVideoId(), page, video.getTitle(), video.getCover());
 
         CgiReplyBucketData cgiReplyBucketData = new CgiReplyBucketData();
         cgiReplyBucketData.setMiniVideoId(video.getVideoId());

+ 22 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/po/GhDetailExt.java

@@ -11,8 +11,12 @@ public class GhDetailExt {
 
     private String page;
 
+    private Long titleId;
+
     private String title;
 
+    private Long coverId;
+
     private String cover;
 
     private Integer sort;
@@ -55,6 +59,14 @@ public class GhDetailExt {
         this.page = page;
     }
 
+    public Long getTitleId() {
+        return titleId;
+    }
+
+    public void setTitleId(Long titleId) {
+        this.titleId = titleId;
+    }
+
     public String getTitle() {
         return title;
     }
@@ -63,6 +75,14 @@ public class GhDetailExt {
         this.title = title;
     }
 
+    public Long getCoverId() {
+        return coverId;
+    }
+
+    public void setCoverId(Long coverId) {
+        this.coverId = coverId;
+    }
+
     public String getCover() {
         return cover;
     }
@@ -113,7 +133,9 @@ public class GhDetailExt {
         sb.append(", ghDetailId=").append(ghDetailId);
         sb.append(", videoId=").append(videoId);
         sb.append(", page=").append(page);
+        sb.append(", titleId=").append(titleId);
         sb.append(", title=").append(title);
+        sb.append(", coverId=").append(coverId);
         sb.append(", cover=").append(cover);
         sb.append(", sort=").append(sort);
         sb.append(", isDelete=").append(isDelete);

+ 120 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/po/GhDetailExtExample.java

@@ -366,6 +366,66 @@ public class GhDetailExtExample {
             return (Criteria) this;
         }
 
+        public Criteria andTitleIdIsNull() {
+            addCriterion("title_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIdIsNotNull() {
+            addCriterion("title_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIdEqualTo(Long value) {
+            addCriterion("title_id =", value, "titleId");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIdNotEqualTo(Long value) {
+            addCriterion("title_id <>", value, "titleId");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIdGreaterThan(Long value) {
+            addCriterion("title_id >", value, "titleId");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("title_id >=", value, "titleId");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIdLessThan(Long value) {
+            addCriterion("title_id <", value, "titleId");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIdLessThanOrEqualTo(Long value) {
+            addCriterion("title_id <=", value, "titleId");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIdIn(List<Long> values) {
+            addCriterion("title_id in", values, "titleId");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIdNotIn(List<Long> values) {
+            addCriterion("title_id not in", values, "titleId");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIdBetween(Long value1, Long value2) {
+            addCriterion("title_id between", value1, value2, "titleId");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIdNotBetween(Long value1, Long value2) {
+            addCriterion("title_id not between", value1, value2, "titleId");
+            return (Criteria) this;
+        }
+
         public Criteria andTitleIsNull() {
             addCriterion("title is null");
             return (Criteria) this;
@@ -436,6 +496,66 @@ public class GhDetailExtExample {
             return (Criteria) this;
         }
 
+        public Criteria andCoverIdIsNull() {
+            addCriterion("cover_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIdIsNotNull() {
+            addCriterion("cover_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIdEqualTo(Long value) {
+            addCriterion("cover_id =", value, "coverId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIdNotEqualTo(Long value) {
+            addCriterion("cover_id <>", value, "coverId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIdGreaterThan(Long value) {
+            addCriterion("cover_id >", value, "coverId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("cover_id >=", value, "coverId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIdLessThan(Long value) {
+            addCriterion("cover_id <", value, "coverId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIdLessThanOrEqualTo(Long value) {
+            addCriterion("cover_id <=", value, "coverId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIdIn(List<Long> values) {
+            addCriterion("cover_id in", values, "coverId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIdNotIn(List<Long> values) {
+            addCriterion("cover_id not in", values, "coverId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIdBetween(Long value1, Long value2) {
+            addCriterion("cover_id between", value1, value2, "coverId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIdNotBetween(Long value1, Long value2) {
+            addCriterion("cover_id not between", value1, value2, "coverId");
+            return (Criteria) this;
+        }
+
         public Criteria andCoverIsNull() {
             addCriterion("cover is null");
             return (Criteria) this;

+ 3 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/GhDetailService.java

@@ -1,6 +1,7 @@
 package com.tzld.piaoquan.api.service;
 
 
+import com.tzld.piaoquan.api.model.po.GhDetailExt;
 import com.tzld.piaoquan.api.model.vo.GhDetailVo;
 import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
 import com.tzld.piaoquan.growth.common.model.po.GhDetail;
@@ -25,4 +26,6 @@ public interface GhDetailService {
     List<GhDetail> getByChannel(String channel);
 
     List<GhDetail> getGhdetailByNames(List<String> nameList);
+
+    List<GhDetailExt> getGhDetailExtList(String ghId, Integer type);
 }

+ 85 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/VideoMultiService.java

@@ -0,0 +1,85 @@
+package com.tzld.piaoquan.api.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.api.component.ManagerApiService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.net.URLEncoder;
+import java.util.Objects;
+
+@Slf4j
+@Service
+public class VideoMultiService {
+
+    @Autowired
+    private ManagerApiService managerApiService;
+
+    public String setVideoMultiTitleCoverPagePath(Long videoId, String pageUrl, String title, String coverUrl) {
+        JSONArray multiTitleList = managerApiService.videoMultiTitleListV2(videoId);
+        JSONArray multiCoverList = managerApiService.videoMultiCoverListV2(videoId);
+        if (!CollectionUtils.isEmpty(multiTitleList)) {
+            Integer titleId = null;
+            for (int i = 0; i < multiTitleList.size(); i++) {
+                JSONObject item = multiTitleList.getJSONObject(i);
+                if (item.getInteger("source") == 0) {
+                    titleId = item.getInteger("id");
+                    break;
+                }
+            }
+            if (Objects.isNull(titleId)) {
+                for (int i = 0; i < multiTitleList.size(); i++) {
+                    JSONObject item = multiTitleList.getJSONObject(i);
+                    if (title.equals(item.getString("title"))) {
+                        titleId = item.getInteger("id");
+                        break;
+                    }
+                }
+            }
+            try {
+                if (Objects.nonNull(titleId) && !pageUrl.contains("shareTitleId")) {
+                    pageUrl += URLEncoder.encode("&shareTitleId=" + titleId, "UTF-8");
+                }
+                if (Objects.nonNull(title) && !pageUrl.contains("shareTitle")) {
+                    pageUrl += URLEncoder.encode("&shareTitle=" + title, "UTF-8");
+                }
+            } catch (Exception e) {
+                log.error("ThirdPartyPushMessageStrategyV1 insertSmallData setCustomerCoverTitleId Error,data:", e);
+            }
+        }
+        if (!CollectionUtils.isEmpty(multiCoverList)) {
+            Integer coverId = null;
+            for (int i = 0; i < multiCoverList.size(); i++) {
+                JSONObject item = multiCoverList.getJSONObject(i);
+                if (item.getInteger("source") == 0) {
+                    coverId = item.getInteger("id");
+                    break;
+                }
+            }
+            if (Objects.isNull(coverId)) {
+                for (int i = 0; i < multiCoverList.size(); i++) {
+                    JSONObject item = multiCoverList.getJSONObject(i);
+                    if (coverUrl.equals(item.getString("coverUrl"))) {
+                        coverId = item.getInteger("id");
+                        break;
+                    }
+                }
+            }
+            try {
+                if (Objects.nonNull(coverId) && !pageUrl.contains("shareImageId")) {
+                    pageUrl += URLEncoder.encode("&shareImageId=" + coverId, "UTF-8");
+                }
+                if (StringUtils.isNotEmpty(coverUrl) && !pageUrl.contains("shareImageUrl")) {
+                    pageUrl += URLEncoder.encode("&shareImageUrl=" + URLEncoder.encode(coverUrl, "UTF-8"), "UTF-8");
+                }
+            } catch (Exception e) {
+                log.error("ThirdPartyPushMessageStrategyV1 insertSmallData setCustomerCoverTitleId Error,data:", e);
+            }
+        }
+        return pageUrl;
+    }
+}

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

@@ -23,6 +23,7 @@ import com.tzld.piaoquan.api.model.vo.contentplatform.QwPlanItemVO;
 import com.tzld.piaoquan.api.model.vo.contentplatform.VideoContentItemVO;
 import com.tzld.piaoquan.api.service.CgiReplyService;
 import com.tzld.piaoquan.api.service.GhDetailService;
+import com.tzld.piaoquan.api.service.VideoMultiService;
 import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformAccountService;
 import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformCooperateAccountService;
 import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformPlanService;
@@ -95,6 +96,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
     private TouLiuHttpClient touLiuHttpClient;
     @Autowired
     private ManagerApiService managerApiService;
+    @Autowired
+    private VideoMultiService videoMultiService;
 
 
     @Value("${vlog.share.appType:11}")
@@ -333,7 +336,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         // 调用aigc重新拉取视频
         if (param.getType() == ContentPlatformGzhPlanTypeEnum.AUTO_REPLY.getVal()) {
             if (PublishStageEnum.PLATFORM.getVal() == param.getPublishStage()) {
-                aigcApiService.refreshGzhAutoReplyMsgData(account.getGhId());
+                new Thread(() -> aigcApiService.refreshGzhAutoReplyMsgData(account.getGhId())).start();
             } else {
                 BucketDataParam bucketDataParam = new BucketDataParam();
                 bucketDataParam.setGhId(account.getGhId());
@@ -409,17 +412,17 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
     private void setCustomTitle(ContentPlatformGzhPlanVideo item, GzhPlanVideoContentItemParam vo) {
         if (StringUtils.hasText(vo.getCustomTitle())) {
             List<ContentPlatformGzhPlanVideo> gzhPlanVideoList = gzhPlanVideoListByVideoTitle(vo.getVideoId());
-            boolean customCoverExist = false;
+            boolean customTitleExist = false;
             if (CollectionUtils.isNotEmpty(gzhPlanVideoList)) {
                 for (ContentPlatformGzhPlanVideo gzhPlanVideo : gzhPlanVideoList) {
                     if (gzhPlanVideo.getCustomTitle().equals(vo.getCustomTitle())) {
                         item.setCustomTitleId(gzhPlanVideo.getCustomTitleId());
-                        customCoverExist = true;
+                        customTitleExist = true;
                         break;
                     }
                 }
             }
-            if (!customCoverExist && vo.getCustomTitle().length() > 5) {
+            if (!customTitleExist && vo.getCustomTitle().length() > 5) {
                 JSONObject multiTitle = managerApiService.videoMultiTitleSave(vo.getVideoId(), vo.getCustomTitle());
                 item.setCustomTitleId(multiTitle.getLong("id"));
             }
@@ -798,6 +801,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
             String pageUrl = messageAttachmentService.getPage(loginUser.getChannel(), carrierId,
                     "dyyqw", "企微", QwPlanTypeEnum.from(param.getType()).getDescription(),
                     "位置1", videoParam.getVideoId());
+            pageUrl = videoMultiService.setVideoMultiTitleCoverPagePath(videoParam.getVideoId(), pageUrl,
+                    videoParam.getTitle(), videoParam.getCover());
             String rootSourceId = MessageUtil.getRootSourceId(pageUrl);
             qwPlan.setPageUrl(pageUrl);
             qwPlan.setRootSourceId(rootSourceId);

+ 56 - 5
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/GhDetailServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.api.component.AigcApiService;
+import com.tzld.piaoquan.api.component.ManagerApiService;
 import com.tzld.piaoquan.api.component.TouLiuHttpClient;
 import com.tzld.piaoquan.api.dao.mapper.GhDetailExtMapper;
 import com.tzld.piaoquan.api.dao.mapper.GhDetailMapperExt;
@@ -49,6 +50,8 @@ public class GhDetailServiceImpl implements GhDetailService {
     private TouLiuHttpClient touLiuHttpClient;
     @Autowired
     private CgiReplyBucketDataMapper cgiReplyBucketDataMapper;
+    @Autowired
+    private ManagerApiService managerApiService;
 
     @Value("${small_page_url}")
     private String GET_SMALL_PAGE_URL;
@@ -164,7 +167,7 @@ public class GhDetailServiceImpl implements GhDetailService {
             ghDetailMapper.insertSelective(ghDetail);
             ghDetailMapperExt.deleteOldGhDetailExt(ghDetailVo.getAccountId(), ghDetailVo.getType());
             batchSaveGhDetailExt(ghDetailVo);
-            aigcApiService.refreshGzhAutoReplyMsgData(ghDetailVo.getAccountId());
+            new Thread(() -> aigcApiService.refreshGzhAutoReplyMsgData(ghDetailVo.getAccountId())).start();
             return CommonResponse.success();
         } catch (Exception e) {
             log.error("addGhDetail error", e);
@@ -187,8 +190,8 @@ public class GhDetailServiceImpl implements GhDetailService {
             ghDetailExt.setVideoId(videoDetail.getVideoId());
             ghDetailExt.setPage(getVideoPageUrl(videoDetail.getVideoId(), ghDetailVo.getChannel(),
                     ghDetailVo.getAccountId(), videoDetail.getSort(), ghDetailVo.getType()));
-            ghDetailExt.setTitle(videoDetail.getTitle());
-            ghDetailExt.setCover(videoDetail.getCover());
+            setCustomTitle(ghDetailExt, videoDetail);
+            setCustomCover(ghDetailExt, videoDetail);
             ghDetailExt.setSort(videoDetail.getSort());
             ghDetailExt.setIsDelete(0);
             ghDetailExts.add(ghDetailExt);
@@ -196,6 +199,50 @@ public class GhDetailServiceImpl implements GhDetailService {
         ghDetailMapperExt.batchInsertGhDetailExt(ghDetailExts);
     }
 
+    private void setCustomTitle(GhDetailExt ghDetailExt, GhDetailVo.VideoDetail videoDetail) {
+        if (StringUtils.isNotEmpty(videoDetail.getTitle())) {
+            JSONArray multiTitleList = managerApiService.videoMultiTitleListV2(videoDetail.getVideoId());
+            boolean titleExist = false;
+            if (!CollectionUtils.isEmpty(multiTitleList)) {
+                for (int i = 0; i < multiTitleList.size(); i++) {
+                    JSONObject item = multiTitleList.getJSONObject(i);
+                    if (item.getString("title").equals(videoDetail.getTitle())) {
+                        ghDetailExt.setTitleId(item.getLong("id"));
+                        titleExist = true;
+                        break;
+                    }
+                }
+            }
+            if (!titleExist) {
+                JSONObject multiTitle = managerApiService.videoMultiTitleSave(videoDetail.getVideoId(), videoDetail.getTitle());
+                ghDetailExt.setTitleId(multiTitle.getLong("id"));
+            }
+            ghDetailExt.setTitle(videoDetail.getTitle());
+        }
+    }
+
+    private void setCustomCover(GhDetailExt ghDetailExt, GhDetailVo.VideoDetail videoDetail) {
+        if (StringUtils.isNotEmpty(videoDetail.getCover())) {
+            JSONArray multiCoverList = managerApiService.videoMultiCoverListV2(videoDetail.getVideoId());
+            boolean customCoverExist = false;
+            if (!CollectionUtils.isEmpty(multiCoverList)) {
+                for (int i = 0; i < multiCoverList.size(); i++) {
+                    JSONObject item = multiCoverList.getJSONObject(i);
+                    if (item.getString("coverUrl").equals(videoDetail.getCover())) {
+                        ghDetailExt.setCoverId(item.getLong("id"));
+                        customCoverExist = true;
+                        break;
+                    }
+                }
+            }
+            if (!customCoverExist) {
+                JSONObject multiCover = managerApiService.videoMultiCoverSave(videoDetail.getVideoId(), videoDetail.getCover());
+                ghDetailExt.setCoverId(multiCover.getLong("id"));
+            }
+            ghDetailExt.setCover(videoDetail.getCover());
+        }
+    }
+
     private String getVideoPageUrl(Long videoId, String channel, String ghId, Integer sort, Integer accountType) {
         // 查询库里是否存在,如果存在即复用
         try {
@@ -275,8 +322,7 @@ public class GhDetailServiceImpl implements GhDetailService {
                 updateGhDetail.setUpdateTime(new Date());
                 ghDetailMapper.updateByPrimaryKey(updateGhDetail);
             }
-            aigcApiService.refreshGzhAutoReplyMsgData(ghDetailVo.getAccountId());
-
+            new Thread(() -> aigcApiService.refreshGzhAutoReplyMsgData(ghDetailVo.getAccountId())).start();
             return CommonResponse.success();
         } catch (Exception e) {
             log.error("updateDetail error", e);
@@ -384,5 +430,10 @@ public class GhDetailServiceImpl implements GhDetailService {
         return ghDetailMapper.selectByExample(ghDetailExample);
     }
 
+    @Override
+    public List<GhDetailExt> getGhDetailExtList(String ghId, Integer type) {
+        return ghDetailMapperExt.getGhDetailExtList(ghId, type);
+    }
+
 
 }

+ 43 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/BuckStrategyV1.java

@@ -9,11 +9,16 @@ import com.tzld.piaoquan.api.dao.mapper.AlgGhAutoreplyVideoRankDataMapper;
 import com.tzld.piaoquan.api.model.bo.*;
 import com.tzld.piaoquan.api.model.po.AlgGhAutoreplyVideoRankData;
 import com.tzld.piaoquan.api.model.po.AlgGhAutoreplyVideoRankDataExample;
+import com.tzld.piaoquan.api.model.po.GhDetailExt;
 import com.tzld.piaoquan.api.model.vo.VideoCharacteristicVO;
+import com.tzld.piaoquan.api.service.GhDetailService;
+import com.tzld.piaoquan.api.service.VideoMultiService;
 import com.tzld.piaoquan.api.service.strategy.ReplyStrategyService;
+import com.tzld.piaoquan.growth.common.common.enums.GhTypeEnum;
 import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
 import com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper;
 import com.tzld.piaoquan.growth.common.dao.mapper.GhDetailMapper;
+import com.tzld.piaoquan.growth.common.dao.mapper.ext.CgiReplyBucketDataMapperExt;
 import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
 import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
 import com.tzld.piaoquan.growth.common.utils.MessageUtil;
@@ -26,7 +31,9 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.net.URLEncoder;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -73,6 +80,12 @@ public class BuckStrategyV1 implements ReplyStrategyService {
     private TouLiuHttpClient touLiuHttpClient;
     @Autowired
     private GhDetailMapper ghDetailMapper;
+    @Autowired
+    private CgiReplyBucketDataMapperExt cgiReplyBucketDataMapperExt;
+    @Autowired
+    private VideoMultiService videoMultiService;
+    @Autowired
+    private GhDetailService ghDetailService;
 
     @Autowired
     private RedisUtils redisUtils;
@@ -256,6 +269,9 @@ public class BuckStrategyV1 implements ReplyStrategyService {
                 cgiReplyBucketData.setIsDelete(1);
                 cgiReplyBucketDataMapper.updateByPrimaryKeySelective(cgiReplyBucketData);
             }
+            List<GhDetailExt> ghDetailExtList = ghDetailService.getGhDetailExtList(bucketDataParam.getGhId(), GhTypeEnum.GH.type);
+            Map<Long, GhDetailExt> ghDetailExtMap = ghDetailExtList.stream()
+                    .collect(Collectors.toMap(GhDetailExt::getVideoId, Function.identity(), (a, b) -> b));
             // 入库
             for (CgiReplyBucketData cgiReplyBucketData : collect) {
                 if (Objects.isNull(cgiReplyBucketData.getMiniVideoId())) {
@@ -263,6 +279,9 @@ public class BuckStrategyV1 implements ReplyStrategyService {
                     cgiReplyBucketData.setMiniVideoId(videoId);
                 }
                 CgiReplyBucketData oldData = cgiReplyBucketDataMap.get(cgiReplyBucketData.getMiniVideoId());
+                if (Objects.isNull(oldData)) {
+                    oldData = cgiReplyBucketDataMapperExt.getOldCgiReplyData(cgiReplyBucketData.getMiniVideoId());
+                }
                 if (Objects.nonNull(oldData)) {
                     if (StringUtils.isEmpty(cgiReplyBucketData.getTitle())) {
                         cgiReplyBucketData.setTitle(oldData.getTitle());
@@ -271,6 +290,30 @@ public class BuckStrategyV1 implements ReplyStrategyService {
                         cgiReplyBucketData.setCoverUrl(oldData.getCoverUrl());
                     }
                 }
+                String pageUrl = cgiReplyBucketData.getMiniPagePath();
+                GhDetailExt ghDetailExt = ghDetailExtMap.get(cgiReplyBucketData.getMiniVideoId());
+                if (Objects.nonNull(ghDetailExt)) {
+                    try {
+                        if (Objects.nonNull(ghDetailExt.getTitleId()) && !pageUrl.contains("shareTitleId")) {
+                            pageUrl += URLEncoder.encode("&shareTitleId=" + ghDetailExt.getTitleId(), "UTF-8");
+                        }
+                        if (!pageUrl.contains("shareTitle")) {
+                            pageUrl += URLEncoder.encode("&shareTitle=" + ghDetailExt.getTitle(), "UTF-8");
+                        }
+                        if (Objects.nonNull(ghDetailExt.getCoverId()) && !pageUrl.contains("shareImageId")) {
+                            pageUrl += URLEncoder.encode("&shareImageId=" + ghDetailExt.getCoverId(), "UTF-8");
+                        }
+                        if (!pageUrl.contains("shareImageUrl")) {
+                            pageUrl += URLEncoder.encode("&shareImageUrl=" + URLEncoder.encode(ghDetailExt.getCover(), "UTF-8"), "UTF-8");
+                        }
+                    } catch (Exception e) {
+                        log.error("BuckStrategyV1 insertSmallData setCoverTitleId Error,data:" + JSON.toJSONString(ghDetailExt), e);
+                    }
+                } else {
+                    pageUrl = videoMultiService.setVideoMultiTitleCoverPagePath(cgiReplyBucketData.getMiniVideoId(),
+                            cgiReplyBucketData.getMiniPagePath(), cgiReplyBucketData.getTitle(), cgiReplyBucketData.getCoverUrl());
+                }
+                cgiReplyBucketData.setMiniPagePath(pageUrl);
                 cgiReplyBucketDataMapper.insertSelective(cgiReplyBucketData);
                 String redisKey = "auto_reply_video_detail_" + cgiReplyBucketData.getRootSourceId();
                 VideoCharacteristicVO vo = new VideoCharacteristicVO();

+ 42 - 18
api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/ThirdPartyPushMessageStrategyV1.java

@@ -3,6 +3,7 @@ package com.tzld.piaoquan.api.service.strategy.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.api.common.enums.ReplyStrategyServiceEnum;
+import com.tzld.piaoquan.api.component.ManagerApiService;
 import com.tzld.piaoquan.api.component.TouLiuHttpClient;
 import com.tzld.piaoquan.api.dao.mapper.AlgGhAutoreplyVideoRankDataMapper;
 import com.tzld.piaoquan.api.model.bo.*;
@@ -10,10 +11,12 @@ import com.tzld.piaoquan.api.model.po.AlgGhAutoreplyVideoRankData;
 import com.tzld.piaoquan.api.model.po.AlgGhAutoreplyVideoRankDataExample;
 import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlanVideo;
 import com.tzld.piaoquan.api.model.vo.VideoCharacteristicVO;
+import com.tzld.piaoquan.api.service.VideoMultiService;
 import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformPlanService;
 import com.tzld.piaoquan.api.service.strategy.ReplyStrategyService;
 import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
 import com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper;
+import com.tzld.piaoquan.growth.common.dao.mapper.ext.CgiReplyBucketDataMapperExt;
 import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
 import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
 import com.tzld.piaoquan.growth.common.utils.MessageUtil;
@@ -67,6 +70,12 @@ public class ThirdPartyPushMessageStrategyV1 implements ReplyStrategyService {
     private TouLiuHttpClient touLiuHttpClient;
     @Autowired
     private ContentPlatformPlanService contentPlatformPlanService;
+    @Autowired
+    private CgiReplyBucketDataMapperExt cgiReplyBucketDataMapperExt;
+    @Autowired
+    private ManagerApiService managerApiService;
+    @Autowired
+    private VideoMultiService videoMultiService;
 
     @Autowired
     private RedisUtils redisUtils;
@@ -174,35 +183,50 @@ public class ThirdPartyPushMessageStrategyV1 implements ReplyStrategyService {
                     Long videoId = MessageUtil.getVideoId(cgiReplyBucketData.getMiniPagePath());
                     cgiReplyBucketData.setMiniVideoId(videoId);
                 }
+                CgiReplyBucketData oldData = cgiReplyBucketDataMap.get(cgiReplyBucketData.getMiniVideoId());
+                if (Objects.isNull(oldData)) {
+                    oldData = cgiReplyBucketDataMapperExt.getOldCgiReplyData(cgiReplyBucketData.getMiniVideoId());
+                }
+                if (Objects.nonNull(oldData)) {
+                    if (StringUtils.isEmpty(cgiReplyBucketData.getTitle())) {
+                        cgiReplyBucketData.setTitle(oldData.getTitle());
+                    }
+                    if (StringUtils.isEmpty(cgiReplyBucketData.getCoverUrl())) {
+                        cgiReplyBucketData.setCoverUrl(oldData.getCoverUrl());
+                    }
+                }
                 ContentPlatformGzhPlanVideo gzhPlanVideo = gzhPlanVideoMap.get(cgiReplyBucketData.getMiniVideoId());
+                String pageUrl = cgiReplyBucketData.getMiniPagePath();
                 if (Objects.nonNull(gzhPlanVideo)) {
                     try {
-                        String pageUrl = cgiReplyBucketData.getMiniPagePath();
-                        if (StringUtils.isNotBlank(gzhPlanVideo.getCustomTitle()) && !pageUrl.contains("shareTitle")) {
-                            if (Objects.nonNull(gzhPlanVideo.getCustomTitleId())) {
-                                pageUrl += URLEncoder.encode("&shareTitleId=" + gzhPlanVideo.getCustomTitleId(), "UTF-8");
+                        if (Objects.nonNull(gzhPlanVideo.getCustomTitleId()) && !pageUrl.contains("shareTitleId")) {
+                            pageUrl += URLEncoder.encode("&shareTitleId=" + gzhPlanVideo.getCustomTitleId(), "UTF-8");
+                        }
+                        if (!pageUrl.contains("shareTitle")) {
+                            if (StringUtils.isNotBlank(gzhPlanVideo.getCustomTitle())) {
+                                pageUrl += URLEncoder.encode("&shareTitle=" + gzhPlanVideo.getCustomTitle(), "UTF-8");
+                            } else {
+                                pageUrl += URLEncoder.encode("&shareTitle=" + gzhPlanVideo.getTitle(), "UTF-8");
                             }
-                            pageUrl += URLEncoder.encode("&shareTitle=" + gzhPlanVideo.getCustomTitle(), "UTF-8");
                         }
-                        if (StringUtils.isNotEmpty(gzhPlanVideo.getCustomCover()) && !pageUrl.contains("shareImageUrl")) {
-                            if (Objects.nonNull(gzhPlanVideo.getCustomCoverId())) {
-                                pageUrl += URLEncoder.encode("&shareImageId=" + gzhPlanVideo.getCustomCoverId(), "UTF-8");
+                        if (Objects.nonNull(gzhPlanVideo.getCustomCoverId()) && !pageUrl.contains("shareImageId")) {
+                            pageUrl += URLEncoder.encode("&shareImageId=" + gzhPlanVideo.getCustomCoverId(), "UTF-8");
+                        }
+                        if (!pageUrl.contains("shareImageUrl")) {
+                            if (StringUtils.isNotEmpty(gzhPlanVideo.getCustomCover())) {
+                                pageUrl += URLEncoder.encode("&shareImageUrl=" + URLEncoder.encode(gzhPlanVideo.getCustomCover(), "UTF-8"), "UTF-8");
+                            } else {
+                                pageUrl += URLEncoder.encode("&shareImageUrl=" + URLEncoder.encode(gzhPlanVideo.getCover(), "UTF-8"), "UTF-8");
                             }
-                            pageUrl += URLEncoder.encode("&shareImageUrl=" + URLEncoder.encode(gzhPlanVideo.getCustomCover(), "UTF-8"), "UTF-8");
                         }
                         cgiReplyBucketData.setMiniPagePath(pageUrl);
                     } catch (Exception e) {
                         log.error("ThirdPartyPushMessageStrategyV1 insertSmallData setCustomerCoverTitleId Error,data:" + JSON.toJSONString(gzhPlanVideo), e);
                     }
-                }
-                CgiReplyBucketData oldData = cgiReplyBucketDataMap.get(cgiReplyBucketData.getMiniVideoId());
-                if (Objects.nonNull(oldData)) {
-                    if (StringUtils.isEmpty(cgiReplyBucketData.getTitle())) {
-                        cgiReplyBucketData.setTitle(oldData.getTitle());
-                    }
-                    if (StringUtils.isEmpty(cgiReplyBucketData.getCoverUrl())) {
-                        cgiReplyBucketData.setCoverUrl(oldData.getCoverUrl());
-                    }
+                } else {
+                    pageUrl = videoMultiService.setVideoMultiTitleCoverPagePath(cgiReplyBucketData.getMiniVideoId(),
+                            pageUrl, cgiReplyBucketData.getTitle(), cgiReplyBucketData.getCoverUrl());
+                    cgiReplyBucketData.setMiniPagePath(pageUrl);
                 }
                 cgiReplyBucketDataMapper.insertSelective(cgiReplyBucketData);
                 String redisKey = "auto_reply_video_detail_" + cgiReplyBucketData.getRootSourceId();

+ 27 - 4
api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/WeComPushMessageStrategyV1.java

@@ -5,15 +5,17 @@ import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.api.common.enums.ReplyStrategyServiceEnum;
 import com.tzld.piaoquan.api.component.TouLiuHttpClient;
 import com.tzld.piaoquan.api.dao.mapper.AlgGhAutoreplyVideoRankDataMapper;
-import com.tzld.piaoquan.api.model.vo.VideoCharacteristicVO;
-import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
-import com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper;
 import com.tzld.piaoquan.api.model.bo.*;
 import com.tzld.piaoquan.api.model.po.AlgGhAutoreplyVideoRankData;
 import com.tzld.piaoquan.api.model.po.AlgGhAutoreplyVideoRankDataExample;
+import com.tzld.piaoquan.api.model.vo.VideoCharacteristicVO;
+import com.tzld.piaoquan.api.service.VideoMultiService;
+import com.tzld.piaoquan.api.service.strategy.ReplyStrategyService;
+import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
+import com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper;
+import com.tzld.piaoquan.growth.common.dao.mapper.ext.CgiReplyBucketDataMapperExt;
 import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
 import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
-import com.tzld.piaoquan.api.service.strategy.ReplyStrategyService;
 import com.tzld.piaoquan.growth.common.utils.MessageUtil;
 import com.tzld.piaoquan.growth.common.utils.RedisUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -60,7 +62,11 @@ public class WeComPushMessageStrategyV1 implements ReplyStrategyService {
     @Autowired
     private CgiReplyBucketDataMapper cgiReplyBucketDataMapper;
     @Autowired
+    private CgiReplyBucketDataMapperExt cgiReplyBucketDataMapperExt;
+    @Autowired
     private TouLiuHttpClient touLiuHttpClient;
+    @Autowired
+    private VideoMultiService videoMultiService;
 
     @Autowired
     private RedisUtils redisUtils;
@@ -153,12 +159,29 @@ public class WeComPushMessageStrategyV1 implements ReplyStrategyService {
             CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
             cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andMsgTypeEqualTo(1).andStrategyEqualTo(key).andGhIdEqualTo(bucketDataParam.getGhId());
             List<CgiReplyBucketData> cgiReplyBucketData1 = cgiReplyBucketDataMapper.selectByExample(cgiReplyBucketDataExample);
+            Map<Long, CgiReplyBucketData> cgiReplyBucketDataMap = cgiReplyBucketData1.stream()
+                    .collect(Collectors.toMap(CgiReplyBucketData::getMiniVideoId, x -> x, (a, b) -> b));
             for (CgiReplyBucketData cgiReplyBucketData : cgiReplyBucketData1) {
                 cgiReplyBucketData.setIsDelete(1);
                 cgiReplyBucketDataMapper.updateByPrimaryKeySelective(cgiReplyBucketData);
             }
             // 入库
             for (CgiReplyBucketData cgiReplyBucketData : collect) {
+                CgiReplyBucketData oldData = cgiReplyBucketDataMap.get(cgiReplyBucketData.getMiniVideoId());
+                if (Objects.isNull(oldData)) {
+                    oldData = cgiReplyBucketDataMapperExt.getOldCgiReplyData(cgiReplyBucketData.getMiniVideoId());
+                }
+                if (Objects.nonNull(oldData)) {
+                    if (StringUtils.isEmpty(cgiReplyBucketData.getTitle())) {
+                        cgiReplyBucketData.setTitle(oldData.getTitle());
+                    }
+                    if (StringUtils.isEmpty(cgiReplyBucketData.getCoverUrl())) {
+                        cgiReplyBucketData.setCoverUrl(oldData.getCoverUrl());
+                    }
+                }
+                String pageUrl = videoMultiService.setVideoMultiTitleCoverPagePath(cgiReplyBucketData.getMiniVideoId(),
+                        cgiReplyBucketData.getMiniPagePath(), cgiReplyBucketData.getTitle(), cgiReplyBucketData.getCoverUrl());
+                cgiReplyBucketData.setMiniPagePath(pageUrl);
                 cgiReplyBucketDataMapper.insertSelective(cgiReplyBucketData);
                 String redisKey = "auto_reply_video_detail_" + cgiReplyBucketData.getRootSourceId();
                 VideoCharacteristicVO vo = new VideoCharacteristicVO();

+ 40 - 7
api-module/src/main/resources/mapper/GhDetailExtMapper.xml

@@ -6,7 +6,9 @@
     <result column="gh_detail_id" jdbcType="BIGINT" property="ghDetailId" />
     <result column="video_id" jdbcType="BIGINT" property="videoId" />
     <result column="page" jdbcType="VARCHAR" property="page" />
+    <result column="title_id" jdbcType="BIGINT" property="titleId" />
     <result column="title" jdbcType="VARCHAR" property="title" />
+    <result column="cover_id" jdbcType="BIGINT" property="coverId" />
     <result column="cover" jdbcType="VARCHAR" property="cover" />
     <result column="sort" jdbcType="INTEGER" property="sort" />
     <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
@@ -72,7 +74,8 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, gh_detail_id, video_id, page, title, cover, sort, is_delete, create_time, update_time
+    id, gh_detail_id, video_id, page, title_id, title, cover_id, cover, sort, is_delete, 
+    create_time, update_time
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.api.model.po.GhDetailExtExample" resultMap="BaseResultMap">
     select
@@ -109,13 +112,15 @@
   </delete>
   <insert id="insert" parameterType="com.tzld.piaoquan.api.model.po.GhDetailExt">
     insert into gh_detail_ext (id, gh_detail_id, video_id, 
-      page, title, cover, 
-      sort, is_delete, create_time, 
-      update_time)
+      page, title_id, title, 
+      cover_id, cover, sort, 
+      is_delete, create_time, update_time
+      )
     values (#{id,jdbcType=BIGINT}, #{ghDetailId,jdbcType=BIGINT}, #{videoId,jdbcType=BIGINT}, 
-      #{page,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{cover,jdbcType=VARCHAR}, 
-      #{sort,jdbcType=INTEGER}, #{isDelete,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
-      #{updateTime,jdbcType=TIMESTAMP})
+      #{page,jdbcType=VARCHAR}, #{titleId,jdbcType=BIGINT}, #{title,jdbcType=VARCHAR}, 
+      #{coverId,jdbcType=BIGINT}, #{cover,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, 
+      #{isDelete,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
+      )
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.api.model.po.GhDetailExt">
     insert into gh_detail_ext
@@ -132,9 +137,15 @@
       <if test="page != null">
         page,
       </if>
+      <if test="titleId != null">
+        title_id,
+      </if>
       <if test="title != null">
         title,
       </if>
+      <if test="coverId != null">
+        cover_id,
+      </if>
       <if test="cover != null">
         cover,
       </if>
@@ -164,9 +175,15 @@
       <if test="page != null">
         #{page,jdbcType=VARCHAR},
       </if>
+      <if test="titleId != null">
+        #{titleId,jdbcType=BIGINT},
+      </if>
       <if test="title != null">
         #{title,jdbcType=VARCHAR},
       </if>
+      <if test="coverId != null">
+        #{coverId,jdbcType=BIGINT},
+      </if>
       <if test="cover != null">
         #{cover,jdbcType=VARCHAR},
       </if>
@@ -205,9 +222,15 @@
       <if test="record.page != null">
         page = #{record.page,jdbcType=VARCHAR},
       </if>
+      <if test="record.titleId != null">
+        title_id = #{record.titleId,jdbcType=BIGINT},
+      </if>
       <if test="record.title != null">
         title = #{record.title,jdbcType=VARCHAR},
       </if>
+      <if test="record.coverId != null">
+        cover_id = #{record.coverId,jdbcType=BIGINT},
+      </if>
       <if test="record.cover != null">
         cover = #{record.cover,jdbcType=VARCHAR},
       </if>
@@ -234,7 +257,9 @@
       gh_detail_id = #{record.ghDetailId,jdbcType=BIGINT},
       video_id = #{record.videoId,jdbcType=BIGINT},
       page = #{record.page,jdbcType=VARCHAR},
+      title_id = #{record.titleId,jdbcType=BIGINT},
       title = #{record.title,jdbcType=VARCHAR},
+      cover_id = #{record.coverId,jdbcType=BIGINT},
       cover = #{record.cover,jdbcType=VARCHAR},
       sort = #{record.sort,jdbcType=INTEGER},
       is_delete = #{record.isDelete,jdbcType=INTEGER},
@@ -256,9 +281,15 @@
       <if test="page != null">
         page = #{page,jdbcType=VARCHAR},
       </if>
+      <if test="titleId != null">
+        title_id = #{titleId,jdbcType=BIGINT},
+      </if>
       <if test="title != null">
         title = #{title,jdbcType=VARCHAR},
       </if>
+      <if test="coverId != null">
+        cover_id = #{coverId,jdbcType=BIGINT},
+      </if>
       <if test="cover != null">
         cover = #{cover,jdbcType=VARCHAR},
       </if>
@@ -282,7 +313,9 @@
     set gh_detail_id = #{ghDetailId,jdbcType=BIGINT},
       video_id = #{videoId,jdbcType=BIGINT},
       page = #{page,jdbcType=VARCHAR},
+      title_id = #{titleId,jdbcType=BIGINT},
       title = #{title,jdbcType=VARCHAR},
+      cover_id = #{coverId,jdbcType=BIGINT},
       cover = #{cover,jdbcType=VARCHAR},
       sort = #{sort,jdbcType=INTEGER},
       is_delete = #{isDelete,jdbcType=INTEGER},

+ 14 - 3
api-module/src/main/resources/mapper/GhDetailMapperExt.xml

@@ -3,11 +3,13 @@
 <mapper namespace="com.tzld.piaoquan.api.dao.mapper.GhDetailMapperExt">
 
     <insert id="batchInsertGhDetailExt">
-        insert into gh_detail_ext (gh_detail_id, video_id, page, title, cover, sort, is_delete, create_time, update_time)
+        insert into gh_detail_ext (gh_detail_id, video_id, page, title_id, title, cover_id, cover, sort,
+                                   is_delete, create_time, update_time)
         values
         <foreach collection="records" item="record" separator=",">
-            (#{record.ghDetailId}, #{record.videoId}, #{record.page}, #{record.title}, #{record.cover}, #{record.sort},
-             #{record.isDelete}, #{record.createTime}, #{record.updateTime})
+            (#{record.ghDetailId}, #{record.videoId}, #{record.page}, #{record.titleId}, #{record.title},
+             #{record.coverId}, #{record.cover}, #{record.sort}, #{record.isDelete},
+             #{record.createTime}, #{record.updateTime})
         </foreach>
     </insert>
 
@@ -19,4 +21,13 @@
         )
     </update>
 
+    <select id="getGhDetailExtList" resultType="com.tzld.piaoquan.api.model.po.GhDetailExt">
+        select gde.*
+        from gh_detail_ext gde
+        join gh_detail gd on gde.gh_detail_id = gd.id
+        where gd.gh_id = #{ghId}
+          and gd.type = #{type}
+          and gde.is_delete = 0
+    </select>
+
 </mapper>

+ 106 - 0
api-module/src/test/java/com/tzld/piaoquan/api/GhDetailTest.java

@@ -0,0 +1,106 @@
+package com.tzld.piaoquan.api;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.api.component.ManagerApiService;
+import com.tzld.piaoquan.api.dao.mapper.GhDetailExtMapper;
+import com.tzld.piaoquan.api.model.po.GhDetailExt;
+import com.tzld.piaoquan.api.model.po.GhDetailExtExample;
+import com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper;
+import com.tzld.piaoquan.growth.common.dao.mapper.ext.CgiReplyBucketDataMapperExt;
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+
+@SpringBootTest(classes = GrowthServerApplication.class)
+@Slf4j
+public class GhDetailTest {
+
+    @Autowired
+    GhDetailExtMapper ghDetailExtMapper;
+    @Autowired
+    ManagerApiService managerApiService;
+    @Autowired
+    CgiReplyBucketDataMapper cgiReplyBucketDataMapper;
+    @Autowired
+    CgiReplyBucketDataMapperExt cgiReplyBucketDataMapperExt;
+
+    @Test
+    public void testGhDetailExtId() {
+        GhDetailExtExample example = new GhDetailExtExample();
+        example.createCriteria().andIsDeleteEqualTo(0);
+        List<GhDetailExt> ghDetailExtList = ghDetailExtMapper.selectByExample(example);
+        for (GhDetailExt ghDetailExt : ghDetailExtList) {
+            setCustomTitle(ghDetailExt);
+            setCustomCover(ghDetailExt);
+            ghDetailExtMapper.updateByPrimaryKeySelective(ghDetailExt);
+        }
+    }
+
+    private void setCustomTitle(GhDetailExt ghDetailExt) {
+        if (StringUtils.isNotEmpty(ghDetailExt.getTitle())) {
+            JSONArray multiTitleList = managerApiService.videoMultiTitleListV2(ghDetailExt.getVideoId());
+            boolean titleExist = false;
+            if (!CollectionUtils.isEmpty(multiTitleList)) {
+                for (int i = 0; i < multiTitleList.size(); i++) {
+                    JSONObject item = multiTitleList.getJSONObject(i);
+                    if (item.getString("title").equals(ghDetailExt.getTitle())) {
+                        ghDetailExt.setTitleId(item.getLong("id"));
+                        titleExist = true;
+                        break;
+                    }
+                }
+            }
+            if (!titleExist) {
+                JSONObject multiTitle = managerApiService.videoMultiTitleSave(ghDetailExt.getVideoId(), ghDetailExt.getTitle());
+                ghDetailExt.setTitleId(multiTitle.getLong("id"));
+            }
+        }
+    }
+
+    private void setCustomCover(GhDetailExt ghDetailExt) {
+        if (StringUtils.isNotEmpty(ghDetailExt.getCover())) {
+            JSONArray multiCoverList = managerApiService.videoMultiCoverListV2(ghDetailExt.getVideoId());
+            boolean customCoverExist = false;
+            if (!CollectionUtils.isEmpty(multiCoverList)) {
+                for (int i = 0; i < multiCoverList.size(); i++) {
+                    JSONObject item = multiCoverList.getJSONObject(i);
+                    if (item.getString("coverUrl").equals(ghDetailExt.getCover())) {
+                        ghDetailExt.setCoverId(item.getLong("id"));
+                        customCoverExist = true;
+                        break;
+                    }
+                }
+            }
+            if (!customCoverExist) {
+                JSONObject multiCover = managerApiService.videoMultiCoverSave(ghDetailExt.getVideoId(), ghDetailExt.getCover());
+                ghDetailExt.setCoverId(multiCover.getLong("id"));
+            }
+        }
+    }
+
+    @Test
+    public void refreshCgiReplyBucketData() {
+        CgiReplyBucketDataExample example = new CgiReplyBucketDataExample();
+        example.createCriteria().andIsDeleteEqualTo(0).andTitleIsNull();
+        List<CgiReplyBucketData> list = cgiReplyBucketDataMapper.selectByExample(example);
+        if (!CollectionUtils.isEmpty(list)) {
+            for (CgiReplyBucketData item : list) {
+                CgiReplyBucketData oldItem = cgiReplyBucketDataMapperExt.getOldCgiReplyData(item.getMiniVideoId());
+                if (oldItem != null) {
+                    item.setTitle(oldItem.getTitle());
+                    item.setCoverUrl(oldItem.getCoverUrl());
+                    cgiReplyBucketDataMapper.updateByPrimaryKeySelective(item);
+                }
+            }
+        }
+    }
+
+}

+ 3 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/ext/CgiReplyBucketDataMapperExt.java

@@ -1,6 +1,7 @@
 package com.tzld.piaoquan.growth.common.dao.mapper.ext;
 
 
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -12,4 +13,6 @@ public interface CgiReplyBucketDataMapperExt {
                                           @Param("cover") String cover);
 
     void deleteBucketDataByGhId(@Param("ghId") String ghId);
+
+    CgiReplyBucketData getOldCgiReplyData(@Param("videoId") Long miniVideoId);
 }

+ 7 - 0
common-module/src/main/resources/mapper/ext/CgiReplyBucketDataMapperExt.xml

@@ -18,4 +18,11 @@
         and is_delete = 0
   </update>
 
+    <select id="getOldCgiReplyData" resultType="com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData">
+        select *
+        from growth.cgi_reply_bucket_data
+        where mini_video_id = #{videoId} and title is not null and cover_url is not null
+        order by id desc limit 1
+    </select>
+
 </mapper>