lyhzzz 2 年之前
父节点
当前提交
2a2679811b

+ 0 - 8
src/main/java/com/fdkankan/tk/entity/Room.java

@@ -66,12 +66,6 @@ public class Room implements Serializable {
     private String roomCoverUrl;
 
     /**
-     * 房间浏览量
-     */
-    @TableField("room_view_count")
-    private Integer roomViewCount;
-
-    /**
      * 房间分享二维码
      */
     @TableField("room_share_code")
@@ -131,8 +125,6 @@ public class Room implements Serializable {
     @TableField("max_man")
     private Integer maxMan;
     //分享次数
-    @TableField("share_count")
-    private Integer shareCount;
     //主持人状态,0未进入房间,1已进入房间
     @TableField("host_status")
     private Integer hostStatus;

+ 2 - 2
src/main/java/com/fdkankan/tk/response/RoomData.java

@@ -6,6 +6,6 @@ import lombok.Data;
 public class RoomData {
     private Long roomCount = 0L;
     private Long visitManCount = 0L;
-    private Integer visitCount = 0;
-    private Integer shareCount = 0;
+    private Long visitCount = 0L;
+    private Long shareCount = 0L;
 }

+ 2 - 2
src/main/java/com/fdkankan/tk/response/RoomListDataVo.java

@@ -32,10 +32,10 @@ public class RoomListDataVo {
     private String roomStatusStr;
 
     @ExcelProperty("总观看次数")
-    private Integer lookManCount;
+    private Long lookManCount;
 
     @ExcelProperty("分享总数")
-    private Integer shareCount;
+    private Long shareCount;
 
     public String getRoomStatusStr() {
         if(roomStatus == null){

+ 7 - 11
src/main/java/com/fdkankan/tk/service/DataCountService.java

@@ -49,14 +49,8 @@ public class DataCountService {
 
         Long visitManCount = roomVisitLogService.manCount(roomIds);
 
-        Integer shareCount = 0 ;
-        for (Room room : roomList) {
-            shareCount += room.getShareCount();
-        }
-        Integer visitCount = 0 ;
-        for (Room room : roomList) {
-            visitCount += room.getRoomViewCount();
-        }
+        Long visitCount =  roomVisitLogService.getCountByRoomIds(roomIds);
+        Long shareCount =  roomShareLogService.getCountByRoomIds(roomIds);
 
         RoomData roomData = new RoomData();
         roomData.setRoomCount(roomCount);
@@ -232,17 +226,19 @@ public class DataCountService {
                 });
             }
             List<RoomVisitLog> roomLives = roomVisitLogService.getByRoomId(record.getRoomId());
-            List<RoomShareLog> shareLogs = roomShareLogService.getByRoomId(record.getRoomId());
             Long roomTime = getRoomTime(roomLives);
 
+            Long visitCount = roomVisitLogService.getCountByRoomIds(Arrays.asList(record.getRoomId()));
+            Long shareCount = roomShareLogService.getCountByRoomIds(Arrays.asList(record.getRoomId()));
+
             RoomListDataVo roomListDataVo = new RoomListDataVo();
             roomListDataVo.setRoomTitle(record.getRoomTitle());
             roomListDataVo.setSceneNameList(sceneTileList);
             roomListDataVo.setCreateTime(record.getCreateTime());
             roomListDataVo.setRoomStatus(record.getRoomStatus());
             roomListDataVo.setLookTime(roomTime);
-            roomListDataVo.setLookManCount(roomLives.size());
-            roomListDataVo.setShareCount(shareLogs.size());
+            roomListDataVo.setLookManCount(visitCount);
+            roomListDataVo.setShareCount(shareCount);
             voList.add(roomListDataVo);
         }
         Page<RoomListDataVo> pageVo = new Page<>(pageNum,pageSize);

+ 2 - 0
src/main/java/com/fdkankan/tk/service/IRoomShareLogService.java

@@ -23,4 +23,6 @@ public interface IRoomShareLogService extends IService<RoomShareLog> {
     Long getShareCountByRoomId(String roomId);
 
     List<RoomShareLog> getByRoomId(String roomId);
+
+    Long getCountByRoomIds(List<String> roomIds);
 }

+ 2 - 0
src/main/java/com/fdkankan/tk/service/IRoomVisitLogService.java

@@ -36,4 +36,6 @@ public interface IRoomVisitLogService extends IService<RoomVisitLog> {
     List<DataCount> getDataCountTop5(List<String> roomIds);
 
     List<RoomVisitLog> getByRoomIdAndUerId(String roomId, String wxUserId);
+
+    Long getCountByRoomIds(List<String> roomIds);
 }

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

@@ -357,9 +357,6 @@ public class RoomServiceImpl extends ServiceImpl<IRoomMapper, Room> implements I
         }
 
         if(role.equals("customer")){
-            if(type == 0 ){
-                room.setRoomViewCount(room.getRoomViewCount() + 1);
-            }
             roomVisitLogService.addLog(roomId,roomUserId,userId,type,0);
             this.updateById(room);
             return;
@@ -378,7 +375,6 @@ public class RoomServiceImpl extends ServiceImpl<IRoomMapper, Room> implements I
         }
 
         if(type == 0 ){     //加入房间,开启带看
-            room.setRoomViewCount(room.getRoomViewCount() + 1);
             room.setHostStatus(1);
             room.setRoomStatus(1);
             roomVisitLogService.addLog(roomId,roomUserId,userId,type,1);
@@ -455,7 +451,6 @@ public class RoomServiceImpl extends ServiceImpl<IRoomMapper, Room> implements I
         if(StringUtils.isNotBlank(userName)){
             wrapper.eq(Room::getRoomUserName,userName);
         }
-        wrapper.orderByDesc(Room::getRoomViewCount);
        return this.list(wrapper);
     }
 

+ 10 - 0
src/main/java/com/fdkankan/tk/service/impl/RoomShareLogServiceImpl.java

@@ -59,4 +59,14 @@ public class RoomShareLogServiceImpl extends ServiceImpl<IRoomShareLogMapper, Ro
         wrapper.eq(RoomShareLog::getRoomId,roomId);
         return this.list(wrapper);
     }
+
+    @Override
+    public Long getCountByRoomIds(List<String> roomIds) {
+        if(roomIds.size() >0){
+            LambdaQueryWrapper<RoomShareLog> wrapper = new LambdaQueryWrapper<>();
+            wrapper.in(RoomShareLog::getRoomId,roomIds);
+            return this.count(wrapper);
+        }
+      return 0L;
+    }
 }

+ 10 - 0
src/main/java/com/fdkankan/tk/service/impl/RoomVisitLogServiceImpl.java

@@ -125,4 +125,14 @@ public class RoomVisitLogServiceImpl extends ServiceImpl<IRoomVisitLogMapper, Ro
     public List<DataCount> getDataCountTop5(List<String> roomIds) {
         return this.getBaseMapper().getDataCountTop5(roomIds);
     }
+
+    @Override
+    public Long getCountByRoomIds(List<String> roomIds) {
+        if(roomIds.size() >0){
+            LambdaQueryWrapper<RoomVisitLog> wrapper = new LambdaQueryWrapper<>();
+            wrapper.in(RoomVisitLog::getRoomId,roomIds);
+            return this.count(wrapper);
+        }
+       return 0L;
+    }
 }