|
@@ -13,6 +13,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import shop.alien.entity.store.FitnessEquipmentInfo;
|
|
import shop.alien.entity.store.FitnessEquipmentInfo;
|
|
|
import shop.alien.entity.store.SportsEquipmentFacility;
|
|
import shop.alien.entity.store.SportsEquipmentFacility;
|
|
|
|
|
+import shop.alien.entity.store.SportsFacilityArea;
|
|
|
import shop.alien.entity.store.StoreImg;
|
|
import shop.alien.entity.store.StoreImg;
|
|
|
import shop.alien.entity.store.vo.FitnessEquipmentCategoryDetailVo;
|
|
import shop.alien.entity.store.vo.FitnessEquipmentCategoryDetailVo;
|
|
|
import shop.alien.entity.store.vo.FitnessEquipmentTypeSummaryVo;
|
|
import shop.alien.entity.store.vo.FitnessEquipmentTypeSummaryVo;
|
|
@@ -20,6 +21,7 @@ import shop.alien.entity.store.vo.SportsEquipmentFacilityCategorySummaryVo;
|
|
|
import shop.alien.entity.store.vo.SportsEquipmentFacilityCategoryVo;
|
|
import shop.alien.entity.store.vo.SportsEquipmentFacilityCategoryVo;
|
|
|
import shop.alien.entity.store.vo.SportsEquipmentFacilityVo;
|
|
import shop.alien.entity.store.vo.SportsEquipmentFacilityVo;
|
|
|
import shop.alien.mapper.SportsEquipmentFacilityMapper;
|
|
import shop.alien.mapper.SportsEquipmentFacilityMapper;
|
|
|
|
|
+import shop.alien.mapper.SportsFacilityAreaMapper;
|
|
|
import shop.alien.mapper.StoreImgMapper;
|
|
import shop.alien.mapper.StoreImgMapper;
|
|
|
import shop.alien.store.service.FitnessEquipmentInfoService;
|
|
import shop.alien.store.service.FitnessEquipmentInfoService;
|
|
|
import shop.alien.store.service.SportsEquipmentFacilityService;
|
|
import shop.alien.store.service.SportsEquipmentFacilityService;
|
|
@@ -42,6 +44,7 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
|
|
|
implements SportsEquipmentFacilityService {
|
|
implements SportsEquipmentFacilityService {
|
|
|
|
|
|
|
|
private final SportsEquipmentFacilityMapper facilityMapper;
|
|
private final SportsEquipmentFacilityMapper facilityMapper;
|
|
|
|
|
+ private final SportsFacilityAreaMapper sportsFacilityAreaMapper;
|
|
|
private final StoreImgMapper storeImgMapper;
|
|
private final StoreImgMapper storeImgMapper;
|
|
|
private final FitnessEquipmentInfoService fitnessEquipmentInfoService;
|
|
private final FitnessEquipmentInfoService fitnessEquipmentInfoService;
|
|
|
|
|
|
|
@@ -199,9 +202,10 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询指定店铺按分类汇总的设备信息(用户端)
|
|
* 查询指定店铺按分类汇总的设备信息(用户端)
|
|
|
- * 包含每个分类的设备数量、图片列表和设备列表
|
|
|
|
|
- * 通过fitnessEquipmentIds关联FitnessEquipmentInfo信息
|
|
|
|
|
- * 按facility_category_name分组查询,支持商户自定义分类名称
|
|
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * 从sports_facility_area表获取区域列表,通过area_id关联sports_equipment_facility,
|
|
|
|
|
+ * 再通过fitness_equipment_ids关联fitness_equipment_info获取设备信息
|
|
|
|
|
+ * </p>
|
|
|
*
|
|
*
|
|
|
* @param storeId 门店ID,不能为空且必须大于0
|
|
* @param storeId 门店ID,不能为空且必须大于0
|
|
|
* @return 分类汇总列表,不会返回null
|
|
* @return 分类汇总列表,不会返回null
|
|
@@ -219,24 +223,23 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
|
|
|
try {
|
|
try {
|
|
|
List<SportsEquipmentFacilityCategorySummaryVo> result = new ArrayList<>();
|
|
List<SportsEquipmentFacilityCategorySummaryVo> result = new ArrayList<>();
|
|
|
|
|
|
|
|
- // 查询该店铺下所有不同的设施分类名称(专门用于categorySummary)
|
|
|
|
|
- List<String> categoryNameList = queryDistinctCategoryNamesForCategorySummary(storeId);
|
|
|
|
|
|
|
+ // 1. 从sports_facility_area表查询该店铺下的所有区域
|
|
|
|
|
+ List<SportsFacilityArea> areaList = queryAreaListByStoreId(storeId);
|
|
|
|
|
|
|
|
- if (CollectionUtils.isEmpty(categoryNameList)) {
|
|
|
|
|
- log.info("查询指定店铺按分类汇总的设备信息完成,storeId={},未找到分类数据", storeId);
|
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(areaList)) {
|
|
|
|
|
+ log.info("查询指定店铺按分类汇总的设备信息完成,storeId={},未找到区域数据", storeId);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 按分类名称分组查询
|
|
|
|
|
- for (String categoryName : categoryNameList) {
|
|
|
|
|
- SportsEquipmentFacilityCategorySummaryVo categoryVo = buildCategorySummaryVoByCategoryNameForCategorySummary(
|
|
|
|
|
- storeId, categoryName);
|
|
|
|
|
- // 只添加有设备数据的分类
|
|
|
|
|
|
|
+ // 2. 按区域分组查询设备信息
|
|
|
|
|
+ for (SportsFacilityArea area : areaList) {
|
|
|
|
|
+ SportsEquipmentFacilityCategorySummaryVo categoryVo = buildCategorySummaryVoByArea(
|
|
|
|
|
+ storeId, area);
|
|
|
|
|
+ // 添加所有区域,包括没有设备的区域
|
|
|
result.add(categoryVo);
|
|
result.add(categoryVo);
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- log.info("查询指定店铺按分类汇总的设备信息完成,storeId={},分类数量:{}", storeId, result.size());
|
|
|
|
|
|
|
+ log.info("查询指定店铺按分类汇总的设备信息完成,storeId={},区域数量:{}", storeId, result.size());
|
|
|
return result;
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("查询指定店铺按分类汇总的设备信息异常,storeId={},异常信息:{}", storeId, e.getMessage(), e);
|
|
log.error("查询指定店铺按分类汇总的设备信息异常,storeId={},异常信息:{}", storeId, e.getMessage(), e);
|
|
@@ -245,83 +248,75 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 查询指定店铺下所有不同的设施分类名称(专门用于categorySummary接口,不与其他接口共用)
|
|
|
|
|
|
|
+ * 根据门店ID查询区域列表(专门用于categorySummary接口)
|
|
|
*
|
|
*
|
|
|
* @param storeId 门店ID
|
|
* @param storeId 门店ID
|
|
|
- * @return 分类名称列表,不会返回null
|
|
|
|
|
|
|
+ * @return 区域列表,按sort_order升序,相同排序号按创建时间降序,不会返回null
|
|
|
*/
|
|
*/
|
|
|
- private List<String> queryDistinctCategoryNamesForCategorySummary(Integer storeId) {
|
|
|
|
|
|
|
+ private List<SportsFacilityArea> queryAreaListByStoreId(Integer storeId) {
|
|
|
try {
|
|
try {
|
|
|
- LambdaQueryWrapper<SportsEquipmentFacility> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- queryWrapper.eq(SportsEquipmentFacility::getStoreId, storeId)
|
|
|
|
|
- .eq(SportsEquipmentFacility::getDeleteFlag, DELETE_FLAG_NOT_DELETED)
|
|
|
|
|
- .isNotNull(SportsEquipmentFacility::getFacilityCategoryName)
|
|
|
|
|
- .ne(SportsEquipmentFacility::getFacilityCategoryName, "");
|
|
|
|
|
|
|
+ LambdaQueryWrapper<SportsFacilityArea> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq(SportsFacilityArea::getStoreId, storeId)
|
|
|
|
|
+ .eq(SportsFacilityArea::getDeleteFlag, DELETE_FLAG_NOT_DELETED)
|
|
|
|
|
+ .orderByAsc(SportsFacilityArea::getSortOrder)
|
|
|
|
|
+ .orderByDesc(SportsFacilityArea::getCreatedTime);
|
|
|
|
|
|
|
|
- List<SportsEquipmentFacility> facilityList = facilityMapper.selectList(queryWrapper);
|
|
|
|
|
|
|
+ List<SportsFacilityArea> areaList = sportsFacilityAreaMapper.selectList(queryWrapper);
|
|
|
|
|
|
|
|
- if (CollectionUtils.isEmpty(facilityList)) {
|
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(areaList)) {
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 提取所有不同的分类名称并排序
|
|
|
|
|
- return facilityList.stream()
|
|
|
|
|
- .map(SportsEquipmentFacility::getFacilityCategoryName)
|
|
|
|
|
- .filter(StringUtils::isNotBlank)
|
|
|
|
|
- .distinct()
|
|
|
|
|
- .sorted()
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
|
|
+ return areaList;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.error("查询设施分类名称列表异常(categorySummary专用),storeId={},异常信息:{}", storeId, e.getMessage(), e);
|
|
|
|
|
|
|
+ log.error("查询区域列表异常(categorySummary专用),storeId={},异常信息:{}", storeId, e.getMessage(), e);
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 根据分类名称构建分类汇总VO对象(专门用于categorySummary接口,不与其他接口共用)
|
|
|
|
|
|
|
+ * 根据区域构建分类汇总VO对象(专门用于categorySummary接口)
|
|
|
*
|
|
*
|
|
|
- * @param storeId 门店ID
|
|
|
|
|
- * @param categoryName 分类名称
|
|
|
|
|
|
|
+ * @param storeId 门店ID
|
|
|
|
|
+ * @param area 区域对象
|
|
|
* @return 分类汇总VO对象
|
|
* @return 分类汇总VO对象
|
|
|
*/
|
|
*/
|
|
|
- private SportsEquipmentFacilityCategorySummaryVo buildCategorySummaryVoByCategoryNameForCategorySummary(Integer storeId, String categoryName) {
|
|
|
|
|
|
|
+ private SportsEquipmentFacilityCategorySummaryVo buildCategorySummaryVoByArea(Integer storeId, SportsFacilityArea area) {
|
|
|
SportsEquipmentFacilityCategorySummaryVo categoryVo = new SportsEquipmentFacilityCategorySummaryVo();
|
|
SportsEquipmentFacilityCategorySummaryVo categoryVo = new SportsEquipmentFacilityCategorySummaryVo();
|
|
|
categoryVo.setStoreId(storeId);
|
|
categoryVo.setStoreId(storeId);
|
|
|
- categoryVo.setFacilityCategoryName(categoryName);
|
|
|
|
|
|
|
+ categoryVo.setFacilityCategoryName(area.getAreaName());
|
|
|
|
|
|
|
|
- // 查询该分类名称下的设备列表(专门用于categorySummary)
|
|
|
|
|
- List<SportsEquipmentFacility> facilityList = queryFacilityListByCategoryNameForCategorySummary(storeId, categoryName);
|
|
|
|
|
|
|
+ // 1. 通过area_id查询sports_equipment_facility表中的设备列表
|
|
|
|
|
+ List<SportsEquipmentFacility> facilityList = queryFacilityListByAreaId(storeId, area.getId());
|
|
|
|
|
|
|
|
- // 收集并解析fitnessEquipmentIds(专门用于categorySummary)
|
|
|
|
|
|
|
+ // 2. 收集并解析fitnessEquipmentIds
|
|
|
List<Integer> fitnessEquipmentIdList = collectFitnessEquipmentIdsForCategorySummary(facilityList, storeId);
|
|
List<Integer> fitnessEquipmentIdList = collectFitnessEquipmentIdsForCategorySummary(facilityList, storeId);
|
|
|
|
|
|
|
|
- // 查询FitnessEquipmentInfo列表(专门用于categorySummary)
|
|
|
|
|
|
|
+ // 3. 通过fitness_equipment_ids关联查询fitness_equipment_info设备记录
|
|
|
List<FitnessEquipmentInfo> fitnessEquipmentInfoList = queryFitnessEquipmentInfoListForCategorySummary(fitnessEquipmentIdList, storeId);
|
|
List<FitnessEquipmentInfo> fitnessEquipmentInfoList = queryFitnessEquipmentInfoListForCategorySummary(fitnessEquipmentIdList, storeId);
|
|
|
|
|
|
|
|
- // 设置设备列表
|
|
|
|
|
|
|
+ // 4. 设置设备列表
|
|
|
categoryVo.setFacilityList(fitnessEquipmentInfoList);
|
|
categoryVo.setFacilityList(fitnessEquipmentInfoList);
|
|
|
categoryVo.setFacilityCount(fitnessEquipmentInfoList.size());
|
|
categoryVo.setFacilityCount(fitnessEquipmentInfoList.size());
|
|
|
|
|
|
|
|
- // 查询并设置图片列表(专门用于categorySummary)
|
|
|
|
|
- // 兼容处理:图片存储时business_id存储的是facility_category编号
|
|
|
|
|
- // 需要从该分类名称下的设备中获取facility_category值来查询图片
|
|
|
|
|
- List<String> imageList = queryCategoryImageListByCategoryNameForCategorySummary(storeId, categoryName, facilityList);
|
|
|
|
|
|
|
+ // 5. 查询并设置图片列表(根据区域ID查询)
|
|
|
|
|
+ List<String> imageList = queryCategoryImageListByAreaId(storeId, area.getId());
|
|
|
categoryVo.setImageList(imageList);
|
|
categoryVo.setImageList(imageList);
|
|
|
|
|
|
|
|
return categoryVo;
|
|
return categoryVo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 根据分类名称查询设备列表(专门用于categorySummary接口,不与其他接口共用)
|
|
|
|
|
|
|
+ * 根据区域ID查询设备列表(专门用于categorySummary接口)
|
|
|
*
|
|
*
|
|
|
- * @param storeId 门店ID
|
|
|
|
|
- * @param categoryName 分类名称
|
|
|
|
|
|
|
+ * @param storeId 门店ID
|
|
|
|
|
+ * @param areaId 区域ID
|
|
|
* @return 设备列表
|
|
* @return 设备列表
|
|
|
*/
|
|
*/
|
|
|
- private List<SportsEquipmentFacility> queryFacilityListByCategoryNameForCategorySummary(Integer storeId, String categoryName) {
|
|
|
|
|
|
|
+ private List<SportsEquipmentFacility> queryFacilityListByAreaId(Integer storeId, Integer areaId) {
|
|
|
LambdaQueryWrapper<SportsEquipmentFacility> facilityWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<SportsEquipmentFacility> facilityWrapper = new LambdaQueryWrapper<>();
|
|
|
facilityWrapper.eq(SportsEquipmentFacility::getStoreId, storeId)
|
|
facilityWrapper.eq(SportsEquipmentFacility::getStoreId, storeId)
|
|
|
- .eq(SportsEquipmentFacility::getFacilityCategoryName, categoryName)
|
|
|
|
|
|
|
+ .eq(SportsEquipmentFacility::getAreaId, areaId)
|
|
|
.eq(SportsEquipmentFacility::getDeleteFlag, DELETE_FLAG_NOT_DELETED)
|
|
.eq(SportsEquipmentFacility::getDeleteFlag, DELETE_FLAG_NOT_DELETED)
|
|
|
.orderByDesc(SportsEquipmentFacility::getCreatedTime);
|
|
.orderByDesc(SportsEquipmentFacility::getCreatedTime);
|
|
|
return facilityMapper.selectList(facilityWrapper);
|
|
return facilityMapper.selectList(facilityWrapper);
|
|
@@ -426,33 +421,19 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 根据分类名称查询图片列表(专门用于categorySummary接口,不与其他接口共用)
|
|
|
|
|
- * 兼容处理:图片存储时business_id存储的是facility_category编号
|
|
|
|
|
- * 需要从该分类名称下的设备中获取facility_category值来查询图片
|
|
|
|
|
|
|
+ * 根据区域ID查询图片列表(专门用于categorySummary接口)
|
|
|
|
|
+ * 图片存储时business_id存储的是区域ID(area_id)
|
|
|
*
|
|
*
|
|
|
- * @param storeId 门店ID
|
|
|
|
|
- * @param categoryName 分类名称
|
|
|
|
|
- * @param facilityList 该分类下的设备列表
|
|
|
|
|
|
|
+ * @param storeId 门店ID
|
|
|
|
|
+ * @param areaId 区域ID
|
|
|
* @return 图片URL列表
|
|
* @return 图片URL列表
|
|
|
*/
|
|
*/
|
|
|
- private List<String> queryCategoryImageListByCategoryNameForCategorySummary(Integer storeId, String categoryName,
|
|
|
|
|
- List<SportsEquipmentFacility> facilityList) {
|
|
|
|
|
|
|
+ private List<String> queryCategoryImageListByAreaId(Integer storeId, Integer areaId) {
|
|
|
try {
|
|
try {
|
|
|
- // 从设备列表中获取所有不同的facility_category值
|
|
|
|
|
- List<Integer> categoryIdList = facilityList.stream()
|
|
|
|
|
- .map(SportsEquipmentFacility::getFacilityCategory)
|
|
|
|
|
- .filter(category -> category != null && category > 0)
|
|
|
|
|
- .distinct()
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
-
|
|
|
|
|
- if (CollectionUtils.isEmpty(categoryIdList)) {
|
|
|
|
|
- return new ArrayList<>();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 查询所有相关分类的图片
|
|
|
|
|
|
|
+ // 查询该区域下的图片
|
|
|
LambdaQueryWrapper<StoreImg> imageWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<StoreImg> imageWrapper = new LambdaQueryWrapper<>();
|
|
|
imageWrapper.eq(StoreImg::getStoreId, storeId)
|
|
imageWrapper.eq(StoreImg::getStoreId, storeId)
|
|
|
- .in(StoreImg::getBusinessId, categoryIdList)
|
|
|
|
|
|
|
+ .eq(StoreImg::getBusinessId, areaId)
|
|
|
.eq(StoreImg::getImgType, IMG_TYPE_SPORTS_EQUIPMENT)
|
|
.eq(StoreImg::getImgType, IMG_TYPE_SPORTS_EQUIPMENT)
|
|
|
.orderByAsc(StoreImg::getImgSort);
|
|
.orderByAsc(StoreImg::getImgSort);
|
|
|
|
|
|
|
@@ -467,8 +448,8 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
|
|
|
.distinct()
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.error("查询分类图片列表异常(categorySummary专用),storeId={},categoryName={},异常信息:{}",
|
|
|
|
|
- storeId, categoryName, e.getMessage(), e);
|
|
|
|
|
|
|
+ log.error("查询区域图片列表异常(categorySummary专用),storeId={},areaId={},异常信息:{}",
|
|
|
|
|
+ storeId, areaId, e.getMessage(), e);
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|