|
@@ -62,7 +62,14 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
records.setData(new ArrayList<>());
|
|
records.setData(new ArrayList<>());
|
|
records.setTotal(0L);
|
|
records.setTotal(0L);
|
|
String name = productDTO.getName();
|
|
String name = productDTO.getName();
|
|
- PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
|
|
|
|
+ PersonnelVO personnelVO = null;
|
|
|
|
+ try {
|
|
|
|
+ if (LoginUtils.getToken() != null) {
|
|
|
|
+ personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+
|
|
|
|
+ }
|
|
//查询登录人关联的产品类别id
|
|
//查询登录人关联的产品类别id
|
|
List<Integer> ids = assoPersonCategoryService.getChoosedProductCategoryIds();
|
|
List<Integer> ids = assoPersonCategoryService.getChoosedProductCategoryIds();
|
|
|
|
|
|
@@ -72,7 +79,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
getProductDTO.setCurrent(current);
|
|
getProductDTO.setCurrent(current);
|
|
getProductDTO.setSize(size);
|
|
getProductDTO.setSize(size);
|
|
getProductDTO.setCategoryIds(ids);
|
|
getProductDTO.setCategoryIds(ids);
|
|
- if (!personnelVO.getPersonType().equals(0)) {
|
|
|
|
|
|
+ if (personnelVO!=null&&!personnelVO.getPersonType().equals(0)) {
|
|
getProductDTO.setIfShow(true);
|
|
getProductDTO.setIfShow(true);
|
|
}
|
|
}
|
|
if (ids != null) {
|
|
if (ids != null) {
|
|
@@ -86,7 +93,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private void loadProduct(List<ProductVO> productVOS, Boolean ifCotentCategoryPath) {
|
|
|
|
|
|
+ public void loadProduct(List<ProductVO> productVOS, Boolean ifCotentCategoryPath) {
|
|
PersonnelVO personnelVO = null;
|
|
PersonnelVO personnelVO = null;
|
|
try {
|
|
try {
|
|
personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
@@ -190,7 +197,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
public Integer addOrUpdateProduct(ProductAddDTO productAddDTO) {
|
|
public Integer addOrUpdateProduct(ProductAddDTO productAddDTO) {
|
|
Product product = new Product();
|
|
Product product = new Product();
|
|
if (productAddDTO.getId() == null) {
|
|
if (productAddDTO.getId() == null) {
|
|
- product = this.addProduct(productAddDTO,null);
|
|
|
|
|
|
+ product = this.addProduct(productAddDTO, null);
|
|
AssoPersonProductDTO assoPersonProductDTO = new AssoPersonProductDTO();
|
|
AssoPersonProductDTO assoPersonProductDTO = new AssoPersonProductDTO();
|
|
assoPersonProductDTO.setProductId(product.getId());
|
|
assoPersonProductDTO.setProductId(product.getId());
|
|
assoPersonProductDTO.setConcernType(productAddDTO.getConcernType());
|
|
assoPersonProductDTO.setConcernType(productAddDTO.getConcernType());
|
|
@@ -203,14 +210,13 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public Product addProduct(Object productAddDTO,String createUuid) {
|
|
|
|
|
|
+ public Product addProduct(Object productAddDTO, String createUuid) {
|
|
Product product = new Product();
|
|
Product product = new Product();
|
|
BeanUtils.copyProperties(productAddDTO, product);
|
|
BeanUtils.copyProperties(productAddDTO, product);
|
|
- if(createUuid==null) {
|
|
|
|
|
|
+ if (createUuid == null) {
|
|
PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
product.setCreateId(personnelVO.getUuid());
|
|
product.setCreateId(personnelVO.getUuid());
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
product.setCreateId(createUuid);
|
|
product.setCreateId(createUuid);
|
|
}
|
|
}
|
|
product.setIfCustomized(true);
|
|
product.setIfCustomized(true);
|
|
@@ -266,7 +272,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public Integer addOrUpdateHotProduct(HotProductAddDTO hotProductAddDTO,String createId) {
|
|
|
|
|
|
+ public Integer addOrUpdateHotProduct(HotProductAddDTO hotProductAddDTO, String createId) {
|
|
Product product = new Product();
|
|
Product product = new Product();
|
|
String name = hotProductAddDTO.getName();
|
|
String name = hotProductAddDTO.getName();
|
|
Integer categoryId = hotProductAddDTO.getProductCategoryId();
|
|
Integer categoryId = hotProductAddDTO.getProductCategoryId();
|
|
@@ -276,6 +282,9 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
|
|
queryWrapper.eq(Product::getName, name)
|
|
queryWrapper.eq(Product::getName, name)
|
|
.eq(Product::getIfHot, true);
|
|
.eq(Product::getIfHot, true);
|
|
|
|
+ if (hotProductAddDTO.getId() != null) {
|
|
|
|
+ queryWrapper.ne(Product::getId, hotProductAddDTO.getId());
|
|
|
|
+ }
|
|
Product orgProject = this.getOne(queryWrapper, false);
|
|
Product orgProject = this.getOne(queryWrapper, false);
|
|
if (orgProject != null) {
|
|
if (orgProject != null) {
|
|
throw new BusinessException("607", "产品名称不可重复");
|
|
throw new BusinessException("607", "产品名称不可重复");
|
|
@@ -361,7 +370,6 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
public void ImportProduct(MultipartFile multipartFile) {
|
|
public void ImportProduct(MultipartFile multipartFile) {
|
|
String guid = "";
|
|
String guid = "";
|
|
|
|
|
|
@@ -371,7 +379,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
if (guids == null | guids.size() == 0) {
|
|
if (guids == null | guids.size() == 0) {
|
|
throw new BusinessException("607", "上传文件错误");
|
|
throw new BusinessException("607", "上传文件错误");
|
|
}
|
|
}
|
|
- guid =guids.get(0);
|
|
|
|
|
|
+ guid = guids.get(0);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
throw new BusinessException("607", "上传文件错误");
|
|
throw new BusinessException("607", "上传文件错误");
|
|
}
|
|
}
|