From 5606486228142d2029d2e60c47c3d1e7c41ac599 Mon Sep 17 00:00:00 2001 From: easonzhu Date: Fri, 21 Feb 2025 10:10:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3=E6=BC=8F?= =?UTF-8?q?=E6=B4=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../syzb/common/config/cache/CacheKey.java | 1 + .../service/common/GroupCacheService.java | 27 +++++++++---------- .../query/common/UpdateVideoOptionQuery.java | 1 + .../admin/AdminVideoStatisticService.java | 3 +-- .../service/common/VideoCacheService.java | 4 +-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/syzb/common/config/cache/CacheKey.java b/src/main/java/com/syzb/common/config/cache/CacheKey.java index ae3f0b5..5681d2e 100644 --- a/src/main/java/com/syzb/common/config/cache/CacheKey.java +++ b/src/main/java/com/syzb/common/config/cache/CacheKey.java @@ -356,6 +356,7 @@ public class CacheKey { public static final String USER_TOTAL_ONLINE = "user_total_online|"; public static final String TEMP_READ_LIST = "temp_read_list"; public static final String GROUP_MESSAGE_DATE_ID_MAP = "group_message_date_id_map|"; + public static final String ONLINE_COUNT = "online_count|"; } public static final String GROUP_ONLINE_USER = "group_online_user"; diff --git a/src/main/java/com/syzb/group/service/common/GroupCacheService.java b/src/main/java/com/syzb/group/service/common/GroupCacheService.java index 1d938c8..7d40ce2 100644 --- a/src/main/java/com/syzb/group/service/common/GroupCacheService.java +++ b/src/main/java/com/syzb/group/service/common/GroupCacheService.java @@ -30,8 +30,7 @@ import java.time.LocalDate; import java.util.*; import java.util.concurrent.TimeUnit; -import static com.syzb.common.config.cache.CacheKey.GROUP_ONLINE_USER; -import static com.syzb.common.config.cache.CacheKey.VIDEO_LIVE; +import static com.syzb.common.config.cache.CacheKey.*; @Service public class GroupCacheService { @@ -172,8 +171,8 @@ public class GroupCacheService { return hazelcastInstance.getMap(GROUP_ONLINE_USER); } - public List getTotalOnlineList(Integer videoId) { - String sql = "SELECT * FROM " + GROUP_ONLINE_USER + " WHERE productId = " + videoId; + public List getTotalOnlineList(Integer groupId) { + String sql = "SELECT * FROM " + GROUP_ONLINE_USER + " WHERE productId = " + groupId; SqlResult result = hazelcastInstance.getSql().execute(sql); List list = new ArrayList<>(); for (SqlRow row : result) { @@ -193,8 +192,8 @@ public class GroupCacheService { return list; } - public Set getOnlineUserIds(Integer videoId) { - String sql = "SELECT distinct userId FROM " + GROUP_ONLINE_USER + " WHERE videoId = " + videoId; + public Set getOnlineUserIds(Integer groupId) { + String sql = "SELECT distinct userId FROM " + GROUP_ONLINE_USER + " WHERE productId = " + groupId; SqlResult result = hazelcastInstance.getSql().execute(sql); Set set = new HashSet<>(); for (SqlRow row : result) { @@ -206,12 +205,12 @@ public class GroupCacheService { /** * 获取在线人数 * - * @param videoId 视频ID + * @param groupId 视频ID * @return 在线人数 */ - public int getOnlineCount(Integer videoId) { - IMap map = hazelcastInstance.getMap(VIDEO_LIVE); - String cacheKey = CacheKey.VideoLiveKey.ONLINE_COUNT + videoId; + public int getOnlineCount(Integer groupId) { + IMap map = hazelcastInstance.getMap(GROUP); + String cacheKey = CacheKey.GroupKey.ONLINE_COUNT + groupId; Integer onlineCount = (Integer) map.get(cacheKey); if (onlineCount != null) { return onlineCount; @@ -222,15 +221,15 @@ public class GroupCacheService { return onlineCount; } long startTime = System.currentTimeMillis(); - onlineCount = getOnlineCountWithoutCache(videoId); - LoggerUtil.websocket.info("getOnlineCount-" + videoId + ":" + (System.currentTimeMillis() - startTime) + "ms"); + onlineCount = getOnlineCountWithoutCache(groupId); + LoggerUtil.websocket.info("getOnlineCount-" + groupId + ":" + (System.currentTimeMillis() - startTime) + "ms"); map.put(cacheKey, onlineCount, 2, TimeUnit.SECONDS); } return onlineCount; } - public int getOnlineCountWithoutCache(Integer videoId) { - String sql = "SELECT COUNT(*) FROM " + GROUP_ONLINE_USER + " WHERE videoId = " + videoId + " and isOnline = 1"; + public int getOnlineCountWithoutCache(Integer groupId) { + String sql = "SELECT COUNT(*) FROM " + GROUP_ONLINE_USER + " WHERE productId = " + groupId + " and isOnline = 1"; SqlResult result = hazelcastInstance.getSql().execute(sql); Iterator iter = result.iterator(); if (iter.hasNext()) { diff --git a/src/main/java/com/syzb/video/query/common/UpdateVideoOptionQuery.java b/src/main/java/com/syzb/video/query/common/UpdateVideoOptionQuery.java index 9609187..bbb0519 100644 --- a/src/main/java/com/syzb/video/query/common/UpdateVideoOptionQuery.java +++ b/src/main/java/com/syzb/video/query/common/UpdateVideoOptionQuery.java @@ -43,6 +43,7 @@ public class UpdateVideoOptionQuery implements IVideoUserOperateQuery { record.setUserName(userName); record.setVideoId(videoId); record.setNum(num); + record.setSaleUserId(saleUserId); record.setCreateTime(LocalDateTime.now()); return record; } diff --git a/src/main/java/com/syzb/video/service/admin/AdminVideoStatisticService.java b/src/main/java/com/syzb/video/service/admin/AdminVideoStatisticService.java index cfe9b3e..1598a0d 100644 --- a/src/main/java/com/syzb/video/service/admin/AdminVideoStatisticService.java +++ b/src/main/java/com/syzb/video/service/admin/AdminVideoStatisticService.java @@ -598,7 +598,7 @@ public class AdminVideoStatisticService { .like(StrUtil.isNotEmpty(nickName), "u.user_name", nickName) .like(StrUtil.isNotEmpty(userId), "u.user_id", userId); -// Map> userCouponMap = Collections.emptyMap(); +// Map> userCouponMap = couponService.queryVideoCoupon(videoId); if (VideoCustomerType.COMPLETE_WATCH.value.equals(type)) { wrapper.exists("SELECT 1 FROM video_user_watch_collect w WHERE w.video_id = u.video_id AND w.user_id = u.user_id and w.finish_read_rate >= {0}", finishReadRatio); @@ -614,7 +614,6 @@ public class AdminVideoStatisticService { wrapper.exists("SELECT 1 FROM app_order o WHERE o.video_id = u.video_id AND o.user_name = u.user_id AND o.status IN (" + OrderQueryService.UNPAID_STATUS_STR + ")"); } // if (VideoCustomerType.COUPON_NOT_USED.value.equals(type) || IsOrNot.IS.value.equals(hasGotCoupon)) { -// userCouponMap = couponService.queryVideoCoupon(videoId); // if (userCouponMap.isEmpty()) { // return Pager.emptyPager(); // } diff --git a/src/main/java/com/syzb/video/service/common/VideoCacheService.java b/src/main/java/com/syzb/video/service/common/VideoCacheService.java index 880bf54..0ead899 100644 --- a/src/main/java/com/syzb/video/service/common/VideoCacheService.java +++ b/src/main/java/com/syzb/video/service/common/VideoCacheService.java @@ -194,7 +194,7 @@ public class VideoCacheService { } public Set getOnlineUserIds(Integer videoId) { - String sql = "SELECT distinct userId FROM " + VIDEO_ONLINE_USER + " WHERE videoId = " + videoId; + String sql = "SELECT distinct userId FROM " + VIDEO_ONLINE_USER + " WHERE productId = " + videoId; SqlResult result = hazelcastInstance.getSql().execute(sql); Set set = new HashSet<>(); for (SqlRow row : result) { @@ -230,7 +230,7 @@ public class VideoCacheService { } public int getOnlineCountWithoutCache(Integer videoId) { - String sql = "SELECT COUNT(*) FROM " + VIDEO_ONLINE_USER + " WHERE videoId = " + videoId + " and isOnline = 1"; + String sql = "SELECT COUNT(*) FROM " + VIDEO_ONLINE_USER + " WHERE productId = " + videoId + " and isOnline = 1"; SqlResult result = hazelcastInstance.getSql().execute(sql); Iterator iter = result.iterator(); if (iter.hasNext()) {