diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantRelationServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantRelationServiceImpl.java index fe89ccfc7..91c091862 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantRelationServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantRelationServiceImpl.java @@ -45,7 +45,7 @@ public class WxMerchantRelationServiceImpl implements WxMerchantRelationService List infByIds = wxMerchantRelationMapper.getInfByIds(ids); List updateList = new ArrayList<>(); if (!CollectionUtils.isEmpty(infByIds)) { - List alreadyList = infByIds.parallelStream().filter(x -> x.getIsDel() == 0).map(WxMerchantRelation::getMerchantId).collect(Collectors.toList()); + List alreadyList = infByIds.parallelStream().filter(x -> x.getIsDel() == 0 && !ids.contains(x.getMerchantId())).map(WxMerchantRelation::getMerchantId).collect(Collectors.toList()); //如果已经存在就返回 if (!CollectionUtils.isEmpty(alreadyList)){ return new ResultData(Result.ERROR, "存在子商户在其他区域商户下"); @@ -58,7 +58,8 @@ public class WxMerchantRelationServiceImpl implements WxMerchantRelationService } List finalList = updateList; - List insertList = ids.parallelStream().filter(x -> !finalList.contains(x)).collect(Collectors.toList()); + List alreadyList = infByIds.parallelStream().filter(x -> x.getIsDel() == 0).map(WxMerchantRelation::getMerchantId).collect(Collectors.toList()); + List insertList = ids.parallelStream().filter(x -> !finalList.contains(x) && !alreadyList.contains(x)).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(updateList)) { wxMerchantRelationMapper.updateByMerchantIds(updateList,regionId); }