|
@ -28,6 +28,7 @@ import com.qs.serve.modules.goods.entity.vo.GoodsAccreditVo; |
|
|
import com.qs.serve.modules.goods.mapper.*; |
|
|
import com.qs.serve.modules.goods.mapper.*; |
|
|
import com.qs.serve.modules.goods.service.GoodsAccreditItemService; |
|
|
import com.qs.serve.modules.goods.service.GoodsAccreditItemService; |
|
|
import com.qs.serve.modules.sys.entity.SysUser; |
|
|
import com.qs.serve.modules.sys.entity.SysUser; |
|
|
|
|
|
import com.qs.serve.modules.sys.entity.dto.SysUserSimpleVo; |
|
|
import com.qs.serve.modules.sys.mapper.SysUserMapper; |
|
|
import com.qs.serve.modules.sys.mapper.SysUserMapper; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
@ -429,6 +430,8 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go |
|
|
boolean b4 = CollUtil.isNotEmpty(param.getNotInBizRegionIds()); |
|
|
boolean b4 = CollUtil.isNotEmpty(param.getNotInBizRegionIds()); |
|
|
boolean b5 = CollUtil.isNotEmpty(param.getOnlySupplierIds()); |
|
|
boolean b5 = CollUtil.isNotEmpty(param.getOnlySupplierIds()); |
|
|
boolean b6 = CollUtil.isNotEmpty(param.getNotInSupplierIds()); |
|
|
boolean b6 = CollUtil.isNotEmpty(param.getNotInSupplierIds()); |
|
|
|
|
|
boolean b7 = CollUtil.isNotEmpty(param.getOnlyUserIds()); |
|
|
|
|
|
boolean b8 = CollUtil.isNotEmpty(param.getNotInUserIds()); |
|
|
|
|
|
|
|
|
//清空历史
|
|
|
//清空历史
|
|
|
if(!param.isOnlyPastUpdate()){ |
|
|
if(!param.isOnlyPastUpdate()){ |
|
@ -442,6 +445,8 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go |
|
|
targetType = "bizRegion"; |
|
|
targetType = "bizRegion"; |
|
|
}else if (b5 || b6){ |
|
|
}else if (b5 || b6){ |
|
|
targetType = "supplier"; |
|
|
targetType = "supplier"; |
|
|
|
|
|
}else if (b7 || b8){ |
|
|
|
|
|
targetType = "user"; |
|
|
}else { |
|
|
}else { |
|
|
targetType = "saleRegion"; |
|
|
targetType = "saleRegion"; |
|
|
} |
|
|
} |
|
@ -453,7 +458,9 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 根据参数中的条件判断是否需要更新商品授权的空标志位
|
|
|
if(!b1 && !b2 && !b3 && !b4 && !b5 && !b6){ |
|
|
if(!b1 && !b2 && !b3 && !b4 && !b5 && !b6){ |
|
|
|
|
|
// 如果参数中没有任何有效的ID列表,则将空标志位设置为1
|
|
|
if(goodsAccredit.getId()!=null){ |
|
|
if(goodsAccredit.getId()!=null){ |
|
|
goodsAccredit.setEmptyFlag(1); |
|
|
goodsAccredit.setEmptyFlag(1); |
|
|
this.updateById(goodsAccredit); |
|
|
this.updateById(goodsAccredit); |
|
@ -559,68 +566,164 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go |
|
|
goodsAccreditItemService.saveBatch(list); |
|
|
goodsAccreditItemService.saveBatch(list); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(b7){ |
|
|
|
|
|
List<SysUser> userList = sysUserMapper.selectBatchIds(param.getNotInSupplierIds()); |
|
|
|
|
|
List<GoodsAccreditItem> list = userList.stream().map(a->{ |
|
|
|
|
|
GoodsAccreditItem item = new GoodsAccreditItem(); |
|
|
|
|
|
item.setAccId(accId); |
|
|
|
|
|
item.setAccType(0); |
|
|
|
|
|
item.setTargetType("user"); |
|
|
|
|
|
item.setTargetCode(a.getCode()); |
|
|
|
|
|
item.setTargetName(a.getName()); |
|
|
|
|
|
item.setTargetId(a.getId()); |
|
|
|
|
|
return item; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
goodsAccreditItemService.saveBatch(list); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(b8){ |
|
|
|
|
|
List<SysUser> userList = sysUserMapper.selectBatchIds(param.getNotInSupplierIds()); |
|
|
|
|
|
List<GoodsAccreditItem> list = userList.stream().map(a->{ |
|
|
|
|
|
GoodsAccreditItem item = new GoodsAccreditItem(); |
|
|
|
|
|
item.setAccId(accId); |
|
|
|
|
|
item.setAccType(1); |
|
|
|
|
|
item.setTargetType("user"); |
|
|
|
|
|
item.setTargetCode(a.getCode()); |
|
|
|
|
|
item.setTargetName(a.getName()); |
|
|
|
|
|
item.setTargetId(a.getId()); |
|
|
|
|
|
return item; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
goodsAccreditItemService.saveBatch(list); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据类别ID、SPU ID和SKU ID获取商品授权信息 |
|
|
|
|
|
* @param cateId 类别ID |
|
|
|
|
|
* @param spuId SPU ID |
|
|
|
|
|
* @param skuId SKU ID |
|
|
|
|
|
* @return 返回商品授权信息对象,如果没有找到则返回null |
|
|
|
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public GoodsAccreditVo getById(String cateId, String spuId, String skuId) { |
|
|
public GoodsAccreditVo getById(String cateId, String spuId, String skuId) { |
|
|
|
|
|
// 获取商品授权基本信息
|
|
|
GoodsAccredit accredit = this.getGoodsAccredit(new GoodsAccreditBo(cateId,spuId,skuId)); |
|
|
GoodsAccredit accredit = this.getGoodsAccredit(new GoodsAccreditBo(cateId,spuId,skuId)); |
|
|
GoodsAccreditVo accreditVo = new GoodsAccreditVo(); |
|
|
GoodsAccreditVo accreditVo = new GoodsAccreditVo(); |
|
|
|
|
|
|
|
|
|
|
|
// 如果授权信息存在且有有效的ID,则进一步处理
|
|
|
if(accredit!=null&&accredit.getId()!=null){ |
|
|
if(accredit!=null&&accredit.getId()!=null){ |
|
|
|
|
|
// 查询该授权下的所有授权项
|
|
|
List<GoodsAccreditItem> accreditItemList = goodsAccreditItemService |
|
|
List<GoodsAccreditItem> accreditItemList = goodsAccreditItemService |
|
|
.list(new LambdaQueryWrapper<GoodsAccreditItem>().eq(GoodsAccreditItem::getAccId,accredit.getId())); |
|
|
.list(new LambdaQueryWrapper<GoodsAccreditItem>().eq(GoodsAccreditItem::getAccId,accredit.getId())); |
|
|
|
|
|
|
|
|
|
|
|
// 将授权项按目标类型分组
|
|
|
Map<String,List<GoodsAccreditItem>> accMap = accreditItemList.stream() |
|
|
Map<String,List<GoodsAccreditItem>> accMap = accreditItemList.stream() |
|
|
.collect(Collectors.groupingBy(GoodsAccreditItem::getTargetType)); |
|
|
.collect(Collectors.groupingBy(GoodsAccreditItem::getTargetType)); |
|
|
|
|
|
|
|
|
|
|
|
// 分别获取供应商、业务区,销售区域,用户,的授权项列表
|
|
|
List<GoodsAccreditItem> list1 = accMap.get("supplier"); |
|
|
List<GoodsAccreditItem> list1 = accMap.get("supplier"); |
|
|
List<GoodsAccreditItem> list2 = accMap.get("bizRegion"); |
|
|
List<GoodsAccreditItem> list2 = accMap.get("bizRegion"); |
|
|
List<GoodsAccreditItem> list3 = accMap.get("saleRegion"); |
|
|
List<GoodsAccreditItem> list3 = accMap.get("saleRegion"); |
|
|
|
|
|
List<GoodsAccreditItem> list4 = accMap.get("user"); |
|
|
|
|
|
|
|
|
|
|
|
// 处理供应商授权项
|
|
|
if(CollUtil.isNotEmpty(list1)){ |
|
|
if(CollUtil.isNotEmpty(list1)){ |
|
|
|
|
|
// 将供应商授权项按授权类型分组
|
|
|
Map<Integer,List<GoodsAccreditItem>> listMap = list1.stream() |
|
|
Map<Integer,List<GoodsAccreditItem>> listMap = list1.stream() |
|
|
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType)); |
|
|
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType)); |
|
|
|
|
|
|
|
|
|
|
|
// 分别处理仅限和除外的供应商授权项
|
|
|
List<GoodsAccreditItem> onlyList = listMap.get(0); |
|
|
List<GoodsAccreditItem> onlyList = listMap.get(0); |
|
|
List<GoodsAccreditItem> notInList = listMap.get(1); |
|
|
List<GoodsAccreditItem> notInList = listMap.get(1); |
|
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(onlyList)){ |
|
|
if(CollUtil.isNotEmpty(onlyList)){ |
|
|
|
|
|
// 获取仅限供应商ID列表并查询供应商信息
|
|
|
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
accreditVo.setOnlySupplierList(supplierMapper.selectBatchIds(ids)); |
|
|
accreditVo.setOnlySupplierList(supplierMapper.selectBatchIds(ids)); |
|
|
} |
|
|
} |
|
|
if(CollUtil.isNotEmpty(notInList)){ |
|
|
if(CollUtil.isNotEmpty(notInList)){ |
|
|
|
|
|
// 获取除外供应商ID列表并查询供应商信息
|
|
|
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
accreditVo.setNotInSupplierList(supplierMapper.selectBatchIds(ids)); |
|
|
accreditVo.setNotInSupplierList(supplierMapper.selectBatchIds(ids)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理业务区域授权项
|
|
|
if(CollUtil.isNotEmpty(list2)){ |
|
|
if(CollUtil.isNotEmpty(list2)){ |
|
|
|
|
|
// 将业务区域授权项按授权类型分组
|
|
|
Map<Integer,List<GoodsAccreditItem>> listMap = list2.stream() |
|
|
Map<Integer,List<GoodsAccreditItem>> listMap = list2.stream() |
|
|
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType)); |
|
|
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType)); |
|
|
|
|
|
|
|
|
|
|
|
// 分别处理仅限和除外的业务区域授权项
|
|
|
List<GoodsAccreditItem> onlyList = listMap.get(0); |
|
|
List<GoodsAccreditItem> onlyList = listMap.get(0); |
|
|
List<GoodsAccreditItem> notInList = listMap.get(1); |
|
|
List<GoodsAccreditItem> notInList = listMap.get(1); |
|
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(onlyList)){ |
|
|
if(CollUtil.isNotEmpty(onlyList)){ |
|
|
|
|
|
// 获取仅限业务区域ID列表并查询区域信息
|
|
|
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
accreditVo.setOnlyBizRegionList(region2Mapper.selectBatchIds(ids)); |
|
|
accreditVo.setOnlyBizRegionList(region2Mapper.selectBatchIds(ids)); |
|
|
} |
|
|
} |
|
|
if(CollUtil.isNotEmpty(notInList)){ |
|
|
if(CollUtil.isNotEmpty(notInList)){ |
|
|
|
|
|
// 获取除外业务区域ID列表并查询区域信息
|
|
|
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
accreditVo.setNotInBizRegionList(region2Mapper.selectBatchIds(ids)); |
|
|
accreditVo.setNotInBizRegionList(region2Mapper.selectBatchIds(ids)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理销售区域授权项
|
|
|
if(CollUtil.isNotEmpty(list3)){ |
|
|
if(CollUtil.isNotEmpty(list3)){ |
|
|
|
|
|
// 将销售区域授权项按授权类型分组
|
|
|
Map<Integer,List<GoodsAccreditItem>> listMap = list3.stream() |
|
|
Map<Integer,List<GoodsAccreditItem>> listMap = list3.stream() |
|
|
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType)); |
|
|
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType)); |
|
|
|
|
|
|
|
|
|
|
|
// 分别处理仅限和除外的销售区域授权项
|
|
|
List<GoodsAccreditItem> onlyList = listMap.get(0); |
|
|
List<GoodsAccreditItem> onlyList = listMap.get(0); |
|
|
List<GoodsAccreditItem> notInList = listMap.get(1); |
|
|
List<GoodsAccreditItem> notInList = listMap.get(1); |
|
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(onlyList)){ |
|
|
if(CollUtil.isNotEmpty(onlyList)){ |
|
|
|
|
|
// 获取仅限销售区域ID列表并查询区域信息
|
|
|
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
accreditVo.setOnlySaleRegionList(regionMapper.selectBatchIds(ids)); |
|
|
accreditVo.setOnlySaleRegionList(regionMapper.selectBatchIds(ids)); |
|
|
} |
|
|
} |
|
|
if(CollUtil.isNotEmpty(notInList)){ |
|
|
if(CollUtil.isNotEmpty(notInList)){ |
|
|
|
|
|
// 获取除外销售区域ID列表并查询区域信息
|
|
|
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
accreditVo.setNotInSaleRegionList(regionMapper.selectBatchIds(ids)); |
|
|
accreditVo.setNotInSaleRegionList(regionMapper.selectBatchIds(ids)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理用户授权项
|
|
|
|
|
|
if(CollUtil.isNotEmpty(list4)){ |
|
|
|
|
|
// 将销售区域授权项按授权类型分组
|
|
|
|
|
|
Map<Integer,List<GoodsAccreditItem>> listMap = list4.stream() |
|
|
|
|
|
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType)); |
|
|
|
|
|
|
|
|
|
|
|
// 分别处理仅限和除外的销售区域授权项
|
|
|
|
|
|
List<GoodsAccreditItem> onlyList = listMap.get(0); |
|
|
|
|
|
List<GoodsAccreditItem> notInList = listMap.get(1); |
|
|
|
|
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(onlyList)){ |
|
|
|
|
|
// 获取仅限销售区域ID列表并查询区域信息
|
|
|
|
|
|
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
|
|
|
List<SysUserSimpleVo> userSimpleVos = sysUserMapper.selectBatchIds(ids).stream() |
|
|
|
|
|
.map(a->a.toSimpleVo(true)).collect(Collectors.toList()); |
|
|
|
|
|
accreditVo.setOnlyUserList(userSimpleVos); |
|
|
|
|
|
} |
|
|
|
|
|
if(CollUtil.isNotEmpty(notInList)){ |
|
|
|
|
|
// 获取除外销售区域ID列表并查询区域信息
|
|
|
|
|
|
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
|
|
|
|
|
List<SysUserSimpleVo> userSimpleVos = sysUserMapper.selectBatchIds(ids).stream() |
|
|
|
|
|
.map(a->a.toSimpleVo(true)).collect(Collectors.toList()); |
|
|
|
|
|
accreditVo.setNotInUserList(userSimpleVos); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 返回构建好的商品授权信息对象
|
|
|
return accreditVo; |
|
|
return accreditVo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 如果没有找到授权信息,则返回null
|
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -814,11 +917,19 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据商品类别ID、SPU ID或SKU ID获取商品授权信息 |
|
|
|
|
|
* @param param 包含商品类别ID、SPU ID或SKU ID的查询参数对象 |
|
|
|
|
|
* @return 返回商品授权信息对象,如果找不到则返回null |
|
|
|
|
|
*/ |
|
|
private GoodsAccredit getGoodsAccredit(GoodsAccreditBo param){ |
|
|
private GoodsAccredit getGoodsAccredit(GoodsAccreditBo param){ |
|
|
GoodsAccredit accredit = null; |
|
|
GoodsAccredit accredit = null; |
|
|
|
|
|
|
|
|
|
|
|
// 根据类别ID查询商品授权信息
|
|
|
if(param.getCategoryId()!=null){ |
|
|
if(param.getCategoryId()!=null){ |
|
|
accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>() |
|
|
accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>() |
|
|
.eq(GoodsAccredit::getCategoryId,param.getCategoryId()),false); |
|
|
.eq(GoodsAccredit::getCategoryId,param.getCategoryId()),false); |
|
|
|
|
|
// 如果未找到对应的授权信息,则根据类别ID创建新的授权信息
|
|
|
if(accredit==null){ |
|
|
if(accredit==null){ |
|
|
GoodsCategory category = categoryMapper.selectById(param.getCategoryId()); |
|
|
GoodsCategory category = categoryMapper.selectById(param.getCategoryId()); |
|
|
accredit = new GoodsAccredit(); |
|
|
accredit = new GoodsAccredit(); |
|
@ -826,9 +937,11 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go |
|
|
accredit.setCode(category.getCode()); |
|
|
accredit.setCode(category.getCode()); |
|
|
accredit.setName(category.getName()); |
|
|
accredit.setName(category.getName()); |
|
|
} |
|
|
} |
|
|
|
|
|
// 根据SPU ID查询商品授权信息
|
|
|
}else if (param.getSpuId()!=null){ |
|
|
}else if (param.getSpuId()!=null){ |
|
|
accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>() |
|
|
accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>() |
|
|
.eq(GoodsAccredit::getSpuId,param.getSpuId()),false); |
|
|
.eq(GoodsAccredit::getSpuId,param.getSpuId()),false); |
|
|
|
|
|
// 如果未找到对应的授权信息,则根据SPU ID创建新的授权信息
|
|
|
if(accredit==null){ |
|
|
if(accredit==null){ |
|
|
GoodsSpu spu = goodsSpuMapper.selectById(param.getSpuId()); |
|
|
GoodsSpu spu = goodsSpuMapper.selectById(param.getSpuId()); |
|
|
accredit = new GoodsAccredit(); |
|
|
accredit = new GoodsAccredit(); |
|
@ -836,9 +949,11 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go |
|
|
accredit.setCode(spu.getSpuCode()); |
|
|
accredit.setCode(spu.getSpuCode()); |
|
|
accredit.setName(spu.getName()); |
|
|
accredit.setName(spu.getName()); |
|
|
} |
|
|
} |
|
|
|
|
|
// 根据SKU ID查询商品授权信息
|
|
|
}else if (param.getSkuId()!=null){ |
|
|
}else if (param.getSkuId()!=null){ |
|
|
accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>() |
|
|
accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>() |
|
|
.eq(GoodsAccredit::getSkuId,param.getSkuId()),false); |
|
|
.eq(GoodsAccredit::getSkuId,param.getSkuId()),false); |
|
|
|
|
|
// 如果未找到对应的授权信息,则根据SKU ID创建新的授权信息
|
|
|
if(accredit==null){ |
|
|
if(accredit==null){ |
|
|
GoodsSku sku = goodsSkuMapper.selectById(param.getSkuId()); |
|
|
GoodsSku sku = goodsSkuMapper.selectById(param.getSkuId()); |
|
|
accredit = new GoodsAccredit(); |
|
|
accredit = new GoodsAccredit(); |
|
|