Showing
1 changed file
with
3 additions
and
0 deletions
@@ -44,7 +44,9 @@ public class BuyerPenaltyRuleSelector { | @@ -44,7 +44,9 @@ public class BuyerPenaltyRuleSelector { | ||
44 | throw new UfoServiceException(501, "buyer penalty order status is null"); | 44 | throw new UfoServiceException(501, "buyer penalty order status is null"); |
45 | } | 45 | } |
46 | Collection<BuyerPenalty.Fee> fees = getFeesByOrderAttributesAndStatus(); | 46 | Collection<BuyerPenalty.Fee> fees = getFeesByOrderAttributesAndStatus(); |
47 | + // 没有时间限制的规则 | ||
47 | Supplier<BuyerPenalty.Fee> nonTimeRangeFeeSupplier = () -> fees.stream().filter(fee -> Objects.isNull(fee.getTimeRange())).findFirst().orElse(null); | 48 | Supplier<BuyerPenalty.Fee> nonTimeRangeFeeSupplier = () -> fees.stream().filter(fee -> Objects.isNull(fee.getTimeRange())).findFirst().orElse(null); |
49 | + // 是否时间限制范围内的规则 | ||
48 | Predicate<BuyerPenalty.Fee> timeRangeFeePredicate = fee -> { | 50 | Predicate<BuyerPenalty.Fee> timeRangeFeePredicate = fee -> { |
49 | BuyerPenalty.Range timeRange = fee.getTimeRange(); | 51 | BuyerPenalty.Range timeRange = fee.getTimeRange(); |
50 | BigDecimal min = timeRange.getMin(); | 52 | BigDecimal min = timeRange.getMin(); |
@@ -54,6 +56,7 @@ public class BuyerPenaltyRuleSelector { | @@ -54,6 +56,7 @@ public class BuyerPenaltyRuleSelector { | ||
54 | boolean ltMax = Objects.isNull(max) || diffTime <= max.intValue(); | 56 | boolean ltMax = Objects.isNull(max) || diffTime <= max.intValue(); |
55 | return gtMin && ltMax; | 57 | return gtMin && ltMax; |
56 | }; | 58 | }; |
59 | + // 选取合适的匹配规则 | ||
57 | BuyerPenalty.Fee fixFee = fees.stream() | 60 | BuyerPenalty.Fee fixFee = fees.stream() |
58 | .filter(e -> Objects.nonNull(e.getTimeRange())) | 61 | .filter(e -> Objects.nonNull(e.getTimeRange())) |
59 | // sort by index | 62 | // sort by index |
-
Please register or login to post a comment