From 5f6bae6fa9019b5a1a550e1386b95407dc6f6b4b Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 7 Jun 2022 15:18:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=87=BA=E7=8E=B0=E7=9A=84=E8=8E=B7=E5=8F=96=E4=BF=83?= =?UTF-8?q?=E9=94=80=E4=BF=A1=E6=81=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/promotion/tools/PromotionTools.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java b/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java index 851faef4..8266a6b0 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java +++ b/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java @@ -167,17 +167,14 @@ public class PromotionTools { } try { //移除无效促销活动 - return map.entrySet().stream().filter(i -> { - if (i != null) { - JSONObject promotionsObj = JSONUtil.parseObj(i.getValue()); - BasePromotions basePromotions = promotionsObj.toBean(BasePromotions.class); - if (basePromotions.getStartTime() != null && basePromotions.getEndTime() != null) { - return basePromotions.getStartTime().getTime() <= System.currentTimeMillis() && basePromotions.getEndTime().getTime() >= System.currentTimeMillis(); - } + return map.entrySet().stream().filter(Objects::nonNull).filter(i -> { + JSONObject promotionsObj = JSONUtil.parseObj(i.getValue()); + BasePromotions basePromotions = promotionsObj.toBean(BasePromotions.class); + if (basePromotions != null && basePromotions.getStartTime() != null && basePromotions.getEndTime() != null) { + return basePromotions.getStartTime().getTime() <= System.currentTimeMillis() && basePromotions.getEndTime().getTime() >= System.currentTimeMillis(); } - - return true; - }).collect(Collectors.toMap(stringObjectEntry -> stringObjectEntry != null ? stringObjectEntry.getKey() : null, stringObjectEntry1 -> stringObjectEntry1 != null ? stringObjectEntry1.getValue() : new BasePromotions(), (oldValue, newValue) -> newValue)); + return i.getValue() != null; + }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> newValue)); } catch (Exception e) { log.error("过滤无效促销活动出现异常。异常促销信息:{},异常信息:{} ", map, e); return new HashMap<>();