|
|
@@ -381,6 +381,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
} else if (CommonConstant.FOOD_LICENCE_NOT_EXPIRED_STATUS.equals(foodLicenceWhetherExpiredStatus)) {//经营许可证筛选状态 2 查询食品经营许可证未到期 距离到期时间大于30天以上
|
|
|
queryWrapper.gt("a.food_licence_expiration_time", nowDay.plusDays(31));
|
|
|
}
|
|
|
+ //查出所有店铺
|
|
|
IPage<StoreInfoVo> storeInfoVoPage = storeInfoMapper.getStoreInfoVoPage(iPage, queryWrapper);
|
|
|
List<StoreInfoVo> records = storeInfoVoPage.getRecords();
|
|
|
if (!records.isEmpty()) {
|
|
|
@@ -957,8 +958,12 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
|
|
|
@Override
|
|
|
public List<StoreDictionaryVo> getBusinessSectionTypes(String parentId) {
|
|
|
- StoreDictionary businessSection = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>().eq(StoreDictionary::getTypeName, "business_section").eq(StoreDictionary::getDictId, parentId));
|
|
|
- List<StoreDictionary> storeDictionaries = storeDictionaryMapper.selectList(new LambdaQueryWrapper<StoreDictionary>().eq(StoreDictionary::getParentId, businessSection.getId()));
|
|
|
+ StoreDictionary businessSection = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>()
|
|
|
+ .eq(StoreDictionary::getTypeName, "business_section")
|
|
|
+ .eq(StoreDictionary::getDictId, parentId)
|
|
|
+ .isNull(StoreDictionary::getParentId));
|
|
|
+ List<StoreDictionary> storeDictionaries = storeDictionaryMapper.selectList(new LambdaQueryWrapper<StoreDictionary>()
|
|
|
+ .eq(StoreDictionary::getParentId, businessSection.getId()));
|
|
|
List<StoreDictionaryVo> voList = new ArrayList<>();
|
|
|
for (StoreDictionary storeDictionary : storeDictionaries) {
|
|
|
StoreDictionaryVo vo = new StoreDictionaryVo();
|
|
|
@@ -3519,7 +3524,123 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public StoreThreeLevelStructureVo getStoreThreeLevelStructure(Integer storeId) {
|
|
|
+ // 1. 根据门店ID查询门店信息
|
|
|
+ StoreInfo storeInfo = storeInfoMapper.selectById(storeId);
|
|
|
+ if (storeInfo == null) {
|
|
|
+ log.warn("门店不存在,storeId={}", storeId);
|
|
|
+ StoreThreeLevelStructureVo vo = new StoreThreeLevelStructureVo();
|
|
|
+ vo.setStoreId(storeId);
|
|
|
+ vo.setStoreName(null);
|
|
|
+ vo.setThreeLevelStructure(new ArrayList<>());
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 获取门店表里的三级分类信息
|
|
|
+ Integer businessSection = storeInfo.getBusinessSection(); // 一级:经营板块ID
|
|
|
+ String businessTypes = storeInfo.getBusinessTypes(); // 二级:经营种类IDs(逗号分隔,fine_food类型)
|
|
|
+ String businessClassify = storeInfo.getBusinessClassify(); // 三级:分类IDs(逗号分隔)
|
|
|
+
|
|
|
+ // 3. 查询一级分类(business_section - 经营板块)
|
|
|
+ // business_section存储的是dictId(字符串),需要转换为String
|
|
|
+ List<StoreDictionary> allDicts = new ArrayList<>();
|
|
|
+ StoreDictionary firstLevelDict = null;
|
|
|
+ if (businessSection != null) {
|
|
|
+ firstLevelDict = storeDictionaryMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<StoreDictionary>()
|
|
|
+ .eq(StoreDictionary::getDictId, String.valueOf(businessSection))
|
|
|
+ .eq(StoreDictionary::getTypeName, "business_section")
|
|
|
+ .eq(StoreDictionary::getDeleteFlag, 0)
|
|
|
+ );
|
|
|
+ if (firstLevelDict != null) {
|
|
|
+ allDicts.add(firstLevelDict);
|
|
|
+ log.debug("查询到一级分类: id={}, dictId={}, dictDetail={}",
|
|
|
+ firstLevelDict.getId(), firstLevelDict.getDictId(), firstLevelDict.getDictDetail());
|
|
|
+ } else {
|
|
|
+ log.warn("未查询到一级分类,businessSection={}", businessSection);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ // 4. 查询二级分类(business_type - 根据门店表里的business_types字段,存储的是dictId)
|
|
|
+ List<StoreDictionary> secondLevelDicts = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotEmpty(businessTypes) && firstLevelDict != null) {
|
|
|
+ // 解析二级分类dictId列表(business_types存储的是dictId字符串)
|
|
|
+ String[] typeDictIds = businessTypes.split(",");
|
|
|
+ List<String> typeDictIdList = new ArrayList<>();
|
|
|
+ for (String typeDictId : typeDictIds) {
|
|
|
+ if (StringUtils.isNotEmpty(typeDictId.trim())) {
|
|
|
+ typeDictIdList.add(typeDictId.trim());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ // 查询二级分类,需要满足:
|
|
|
+ // 1. dict_id 在门店配置的经营种类dictId列表中
|
|
|
+ // 2. type_name = "business_type"
|
|
|
+ // 3. parent_id = 一级分类的id(不是dictId)
|
|
|
+ if (!typeDictIdList.isEmpty() && firstLevelDict != null) {
|
|
|
+ LambdaQueryWrapper<StoreDictionary> secondLevelWrapper = new LambdaQueryWrapper<>();
|
|
|
+ secondLevelWrapper.in(StoreDictionary::getDictId, typeDictIdList);
|
|
|
+ secondLevelWrapper.eq(StoreDictionary::getTypeName, "business_type");
|
|
|
+ secondLevelWrapper.eq(StoreDictionary::getParentId, firstLevelDict.getId());
|
|
|
+ secondLevelWrapper.eq(StoreDictionary::getDeleteFlag, 0);
|
|
|
+// secondLevelWrapper.orderByAsc(StoreDictionary::getSortId);
|
|
|
+ secondLevelDicts = storeDictionaryMapper.selectList(secondLevelWrapper);
|
|
|
+ allDicts.addAll(secondLevelDicts);
|
|
|
+ log.debug("查询到二级分类数量: {}, dictIds={}", secondLevelDicts.size(), typeDictIdList);
|
|
|
+ } else {
|
|
|
+ log.warn("无法查询二级分类: typeDictIdList为空或一级分类不存在, typeDictIdList={}, firstLevelDict={}",
|
|
|
+ typeDictIdList, firstLevelDict != null ? firstLevelDict.getId() : null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. 查询三级分类(business_classify - 根据门店表里的business_classify字段,存储的是dictId)
|
|
|
+ if (!secondLevelDicts.isEmpty() && StringUtils.isNotEmpty(businessClassify)) {
|
|
|
+ // 解析三级分类dictId列表(business_classify存储的是dictId字符串)
|
|
|
+ String[] classifyDictIds = businessClassify.split(",");
|
|
|
+ List<String> classifyDictIdList = new ArrayList<>();
|
|
|
+ for (String classifyDictId : classifyDictIds) {
|
|
|
+ if (StringUtils.isNotEmpty(classifyDictId.trim())) {
|
|
|
+ classifyDictIdList.add(classifyDictId.trim());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询三级分类,需要满足:
|
|
|
+ // 1. dict_id 在门店配置的分类dictId列表中
|
|
|
+ // 2. parent_id 在二级分类的id列表中(不是dictId)
|
|
|
+ // 3. type_name = "business_classify"
|
|
|
+ if (!classifyDictIdList.isEmpty() && !secondLevelDicts.isEmpty()) {
|
|
|
+ Set<Integer> secondLevelIds = secondLevelDicts.stream()
|
|
|
+ .map(StoreDictionary::getId)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ List<StoreDictionary> thirdLevelDicts = storeDictionaryMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<StoreDictionary>()
|
|
|
+ .in(StoreDictionary::getDictId, classifyDictIdList)
|
|
|
+ .in(StoreDictionary::getParentId, secondLevelIds)
|
|
|
+ .eq(StoreDictionary::getTypeName, "business_classify")
|
|
|
+ .eq(StoreDictionary::getDeleteFlag, 0)
|
|
|
+// .orderByAsc(StoreDictionary::getSortId)
|
|
|
+ );
|
|
|
+ allDicts.addAll(thirdLevelDicts);
|
|
|
+ log.debug("查询到三级分类数量: {}, dictIds={}, parentIds={}",
|
|
|
+ thirdLevelDicts.size(), classifyDictIdList, secondLevelIds);
|
|
|
+ } else {
|
|
|
+ log.warn("无法查询三级分类: classifyDictIdList为空或二级分类为空, classifyDictIdList={}, secondLevelDicts.size={}",
|
|
|
+ classifyDictIdList, secondLevelDicts.size());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 6. 构建树形结构(根据parent_id关系组装)
|
|
|
+ List<StoreDictionary> treeStructure = buildTreeOptimized(allDicts);
|
|
|
+
|
|
|
+ // 7. 构建返回对象
|
|
|
+ StoreThreeLevelStructureVo vo = new StoreThreeLevelStructureVo();
|
|
|
+ vo.setStoreId(storeInfo.getId());
|
|
|
+ vo.setStoreName(storeInfo.getStoreName());
|
|
|
+ vo.setThreeLevelStructure(treeStructure);
|
|
|
+
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
|
|
|
}
|