Browse Source

更新当前任务数据缓存

yuhongqi 4 tuần trước cách đây
mục cha
commit
97ce76e76f

+ 2 - 0
fs-live-socket/src/main/java/com/fs/live/task/Task.java

@@ -242,6 +242,7 @@ public class Task {
                 sendMsgVo.setLiveId(Long.valueOf(liveKey));
                 sendMsgVo.setCmd("red");
                 sendMsgVo.setStatus(-1);
+                liveService.asyncToCacheLiveConfig(Long.parseLong(liveKey));
                 webSocketServer.broadcastMessage(Long.valueOf(liveKey), JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
             } catch (Exception e) {
                 log.error("更新红包状态异常", e);
@@ -325,6 +326,7 @@ public class Task {
             sendMsgVo.setData(JSON.toJSONString(lotteryVos));
             webSocketServer.broadcastMessage(liveLottery.getLiveId(), JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
 
+            liveService.asyncToCacheLiveConfig(liveLottery.getLiveId());
             // 删除缓存 同步抽奖记录
             redisUtil.delete(hashKey);
         }

+ 6 - 0
fs-live-socket/src/main/java/com/fs/live/websocket/service/WebSocketServer.java

@@ -315,6 +315,7 @@ public class WebSocketServer {
         msg.setStatus(status);
         LiveGoodsVo liveGoods = liveGoodsService.selectLiveGoodsVoByGoodsId(goodsId);
         if(liveGoods == null) return;
+        liveService.asyncToCacheLiveConfig(liveId);
         msg.setLiveId(liveId);
         msg.setData(JSONObject.toJSONString(liveGoods));
         broadcastMessage(liveId, JSONObject.toJSONString(R.ok().put("data", msg)));
@@ -330,6 +331,7 @@ public class WebSocketServer {
         msg.setStatus( status);
         LiveRedConf liveRedConf = liveRedConfService.selectLiveRedConfByRedId(jsonObject.getLong("redId"));
         if (Objects.nonNull(liveRedConf)) {
+            liveService.asyncToCacheLiveConfig(liveId);
             msg.setData(JSONObject.toJSONString(liveRedConf));
             broadcastMessage(liveId, JSONObject.toJSONString(R.ok().put("data", msg)));
         }
@@ -345,6 +347,7 @@ public class WebSocketServer {
         msg.setStatus( status);
         LiveLotteryConf liveLotteryConf = liveLotteryConfService.selectLiveLotteryConfByLotteryId(jsonObject.getLong("lotteryId"));
         if (Objects.nonNull(liveLotteryConf)) {
+            liveService.asyncToCacheLiveConfig(liveId);
             msg.setData(JSONObject.toJSONString(liveLotteryConf));
             broadcastMessage(liveId, JSONObject.toJSONString(R.ok().put("data", msg)));
         }
@@ -477,6 +480,7 @@ public class WebSocketServer {
                 msg.setCmd("goods");
                 LiveGoodsVo liveGoodsVo = JSON.parseObject(task.getContent(), LiveGoodsVo.class);
                 liveGoodsService.updateLiveIsShow(liveGoodsVo.getGoodsId(), task.getLiveId());
+                liveService.asyncToCacheLiveConfig(task.getLiveId());
             }else if (task.getTaskType() == 2L) {
                 msg.setCmd("red");
                 LiveRedConf liveRedConf = JSON.parseObject(task.getContent(), LiveRedConf.class);
@@ -488,6 +492,7 @@ public class WebSocketServer {
                 liveRedConf.setUpdateTime( now);
                 msg.setData(JSON.toJSONString(liveRedConf));
                 liveRedConfService.updateLiveRedConf(liveRedConf);
+                liveService.asyncToCacheLiveConfig(task.getLiveId());
             }else if (task.getTaskType() == 4L) {
                 msg.setCmd("lottery");
                 LiveLotteryConf liveLotteryConf = JSON.parseObject(task.getContent(), LiveLotteryConf.class);
@@ -499,6 +504,7 @@ public class WebSocketServer {
                 liveLotteryConf.setUpdateTime( now);
                 msg.setData(JSON.toJSONString(liveLotteryConf));
                 liveLotteryConfService.updateLiveLotteryConf(liveLotteryConf);
+                liveService.asyncToCacheLiveConfig(task.getLiveId());
             }else if (task.getTaskType() == 3L) {
                 msg.setCmd("sendMsg");
                 msg.setMsg(task.getContent());