Ver código fonte

直播积分优化

xw 4 dias atrás
pai
commit
2321f415c6

+ 1 - 0
fs-admin/src/main/java/com/fs/his/controller/FsIntegralGoodsController.java

@@ -117,6 +117,7 @@ public class FsIntegralGoodsController extends BaseController
     {
 
         redisCacheUtil.delRedisKey("getIntegralGoodsList");
+        redisCacheUtil.delSpringCacheKey("getIntegralGoodsById", fsIntegralGoods.getGoodsId());
         redisCacheUtil.delRedisKey("getIntegralGoodsById");
         return toAjax(fsIntegralGoodsService.updateFsIntegralGoods(fsIntegralGoods));
     }

+ 1 - 0
fs-company/src/main/java/com/fs/hisStore/controller/FsIntegralGoodsController.java

@@ -110,6 +110,7 @@ public class FsIntegralGoodsController extends BaseController
     {
 
         redisCacheUtil.delRedisKey("getIntegralGoodsList");
+        redisCacheUtil.delSpringCacheKey("getIntegralGoodsById", fsIntegralGoods.getGoodsId());
         redisCacheUtil.delRedisKey("getIntegralGoodsById");
         return toAjax(fsIntegralGoodsService.updateFsIntegralGoods(fsIntegralGoods));
     }

+ 0 - 27
fs-live-app/src/main/java/com/fs/live/task/LiveCompletionPointsTask.java

@@ -137,31 +137,4 @@ public class LiveCompletionPointsTask {
             log.error("发送完课通知失败, liveId={}, userId={}", liveId, userId, e);
         }
     }
-
-    /**
-     * 发送完课通知(通过WebSocket推送弹窗) - 旧版本(保留)
-     */
-    private void sendCompletionNotification(Long liveId, Long userId) {
-        try {
-            // 查询未领取的完课记录
-            List<LiveCompletionPointsRecord> unreceivedRecords = completionPointsRecordService.getUserUnreceivedRecords(liveId, userId);
-            
-            if (unreceivedRecords != null && !unreceivedRecords.isEmpty()) {
-                // 构造弹窗消息
-                SendMsgVo sendMsgVo = new SendMsgVo();
-                sendMsgVo.setLiveId(liveId);
-                sendMsgVo.setUserId(userId);
-                sendMsgVo.setCmd("completionPoints");
-                sendMsgVo.setMsg("完成任务!");
-                sendMsgVo.setData(JSONObject.toJSONString(unreceivedRecords.get(0)));
-
-                // 通过WebSocket发送给特定用户(调用已有的发送方法)
-                webSocketServer.sendCompletionPointsMessage(liveId, userId, sendMsgVo);
-                
-                log.info("发送完课积分弹窗通知成功, liveId={}, userId={}", liveId, userId);
-            }
-        } catch (Exception e) {
-            log.error("发送完课通知失败, liveId={}, userId={}", liveId, userId, e);
-        }
-    }
 }

+ 5 - 1
fs-live-app/src/main/java/com/fs/live/websocket/service/WebSocketServer.java

@@ -321,11 +321,15 @@ public class WebSocketServer {
 
                     // 心跳时同步更新观看时长到Redis Hash
                     long watchUserId = (long) userProperties.get("userId");
+
+                    log.info("[心跳-观看时长] 接收心跳, liveId={}, userId={}, data={}",
+                            liveId, watchUserId, msg.getData());
                     
                     if (msg.getData() != null && !msg.getData().isEmpty()) {
                         try {
                             Long currentDuration = Long.parseLong(msg.getData());
-                            
+                            log.info("[心跳-观看时长] 解析成功, duration={}", currentDuration);
+
                             // 使用Hash结构存储:一个直播间一个Hash,包含所有用户的时长
                             String hashKey = "live:watch:duration:hash:" + liveId;
                             String userIdField = String.valueOf(watchUserId);

+ 1 - 1
fs-service/src/main/java/com/fs/his/param/FsIntegralCartParam.java

@@ -16,7 +16,7 @@ public class FsIntegralCartParam {
 
     @NotNull(message = "添加数量不能为空")
     @Min(value = 1, message = "数量不再合法范围内")
-    @Max(value = 999, message = "数量不再合法范围内")
+    @Max(value = 9999, message = "数量不再合法范围内")
     @ApiModelProperty("数量")
     private Integer cartNum;
 

+ 10 - 0
fs-service/src/main/java/com/fs/his/utils/RedisCacheUtil.java

@@ -20,4 +20,14 @@ public class RedisCacheUtil {
             redisCache.deleteObject(key);
         }
     }
+
+    /**
+     * 删除 Spring Cache 格式的缓存(带双冒号)
+     * @param cacheName 缓存名称(如 getIntegralGoodsById)
+     * @param cacheKey 缓存key(如 商品ID)
+     */
+    public void delSpringCacheKey(String cacheName, Object cacheKey) {
+        String key = cacheName + "::" + cacheKey;
+        redisCache.deleteObject(key);
+    }
 }

+ 3 - 0
fs-service/src/main/java/com/fs/his/vo/FsIntegralCartVO.java

@@ -34,6 +34,9 @@ public class FsIntegralCartVO {
     @ApiModelProperty("最新所需金额")
     private BigDecimal newCash;
 
+    @ApiModelProperty("库存")
+    private Long stock;
+
     @ApiModelProperty("数量")
     private Integer cartNum;
 

+ 1 - 0
fs-service/src/main/resources/mapper/his/FsIntegralCartMapper.xml

@@ -61,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             ic.cash,
             ig.integral newIntegral,
             ig.cash newCash,
+            ig.stock,
             ic.cart_num,
             ic.create_time,
             ic.update_time