|
@@ -1224,7 +1224,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
}
|
|
|
Long tenantId = 867735392558919680L;
|
|
|
Long newTenantId = bo.getTenantId();
|
|
|
- List<Goods> oldGoodsList = goodsList.stream().map(x -> BeanUtil.toBean(x, Goods.class)).collect(Collectors.toList());
|
|
|
+ List<GoodsSpecAttributeRelation> newRelationList = new ArrayList<>();
|
|
|
for (Goods goods : goodsList) {
|
|
|
//判断商品是否存在
|
|
|
GoodsVo newGoods = this.baseMapper.queryGoodsByIdTenant(goods.getGoodsId(),newTenantId);
|
|
@@ -1469,13 +1469,153 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
|
|
|
//规格模板
|
|
|
if (ObjectUtils.isNotNull(goods.getSpecTemplateId())){
|
|
|
+ List<GoodsSpecAttributeRelation> attributeRelationList = goodsSpecAttributeRelationService
|
|
|
+ .list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
+ .eq(GoodsSpecAttributeRelation::getGoodsId, goods.getGoodsId()));
|
|
|
+ if (CollectionUtils.isNotEmpty(attributeRelationList)){
|
|
|
+ for (GoodsSpecAttributeRelation relation : attributeRelationList) {
|
|
|
+ GoodsSpecTemplate specTemplate = goodsSpecTemplateService.getById(relation.getSpecTemplateId());
|
|
|
+ GoodsSpecTemplate newSpecTemplate = goodsSpecTemplateService.getSpecTpByTenant(specTemplate.getName(),specTemplate.getCreateTime(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newSpecTemplate)){
|
|
|
+ //更新
|
|
|
+ List<Long> specIds = goodsSpecService.getIdsByTenant(newSpecTemplate.getSpecTemplateId(),newTenantId);
|
|
|
+ if (CollectionUtils.isNotEmpty(specIds)){
|
|
|
+ //删除关联信息
|
|
|
+ List<Long> specAttrIds = goodsSpecAttributeService.getIdsByTenant(specIds);
|
|
|
+ if (CollectionUtils.isNotEmpty(specAttrIds)){
|
|
|
+ goodsSpecAttributeService.deleteByIdsTenant(specAttrIds);
|
|
|
+ goodsSpecAttributeRelationService.deleteByTemplateIdTenant(newSpecTemplate.getSpecTemplateId(),newTenantId);
|
|
|
+ }
|
|
|
+ goodsSpecService.deleteByIdsTenant(specIds);
|
|
|
+ }
|
|
|
+ //新增关联
|
|
|
+ List<GoodsSpec> specList = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>()
|
|
|
+ .eq(GoodsSpec::getSpecTemplateId, specTemplate.getSpecTemplateId()));
|
|
|
+ if (CollectionUtils.isNotEmpty(specList)){
|
|
|
+ specList.forEach(item -> {
|
|
|
+ Long oldSpecId = item.getSpecId();
|
|
|
+ item.setSpecId(null);
|
|
|
+ item.setSpecTemplateId(newSpecTemplate.getSpecTemplateId());
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ goodsSpecService.save(item);
|
|
|
+ List<GoodsSpecAttribute> specAttributeList = goodsSpecAttributeService
|
|
|
+ .list(new LambdaQueryWrapper<GoodsSpecAttribute>()
|
|
|
+ .eq(GoodsSpecAttribute::getSpecId, oldSpecId));
|
|
|
+ if (CollectionUtils.isNotEmpty(specAttributeList)){
|
|
|
+ List<GoodsSpecAttributeRelation> relationList = goodsSpecAttributeRelationService
|
|
|
+ .list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
+ .eq(GoodsSpecAttributeRelation::getSpecTemplateId, specTemplate.getSpecTemplateId()));
|
|
|
+ if (CollectionUtils.isNotEmpty(relationList)){
|
|
|
+ newRelationList.addAll(relationList);
|
|
|
+ }
|
|
|
+ List<GoodsSpecAttribute> collect = specAttributeList.stream().map(attrItem -> {
|
|
|
+ attrItem.setSpecAttributeId(null);
|
|
|
+ attrItem.setSpecId(item.getSpecId());
|
|
|
+ attrItem.setTenantId(newTenantId);
|
|
|
+ return attrItem;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ goodsSpecAttributeService.saveBatch(collect);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ Long oldSpecTemplateId = specTemplate.getSpecTemplateId();
|
|
|
+ //新增
|
|
|
+ specTemplate.setSpecTemplateId(null);
|
|
|
+ specTemplate.setTenantId(newTenantId);
|
|
|
+ goodsSpecTemplateService.save(specTemplate);
|
|
|
+ //新增关联
|
|
|
+ List<GoodsSpec> specList = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>()
|
|
|
+ .eq(GoodsSpec::getSpecTemplateId, oldSpecTemplateId));
|
|
|
+ if (CollectionUtils.isNotEmpty(specList)){
|
|
|
+ specList.forEach(item -> {
|
|
|
+ Long oldSpecId = item.getSpecId();
|
|
|
+ item.setSpecId(null);
|
|
|
+ item.setSpecTemplateId(specTemplate.getSpecTemplateId());
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ goodsSpecService.save(item);
|
|
|
+ List<GoodsSpecAttribute> specAttributeList = goodsSpecAttributeService
|
|
|
+ .list(new LambdaQueryWrapper<GoodsSpecAttribute>()
|
|
|
+ .eq(GoodsSpecAttribute::getSpecId, oldSpecId));
|
|
|
+ if (CollectionUtils.isNotEmpty(specAttributeList)){
|
|
|
+ List<GoodsSpecAttributeRelation> relationList = goodsSpecAttributeRelationService
|
|
|
+ .list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
+ .eq(GoodsSpecAttributeRelation::getSpecTemplateId,oldSpecTemplateId));
|
|
|
+ if (CollectionUtils.isNotEmpty(relationList)){
|
|
|
+ newRelationList.addAll(relationList);
|
|
|
+ }
|
|
|
+ List<GoodsSpecAttribute> collect = specAttributeList.stream().map(attrItem -> {
|
|
|
+ attrItem.setSpecAttributeId(null);
|
|
|
+ attrItem.setSpecId(item.getSpecId());
|
|
|
+ attrItem.setTenantId(newTenantId);
|
|
|
+ return attrItem;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ goodsSpecAttributeService.saveBatch(collect);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //商品课程
|
|
|
+
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ private void disposeGoodsCourse(Goods goods,Long newTenantId){
|
|
|
+ List<GoodsCourse> goodsCourseList = iGoodsCourseService
|
|
|
+ .list(new LambdaQueryWrapper<GoodsCourse>()
|
|
|
+ .eq(GoodsCourse::getGoodsId, goods.getGoodsId()));
|
|
|
+ for (GoodsCourse goodsCourse : goodsCourseList) {
|
|
|
+ Course course = iCourseService.getById(goodsCourse.getCourseId());
|
|
|
+ if(ObjectUtils.isNotNull(course)){
|
|
|
+ Long oldCourseId = course.getCourseId();
|
|
|
+ Long newCourseId = 0L;
|
|
|
+ Course newCourse = iCourseService.getCourseByTenant(course.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newCourse)){
|
|
|
+ newCourseId = newCourse.getCourseId();
|
|
|
+ }else {
|
|
|
+ course.setCourseId(null);
|
|
|
+ course.setTenantId(newTenantId);
|
|
|
+ course.setEducationTypeId(getNewEducationTypeId(course.getEducationTypeId(),newTenantId));
|
|
|
+ course.setProjectId(getNewProjectTypeId(course.getProjectId(),newTenantId));
|
|
|
+ course.setSubjectId(getNewSubjectId(course.getSubjectId(), newTenantId));
|
|
|
+ course.setProjectId(getNewProjectTypeId(course.getProjectId(), newTenantId));
|
|
|
+ course.setMajorId(getNewMajorId(course.getMajorId(),newTenantId));
|
|
|
+ iCourseService.save(course);
|
|
|
+ newCourseId = course.getCourseId();
|
|
|
+ }
|
|
|
+ List<CourseMenu> courseMenuList = iCourseMenuService.list(new LambdaQueryWrapper<CourseMenu>()
|
|
|
+ .eq(CourseMenu::getCourseId, oldCourseId));
|
|
|
+ if (CollectionUtils.isNotEmpty(courseMenuList)){
|
|
|
+ for (CourseMenu courseMenu : courseMenuList) {
|
|
|
+ courseMenu.setCourseId(newCourseId);
|
|
|
+ Long menuId = courseMenu.getMenuId();
|
|
|
+ switch (courseMenu.getType()){
|
|
|
+ case 1:
|
|
|
+ //模块
|
|
|
+ CourseModule module = iCourseModuleService.getById(menuId);
|
|
|
+ if (ObjectUtils.isNotNull(module)){
|
|
|
+ CourseModule newModule = iCourseModuleService.getModuleByTenant(module.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newModule)){
|
|
|
+ courseMenu.setMenuId(newModule.getTenantId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private Long getNewCertificateId(Long certificateId,Long newTenantId){
|
|
|
CertificateCommon certificateCommon = iCertificateCommonService.getById(certificateId);
|
|
|
if (ObjectUtils.isNotNull(certificateCommon)){
|
|
@@ -1551,6 +1691,24 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
return newProject.getId();
|
|
|
}
|
|
|
|
|
|
+ private Long getNewMajorId(Long majorId,Long newTenantId){
|
|
|
+ //专业
|
|
|
+ Major major = iMajorService.getById(majorId);
|
|
|
+ if (ObjectUtils.isNull(major)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Major newMajor = iMajorService.getMajorByTenant(major.getEncoder(), newTenantId);
|
|
|
+ if (ObjectUtil.isNull(newMajor)){
|
|
|
+ //新增专业
|
|
|
+ major.setId(null);
|
|
|
+ major.setTenantId(newTenantId);
|
|
|
+ iMajorService.save(major);
|
|
|
+
|
|
|
+ return major.getId();
|
|
|
+ }
|
|
|
+ return newMajor.getId();
|
|
|
+ }
|
|
|
+
|
|
|
private Long getNewBusinessId(Long businessId,Long newTenantId){
|
|
|
//业务层次
|
|
|
CourseBusiness business = iCourseBusinessService.getById(businessId);
|