This commit is contained in:
shuo.wang
2025-04-17 21:07:58 +08:00
parent fe574d5368
commit 146d4b11cf

View File

@@ -583,31 +583,27 @@ public class ShopServiceImpl implements ShopService {
public ShopResponse getShopNameAndCode(Long shopId, Long lineId) {
boolean flag = false;
LineInfoDO lineInfoDO = lineInfoDAO.getLineInfo(lineId);
if (lineInfoDO == null){
if (lineInfoDO == null) {
throw new ServiceException(ErrorCodeEnum.LINE_ID_IS_NOT_EXIST);
}
ShopResponse response = new ShopResponse();
if (shopId != null) {
MiniShopsResponse shopInfo = shopInfoDAO.currentShopWhetherOpen(shopId, eid);
if (Objects.nonNull(shopInfo) && StringUtils.isNotBlank(shopInfo.getShopCode())) {
ShopNameAndCodeDTO currentShop = new ShopNameAndCodeDTO();
currentShop.setShopName(shopInfo.getShopName());
currentShop.setShopCode(shopInfo.getShopCode());
response.setCurrentShop(currentShop);
flag = true;
}
}
List<ShopNameAndCodeDTO> list = new ArrayList<>();
if (lineId != null) {
List<MiniShopsResponse> shopList = shopInfoDAO.getShopListSuccessOpen(eid, lineId);
if (CollectionUtils.isNotEmpty(shopList)) {
for (MiniShopsResponse shopInfoDO : shopList) {
ShopNameAndCodeDTO dto = new ShopNameAndCodeDTO();
dto.setShopName(shopInfoDO.getShopName());
dto.setShopCode(shopInfoDO.getShopCode());
list.add(dto);
}
flag = true;
List<MiniShopsResponse> shopList = shopInfoDAO.getShopListSuccessOpen(eid, lineId);
if (CollectionUtils.isNotEmpty(shopList)) {
for (MiniShopsResponse shopInfoDO : shopList) {
ShopNameAndCodeDTO dto = new ShopNameAndCodeDTO();
dto.setShopName(shopInfoDO.getShopName());
dto.setShopCode(shopInfoDO.getShopCode());
list.add(dto);
}
Map<Long, MiniShopsResponse> shopMap = shopList.stream().collect(Collectors.toMap(MiniShopsResponse::getShopId, Function.identity()));
//获取当前门店
if (Objects.nonNull(shopMap.get(shopId))) {
ShopNameAndCodeDTO currentShop = new ShopNameAndCodeDTO();
currentShop.setShopName(shopMap.get(shopId).getShopName());
currentShop.setShopCode(shopMap.get(shopId).getShopCode());
response.setCurrentShop(currentShop);
}
}
List<OldShopDO> oldMobile = oldShopDAO.getByMobile(lineInfoDO.getMobile());
@@ -618,24 +614,30 @@ public class ShopServiceImpl implements ShopService {
dto.setShopCode(oldShopDO.getShopCode());
list.add(dto);
}
flag = true;
}
response.setShopList(list);
if (flag) {
return response;
} else {
if (CollectionUtils.isEmpty(list)) {
return null;
}
//去重
List<ShopNameAndCodeDTO> distinctList = new ArrayList<>(list.stream()
.collect(Collectors.toMap(
ShopNameAndCodeDTO::getShopCode,
dto -> dto,
(existing, replacement) -> existing
))
.values());
response.setShopList(distinctList);
return response;
}
@Override
public String getFranchiseBrandName(Long shopId) {
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
if (shopInfo == null){
if (shopInfo == null) {
throw new ServiceException(ErrorCodeEnum.SHOP_NOT_EXIST);
}
return FranchiseBrandEnum.getDescByCode(shopInfo.getFranchiseBrand());
return FranchiseBrandEnum.getDescByCode(shopInfo.getFranchiseBrand());
}