|
@@ -984,17 +984,23 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
if (Validator.isEmpty(bo.getTelphone())) {
|
|
|
throw new CustomException("参数错误");
|
|
|
}
|
|
|
- User user = iUserService.getOne(new LambdaQueryWrapper<User>()
|
|
|
- .eq(User::getTelphone, bo.getTelphone()));
|
|
|
- if (ObjectUtils.isNull(user)) {
|
|
|
+
|
|
|
+ List<User> users = iUserService.getUserByTelNotTenant(bo.getTelphone());
|
|
|
+ if (CollectionUtils.isNotEmpty(users)) {
|
|
|
throw new CustomException("通过手机号获取用户信息失败");
|
|
|
}
|
|
|
//获取用户订单商品信息
|
|
|
- List<UserGoodsListVo> voList = baseMapper.getOrderGoodsListByUser(user.getUserId());
|
|
|
+ List<UserGoodsListVo> voList = new ArrayList<>();
|
|
|
+ users.forEach(item -> {
|
|
|
+ List<UserGoodsListVo> orderGoodsListByUser = baseMapper.getOrderGoodsListByUser(item.getUserId());
|
|
|
+ voList.addAll(orderGoodsListByUser);
|
|
|
+ });
|
|
|
+
|
|
|
if (CollectionUtils.isEmpty(voList)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
voList.forEach(goodsVo -> {
|
|
|
+ User user = users.stream().filter(x -> x.getTenantId().equals(goodsVo.getTenantId())).findFirst().orElse(null);
|
|
|
//已学和未学
|
|
|
Long secLong = 0L;
|
|
|
Long studyLong = 0L;
|
|
@@ -1390,19 +1396,214 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
if (ObjectUtil.isNotNull(newCourseHandouts)){
|
|
|
goods.setHandoutsId(newCourseHandouts.getHandoutsId());
|
|
|
}else {
|
|
|
+ //讲义业务层次
|
|
|
+ List<CourseHandoutsBusiness> handoutsBusinessList = iCourseHandoutsBusinessService
|
|
|
+ .list(new LambdaQueryWrapper<CourseHandoutsBusiness>()
|
|
|
+ .eq(CourseHandoutsBusiness::getHandoutsId, courseHandouts.getHandoutsId()));
|
|
|
newCourseHandouts.setHandoutsId(null);
|
|
|
newCourseHandouts.setTenantId(newTenantId);
|
|
|
iCourseHandoutsService.save(newCourseHandouts);
|
|
|
goods.setHandoutsId(courseHandouts.getHandoutsId());
|
|
|
+ if (CollectionUtils.isNotEmpty(handoutsBusinessList)){
|
|
|
+ List<CourseHandoutsBusiness> collect = handoutsBusinessList.stream().map(business -> {
|
|
|
+ business.setId(null);
|
|
|
+ business.setTenantId(newTenantId);
|
|
|
+ //项目
|
|
|
+ business.setEducationId(getNewEducationTypeId(business.getEducationId(), newTenantId));
|
|
|
+ //业务
|
|
|
+ business.setBusinessId(getNewBusinessId(business.getBusinessId(), newTenantId));
|
|
|
+ //科目
|
|
|
+ business.setSubjectId(getNewSubjectId(business.getSubjectId(), newTenantId));
|
|
|
+ //讲义
|
|
|
+ business.setHandoutsId(courseHandouts.getHandoutsId());
|
|
|
+ return business;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ iCourseHandoutsBusinessService.saveBatch(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //科目ID,拼接
|
|
|
+ if (StringUtils.isNotBlank(goods.getSubjectIds())){
|
|
|
+ List<Long> subIds = new ArrayList<>();
|
|
|
+ List<Long> ids = Arrays.asList(goods.getSubjectIds().split(",")).stream().map(x -> Long.valueOf(x)).collect(Collectors.toList());
|
|
|
+ ids.forEach(item -> {
|
|
|
+ Long newSubjectId = getNewSubjectId(item, newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newSubjectId)){
|
|
|
+ subIds.add(newSubjectId);
|
|
|
}
|
|
|
+ });
|
|
|
+ if (CollectionUtils.isNotEmpty(subIds)){
|
|
|
+ goods.setSubjectIds(subIds.stream().map(x -> x.toString()).collect(Collectors.joining(",")));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //证书类型
|
|
|
+ if (ObjectUtils.isNotNull(goods.getCertificateTypeId())){
|
|
|
+ goods.setCertificateTypeId(getNewCertificateTypeId(goods.getCertificateTypeId(),newTenantId));
|
|
|
+ }
|
|
|
+
|
|
|
+ //证书
|
|
|
+ if (ObjectUtils.isNotNull(goods.getCertificateId())){
|
|
|
+ goods.setCertificateId(getNewCertificateId(goods.getCertificateId(),newTenantId));
|
|
|
+ }
|
|
|
+
|
|
|
+ //证书模板
|
|
|
+ if (ObjectUtils.isNotNull(goods.getCertificateTpId())){
|
|
|
+ CertificateTp certificateTp = iCertificateTpService.getById(goods.getCertificateTpId());
|
|
|
+ if (ObjectUtils.isNotNull(certificateTp)){
|
|
|
+ CertificateTp newCertificateTp =iCertificateTpService.getCertificateTpByTenant(certificateTp.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newCertificateTp)){
|
|
|
+ goods.setCertificateTpId(newCertificateTp.getTpId());
|
|
|
+ }else {
|
|
|
+ certificateTp.setTpId(null);
|
|
|
+ certificateTp.setTenantId(newTenantId);
|
|
|
+ certificateTp.setCertificateId(getNewCertificateId(certificateTp.getCertificateId(),newTenantId));
|
|
|
+ certificateTp.setTpId(getNewCertificateTypeId(certificateTp.getTpId(),newTenantId));
|
|
|
+ iCertificateTpService.save(certificateTp);
|
|
|
+ goods.setCertificateTpId(certificateTp.getTpId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //规格模板
|
|
|
+ if (ObjectUtils.isNotNull(goods.getSpecTemplateId())){
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ private Long getNewCertificateId(Long certificateId,Long newTenantId){
|
|
|
+ CertificateCommon certificateCommon = iCertificateCommonService.getById(certificateId);
|
|
|
+ if (ObjectUtils.isNotNull(certificateCommon)){
|
|
|
+ CertificateCommon newCertificateCommon = iCertificateCommonService.getCertificateByTenant(certificateCommon.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newCertificateCommon)){
|
|
|
+ return newCertificateCommon.getId();
|
|
|
+ }else {
|
|
|
+ certificateCommon.setId(null);
|
|
|
+ certificateCommon.setTenantId(newTenantId);
|
|
|
+ //证书类型
|
|
|
+ //证书类型
|
|
|
+ if (ObjectUtils.isNotNull(certificateCommon.getCertificateTypeId())){
|
|
|
+ certificateCommon.setCertificateTypeId(getNewCertificateTypeId(certificateCommon.getCertificateTypeId(),newTenantId));
|
|
|
+ }
|
|
|
+ iCertificateCommonService.save(certificateCommon);
|
|
|
+ return certificateCommon.getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Long getNewCertificateTypeId(Long certificateTypeId,Long newTenantId){
|
|
|
+ Certificate certificate = iCertificateService.getById(certificateTypeId);
|
|
|
+ if (ObjectUtils.isNotNull(certificate)){
|
|
|
+ Certificate newCertificate = iCertificateService.getCertificateByTenant(certificate.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newCertificate)){
|
|
|
+ return newCertificate.getId();
|
|
|
+ }else {
|
|
|
+ certificate.setId(null);
|
|
|
+ certificate.setTenantId(newTenantId);
|
|
|
+ iCertificateService.save(certificate);
|
|
|
+ return certificate.getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Long getNewEducationTypeId(Long oldEducationTypeId,Long newTenantId){
|
|
|
+ //教育类型
|
|
|
+ CourseEducationType educationType = iCourseEducationTypeService.getById(oldEducationTypeId);
|
|
|
+ if (ObjectUtils.isNull(educationType)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CourseEducationType newEducationType = iCourseEducationTypeService.getEducationTypeBytenant(educationType.getEncoder(), newTenantId);
|
|
|
+ if (ObjectUtil.isNull(newEducationType)){
|
|
|
+ //新增教育类型
|
|
|
+ educationType.setId(null);
|
|
|
+ educationType.setTenantId(newTenantId);
|
|
|
+ iCourseEducationTypeService.save(educationType);
|
|
|
+ return educationType.getId();
|
|
|
+ }
|
|
|
+ return newEducationType.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ private Long getNewProjectTypeId(Long projectTypeId,Long newTenantId){
|
|
|
+ //项目类型
|
|
|
+ CourseProjectType project = iCourseProjectTypeService.getById(projectTypeId);
|
|
|
+ if (ObjectUtils.isNull(project)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CourseProjectType newProject = iCourseProjectTypeService.getProjectByTenant(project.getEncoder(),newTenantId);
|
|
|
+ if (ObjectUtil.isNull(newProject)){
|
|
|
+ //新增项目类型
|
|
|
+ project.setId(null);
|
|
|
+ project.setTenantId(newTenantId);
|
|
|
+ //教育类型
|
|
|
+ Long newEducationTypeId = getNewEducationTypeId(project.getEducationId().longValue(), newTenantId);
|
|
|
+ project.setEducationId(newEducationTypeId.intValue());
|
|
|
+ iCourseProjectTypeService.save(project);
|
|
|
+
|
|
|
+ return project.getId();
|
|
|
+ }
|
|
|
+ return newProject.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ private Long getNewBusinessId(Long businessId,Long newTenantId){
|
|
|
+ //业务层次
|
|
|
+ CourseBusiness business = iCourseBusinessService.getById(businessId);
|
|
|
+ if (ObjectUtils.isNull(business)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CourseBusiness newBusiness = iCourseBusinessService.getBusinessByTenant(business.getEncoder(),newTenantId);
|
|
|
+ if (ObjectUtil.isNull(newBusiness)){
|
|
|
+ //新增业务层次
|
|
|
+ business.setId(null);
|
|
|
+ business.setTenantId(newTenantId);
|
|
|
+ iCourseBusinessService.save(business);
|
|
|
+ return business.getId();
|
|
|
+ }
|
|
|
+ return newBusiness.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private Long getNewSubjectId(Long subjectId,Long newTenantId){
|
|
|
+ //业务层次
|
|
|
+ CourseSubject courseSubject = iCourseSubjectService.getById(subjectId);
|
|
|
+ if (ObjectUtils.isNull(courseSubject)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CourseSubject newCourseSubject = iCourseSubjectService.getSubjectByTenant(courseSubject.getEncoder(),newTenantId);
|
|
|
+ if (ObjectUtil.isNull(newCourseSubject)){
|
|
|
+ //业务项目关联
|
|
|
+ List<CourseSubjectProject> projectList = iCourseSubjectProjectService
|
|
|
+ .list(new LambdaQueryWrapper<CourseSubjectProject>()
|
|
|
+ .eq(CourseSubjectProject::getSubjectId, courseSubject.getId()));
|
|
|
+ //新增业务层次
|
|
|
+ courseSubject.setId(null);
|
|
|
+ courseSubject.setTenantId(newTenantId);
|
|
|
+ iCourseSubjectService.save(courseSubject);
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(projectList)){
|
|
|
+ List<CourseSubjectProject> collect = projectList.stream().map(item -> {
|
|
|
+ item.setId(null);
|
|
|
+ item.setSubjectId(courseSubject.getId());
|
|
|
+ //项目ID
|
|
|
+ Long newProjectTypeId = getNewProjectTypeId(item.getProjectId(), newTenantId);
|
|
|
+ item.setProjectId(newProjectTypeId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ iCourseSubjectProjectService.saveBatch(collect);
|
|
|
+ }
|
|
|
+ return courseSubject.getId();
|
|
|
+ }
|
|
|
+ return newCourseSubject.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean goodsBatchCopyTenant(GoodsBatchCopyTenantBo bo) {
|