Commit d41b7412c4d6720357381e39bb72d4b3171435ff

Authored by fengliang
1 parent ee659743

update:购物车直接删除异常商品

etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/ShopCartImpl.java
1 1 package com.diligrp.etrade.order.service.impl;
2 2  
3 3 import com.diligrp.etrade.core.domain.Message;
4   -import com.diligrp.etrade.core.type.SaleUnitType;
5 4 import com.diligrp.etrade.core.util.AssertUtils;
6 5 import com.diligrp.etrade.core.util.JsonUtils;
7 6 import com.diligrp.etrade.core.util.MoneyUtil;
... ... @@ -14,7 +13,6 @@ import com.diligrp.etrade.order.model.ShopCart;
14 13 import com.diligrp.etrade.order.model.ShopCartMessage;
15 14 import com.diligrp.etrade.order.service.IShopCartMessageService;
16 15 import com.diligrp.etrade.order.service.IShopCartService;
17   -import com.diligrp.etrade.order.type.ProductTradeType;
18 16 import com.diligrp.etrade.order.type.ShopCartMessageCheckFlag;
19 17 import com.diligrp.etrade.order.type.ShopCartMessageProductState;
20 18 import com.diligrp.etrade.shop.domain.response.ProductDetailVo;
... ... @@ -111,6 +109,8 @@ public class ShopCartImpl implements IShopCartService {
111 109 //封装商品预设信息productPresetMap
112 110 productPresetMap.put(productListVo.getId(), map);
113 111 }
  112 + ShopCartDto deleteCartDto = new ShopCartDto();
  113 + List<Long> deleteIds = new ArrayList<>();
114 114  
115 115 //组装数据
116 116 shopCartVos.forEach(shopCartVo -> {
... ... @@ -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 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 /**
... ...