Commit d41b7412c4d6720357381e39bb72d4b3171435ff
1 parent
ee659743
update:购物车直接删除异常商品
Showing
1 changed file
with
12 additions
and
4 deletions
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/ShopCartImpl.java
1 | package com.diligrp.etrade.order.service.impl; | 1 | package com.diligrp.etrade.order.service.impl; |
2 | 2 | ||
3 | import com.diligrp.etrade.core.domain.Message; | 3 | import com.diligrp.etrade.core.domain.Message; |
4 | -import com.diligrp.etrade.core.type.SaleUnitType; | ||
5 | import com.diligrp.etrade.core.util.AssertUtils; | 4 | import com.diligrp.etrade.core.util.AssertUtils; |
6 | import com.diligrp.etrade.core.util.JsonUtils; | 5 | import com.diligrp.etrade.core.util.JsonUtils; |
7 | import com.diligrp.etrade.core.util.MoneyUtil; | 6 | import com.diligrp.etrade.core.util.MoneyUtil; |
@@ -14,7 +13,6 @@ import com.diligrp.etrade.order.model.ShopCart; | @@ -14,7 +13,6 @@ import com.diligrp.etrade.order.model.ShopCart; | ||
14 | import com.diligrp.etrade.order.model.ShopCartMessage; | 13 | import com.diligrp.etrade.order.model.ShopCartMessage; |
15 | import com.diligrp.etrade.order.service.IShopCartMessageService; | 14 | import com.diligrp.etrade.order.service.IShopCartMessageService; |
16 | import com.diligrp.etrade.order.service.IShopCartService; | 15 | import com.diligrp.etrade.order.service.IShopCartService; |
17 | -import com.diligrp.etrade.order.type.ProductTradeType; | ||
18 | import com.diligrp.etrade.order.type.ShopCartMessageCheckFlag; | 16 | import com.diligrp.etrade.order.type.ShopCartMessageCheckFlag; |
19 | import com.diligrp.etrade.order.type.ShopCartMessageProductState; | 17 | import com.diligrp.etrade.order.type.ShopCartMessageProductState; |
20 | import com.diligrp.etrade.shop.domain.response.ProductDetailVo; | 18 | import com.diligrp.etrade.shop.domain.response.ProductDetailVo; |
@@ -111,6 +109,8 @@ public class ShopCartImpl implements IShopCartService { | @@ -111,6 +109,8 @@ public class ShopCartImpl implements IShopCartService { | ||
111 | //封装商品预设信息productPresetMap | 109 | //封装商品预设信息productPresetMap |
112 | productPresetMap.put(productListVo.getId(), map); | 110 | productPresetMap.put(productListVo.getId(), map); |
113 | } | 111 | } |
112 | + ShopCartDto deleteCartDto = new ShopCartDto(); | ||
113 | + List<Long> deleteIds = new ArrayList<>(); | ||
114 | 114 | ||
115 | //组装数据 | 115 | //组装数据 |
116 | shopCartVos.forEach(shopCartVo -> { | 116 | shopCartVos.forEach(shopCartVo -> { |
@@ -151,11 +151,19 @@ public class ShopCartImpl implements IShopCartService { | @@ -151,11 +151,19 @@ public class ShopCartImpl implements IShopCartService { | ||
151 | } | 151 | } |
152 | }); | 152 | }); |
153 | //对购物车商品信息集合按修改时间倒序排序 | 153 | //对购物车商品信息集合按修改时间倒序排序 |
154 | - List<ShopCartMessageVo> shopCartMessageVos = shopCartMessageVoList.stream().sorted(Comparator.comparing(ShopCartMessageVo::getCreatedTime, Comparator.reverseOrder())).collect(Collectors.toList()); | 154 | + List<ShopCartMessageVo> shopCartMessageVos = shopCartMessageVoList.stream().filter(en->en.getProductState().equals(ShopCartMessageProductState.NORMAL.getCodeInteger())).sorted(Comparator.comparing(ShopCartMessageVo::getCreatedTime, Comparator.reverseOrder())).collect(Collectors.toList()); |
155 | shopCartVo.setShopCartMessageVoList(shopCartMessageVos); | 155 | shopCartVo.setShopCartMessageVoList(shopCartMessageVos); |
156 | + List<Long> collect = shopCartMessageVoList.stream().filter(en -> !en.getProductState().equals(ShopCartMessageProductState.NORMAL.getCodeInteger())).map(ShopCartMessageVo::getId).collect(Collectors.toList()); | ||
157 | + if(collect!=null&&collect.size()>0){ | ||
158 | + deleteIds.addAll(collect); | ||
159 | + } | ||
156 | }); | 160 | }); |
161 | + deleteCartDto.setIds(deleteIds); | ||
162 | + if(deleteIds.size()>0){ | ||
163 | + deleteShopCartMessageList(deleteCartDto); | ||
164 | + } | ||
157 | //对购物车集合按修改时间倒序排序 | 165 | //对购物车集合按修改时间倒序排序 |
158 | - return shopCartVos.stream().sorted(Comparator.comparing(ShopCartVo::getModifiedTime, Comparator.reverseOrder())).collect(Collectors.toList()); | 166 | + return shopCartVos.stream().filter(en->en.getShopCartMessageVoList().size()>0).sorted(Comparator.comparing(ShopCartVo::getModifiedTime, Comparator.reverseOrder())).collect(Collectors.toList()); |
159 | } | 167 | } |
160 | 168 | ||
161 | /** | 169 | /** |