|
@@ -24,7 +24,6 @@ import com.fdkankan.tk.common.util.RedisKeyUtil;
|
|
|
import com.fdkankan.tk.common.util.RoomUtil;
|
|
|
import com.fdkankan.tk.common.util.UploadToOssUtil;
|
|
|
import com.fdkankan.tk.entity.Room;
|
|
|
-import com.fdkankan.tk.entity.RoomLive;
|
|
|
import com.fdkankan.tk.entity.RoomUser;
|
|
|
import com.fdkankan.tk.entity.WxUser;
|
|
|
import com.fdkankan.tk.exception.BusinessException;
|
|
@@ -81,9 +80,9 @@ public class RoomServiceImpl extends ServiceImpl<IRoomMapper, Room> implements I
|
|
|
@Autowired
|
|
|
IRoomUserService roomUserService;
|
|
|
@Autowired
|
|
|
- IRoomLiveService roomLiveService;
|
|
|
- @Autowired
|
|
|
IRoomVisitLogService roomVisitLogService;
|
|
|
+ @Autowired
|
|
|
+ IRoomDanmakuService roomDanmakuService;
|
|
|
|
|
|
@Override
|
|
|
public PageInfo pageList(RoomListParam param, String token,String wxToken) {
|
|
@@ -320,11 +319,11 @@ public class RoomServiceImpl extends ServiceImpl<IRoomMapper, Room> implements I
|
|
|
throw new BusinessException(ResultCode.PARAM_MISS);
|
|
|
}
|
|
|
String wxRoomId = roomId;
|
|
|
- String roomUserId = null;
|
|
|
+ Integer roomUserId = null;
|
|
|
if(roomId.contains("_")){
|
|
|
String[] split = roomId.split("_");
|
|
|
roomId =split[0];
|
|
|
- roomUserId = split[1];
|
|
|
+ roomUserId = Integer.parseInt(split[1]);
|
|
|
}
|
|
|
Room room = this.getById(roomId);
|
|
|
if(room == null){
|
|
@@ -343,10 +342,7 @@ public class RoomServiceImpl extends ServiceImpl<IRoomMapper, Room> implements I
|
|
|
if(type == 0 ){
|
|
|
room.setRoomViewCount(room.getRoomViewCount() + 1);
|
|
|
}
|
|
|
- String liveId = redisUtil.get(RoomUtil.redisKey+"live:"+wxRoomId);
|
|
|
- if(StringUtils.isNotBlank(liveId)){
|
|
|
- roomVisitLogService.addLog(Integer.parseInt(liveId),roomId,userId,type);
|
|
|
- }
|
|
|
+ roomVisitLogService.addLog(roomId,roomUserId,userId,type);
|
|
|
room.setUpdateTime(null);
|
|
|
this.updateById(room);
|
|
|
return;
|
|
@@ -354,10 +350,6 @@ public class RoomServiceImpl extends ServiceImpl<IRoomMapper, Room> implements I
|
|
|
|
|
|
if(roomUserId != null){ //协作带看
|
|
|
RoomUser roomuser = roomUserService.getById(roomUserId);
|
|
|
- if(roomuser.getUseEndTime() != null && roomuser.getUseEndTime().getTime() <= new Date().getTime()){
|
|
|
- throw new BusinessException(ResultCode.ROOM_END_EX);
|
|
|
- }
|
|
|
-
|
|
|
if(type == 0 ){ //加入房间,开启带看
|
|
|
roomuser.setRoomStatus(1);
|
|
|
}
|
|
@@ -371,17 +363,12 @@ public class RoomServiceImpl extends ServiceImpl<IRoomMapper, Room> implements I
|
|
|
if(type == 0 ){ //加入房间,开启带看
|
|
|
room.setRoomViewCount(room.getRoomViewCount() + 1);
|
|
|
room.setRoomStatus(1);
|
|
|
- RoomLive roomLive = roomLiveService.addLiveByRoomId(roomId,roomUserId);
|
|
|
- roomVisitLogService.addLog(roomLive.getLiveId(),roomId,userId,type);
|
|
|
+ roomVisitLogService.addLog(roomId,roomUserId,userId,type);
|
|
|
}
|
|
|
if(type == 1 ){ //离开房间
|
|
|
room.setRoomStatus(2);
|
|
|
- String liveId = redisUtil.get(RoomUtil.redisKey+"live:"+wxRoomId);
|
|
|
- if(StringUtils.isNotBlank(liveId)){
|
|
|
- roomLiveService.stopByLiveId(liveId,new Date());
|
|
|
- roomVisitLogService.addLog(Integer.parseInt(liveId),roomId,userId,type);
|
|
|
- }
|
|
|
- redisUtil.del(RoomUtil.redisKey+"live:"+wxRoomId);
|
|
|
+ this.stopRoom(roomId,roomUserId);
|
|
|
+ roomVisitLogService.addLog(roomId,roomUserId,userId,type);
|
|
|
}
|
|
|
|
|
|
room.setLastLookTime(DateUtil.formatDateTime(new Date()));
|
|
@@ -403,18 +390,27 @@ public class RoomServiceImpl extends ServiceImpl<IRoomMapper, Room> implements I
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void stopRoom(Room room) {
|
|
|
- LambdaUpdateWrapper<Room> wrapper = new LambdaUpdateWrapper<>();
|
|
|
- wrapper.eq(Room::getRoomId,room.getRoomId());
|
|
|
- wrapper.set(Room::getRoomStatus,2);
|
|
|
- this.update(wrapper);
|
|
|
- roomLiveService.stopByRoomId(room);
|
|
|
- redisUtil.del(RoomUtil.redisKey+"live:"+room.getRoomId());
|
|
|
-
|
|
|
- List<RoomUser> byRoomId = roomUserService.getByRoomId(room.getRoomId());
|
|
|
- for (RoomUser roomUser : byRoomId) {
|
|
|
- roomUserService.stopRoom(roomUser);
|
|
|
+ public void stopRoom(String roomId,Integer roomUserId) {
|
|
|
+ if(roomUserId == null){
|
|
|
+ LambdaUpdateWrapper<Room> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(Room::getRoomId,roomId);
|
|
|
+ wrapper.set(Room::getRoomStatus,2);
|
|
|
+ this.update(wrapper);
|
|
|
+ roomVisitLogService.stopRoom(roomId,roomUserId);
|
|
|
+ roomDanmakuService.saveDanMaku(roomId,roomUserId);
|
|
|
+
|
|
|
+ List<RoomUser> byRoomId = roomUserService.getByRoomId(roomId);
|
|
|
+ for (RoomUser roomUser : byRoomId) {
|
|
|
+ roomUserService.stopRoom(roomUser);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ RoomUser roomUser = roomUserService.getById(roomUserId);
|
|
|
+ if(roomUser != null){
|
|
|
+ roomUserService.stopRoom(roomUser);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -447,4 +443,12 @@ public class RoomServiceImpl extends ServiceImpl<IRoomMapper, Room> implements I
|
|
|
wrapper.orderByDesc(Room::getRoomViewCount);
|
|
|
return this.list(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addShareCount(String roomId) {
|
|
|
+ LambdaUpdateWrapper<Room> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.setSql("share_count = share_count +1");
|
|
|
+ wrapper.eq(Room::getRoomId,roomId);
|
|
|
+ this.update(wrapper);
|
|
|
+ }
|
|
|
}
|