Pārlūkot izejas kodu

修复封面不存在时获取失败的问题

xueyiming 9 stundas atpakaļ
vecāks
revīzija
a830fd80ed

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/WeComAutoReplyImpl.java

@@ -80,7 +80,7 @@ public class WeComAutoReplyImpl implements WeComAutoReply {
                 JSONObject attachment = new JSONObject();
                 attachment.put("msgtype", "miniprogram");
                 JSONObject miniprogram = new JSONObject();
-                String picMediaId = messageAttachmentService.getPicMediaId(msgData.getCoverUrl(), corpId);
+                String picMediaId = messageAttachmentService.getPicMediaId(msgData.getCoverUrl(), corpId, msgData.getMiniVideoId());
                 miniprogram.put("title", msgData.getTitle());
                 miniprogram.put("pic_media_id", picMediaId);
                 miniprogram.put("appid", msgData.getMiniAppId());

+ 5 - 1
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageAttachmentServiceImpl.java

@@ -337,7 +337,11 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
     }
 
     @Override
-    public String getPicMediaId(String cover, Long corpId) {
+    public String getPicMediaId(String cover, Long corpId, Long miniprogramVideoId) {
+        if (StringUtils.isEmpty(cover)) {
+            Map<Long, VideoDetail> videoDetail = getVideoDetail(Collections.singleton(miniprogramVideoId));
+            cover = videoDetail.get(miniprogramVideoId).getCover();
+        }
         String key = corpId + "_" + cover;
         String mediaId = (String) redisTemplate.opsForValue().get(key);
         if (StringUtils.isNotEmpty(mediaId)) {

+ 1 - 1
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/MessageAttachmentService.java

@@ -23,7 +23,7 @@ public interface MessageAttachmentService {
 
     Map<Long, VideoDetail> getVideoDetail(Set<Long> videoIdList);
 
-    String getPicMediaId(String cover, Long corpId);
+    String getPicMediaId(String cover, Long corpId, Long miniprogramVideoId);
 
     String getPage(Staff staff, Long videoId);
 

+ 1 - 1
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComMessageDataJob.java

@@ -535,7 +535,7 @@ public class WeComMessageDataJob {
                 title = ToolUtils.truncateString(title, MAX_BYTES - 3) + "...";
             }
             miniprogram.put("title", title);
-            String picMediaId = messageAttachmentService.getPicMediaId(messageAttachment.getCover(), sendMessage.getCorpId());
+            String picMediaId = messageAttachmentService.getPicMediaId(messageAttachment.getCover(), sendMessage.getCorpId(), messageAttachment.getMiniprogramVideoId());
             if (StringUtils.isEmpty(picMediaId)) {
                 log.error("pushMessage getPicMediaId error cover={}", messageAttachment.getCover());
                 return false;