|
|
|
@@ -43,25 +43,27 @@ public class WxMerchantRelationServiceImpl implements WxMerchantRelationService |
|
|
|
|
|
|
|
//先去查询是否存在,如果存在再去排除这个id去进行查询是否存在 |
|
|
|
List<WxMerchantRelation> infByIds = wxMerchantRelationMapper.getInfByIds(ids); |
|
|
|
List<Long> list = new ArrayList<>(); |
|
|
|
List<Long> updateList = new ArrayList<>(); |
|
|
|
if (!CollectionUtils.isEmpty(infByIds)) { |
|
|
|
list = infByIds.parallelStream().map(WxMerchantRelation::getMerchantId).collect(Collectors.toList()); |
|
|
|
//判断子商户是否已经被选了 |
|
|
|
Integer integer = wxMerchantRelationMapper.selectByIds(list); |
|
|
|
if (integer > 0) { |
|
|
|
List<Long> alreadyList = infByIds.parallelStream().filter(x -> x.getIsDel() == 0).map(WxMerchantRelation::getMerchantId).collect(Collectors.toList()); |
|
|
|
//如果已经存在就返回 |
|
|
|
if (!CollectionUtils.isEmpty(alreadyList)){ |
|
|
|
return new ResultData(Result.ERROR, "存在子商户在其他区域商户下"); |
|
|
|
} |
|
|
|
//如果存在且是同一个区域商户下就 修改 是否删除字段 |
|
|
|
List<Long> delList = infByIds.parallelStream().filter(x -> x.getIsDel() == 1 && x.getRegionMerchantId().equals(regionId)).map(WxMerchantRelation::getMerchantId).collect(Collectors.toList()); |
|
|
|
if (!CollectionUtils.isEmpty(delList)){ |
|
|
|
updateList = delList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<Long> finalList = list; |
|
|
|
List<Long> collected = ids.parallelStream().filter(x -> !finalList.contains(x)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(list)) { |
|
|
|
wxMerchantRelationMapper.updateByMerchantIds(list); |
|
|
|
List<Long> finalList = updateList; |
|
|
|
List<Long> insertList = ids.parallelStream().filter(x -> !finalList.contains(x)).collect(Collectors.toList()); |
|
|
|
if (!CollectionUtils.isEmpty(updateList)) { |
|
|
|
wxMerchantRelationMapper.updateByMerchantIds(updateList,regionId); |
|
|
|
} |
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(collected)) { |
|
|
|
insertInfo(regionId, collected, tenantId); |
|
|
|
if (!CollectionUtils.isEmpty(insertList)) { |
|
|
|
insertInfo(regionId, insertList, tenantId); |
|
|
|
} |
|
|
|
return new ResultData(Result.SUCCESS, "编辑成功", null); |
|
|
|
} |
|
|
|
|