Bläddra i källkod

直播结束时间

lyhzzz 2 år sedan
förälder
incheckning
1a275c994a

+ 3 - 2
src/main/java/com/fdkankan/tk/service/IRoomLiveService.java

@@ -1,5 +1,6 @@
 package com.fdkankan.tk.service;
 
+import com.fdkankan.tk.entity.Room;
 import com.fdkankan.tk.entity.RoomLive;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -18,9 +19,9 @@ public interface IRoomLiveService extends IService<RoomLive> {
 
     RoomLive addLiveByRoomId(String roomId,String roomUserId);
 
-    void stopByLiveId(String liveId);
+    void stopByLiveId(String liveId,Date overTime);
 
-    void stopByRoomId(String roomId);
+    void stopByRoomId(Room room);
 
     List<RoomLive> getByRoomId(String roomId);
 }

+ 6 - 5
src/main/java/com/fdkankan/tk/service/impl/RoomLiveServiceImpl.java

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.tk.common.util.RoomUtil;
+import com.fdkankan.tk.entity.Room;
 import com.fdkankan.tk.entity.RoomLive;
 import com.fdkankan.tk.httpClient.client.LiveClient;
 import com.fdkankan.tk.mapper.IRoomLiveMapper;
@@ -46,10 +47,10 @@ public class RoomLiveServiceImpl extends ServiceImpl<IRoomLiveMapper, RoomLive>
     }
 
     @Override
-    public void stopByLiveId(String liveId) {
+    public void stopByLiveId(String liveId,Date overTime) {
         LambdaUpdateWrapper<RoomLive> wrapper = new LambdaUpdateWrapper<>();
         wrapper.eq(RoomLive::getLiveId,liveId);
-        wrapper.set(RoomLive::getOverTime,new Date());
+        wrapper.set(RoomLive::getOverTime,overTime);
         wrapper.set(RoomLive::getStatus,2);
         this.update(wrapper);
 
@@ -58,10 +59,10 @@ public class RoomLiveServiceImpl extends ServiceImpl<IRoomLiveMapper, RoomLive>
     }
 
     @Override
-    public void stopByRoomId(String roomId) {
-        List<RoomLive> list = this.getByRoomId(roomId);
+    public void stopByRoomId(Room room) {
+        List<RoomLive> list = this.getByRoomId(room.getRoomId());
         for (RoomLive roomLive : list) {
-            this.stopByLiveId(roomLive.getLiveId().toString());
+            this.stopByLiveId(roomLive.getLiveId().toString(),room.getUseEndTime());
         }
     }
 

+ 2 - 2
src/main/java/com/fdkankan/tk/service/impl/RoomServiceImpl.java

@@ -371,7 +371,7 @@ public class RoomServiceImpl extends ServiceImpl<IRoomMapper, Room> implements I
             room.setRoomStatus(2);
             String liveId = redisUtil.get(RoomUtil.redisKey+"live:"+wxRoomId);
             if(StringUtils.isNotBlank(liveId)){
-                roomLiveService.stopByLiveId(liveId);
+                roomLiveService.stopByLiveId(liveId,new Date());
                 roomVisitLogService.addLog(Integer.parseInt(liveId),roomId,userId,type);
             }
             redisUtil.del(RoomUtil.redisKey+"live:"+wxRoomId);
@@ -403,7 +403,7 @@ public class RoomServiceImpl extends ServiceImpl<IRoomMapper, Room> implements I
         wrapper.eq(Room::getRoomId,room.getRoomId());
         wrapper.set(Room::getRoomStatus,2);
         this.update(wrapper);
-        roomLiveService.stopByRoomId(room.getRoomId());
+        roomLiveService.stopByRoomId(room);
         redisUtil.del(RoomUtil.redisKey+"live:"+room.getRoomId());
 
         List<RoomUser> byRoomId = roomUserService.getByRoomId(room.getRoomId());

+ 1 - 1
src/main/java/com/fdkankan/tk/service/impl/RoomUserServiceImpl.java

@@ -132,7 +132,7 @@ public class RoomUserServiceImpl extends ServiceImpl<IRoomUserMapper, RoomUser>
 
         String liveId = redisUtil.get(RoomUtil.redisKey+"live:"+RoomUtil.getLiveRoomId(roomUser.getRoomId(),roomUser.getRoomUserId().toString()));
         if(StringUtils.isNotBlank(liveId)){
-            roomLiveService.stopByLiveId(liveId);
+            roomLiveService.stopByLiveId(liveId,roomUser.getUseEndTime());
             roomVisitLogService.stopRoom(Integer.parseInt(liveId));
             redisUtil.del(RoomUtil.redisKey+"live:"+RoomUtil.getLiveRoomId(roomUser.getRoomId(),roomUser.getRoomUserId().toString()));