Browse Source

添加保底视频时,提示是否发送过

xueyiming 5 months ago
parent
commit
945ccf8130

+ 15 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageAttachmentServiceImpl.java

@@ -42,6 +42,7 @@ import static com.tzld.piaoquan.wecom.common.constant.MessageConstant.appid;
 import static com.tzld.piaoquan.wecom.common.constant.OtherServerURL.POST_ADD_TENCENT;
 import static com.tzld.piaoquan.wecom.common.constant.OtherServerURL.POST_VIDEO_DETAIL_URL;
 import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINI_PROGRAM_KEY;
+import static com.tzld.piaoquan.wecom.common.constant.TimeConstant.MILLISECOND_DAY;
 import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.POST_WE_COM_MEDIA_UPLOAD;
 
 
@@ -95,6 +96,20 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
             if (CollectionUtils.isEmpty(videoParam.getVideoIds()) || videoParam.getVideoIds().size() < MAX_VIDEO_NUM) {
                 LarkRobotUtil.sendMessage("保底视频数量异常,请查看" + guaranteedParam.getDate());
             }
+            for (Long videoId : videoParam.getVideoIds()) {
+                MessageAttachmentExample example = new MessageAttachmentExample();
+                example.createCriteria().andMiniprogramVideoIdEqualTo(videoId).andStaffIdEqualTo(videoParam.getStaffId());
+                List<MessageAttachment> messageAttachmentList = messageAttachmentMapper.selectByExample(example);
+                if (CollectionUtils.isEmpty(messageAttachmentList)) {
+                    continue;
+                }
+                MessageAttachment messageAttachment = messageAttachmentList.get(0);
+                if (messageAttachment.getSendTime() != null
+                        && DateUtil.dateDifference(new Date(), messageAttachment.getSendTime()) < 180 * MILLISECOND_DAY) {
+                    LarkRobotUtil.sendMessage("保底视频半年内已发送,请查看videoId=" + videoId);
+                    return CommonResponse.create(500, "保底视频半年内已发送,请查看videoId=" + videoId);
+                }
+            }
             videoIds.addAll(videoParam.getVideoIds());
         }
         Map<Long, VideoDetail> coverMap = getVideoDetail(videoIds);