|
@@ -1,6 +1,5 @@
|
|
|
package com.gree.mall.manager.logic.goods;
|
|
package com.gree.mall.manager.logic.goods;
|
|
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
|
import com.gree.mall.manager.bean.admin.AdminUserCom;
|
|
import com.gree.mall.manager.bean.admin.AdminUserCom;
|
|
|
import com.gree.mall.manager.bean.goods.GoodsCategoryBean;
|
|
import com.gree.mall.manager.bean.goods.GoodsCategoryBean;
|
|
|
import com.gree.mall.manager.commonmapper.CustomGoodsCategoryMapper;
|
|
import com.gree.mall.manager.commonmapper.CustomGoodsCategoryMapper;
|
|
@@ -8,7 +7,6 @@ import com.gree.mall.manager.exception.RemoteServiceException;
|
|
|
import com.gree.mall.manager.logic.common.CommonLogic;
|
|
import com.gree.mall.manager.logic.common.CommonLogic;
|
|
|
import com.gree.mall.manager.plus.entity.*;
|
|
import com.gree.mall.manager.plus.entity.*;
|
|
|
import com.gree.mall.manager.plus.service.*;
|
|
import com.gree.mall.manager.plus.service.*;
|
|
|
-import net.bytebuddy.asm.Advice;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
@@ -19,7 +17,6 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
-import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Component
|
|
@Component
|
|
@@ -48,14 +45,14 @@ public class GoodsCategoryLogic {
|
|
|
* @param status
|
|
* @param status
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public List<GoodsCategoryBean> list(Integer type,Integer level, String name, Boolean status, HttpServletRequest request) {
|
|
|
|
|
|
|
+ public List<GoodsCategoryBean> list(Integer type, Integer level, String name, Boolean status, Boolean platform, HttpServletRequest request) {
|
|
|
//获取当前登录企业微信id
|
|
//获取当前登录企业微信id
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
List<String> companyWechatIds = adminUser.getCompanyWechatIds();
|
|
List<String> companyWechatIds = adminUser.getCompanyWechatIds();
|
|
|
- if(type == null){
|
|
|
|
|
|
|
+ if (type == null) {
|
|
|
type = 1;
|
|
type = 1;
|
|
|
}
|
|
}
|
|
|
- return customGoodsCategoryMapper.list(type,level, status, name, companyWechatIds);
|
|
|
|
|
|
|
+ return customGoodsCategoryMapper.list(type, level, status, name, platform, companyWechatIds);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -70,25 +67,25 @@ public class GoodsCategoryLogic {
|
|
|
// throw new RemoteServiceException("非租户账号不可操作当前信息");
|
|
// throw new RemoteServiceException("非租户账号不可操作当前信息");
|
|
|
// }
|
|
// }
|
|
|
GoodsCategoryBean goodsCategory = goodsCategoryBean;
|
|
GoodsCategoryBean goodsCategory = goodsCategoryBean;
|
|
|
- if(!CollectionUtils.isEmpty(goodsCategoryBean.getChildren())){
|
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(goodsCategoryBean.getChildren())) {
|
|
|
goodsCategory = goodsCategoryBean.getChildren().get(0);
|
|
goodsCategory = goodsCategoryBean.getChildren().get(0);
|
|
|
}
|
|
}
|
|
|
- if(goodsCategory.getType() == null){
|
|
|
|
|
|
|
+ if (goodsCategory.getType() == null) {
|
|
|
goodsCategory.setType(1);
|
|
goodsCategory.setType(1);
|
|
|
}
|
|
}
|
|
|
//检查名称不可重复
|
|
//检查名称不可重复
|
|
|
Integer count = goodsCategoryService.lambdaQuery()
|
|
Integer count = goodsCategoryService.lambdaQuery()
|
|
|
.ne(StringUtils.isNotBlank(goodsCategory.getCategoryId()), GoodsCategory::getCategoryId, goodsCategory.getCategoryId())
|
|
.ne(StringUtils.isNotBlank(goodsCategory.getCategoryId()), GoodsCategory::getCategoryId, goodsCategory.getCategoryId())
|
|
|
- .eq(GoodsCategory::getType,goodsCategory.getType())
|
|
|
|
|
|
|
+ .eq(GoodsCategory::getType, goodsCategory.getType())
|
|
|
.eq(GoodsCategory::getName, goodsCategory.getName())
|
|
.eq(GoodsCategory::getName, goodsCategory.getName())
|
|
|
.eq(GoodsCategory::getCompanyWechatId, adminUser.getCompanyWechatId()).count();
|
|
.eq(GoodsCategory::getCompanyWechatId, adminUser.getCompanyWechatId()).count();
|
|
|
- if(count > 0){
|
|
|
|
|
- throw new RemoteServiceException("分类名称【"+goodsCategory.getName()+"】已存在");
|
|
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ throw new RemoteServiceException("分类名称【" + goodsCategory.getName() + "】已存在");
|
|
|
}
|
|
}
|
|
|
//最多只能2级
|
|
//最多只能2级
|
|
|
- if(StringUtils.isNotBlank(goodsCategory.getParentId())) {
|
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(goodsCategory.getParentId())) {
|
|
|
goodsCategory.setLevel(2);
|
|
goodsCategory.setLevel(2);
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
goodsCategory.setLevel(1);
|
|
goodsCategory.setLevel(1);
|
|
|
}
|
|
}
|
|
|
goodsCategory.setCreateTime(new Date());
|
|
goodsCategory.setCreateTime(new Date());
|
|
@@ -110,11 +107,11 @@ public class GoodsCategoryLogic {
|
|
|
//检查名称不可重复
|
|
//检查名称不可重复
|
|
|
Integer count = goodsCategoryService.lambdaQuery()
|
|
Integer count = goodsCategoryService.lambdaQuery()
|
|
|
.ne(GoodsCategory::getCategoryId, goodsCategory.getCategoryId())
|
|
.ne(GoodsCategory::getCategoryId, goodsCategory.getCategoryId())
|
|
|
- .eq(GoodsCategory::getType,old.getType())
|
|
|
|
|
|
|
+ .eq(GoodsCategory::getType, old.getType())
|
|
|
.eq(GoodsCategory::getName, goodsCategory.getName())
|
|
.eq(GoodsCategory::getName, goodsCategory.getName())
|
|
|
.eq(GoodsCategory::getCompanyWechatId, old.getCompanyWechatId()).count();
|
|
.eq(GoodsCategory::getCompanyWechatId, old.getCompanyWechatId()).count();
|
|
|
- if(count > 0){
|
|
|
|
|
- throw new RemoteServiceException("分类名称【"+goodsCategory.getName()+"】已存在");
|
|
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ throw new RemoteServiceException("分类名称【" + goodsCategory.getName() + "】已存在");
|
|
|
}
|
|
}
|
|
|
goodsCategoryService.updateById(goodsCategory);
|
|
goodsCategoryService.updateById(goodsCategory);
|
|
|
//如果有子集,覆盖子集的一些参数
|
|
//如果有子集,覆盖子集的一些参数
|
|
@@ -124,7 +121,6 @@ public class GoodsCategoryLogic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 删除分类
|
|
* 删除分类
|
|
|
*
|
|
*
|
|
@@ -140,15 +136,15 @@ public class GoodsCategoryLogic {
|
|
|
.eq(GoodsCategory::getParentId, categoryId).list();
|
|
.eq(GoodsCategory::getParentId, categoryId).list();
|
|
|
List<String> goodsCategoryIds = list.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toList());
|
|
List<String> goodsCategoryIds = list.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toList());
|
|
|
Integer count = goodsService.lambdaQuery().in(Goods::getCategoryId, goodsCategoryIds).count();
|
|
Integer count = goodsService.lambdaQuery().in(Goods::getCategoryId, goodsCategoryIds).count();
|
|
|
- if(count > 0){
|
|
|
|
|
|
|
+ if (count > 0) {
|
|
|
throw new RemoteServiceException("分类已被商品使用,不可删除");
|
|
throw new RemoteServiceException("分类已被商品使用,不可删除");
|
|
|
}
|
|
}
|
|
|
Integer count1 = goodsMaterialService.lambdaQuery().in(GoodsMaterial::getMainId, goodsCategoryIds).count();
|
|
Integer count1 = goodsMaterialService.lambdaQuery().in(GoodsMaterial::getMainId, goodsCategoryIds).count();
|
|
|
- if(count1 > 0){
|
|
|
|
|
|
|
+ if (count1 > 0) {
|
|
|
throw new RemoteServiceException("服务分类已被物料使用,不可删除");
|
|
throw new RemoteServiceException("服务分类已被物料使用,不可删除");
|
|
|
}
|
|
}
|
|
|
Integer count2 = goodsSpecService.lambdaQuery().in(GoodsSpec::getMainId, goodsCategoryIds).count();
|
|
Integer count2 = goodsSpecService.lambdaQuery().in(GoodsSpec::getMainId, goodsCategoryIds).count();
|
|
|
- if(count2 > 0){
|
|
|
|
|
|
|
+ if (count2 > 0) {
|
|
|
throw new RemoteServiceException("服务分类已被商品规格使用,不可删除");
|
|
throw new RemoteServiceException("服务分类已被商品规格使用,不可删除");
|
|
|
}
|
|
}
|
|
|
|
|
|