| | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | redisCache.deleteObject("shopCart:"+userId); |
| | | } |
| | | @ApiOperation(value = "海诊商城-购买后删除购物车商品") |
| | | @GetMapping(value = "/clearByIds") |
| | | public void clearByIds(String ids) { |
| | | List<String> list = Arrays.asList(ids.split(",")); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | List<ShoppingCartItem> cacheList = redisCache.getCacheList("shopCart:"+userId); |
| | | List<ShoppingCartItem> res = new ArrayList<>(); |
| | | redisCache.deleteObject("shopCart:"+userId); |
| | | for (ShoppingCartItem shoppingCartItem : cacheList) { |
| | | if (!list.contains(shoppingCartItem.getId())){ |
| | | res.add(shoppingCartItem); |
| | | } |
| | | } |
| | | if (!res.isEmpty()){ |
| | | redisCache.setCacheList("shopCart:"+userId, res); |
| | | } |
| | | } |
| | | @ApiOperation(value = "海诊商城-单删购物车") |
| | | @GetMapping(value = "/clearById") |
| | | public void clear(String id) { |
| | |
| | | if (!res.isEmpty()){ |
| | | redisCache.setCacheList("shopCart:"+userId, res); |
| | | } |
| | | |
| | | } |
| | | /** |
| | | * 海诊商城-加入购物车 |