|
@@ -218,7 +218,6 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
return;
|
|
|
}
|
|
|
- Date now = new Date();
|
|
|
//查询房间过期时间
|
|
|
String expiredMinuteStr = sysConfigDao.findConfigValue("destroy_expired_live_room_minute");
|
|
|
if (StringUtils.isEmpty(expiredMinuteStr)) {
|
|
@@ -226,6 +225,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
return;
|
|
|
}
|
|
|
int expiredMinute = Integer.parseInt(expiredMinuteStr);
|
|
|
+ Date now = new Date();
|
|
|
list.forEach(room -> {
|
|
|
try {
|
|
|
destroyExpiredLiveRoom(now, room, expiredMinute);
|
|
@@ -244,21 +244,23 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
RBucket<RoomSpeakerInfo> speakerCache = redissonClient.getBucket(LIVE_SPEAKER_INFO.replace(USER_ID, room.getSpeakerId().toString()));
|
|
|
if (speakerCache.isExists()) {
|
|
|
RoomSpeakerInfo speakerInfo = speakerCache.get();
|
|
|
- //超过30分钟,没有进入房间
|
|
|
+ //超过expiredMinute分钟,没有进入房间
|
|
|
if (Objects.isNull(speakerInfo.getJoinRoomTime())) {
|
|
|
- roomDestroy(room.getId());
|
|
|
+ roomDestroy(room);
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
//超过expiredMinute分钟,但是未开启直播,则销毁
|
|
|
if (Objects.isNull(speakerInfo.getState())) {
|
|
|
- roomDestroy(room.getId());
|
|
|
+ roomDestroy(room);
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
//现在时间 大于 (退出房间的时间 + expiredMinute 分钟),则销毁
|
|
|
if (Objects.nonNull(speakerInfo.getExitRoomTime())) {
|
|
|
Date comparedTime = DateUtil.addMinutes(speakerInfo.getExitRoomTime(), expiredMinute);
|
|
|
if (now.getTime() >= comparedTime.getTime()) {
|
|
|
- roomDestroy(room.getId());
|
|
|
+ roomDestroy(room);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -280,14 +282,16 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
if (room.getLiveState() == 0) {
|
|
|
throw new BizException("直播未开始");
|
|
|
}
|
|
|
+ roomDestroy(room);
|
|
|
+ }
|
|
|
|
|
|
+ public void roomDestroy(ImLiveBroadcastRoom room) {
|
|
|
String roomUid = room.getRoomUid();
|
|
|
Integer speakerId = room.getSpeakerId();
|
|
|
try {
|
|
|
imFeignService.destroyLiveRoom(roomUid);
|
|
|
} catch (Exception e) {
|
|
|
log.error("roomDestroy>>>> errorMsg{}", e.getMessage(), e.getCause());
|
|
|
- throw new BizException(e.getMessage());
|
|
|
}
|
|
|
|
|
|
//获取所有直播间缓存数据并写入数据库后并清理缓存
|
|
@@ -298,7 +302,12 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
Date date = new Date();
|
|
|
room.setRoomState(2);
|
|
|
room.setLiveState(2);
|
|
|
- room.setUpdatedBy(getSysUser().getId());
|
|
|
+ Integer userId = -1;
|
|
|
+ try {
|
|
|
+ userId = getSysUser().getId();
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ }
|
|
|
+ room.setUpdatedBy(userId);
|
|
|
room.setUpdatedTime(date);
|
|
|
room.setLiveEndTime(date);
|
|
|
this.updateById(room);
|