|
@@ -737,7 +737,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
liveData.setLikeNum(like);
|
|
|
liveData.setTotalUserNum(CollectionUtils.isNotEmpty(memberList) ? memberList.size() : 0);
|
|
|
liveData.setUpdatedTime(now);
|
|
|
- liveData.setLiveTime(getLookMinutes(speakerInfo.getStartLiveTime(), now, speakerInfo.getTotalLiveTime()));
|
|
|
+ liveData.setLiveTime(getLookMillisecond(speakerInfo.getStartLiveTime(), now, speakerInfo.getTotalLiveTime()));
|
|
|
liveBroadcastRoomDataService.save(liveData);
|
|
|
//删除房间主讲人数据
|
|
|
speakerCache.delete();
|
|
@@ -1422,10 +1422,10 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
roomSpeakerInfo.setEndLiveTime(now);
|
|
|
roomSpeakerInfo.setState(1);
|
|
|
//如果开播时间和本次操作结束播放时间小于1分钟则不计算观看时间
|
|
|
- int liveMinutes = getLookMinutes(roomSpeakerInfo.getStartLiveTime(), null);
|
|
|
+ int liveMinutes = getLookMillisecond(roomSpeakerInfo.getStartLiveTime(), null);
|
|
|
if (liveMinutes > 1) {
|
|
|
//写入本次直播时长
|
|
|
- roomSpeakerInfo.setTotalLiveTime(getLookMinutes(roomSpeakerInfo.getStartLiveTime(), roomSpeakerInfo.getTotalLiveTime()));
|
|
|
+ roomSpeakerInfo.setTotalLiveTime(getLookMillisecond(roomSpeakerInfo.getStartLiveTime(), roomSpeakerInfo.getTotalLiveTime()));
|
|
|
//关闭直播后异步执行计算房间人员观看时长
|
|
|
CompletableFuture.runAsync(() -> this.asyncOpsLiveLookTime(roomSpeakerInfo.getRoomUid(), 2, now));
|
|
|
}
|
|
@@ -1902,7 +1902,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
imLiveBroadcastRoom.setSpeakerStatus(liveRoom.getSpeakerStatus());
|
|
|
imLiveBroadcastRoom.setPushStatus(liveRoom.getPushStatus());
|
|
|
imLiveBroadcastRoom.setBanStatus(liveRoom.getBanStatus());
|
|
|
- imLiveBroadcastRoom.setLiveTotalTime(liveRoom.getLiveTotalTime());
|
|
|
+ // 不用前端传时间
|
|
|
+ // imLiveBroadcastRoom.setLiveTotalTime(liveRoom.getLiveTotalTime());
|
|
|
|
|
|
return this.updateById(imLiveBroadcastRoom);
|
|
|
}
|
|
@@ -2194,6 +2195,41 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
return Math.max(minutesBetween, 0);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算观看时长差-毫秒数
|
|
|
+ *
|
|
|
+ * @param startDT 开始时间
|
|
|
+ * @param nowMinutes 现在观看时长
|
|
|
+ */
|
|
|
+ private int getLookMillisecond(Date startDT, Integer nowMinutes) {
|
|
|
+ return getLookMillisecond(startDT, new Date(), nowMinutes);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 计算观看时长差-毫秒数
|
|
|
+ *
|
|
|
+ * @param startDT 开始时间
|
|
|
+ * @param endDT 结束时间
|
|
|
+ * @param nowMinutes 现在观看时长
|
|
|
+ */
|
|
|
+ private int getLookMillisecond(Date startDT, Date endDT, Integer nowMinutes) {
|
|
|
+ if (Objects.isNull(nowMinutes)) {
|
|
|
+ nowMinutes = 0;
|
|
|
+ }
|
|
|
+ if (Objects.isNull(startDT)) {
|
|
|
+ return nowMinutes;
|
|
|
+ }
|
|
|
+ if (startDT.getTime() > endDT.getTime()) {
|
|
|
+ return nowMinutes;
|
|
|
+ }
|
|
|
+ //课程结束时间-课程开始时间
|
|
|
+ long durationTime = endDT.getTime() - startDT.getTime();
|
|
|
+ //相差多少分钟
|
|
|
+ int minutesBetween = new Long(durationTime).intValue();
|
|
|
+ minutesBetween += nowMinutes;
|
|
|
+ return Math.max(minutesBetween, 0);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 判断Integer是否相等-null值不相等
|
|
|
*
|