|
|
|
@ -8,6 +8,7 @@ import com.baiye.modules.distribute.entity.CustomStoreEntity;
|
|
|
|
|
import com.baiye.modules.distribute.mapper.CustomStoreMapper;
|
|
|
|
|
import com.baiye.modules.distribute.service.CustomStoreService;
|
|
|
|
|
import com.baiye.modules.distribute.vo.StoreDetailsExportVO;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -68,24 +69,22 @@ public class CustomStoreServiceImpl extends ExtendServiceImpl<CustomStoreMapper,
|
|
|
|
|
if (CollUtil.isEmpty(customStoreEntities)) throw new BadRequestException("预约门店不能为空");
|
|
|
|
|
// 修改时,预约门店关联的客户ID是确定的(编辑客户时新增门店,关联客户ID)
|
|
|
|
|
customStoreEntities.forEach(c -> c.setCustomId(customId));
|
|
|
|
|
// List<CustomStoreEntity> entities = baseMapper.selectList(new LambdaQueryWrapper<CustomStoreEntity>().eq(CustomStoreEntity::getCustomId, customId));
|
|
|
|
|
// List<Long> allIdList = null;
|
|
|
|
|
// if (CollUtil.isNotEmpty(entities))
|
|
|
|
|
// allIdList = entities.stream().map(CustomStoreEntity::getCustomStoreId).collect(Collectors.toList());
|
|
|
|
|
List<CustomStoreEntity> entities = baseMapper.selectList(new LambdaQueryWrapper<CustomStoreEntity>().eq(CustomStoreEntity::getCustomId, customId));
|
|
|
|
|
List<Long> allIdList = null;
|
|
|
|
|
if (CollUtil.isNotEmpty(entities))
|
|
|
|
|
allIdList = entities.stream().map(CustomStoreEntity::getCustomStoreId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<CustomStoreEntity> filterList = customStoreEntities.stream().filter(c -> c.getCustomStoreId() != null).collect(Collectors.toList());
|
|
|
|
|
if (CollUtil.isNotEmpty(filterList)) {
|
|
|
|
|
this.updateBatchById(filterList);
|
|
|
|
|
if (CollUtil.isNotEmpty(allIdList)) {
|
|
|
|
|
List<Long> customStoreIdList = filterList.stream().map(CustomStoreEntity::getCustomStoreId).collect(Collectors.toList());
|
|
|
|
|
allIdList.removeAll(customStoreIdList);
|
|
|
|
|
if (CollUtil.isNotEmpty(allIdList)) baseMapper.deleteBatchIds(allIdList);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (CollUtil.isNotEmpty(allIdList)) baseMapper.deleteBatchIds(allIdList);
|
|
|
|
|
}
|
|
|
|
|
// if (CollUtil.isNotEmpty(allIdList)) {
|
|
|
|
|
// List<Long> customStoreIdList = filterList.stream().map(CustomStoreEntity::getCustomStoreId).collect(Collectors.toList());
|
|
|
|
|
// allIdList.removeAll(customStoreIdList);
|
|
|
|
|
// if (CollUtil.isNotEmpty(allIdList)) baseMapper.deleteBatchIds(allIdList);
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// if (CollUtil.isNotEmpty(allIdList)) baseMapper.deleteBatchIds(allIdList);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
List<CustomStoreEntity> saveCustomStoreList = customStoreEntities.stream().filter(c -> c.getCustomStoreId() == null).collect(Collectors.toList());
|
|
|
|
|
if (CollUtil.isNotEmpty(saveCustomStoreList)) baseMapper.insertBatchSomeColumn(saveCustomStoreList);
|
|
|
|
|
}
|
|
|
|
|