Showing
1 changed file
with
13 additions
and
7 deletions
@@ -117,7 +117,7 @@ public class PromotionPriceService { | @@ -117,7 +117,7 @@ public class PromotionPriceService { | ||
117 | } | 117 | } |
118 | if ("Discount".equals(promotionTag.get("type"))) { | 118 | if ("Discount".equals(promotionTag.get("type"))) { |
119 | Double discount = Double.valueOf(actionParamJson.get("discount").toString()); | 119 | Double discount = Double.valueOf(actionParamJson.get("discount").toString()); |
120 | - if (discount == null||currentSalesPrice==null) { | 120 | + if (discount == null || currentSalesPrice == null) { |
121 | continue; | 121 | continue; |
122 | } | 122 | } |
123 | currentSalesPrice = currentSalesPrice * discount; | 123 | currentSalesPrice = currentSalesPrice * discount; |
@@ -125,14 +125,14 @@ public class PromotionPriceService { | @@ -125,14 +125,14 @@ public class PromotionPriceService { | ||
125 | } | 125 | } |
126 | if ("Cashreduce".equals(promotionTag.get("type"))) { | 126 | if ("Cashreduce".equals(promotionTag.get("type"))) { |
127 | Double reduce = Double.valueOf(actionParamJson.get("reduce").toString()); | 127 | Double reduce = Double.valueOf(actionParamJson.get("reduce").toString()); |
128 | - if (reduce == null||currentSalesPrice==null) { | 128 | + if (reduce == null || currentSalesPrice == null) { |
129 | continue; | 129 | continue; |
130 | } | 130 | } |
131 | currentSalesPrice = currentSalesPrice - reduce; | 131 | currentSalesPrice = currentSalesPrice - reduce; |
132 | isPromotionPriceActive = true; | 132 | isPromotionPriceActive = true; |
133 | } | 133 | } |
134 | if ("Degressdiscount".equals(promotionTag.get("type"))) { | 134 | if ("Degressdiscount".equals(promotionTag.get("type"))) { |
135 | - if (actionParamJson.get("degress_discount_list") == null||currentSalesPrice==null) { | 135 | + if (actionParamJson.get("degress_discount_list") == null || currentSalesPrice == null) { |
136 | continue; | 136 | continue; |
137 | } | 137 | } |
138 | String degressDiscountList = actionParamJson.get("degress_discount_list").toString(); | 138 | String degressDiscountList = actionParamJson.get("degress_discount_list").toString(); |
@@ -192,13 +192,19 @@ public class PromotionPriceService { | @@ -192,13 +192,19 @@ public class PromotionPriceService { | ||
192 | private Double getProductPricePlanSalesPrice(Map<String, Object> productMap) { | 192 | private Double getProductPricePlanSalesPrice(Map<String, Object> productMap) { |
193 | Double salesPrice = Double.valueOf(productMap.get("sales_price").toString()); | 193 | Double salesPrice = Double.valueOf(productMap.get("sales_price").toString()); |
194 | List<Map<String, String>> pricePlanList = (List<Map<String, String>>) productMap.get("product_price_plan_list"); | 194 | List<Map<String, String>> pricePlanList = (List<Map<String, String>>) productMap.get("product_price_plan_list"); |
195 | - if (CollectionUtils.isNotEmpty(pricePlanList)) { | 195 | + List<Map<String, String>> pricePlanListSorted; |
196 | + pricePlanListSorted = pricePlanList.stream().sorted(Comparator.comparingInt(map -> MapUtils.getInteger((Map) map, "effect_time")).reversed()).collect(Collectors.toList()); | ||
197 | + if (CollectionUtils.isNotEmpty(pricePlanListSorted)) { | ||
196 | long currentTime = DateUtil.getCurrentTimeSecond(); | 198 | long currentTime = DateUtil.getCurrentTimeSecond(); |
197 | - for (Map<String, String> pricePlanMap : pricePlanList) { | 199 | + for (Map<String, String> pricePlanMap : pricePlanListSorted) { |
198 | Integer effectTime = MapUtils.getInteger(pricePlanMap, "effect_time"); | 200 | Integer effectTime = MapUtils.getInteger(pricePlanMap, "effect_time"); |
199 | Integer endTime = MapUtils.getInteger(pricePlanMap, "end_time"); | 201 | Integer endTime = MapUtils.getInteger(pricePlanMap, "end_time"); |
200 | - if (effectTime <= currentTime && endTime >= currentTime) { | ||
201 | - salesPrice = MapUtils.getDouble(pricePlanMap, "current_saleprice") == null ? salesPrice : MapUtils.getDouble(pricePlanMap, "current_saleprice"); | 202 | + if (effectTime <= currentTime && (endTime >= currentTime || endTime == 0)) { |
203 | + if (MapUtils.getDouble(pricePlanMap, "current_saleprice") == null) { | ||
204 | + continue; | ||
205 | + } | ||
206 | + salesPrice = MapUtils.getDouble(pricePlanMap, "current_saleprice"); | ||
207 | + return salesPrice; | ||
202 | } | 208 | } |
203 | } | 209 | } |
204 | } | 210 | } |
-
Please register or login to post a comment