Commit 5b590907 authored by zhengyi's avatar zhengyi

允许选择了主营类别,但是该主营类别下面没有对应的商品,并保存时对数据进行去重

parent 4950d20a
......@@ -57,6 +57,7 @@ import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.mysql.order.OrderMapper;
import cn.iocoder.yudao.module.product.vo.product.ProductRespVO;
import cn.iocoder.yudao.module.product.vo.product.ProductTypeRespVO;
import cn.iocoder.yudao.module.sale.dal.dataobject.offer.OfferDO;
import cn.iocoder.yudao.module.sale.dal.mysql.offer.OfferMapper;
import cn.iocoder.yudao.module.system.api.file.FileMakeApi;
......@@ -169,9 +170,9 @@ public class CustomerController {
createReqVO.setIsPotential(true);
createReqVO.setCustomerOperateLogRemark("新增潜在客户");
if (CollectionUtil.isNotEmpty(createReqVO.getProducts())){
createReqVO.setProductTypes(createReqVO.getProducts().stream().map(CustomerProductTypeGroupVO::getTypeId).filter(Objects::nonNull).map(String::valueOf).collect(Collectors.joining(",")));
createReqVO.setProductTypes(createReqVO.getProducts().stream().map(CustomerProductTypeGroupVO::getTypeId).filter(Objects::nonNull).distinct().map(String::valueOf).collect(Collectors.joining(",")));
createReqVO.setProductIds(createReqVO.getProducts().stream().map(CustomerProductTypeGroupVO::getProductIds)
.flatMap(Collection::stream).filter(Objects::nonNull).map(String::valueOf).collect(Collectors.joining(",")));
.flatMap(Collection::stream).filter(Objects::nonNull).distinct().map(String::valueOf).collect(Collectors.joining(",")));
}
return createCustomerPrivate(createReqVO);
}
......@@ -185,9 +186,9 @@ public class CustomerController {
HttpServletRequest request) {
createReqVO.setCustomerOperateLogRemark("管理端页面新建客户");
if (CollectionUtil.isNotEmpty(createReqVO.getProducts())){
createReqVO.setProductTypes(createReqVO.getProducts().stream().map(CustomerProductTypeGroupVO::getTypeId).filter(Objects::nonNull).map(String::valueOf).map(String::valueOf).collect(Collectors.joining(",")));
createReqVO.setProductTypes(createReqVO.getProducts().stream().map(CustomerProductTypeGroupVO::getTypeId).filter(Objects::nonNull).distinct().map(String::valueOf).collect(Collectors.joining(",")));
createReqVO.setProductIds(createReqVO.getProducts().stream().map(CustomerProductTypeGroupVO::getProductIds)
.flatMap(Collection::stream).filter(Objects::nonNull).map(String::valueOf).map(String::valueOf).collect(Collectors.joining(",")));
.flatMap(Collection::stream).filter(Objects::nonNull).distinct().map(String::valueOf).collect(Collectors.joining(",")));
}
return createCustomerPrivate(createReqVO);
}
......@@ -261,9 +262,9 @@ public class CustomerController {
List<CustomerContactsUpdateReqVO> customerContacts =
updateReqVO.getCustomerContacts();
if (CollectionUtil.isNotEmpty(updateReqVO.getProducts())){
updateReqVO.setProductTypes(updateReqVO.getProducts().stream().map(CustomerProductTypeGroupVO::getTypeId).filter(Objects::nonNull).map(String::valueOf).collect(Collectors.joining(",")));
updateReqVO.setProductTypes(updateReqVO.getProducts().stream().map(CustomerProductTypeGroupVO::getTypeId).filter(Objects::nonNull).distinct().map(String::valueOf).collect(Collectors.joining(",")));
updateReqVO.setProductIds(updateReqVO.getProducts().stream().map(CustomerProductTypeGroupVO::getProductIds)
.flatMap(Collection::stream).filter(Objects::nonNull).map(String::valueOf).collect(Collectors.joining(",")));
.flatMap(Collection::stream).filter(Objects::nonNull).distinct().map(String::valueOf).collect(Collectors.joining(",")));
}
if (!CollectionUtils.isEmpty(customerContacts)) {
long count = customerContacts.stream().filter(t -> CustomerContactsDefaultEnum.IS_DEFAULT.getValue().equals(t.getIsDefault())).count();
......@@ -354,9 +355,9 @@ public class CustomerController {
//完善信息要确认接收
updateReqVO.setIsCustomerServiceConfirmed(true);
if (CollectionUtil.isNotEmpty(updateReqVO.getProducts())){
updateReqVO.setProductTypes(updateReqVO.getProducts().stream().map(CustomerProductTypeGroupVO::getTypeId).filter(Objects::nonNull).map(String::valueOf).collect(Collectors.joining(",")));
updateReqVO.setProductTypes(updateReqVO.getProducts().stream().map(CustomerProductTypeGroupVO::getTypeId).filter(Objects::nonNull).distinct().map(String::valueOf).collect(Collectors.joining(",")));
updateReqVO.setProductIds(updateReqVO.getProducts().stream().map(CustomerProductTypeGroupVO::getProductIds)
.flatMap(Collection::stream).filter(Objects::nonNull).map(String::valueOf).collect(Collectors.joining(",")));
.flatMap(Collection::stream).filter(Objects::nonNull).distinct().map(String::valueOf).collect(Collectors.joining(",")));
}
//完善客户信息确认接收时要计算客户的业绩类型
return this.updateCustomer(updateReqVO);
......@@ -446,6 +447,17 @@ public class CustomerController {
productTypeGroupVO.setProductIds(entry.getValue().stream().map(ProductRespVO::getId).collect(Collectors.toList()));
return productTypeGroupVO;
}).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(respVO.getProductTypeList())){
// 允许选择了主营类别,但是该主营类别下面没有对应的商品
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);
}
}
}
respVO.setProducts(products);
}
......@@ -498,6 +510,17 @@ public class CustomerController {
productTypeGroupVO.setProductIds(entry.getValue().stream().map(ProductRespVO::getId).collect(Collectors.toList()));
return productTypeGroupVO;
}).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(respVO.getProductTypeList())){
// 允许选择了主营类别,但是该主营类别下面没有对应的商品
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);
}
}
}
respVO.setProducts(products);
}
Long founder = respVO.getFounder();
......
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