| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -61,7 +61,9 @@ import org.springframework.transaction.annotation.Transactional; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.math.BigDecimal; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.concurrent.ConcurrentHashMap; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.function.Function; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.function.Predicate; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.stream.Collectors; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.stream.Stream; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -868,6 +870,9 @@ public class CereShopProductServiceImpl implements CereShopProductService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            list=cereShopProductDAO.getProducts(param); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //可能会存在重复商品元素。去重处理 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        list = list.stream().filter(distinctByKey(CanvasProduct::getProductId)).collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<Long> productIdList = new ArrayList<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        productIdList.addAll(list.stream().map(CanvasProduct::getProductId).collect(Collectors.toList())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        productIdList = productIdList.stream().filter(item -> item != null && item > 0).distinct().collect(Collectors.toList()); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -1355,4 +1360,9 @@ public class CereShopProductServiceImpl implements CereShopProductService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            stringRedisService.set(skuTotalStockKey, sku.getTotal()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<Object, Boolean> seen = new ConcurrentHashMap<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} |