feat:所属大区
This commit is contained in:
@@ -16,10 +16,7 @@ import com.cool.store.dto.StoreDTO;
|
||||
import com.cool.store.dto.store.StoreAreaDTO;
|
||||
import com.cool.store.dto.store.StoreUserDTO;
|
||||
import com.cool.store.dto.store.StoreUserPositionDTO;
|
||||
import com.cool.store.entity.EnterpriseUserDO;
|
||||
import com.cool.store.entity.StoreDO;
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import com.cool.store.entity.UserAuthMappingDO;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.entity.store.StoreMasterSignerInfoDO;
|
||||
import com.cool.store.enums.*;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
@@ -43,6 +40,7 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
@@ -89,7 +87,17 @@ public class StoreServiceImpl implements StoreService {
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
return info;
|
||||
}
|
||||
List<StoreDTO> storeDTOS = processStores(list);
|
||||
//使用regionId与branch 合并的集合
|
||||
Set<Long> regionIds = list.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.flatMap(store -> Stream.of(store.getBranch(), store.getRegionId()))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
List<RegionDO> regionList = regionMapper.getByIds(new ArrayList<>(regionIds));
|
||||
Map<Long, String> regionNameMap = regionList.stream().collect(Collectors.toMap(RegionDO::getId, RegionDO::getName));
|
||||
|
||||
List<StoreDTO> storeDTOS = processStores(list, regionNameMap);
|
||||
info.setList(storeDTOS);
|
||||
return info;
|
||||
}
|
||||
@@ -381,7 +389,7 @@ public class StoreServiceImpl implements StoreService {
|
||||
}
|
||||
|
||||
|
||||
public static List<StoreDTO> processStores(List<StoreDO> stores) {
|
||||
public static List<StoreDTO> processStores(List<StoreDO> stores,Map<Long, String> regionMap) {
|
||||
// 处理每个门店
|
||||
return stores.stream().map(store -> {
|
||||
StoreDTO dto = BeanUtil.toBean(store, StoreDTO.class);
|
||||
@@ -391,6 +399,12 @@ public class StoreServiceImpl implements StoreService {
|
||||
dto.setJoinMode(JoinModeEnum.getByCode(store.getJoinModel()));
|
||||
dto.setBrand(FranchiseBrandEnum.getDescByCode(store.getJoinBrand()));
|
||||
dto.setOrderMiniProgramName(store.getMiniProgramOrderStoreName());
|
||||
if (store.getRegionId() != null){
|
||||
dto.setManagerSupervisionName(regionMap.get(store.getRegionId()));
|
||||
}
|
||||
if (store.getBranch()!=null){
|
||||
dto.setBranchName(regionMap.get(store.getBranch()));
|
||||
}
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user