|
|
@@ -156,33 +156,33 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
|
|
|
LiveWatchUser liveWatchUser = getByLiveIdAndUserId(liveId, userId);
|
|
|
FsUser fsUserVO = fsUserService.selectFsUserByUserId(userId);
|
|
|
Date now = DateUtils.getNowDate();
|
|
|
-
|
|
|
+
|
|
|
// 查询直播间信息
|
|
|
Live live = liveMapper.selectLiveByLiveId(liveId);
|
|
|
-
|
|
|
+
|
|
|
// 判断用户进入时间:如果进入时间大于直播结束时间,说明是回放
|
|
|
boolean isReplay = false;
|
|
|
if (live != null && live.getFinishTime() != null) {
|
|
|
Date finishTime = java.sql.Timestamp.valueOf(live.getFinishTime());
|
|
|
isReplay = now.after(finishTime);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if(liveWatchUser != null) {
|
|
|
liveWatchUser.setUpdateTime(now);
|
|
|
liveWatchUser.setOnline(0);
|
|
|
-
|
|
|
+
|
|
|
// 更新location
|
|
|
if (StringUtils.isNotEmpty(location)) {
|
|
|
liveWatchUser.setLocation(location);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 更新进入标记
|
|
|
if (isReplay) {
|
|
|
liveWatchUser.setReplayFlag(1);
|
|
|
} else {
|
|
|
liveWatchUser.setLiveFlag(1);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
baseMapper.updateLiveWatchUser(liveWatchUser);
|
|
|
}else{
|
|
|
liveWatchUser = new LiveWatchUser();
|
|
|
@@ -192,7 +192,7 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
|
|
|
liveWatchUser.setMsgStatus(0);
|
|
|
liveWatchUser.setOnline(0);
|
|
|
liveWatchUser.setLocation(location);
|
|
|
-
|
|
|
+
|
|
|
// 设置进入标记
|
|
|
if (isReplay) {
|
|
|
liveWatchUser.setReplayFlag(1);
|
|
|
@@ -201,7 +201,63 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
|
|
|
liveWatchUser.setLiveFlag(1);
|
|
|
liveWatchUser.setReplayFlag(0);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ liveWatchUser.setCreateTime(now);
|
|
|
+ liveWatchUser.setUpdateTime(now);
|
|
|
+ baseMapper.insertLiveWatchUser(liveWatchUser);
|
|
|
+ }
|
|
|
+ liveWatchUser.setAvatar(fsUserVO.getAvatar());
|
|
|
+ liveWatchUser.setNickName(fsUserVO.getNickname());
|
|
|
+ String hashKey = String.format(LiveKeysConstant.LIVE_WATCH_USERS, liveId);
|
|
|
+ redisCache.hashPut(hashKey, String.valueOf(userId), JSON.toJSONString(liveWatchUser));
|
|
|
+ return liveWatchUser;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public LiveWatchUser joinWithoutLocation(long liveId, long userId) {
|
|
|
+ LiveWatchUser liveWatchUser = getByLiveIdAndUserId(liveId, userId);
|
|
|
+ FsUser fsUserVO = fsUserService.selectFsUserByUserId(userId);
|
|
|
+ Date now = DateUtils.getNowDate();
|
|
|
+
|
|
|
+ // 查询直播间信息
|
|
|
+ Live live = liveMapper.selectLiveByLiveId(liveId);
|
|
|
+
|
|
|
+ // 判断用户进入时间:如果进入时间大于直播结束时间,说明是回放
|
|
|
+ boolean isReplay = false;
|
|
|
+ if (live != null && live.getFinishTime() != null) {
|
|
|
+ Date finishTime = java.sql.Timestamp.valueOf(live.getFinishTime());
|
|
|
+ isReplay = now.after(finishTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(liveWatchUser != null) {
|
|
|
+ liveWatchUser.setUpdateTime(now);
|
|
|
+ liveWatchUser.setOnline(0);
|
|
|
+
|
|
|
+ // 更新进入标记
|
|
|
+ if (isReplay) {
|
|
|
+ liveWatchUser.setReplayFlag(1);
|
|
|
+ } else {
|
|
|
+ liveWatchUser.setLiveFlag(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ baseMapper.updateLiveWatchUser(liveWatchUser);
|
|
|
+ }else{
|
|
|
+ liveWatchUser = new LiveWatchUser();
|
|
|
+ liveWatchUser.setLiveId(liveId);
|
|
|
+ liveWatchUser.setUserId(userId);
|
|
|
+ liveWatchUser.setAvatar(fsUserVO.getAvatar());
|
|
|
+ liveWatchUser.setMsgStatus(0);
|
|
|
+ liveWatchUser.setOnline(0);
|
|
|
+
|
|
|
+ // 设置进入标记
|
|
|
+ if (isReplay) {
|
|
|
+ liveWatchUser.setReplayFlag(1);
|
|
|
+ liveWatchUser.setLiveFlag(0);
|
|
|
+ } else {
|
|
|
+ liveWatchUser.setLiveFlag(1);
|
|
|
+ liveWatchUser.setReplayFlag(0);
|
|
|
+ }
|
|
|
+
|
|
|
liveWatchUser.setCreateTime(now);
|
|
|
liveWatchUser.setUpdateTime(now);
|
|
|
baseMapper.insertLiveWatchUser(liveWatchUser);
|