Browse Source

报错处理

yuhongqi 1 day ago
parent
commit
6f8d8ae5c5

+ 3 - 1
fs-admin/src/main/java/com/fs/live/controller/LiveAfterSalesController.java

@@ -79,7 +79,9 @@ public class LiveAfterSalesController extends BaseController
         List<LiveAfterSalesItem> list = liveAfterSalesItemService.selectLiveAfterSalesItemByAfterId(id);
         List<LiveAfterSalesLogs> logList = liveAfterSalesLogsService.selectLiveAfterSalesLogsByAfterId(id);
         FsUser user=userService.selectFsUserById(liveAfterSales.getUserId());
-        user.setPhone(ParseUtils.parsePhone(user.getPhone()));
+        if (user != null) {
+            user.setPhone(ParseUtils.parsePhone(user.getPhone()));
+        }
         LiveOrder liveOrder = orderService.selectLiveOrderByOrderId(String.valueOf(liveAfterSales.getOrderId()));
         return R.ok().put("afterSales",liveAfterSales).put("items",list).put("logs",logList).put("user",user).put("order",liveOrder);
 

+ 5 - 5
fs-service/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java

@@ -1004,16 +1004,16 @@ public class LiveServiceImpl implements ILiveService
             }
 
             // 如果视频时长大于0,将直播间信息存入Redis
-            if (videoDuration > 0 && live.getStartTime() != null) {
+            if (videoDuration > 0 && exist.getStartTime() != null) {
                 Map<String, Object> tagMarkInfo = new HashMap<>();
-                tagMarkInfo.put("liveId", live.getLiveId());
-                tagMarkInfo.put("startTime", live.getStartTime().atZone(java.time.ZoneId.systemDefault()).toInstant().toEpochMilli());
+                tagMarkInfo.put("liveId", exist.getLiveId());
+                tagMarkInfo.put("startTime", exist.getStartTime().atZone(java.time.ZoneId.systemDefault()).toInstant().toEpochMilli());
                 tagMarkInfo.put("videoDuration", videoDuration);
 
-                String tagMarkKey = String.format(LiveKeysConstant.LIVE_TAG_MARK_CACHE, live.getLiveId());
+                String tagMarkKey = String.format(LiveKeysConstant.LIVE_TAG_MARK_CACHE, exist.getLiveId());
                 redisCache.setCacheObject(tagMarkKey, JSON.toJSONString(tagMarkInfo), 24, TimeUnit.HOURS);
                 log.info("手动开直播间开启,已加入打标签缓存: liveId={}, startTime={}, videoDuration={}",
-                        live.getLiveId(), live.getStartTime(), videoDuration);
+                        exist.getLiveId(), exist.getStartTime(), videoDuration);
             }
         } catch (Exception e) {
             log.error("手动开写入直播间打标签缓存失败: liveId={}, error={}", live.getLiveId(), e.getMessage(), e);

+ 2 - 1
fs-service/src/main/java/com/fs/live/utils/redis/RedisBatchHandler.java

@@ -51,6 +51,7 @@ public class RedisBatchHandler {
         List<LiveTrafficLog> batchList = jsonList.stream()
                 .map(json -> JSON.parseObject(json, LiveTrafficLog.class))
                 .collect(Collectors.toList());
+        int size = batchList.size();
 
         Map<String, LiveTrafficLog> uniqueMap = batchList.stream()
                 .collect(Collectors.toMap(
@@ -72,7 +73,7 @@ public class RedisBatchHandler {
             // 批量写入数据库
             liveTrafficLogMapper.batchInsert(batchList);
             // 删除已消费的数据
-            redisTemplate.opsForList().trim(BATCH_QUEUE_KEY, batchList.size(), -1);
+            redisTemplate.opsForList().trim(BATCH_QUEUE_KEY, size, -1);
         } catch (Exception e) {
             // 消费失败:记录日志,不删除Redis数据(重试)
             log.error("Redis批量消费失败,将重试", e);