Commit 454adc55 authored by zhengyi's avatar zhengyi

客户详情主营类别和主营商品回显返回值格式化封装bug修复

parent b5b46bf2
...@@ -438,29 +438,23 @@ public class CustomerController { ...@@ -438,29 +438,23 @@ public class CustomerController {
respVO.setPromoterName(customer1.getName()); respVO.setPromoterName(customer1.getName());
} }
} }
if (CollectionUtil.isNotEmpty(respVO.getProductList())) { // 主营类别是必须的
// 对商品数据进行分组返回 if (CollectionUtil.isNotEmpty(respVO.getProductTypeList())){
Map<Long, List<ProductRespVO>> productRespVOMap = respVO.getProductList().stream().collect(Collectors.groupingBy(ProductRespVO::getTypeId)); // 允许选择了主营类别,但是该主营类别下面没有对应的商品
List<CustomerProductTypeGroupVO> products = productRespVOMap.entrySet().stream().map(entry -> { List<CustomerProductTypeGroupVO> products = new ArrayList<>();
for (ProductTypeRespVO typeRespVO : respVO.getProductTypeList()) {
CustomerProductTypeGroupVO productTypeGroupVO = new CustomerProductTypeGroupVO(); CustomerProductTypeGroupVO productTypeGroupVO = new CustomerProductTypeGroupVO();
productTypeGroupVO.setTypeId(entry.getKey()); productTypeGroupVO.setTypeId(typeRespVO.getId());
productTypeGroupVO.setProductIds(entry.getValue().stream().map(ProductRespVO::getId).collect(Collectors.toList())); if (CollectionUtil.isNotEmpty(respVO.getProductList())) {
return productTypeGroupVO; List<Long> prodIds = respVO.getProductList().stream().filter(p -> p.getTypeId() == typeRespVO.getId()).map(ProductRespVO::getId).collect(Collectors.toList());
}).collect(Collectors.toList()); productTypeGroupVO.setProductIds(CollectionUtil.isEmpty(prodIds) ? new ArrayList<>() : prodIds);
if (CollectionUtil.isNotEmpty(respVO.getProductTypeList())){ } else {
// 允许选择了主营类别,但是该主营类别下面没有对应的商品 productTypeGroupVO.setProductIds(new ArrayList<>());
for (ProductTypeRespVO typeRespVO : respVO.getProductTypeList()) {
if (!productRespVOMap.containsKey(typeRespVO.getId())) {
CustomerProductTypeGroupVO productTypeGroupVO = new CustomerProductTypeGroupVO();
productTypeGroupVO.setTypeId(typeRespVO.getId());
productTypeGroupVO.setProductIds(new ArrayList<>());
products.add(productTypeGroupVO);
}
} }
products.add(productTypeGroupVO);
} }
respVO.setProducts(products); respVO.setProducts(products);
} }
//设置银行账号 //设置银行账号
CustomerBankQueryVO customerBankQueryVO = new CustomerBankQueryVO(); CustomerBankQueryVO customerBankQueryVO = new CustomerBankQueryVO();
customerBankQueryVO.setCustomerId(id); customerBankQueryVO.setCustomerId(id);
...@@ -501,25 +495,20 @@ public class CustomerController { ...@@ -501,25 +495,20 @@ public class CustomerController {
if (Objects.isNull(respVO)) { if (Objects.isNull(respVO)) {
throw exception(CUSTOMER_NOT_EXISTS); throw exception(CUSTOMER_NOT_EXISTS);
} }
if (CollectionUtil.isNotEmpty(respVO.getProductList())) { // 主营类别是必须的
// 对商品数据进行分组返回 if (CollectionUtil.isNotEmpty(respVO.getProductTypeList())){
Map<Long, List<ProductRespVO>> productRespVOMap = respVO.getProductList().stream().collect(Collectors.groupingBy(ProductRespVO::getTypeId)); // 允许选择了主营类别,但是该主营类别下面没有对应的商品
List<CustomerProductTypeGroupVO> products = productRespVOMap.entrySet().stream().map(entry -> { List<CustomerProductTypeGroupVO> products = new ArrayList<>();
for (ProductTypeRespVO typeRespVO : respVO.getProductTypeList()) {
CustomerProductTypeGroupVO productTypeGroupVO = new CustomerProductTypeGroupVO(); CustomerProductTypeGroupVO productTypeGroupVO = new CustomerProductTypeGroupVO();
productTypeGroupVO.setTypeId(entry.getKey()); productTypeGroupVO.setTypeId(typeRespVO.getId());
productTypeGroupVO.setProductIds(entry.getValue().stream().map(ProductRespVO::getId).collect(Collectors.toList())); if (CollectionUtil.isNotEmpty(respVO.getProductList())) {
return productTypeGroupVO; List<Long> prodIds = respVO.getProductList().stream().filter(p -> p.getTypeId() == typeRespVO.getId()).map(ProductRespVO::getId).collect(Collectors.toList());
}).collect(Collectors.toList()); productTypeGroupVO.setProductIds(CollectionUtil.isEmpty(prodIds) ? new ArrayList<>() : prodIds);
if (CollectionUtil.isNotEmpty(respVO.getProductTypeList())){ } else {
// 允许选择了主营类别,但是该主营类别下面没有对应的商品 productTypeGroupVO.setProductIds(new ArrayList<>());
for (ProductTypeRespVO typeRespVO : respVO.getProductTypeList()) {
if (!productRespVOMap.containsKey(typeRespVO.getId())) {
CustomerProductTypeGroupVO productTypeGroupVO = new CustomerProductTypeGroupVO();
productTypeGroupVO.setTypeId(typeRespVO.getId());
productTypeGroupVO.setProductIds(new ArrayList<>());
products.add(productTypeGroupVO);
}
} }
products.add(productTypeGroupVO);
} }
respVO.setProducts(products); respVO.setProducts(products);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment