Browse Source

修改daily配置接口

xueyiming 1 month ago
parent
commit
659b0f474c

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

@@ -131,10 +131,12 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
         if (isInvalidGuaranteedParam(guaranteedParam)) {
             return CommonResponse.create(500, "参数错误");
         }
-
         Set<Long> videoIds = new HashSet<>();
         for (VideoParam videoParam : guaranteedParam.getVideoParamList()) {
-            processVideoParam(videoParam, guaranteedParam.getDate(), videoIds);
+            CommonResponse<Void> voidCommonResponse = processVideoParam(videoParam, guaranteedParam.getDate(), videoIds);
+            if (voidCommonResponse != null) {
+                return voidCommonResponse;
+            }
         }
 
         Map<Long, VideoDetail> coverMap = getVideoDetail(videoIds);
@@ -156,9 +158,9 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
     }
 
 
-    private void processVideoParam(VideoParam videoParam, String date, Set<Long> videoIds) {
+    private CommonResponse<Void> processVideoParam(VideoParam videoParam, String date, Set<Long> videoIds) {
         if (CollectionUtils.isEmpty(videoParam.getVideoIds()) || videoParam.getVideoIds().size() < MAX_VIDEO_NUM) {
-            LarkRobotUtil.sendMessage("保底视频数量异常,请查看" + date);
+            return CommonResponse.create(500, "保底视频数量异常,请查看" + date);
         }
         List<Long> staffIds = Optional.ofNullable(videoParam.getStaffIds()).orElseGet(() -> {
             List<Long> newStaffIds = new ArrayList<>();
@@ -168,12 +170,16 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
             return newStaffIds;
         });
         for (Long staffId : staffIds) {
-            checkVideoSendTime(videoParam, staffId);
+            CommonResponse<Void> voidCommonResponse = checkVideoSendTime(videoParam, staffId);
+            if (voidCommonResponse != null) {
+                return voidCommonResponse;
+            }
             videoIds.addAll(videoParam.getVideoIds());
         }
+        return null;
     }
 
-    private void checkVideoSendTime(VideoParam videoParam, Long staffId) {
+    private CommonResponse<Void> checkVideoSendTime(VideoParam videoParam, Long staffId) {
         for (Long videoId : videoParam.getVideoIds()) {
             MessageAttachmentExample example = new MessageAttachmentExample();
             example.createCriteria().andMiniprogramVideoIdEqualTo(videoId).andStaffIdEqualTo(staffId);
@@ -184,10 +190,10 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
             MessageAttachment messageAttachment = messageAttachmentList.get(0);
             if (messageAttachment.getSendTime() != null &&
                     DateUtil.dateDifference(new Date(), messageAttachment.getSendTime()) < 30 * MILLISECOND_DAY) {
-                LarkRobotUtil.sendMessage("保底视频90天内已发送,请查看videoId=" + videoId);
-                throw new RuntimeException("保底视频90天内已发送,请查看videoId=" + videoId);
+                return CommonResponse.create(500, "保底视频30天内已发送,请查看videoId=" + videoId);
             }
         }
+        return null;
     }
 
     private Map<Long, MessageAttachment> createMessageAttachmentMap(Set<Long> videoIds, Map<Long, VideoDetail> coverMap) {

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

@@ -166,7 +166,7 @@ public class WeComMessageDataJob {
             }
             if (CollectionUtils.isEmpty(videoParam.getVideoIds()) || videoParam.getVideoIds().size() < MAX_VIDEO_NUM) {
                 LarkRobotUtil.sendMessage("保底视频数量异常,请查看" + guaranteedParam.getDate() + videoParam.getStaffId());
-                throw new RuntimeException();
+                continue;
             }
             for (Long videoId : videoParam.getVideoIds()) {
                 MessageAttachmentExample example = new MessageAttachmentExample();
@@ -179,7 +179,7 @@ public class WeComMessageDataJob {
                 MessageAttachment messageAttachment = messageAttachmentList.get(0);
                 if (messageAttachment.getSendTime() != null
                         && DateUtil.dateDifference(new Date(), messageAttachment.getSendTime()) < 30 * MILLISECOND_DAY) {
-                    LarkRobotUtil.sendMessage("保底视频90天内已发送,请查看videoId=" + videoId);
+                    LarkRobotUtil.sendMessage("保底视频30天内已发送,请查看videoId=" + videoId);
                 }
             }
             //重新组合视频id
@@ -187,7 +187,6 @@ public class WeComMessageDataJob {
         }
         if (!videoMap.containsKey(0L)) {
             LarkRobotUtil.sendMessage("保底视频没有默认组,请查看" + guaranteedParam.getDate());
-            throw new RuntimeException();
         }
         log.info("保底数据获取,videoMap={}", videoMap);
         this.guaranteedVideoMap = videoMap;