fix 增加修改门店区域

This commit is contained in:
shuo.wang
2024-11-13 14:11:12 +08:00
parent 6eda5bdba4
commit 0c7ece5410
2 changed files with 20 additions and 8 deletions

View File

@@ -6,10 +6,7 @@ import com.cool.store.enums.point.ShopSubStageStatusEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
/**
* @author zhangchenbiao
@@ -35,15 +32,22 @@ public class MiniShopPageVO {
@ApiModelProperty("铺位id")
private Long pointId;
public MiniShopPageVO(Long shopId, String shopName,String shopCode,Boolean flag,Long pointId) {
@ApiModelProperty("门店所属区域id")
private Long regionId;
@ApiModelProperty("门店所属区域name")
private String regionName;
public MiniShopPageVO(Long shopId, String shopName,String shopCode,Boolean flag,Long pointId,Long regionId,String regionName) {
this.shopId = shopId;
this.shopName = shopName;
this.shopCode = shopCode;
this.flag = flag;
this.pointId = pointId;
this.regionId = regionId;
this.regionName = regionName;
}
public static List<MiniShopPageVO> convertList(List<ShopInfoDO> shopInfoList, Map<Long, ShopStageInfoDO> stageMap ) {
public static List<MiniShopPageVO> convertList(List<ShopInfoDO> shopInfoList, Map<Long, ShopStageInfoDO> stageMap, Map<Long, String> regionNameMap ) {
List<MiniShopPageVO> resultList = new ArrayList<>();
for (ShopInfoDO shopInfo : shopInfoList) {
ShopStageInfoDO stageInfoDO = stageMap.get(shopInfo.getId());
@@ -53,7 +57,10 @@ public class MiniShopPageVO {
flag = Boolean.TRUE;
}
}
resultList.add(new MiniShopPageVO(shopInfo.getId(), shopInfo.getShopName(),shopInfo.getShopCode(),flag,shopInfo.getPointId()));
if(Objects.isNull(regionNameMap)){
regionNameMap = new HashMap<>();
}
resultList.add(new MiniShopPageVO(shopInfo.getId(), shopInfo.getShopName(),shopInfo.getShopCode(),flag,shopInfo.getPointId(),shopInfo.getRegionId(), regionNameMap.getOrDefault(shopInfo.getRegionId(),"")));
}
return resultList;
}

View File

@@ -18,6 +18,7 @@ import com.cool.store.utils.RandomEightCharCodeUtils;
import com.cool.store.vo.shop.MiniShopPageVO;
import com.cool.store.vo.shop.ShopStageInfoVO;
import com.cool.store.vo.shop.StageShopCountVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -51,6 +52,8 @@ public class ShopServiceImpl implements ShopService {
private CommonService commonService;
@Resource
UserAuthMappingService userAuthMappingService;
@Autowired
private RegionDao regionDao;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -96,7 +99,9 @@ public class ShopServiceImpl implements ShopService {
List<Long> shopIds = shopList.stream().map(ShopInfoDO::getId).collect(Collectors.toList());
List<ShopStageInfoDO> subStageList = shopStageInfoDAO.getSubStageList(shopIds, ShopSubStageEnum.SHOP_STAGE_8.getShopSubStage());
Map<Long, ShopStageInfoDO> stageMap = subStageList.stream().collect(Collectors.toMap(ShopStageInfoDO::getShopId, Function.identity()));
return MiniShopPageVO.convertList(shopList,stageMap);
List<Long> regionIds = shopList.stream().map(ShopInfoDO::getRegionId).collect(Collectors.toList());
Map<Long, String> regionNameMap = regionDao.getRegionNameMap(regionIds);
return MiniShopPageVO.convertList(shopList,stageMap,regionNameMap);
}
@Override