Quellcode durchsuchen

1.经销商app门店保存接口bug修改

纪新园 vor 4 Tagen
Ursprung
Commit
1fd03265a8

+ 15 - 3
blade-service/gubersail-dealer-app/src/main/java/com/gubersail/app/corp/service/impl/AppCorpsDescServiceImpl.java

@@ -117,11 +117,19 @@ public class AppCorpsDescServiceImpl extends ServiceImpl<AppCorpsDescMapper, App
 			.eq(AppPjCorpsDesc::getIsDeleted, 0)
 			.eq(AppPjCorpsDesc::getSalesCompanyId, AuthUtil.getTenantId())
 			.eq(AppPjCorpsDesc::getCname, corpsDesc.getCname()));
+		List<AppPjCorpsDesc> tel = baseMapper.selectList(new LambdaQueryWrapper<AppPjCorpsDesc>()
+			.eq(AppPjCorpsDesc::getTenantId, AuthUtil.getTenantId())
+			.eq(AppPjCorpsDesc::getIsDeleted, 0)
+			.eq(AppPjCorpsDesc::getSalesCompanyId, AuthUtil.getTenantId())
+			.eq(AppPjCorpsDesc::getTel, corpsDescVO.getContactsPhone()));
 		//保存客户信息
 		if (corpsDesc.getId() == null) {
 			if (!pjCorpsDesc.isEmpty()) {
 				throw new RuntimeException("客户" + corpsDesc.getCname() + "已存在,请勿重复添加!");
 			}
+			if (!tel.isEmpty()) {
+				throw new RuntimeException("电话" + corpsDescVO.getContactsPhone() + "已存在,请勿重复添加!");
+			}
 			corpsDesc.setTenantId(SecureUtil.getTenantId());
 			corpsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
 			corpsDesc.setCreateTime(date);
@@ -142,6 +150,10 @@ public class AppCorpsDescServiceImpl extends ServiceImpl<AppCorpsDescMapper, App
 			if (!pjCorpsDesc.isEmpty() && !ids.contains(corpsDesc.getId())) {
 				throw new RuntimeException("客户" + corpsDesc.getCname() + "已存在,请勿重复添加!");
 			}
+			List<Long> telIds = tel.stream().map(AppPjCorpsDesc::getId).collect(Collectors.toList());
+			if (!tel.isEmpty() && !telIds.contains(corpsDesc.getId())) {
+				throw new RuntimeException("电话" + corpsDescVO.getContactsPhone() + "已存在,请勿重复添加!");
+			}
 			corpsDesc.setTenantId(SecureUtil.getTenantId());
 			corpsDesc.setUpdateTime(date);
 			corpsDesc.setUpdateUser(AuthUtil.getUserId());
@@ -359,7 +371,7 @@ public class AppCorpsDescServiceImpl extends ServiceImpl<AppCorpsDescMapper, App
 			return;
 		}
 		List<String> list = Arrays.asList(corpsDesc.getCorpsTypeId().split(","));
-		corpsTypeDescService.remove(new QueryWrapper<AppPjCorpsTypeDesc>().eq("corp_id", corpsDesc.getId()));
+		corpsTypeDescService.remove(new QueryWrapper<AppPjCorpsTypeDesc>().eq("corp_id", pId));
 		List<AppPjCorpsTypeDesc> typeDescList = corpsTypeDescService.list(new QueryWrapper<AppPjCorpsTypeDesc>().eq("corp_id", pId)
 			.in("corp_type_id", list));
 		List<AppPjCorpsTypeDesc> typeDescListNew = new ArrayList<>();
@@ -367,13 +379,13 @@ public class AppCorpsDescServiceImpl extends ServiceImpl<AppCorpsDescMapper, App
 			AppPjCorpsTypeDesc typeDesc = typeDescList.stream().filter(e -> item.equals(e.getCorpTypeId() + "")).findFirst().orElse(null);
 			if (typeDesc != null) {
 				typeDesc.setCorpTypeId(Long.valueOf(item));
-				typeDesc.setCorpId(corpsDesc.getId());
+				typeDesc.setCorpId(pId);
 				typeDesc.setUpdateTime(date);
 				typeDesc.setUpdateUser(userId);
 				typeDescListNew.add(typeDesc);
 			} else {
 				AppPjCorpsTypeDesc corpsTypeDesc = new AppPjCorpsTypeDesc();
-				corpsTypeDesc.setCorpId(corpsDesc.getId());
+				corpsTypeDesc.setCorpId(pId);
 				corpsTypeDesc.setCorpTypeId(Long.valueOf(item));
 				corpsTypeDesc.setCreateUser(userId);
 				corpsTypeDesc.setCreateTime(date);