|
|
@ -35,6 +35,9 @@ import org.springframework.stereotype.Service; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.function.Predicate; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@Service |
|
|
@ -62,11 +65,12 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Classify> getFirstClassify(ClassifyParam param) throws CoBusinessException { |
|
|
|
String project = ContextUtil.getProject(); |
|
|
|
List<Classify> classifies=null; |
|
|
|
List<Long> classifyIdList = new ArrayList<>(); |
|
|
|
if(EmptyUtils.isEmpty(param.getClassifyId())){ |
|
|
|
//查询所有一级类目 |
|
|
|
classifies = cereProductClassifyDAO.getFirstClassify(ContextUtil.getProject(), null); |
|
|
|
classifies = cereProductClassifyDAO.getFirstClassify(project, null); |
|
|
|
}else { |
|
|
|
//查询所有二级类目 |
|
|
|
classifies = cereProductClassifyDAO.getFirstClassify(ContextUtil.getProject(), param.getClassifyId()); |
|
|
@ -138,6 +142,8 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic |
|
|
|
param.setProject(ContextUtil.getProject()); |
|
|
|
List<Product> list=cereProductClassifyDAO.getClaasifyProducts(param); |
|
|
|
if(!EmptyUtils.isEmpty(list)){ |
|
|
|
//可能会存在重复商品元素。去重处理 |
|
|
|
list = list.stream().filter(distinctByKey(Product::getProductId)).collect(Collectors.toList()); |
|
|
|
list.forEach(a -> { |
|
|
|
//查询付款人数 |
|
|
|
a.setUsers(cerePlatformShopservice.findPayUsers(a.getProductId())); |
|
|
@ -157,6 +163,11 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic |
|
|
|
return page; |
|
|
|
} |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Page getClassifyProducts2(ClassifyProductParam param, CereBuyerUser user) { |
|
|
|
PageHelper.startPage(param.getPage(),param.getPageSize()); |
|
|
|