|
|
@@ -59,6 +59,8 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
|
|
|
private final StoreEvaluationMapper storeEvaluationMapper;
|
|
|
private final StoreCommentAppealMapper storeCommentAppealMapper;
|
|
|
private final StorePriceMapper storePriceMapper;
|
|
|
+ private final StoreCuisineMapper storeCuisineMapper;
|
|
|
+ private final StoreInfoMapper storeInfoMapper;
|
|
|
private final StoreUserMapper storeUserMapper;
|
|
|
private final StoreOperationalStatisticsHistoryMapper statisticsHistoryMapper;
|
|
|
private final StoreTrackStatisticsMapper storeTrackStatisticsMapper;
|
|
|
@@ -115,7 +117,7 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
|
|
|
}
|
|
|
|
|
|
// 聚合统计数据(优先取结束日期的数据,只累加新增访客数)
|
|
|
- return aggregateStatistics(statisticsList, endDate);
|
|
|
+ return aggregateStatistics(statisticsList, endDate, storeId);
|
|
|
|
|
|
} catch (ParseException e) {
|
|
|
log.error("StoreOperationalStatisticsServiceImpl.calculateStatistics - 时间解析错误", e);
|
|
|
@@ -132,8 +134,9 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
|
|
|
*
|
|
|
* @param statisticsList 统计数据列表
|
|
|
* @param endDate 结束日期(用于优先选择该日期的数据)
|
|
|
+ * @param storeId 店铺ID
|
|
|
*/
|
|
|
- private StoreOperationalStatisticsVo aggregateStatistics(List<StoreTrackStatistics> statisticsList, Date endDate) {
|
|
|
+ private StoreOperationalStatisticsVo aggregateStatistics(List<StoreTrackStatistics> statisticsList, Date endDate, Integer storeId) {
|
|
|
StoreOperationalStatisticsVo result = new StoreOperationalStatisticsVo();
|
|
|
|
|
|
// 优先查找结束日期的数据(比较日期部分,忽略时间)
|
|
|
@@ -247,7 +250,7 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
|
|
|
}
|
|
|
|
|
|
if (latestStat.getPriceRankingData() != null && !latestStat.getPriceRankingData().isEmpty()) {
|
|
|
- result.setPriceListRanking(convertToPriceListRankingVoFromJson(latestStat.getPriceRankingData()));
|
|
|
+ result.setPriceListRanking(convertToPriceListRankingVoFromJson(latestStat.getPriceRankingData(), storeId));
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
@@ -292,7 +295,7 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
|
|
|
comparison.setCouponData(buildCouponDataComparison(currentStatistics.getCouponData(), previousStatistics.getCouponData()));
|
|
|
comparison.setVoucherData(buildVoucherDataComparison(currentStatistics.getVoucherData(), previousStatistics.getVoucherData()));
|
|
|
comparison.setServiceQualityData(buildServiceQualityDataComparison(currentStatistics.getServiceQualityData(), previousStatistics.getServiceQualityData()));
|
|
|
- comparison.setPriceListRanking(buildPriceListRankingComparison(currentStatistics.getPriceListRanking(), previousStatistics.getPriceListRanking()));
|
|
|
+ comparison.setPriceListRanking(buildPriceListRankingComparison(currentStatistics.getPriceListRanking(), previousStatistics.getPriceListRanking(), storeId));
|
|
|
|
|
|
// 保存历史记录(不包含PDF URL,PDF URL只在 generateStatisticsComparisonPdf 接口中保存)
|
|
|
Integer historyId = saveStatisticsHistory(storeId, currentStartTime, currentEndTime,
|
|
|
@@ -889,7 +892,7 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
|
|
|
* 构建价目表排名数据对比
|
|
|
*/
|
|
|
private List<StoreOperationalStatisticsComparisonVo.PriceListRankingComparison> buildPriceListRankingComparison(
|
|
|
- List<StoreOperationalStatisticsVo.PriceListRanking> current, List<StoreOperationalStatisticsVo.PriceListRanking> previous) {
|
|
|
+ List<StoreOperationalStatisticsVo.PriceListRanking> current, List<StoreOperationalStatisticsVo.PriceListRanking> previous, Integer storeId) {
|
|
|
List<StoreOperationalStatisticsComparisonVo.PriceListRankingComparison> result = new ArrayList<>();
|
|
|
|
|
|
// 如果当期数据为空,返回空列表
|
|
|
@@ -919,16 +922,32 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 批量查询价目表名称
|
|
|
+ // 批量查询价目表名称(根据business_section判断查询美食价目表还是通用价目表)
|
|
|
Map<Integer, String> priceNameMap = new HashMap<>();
|
|
|
- if (!needQueryPriceIds.isEmpty()) {
|
|
|
- LambdaQueryWrapper<StorePrice> priceWrapper = new LambdaQueryWrapper<>();
|
|
|
- priceWrapper.in(StorePrice::getId, needQueryPriceIds)
|
|
|
- .eq(StorePrice::getDeleteFlag, 0);
|
|
|
- List<StorePrice> prices = storePriceMapper.selectList(priceWrapper);
|
|
|
- for (StorePrice price : prices) {
|
|
|
- if (price.getId() != null && price.getName() != null) {
|
|
|
- priceNameMap.put(price.getId(), price.getName());
|
|
|
+ if (!needQueryPriceIds.isEmpty() && storeId != null) {
|
|
|
+ // 查询店铺信息,获取business_section
|
|
|
+ StoreInfo storeInfo = storeInfoMapper.selectById(storeId);
|
|
|
+ if (storeInfo != null && storeInfo.getBusinessSection() != null && storeInfo.getBusinessSection() == 1) {
|
|
|
+ // business_section = 1 表示美食,查询美食价目表
|
|
|
+ LambdaQueryWrapper<StoreCuisine> cuisineWrapper = new LambdaQueryWrapper<>();
|
|
|
+ cuisineWrapper.in(StoreCuisine::getId, needQueryPriceIds)
|
|
|
+ .eq(StoreCuisine::getDeleteFlag, 0);
|
|
|
+ List<StoreCuisine> cuisines = storeCuisineMapper.selectList(cuisineWrapper);
|
|
|
+ for (StoreCuisine cuisine : cuisines) {
|
|
|
+ if (cuisine.getId() != null && cuisine.getName() != null) {
|
|
|
+ priceNameMap.put(cuisine.getId(), cuisine.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 其他情况查询通用价目表
|
|
|
+ LambdaQueryWrapper<StorePrice> priceWrapper = new LambdaQueryWrapper<>();
|
|
|
+ priceWrapper.in(StorePrice::getId, needQueryPriceIds)
|
|
|
+ .eq(StorePrice::getDeleteFlag, 0);
|
|
|
+ List<StorePrice> prices = storePriceMapper.selectList(priceWrapper);
|
|
|
+ for (StorePrice price : prices) {
|
|
|
+ if (price.getId() != null && price.getName() != null) {
|
|
|
+ priceNameMap.put(price.getId(), price.getName());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1668,7 +1687,7 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
|
|
|
/**
|
|
|
* 转换为价目表排名数据VO
|
|
|
*/
|
|
|
- private List<StoreOperationalStatisticsVo.PriceListRanking> convertToPriceListRankingVo(Map<Integer, Map<String, Long>> accumulator) {
|
|
|
+ private List<StoreOperationalStatisticsVo.PriceListRanking> convertToPriceListRankingVo(Map<Integer, Map<String, Long>> accumulator, Integer storeId) {
|
|
|
List<StoreOperationalStatisticsVo.PriceListRanking> result = new ArrayList<>();
|
|
|
|
|
|
// 如果累加器为空,直接返回
|
|
|
@@ -1676,17 +1695,33 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- // 批量查询价目表名称
|
|
|
+ // 批量查询价目表名称(根据business_section判断查询美食价目表还是通用价目表)
|
|
|
List<Integer> priceIds = new ArrayList<>(accumulator.keySet());
|
|
|
Map<Integer, String> priceNameMap = new HashMap<>();
|
|
|
- if (!priceIds.isEmpty()) {
|
|
|
- LambdaQueryWrapper<StorePrice> priceWrapper = new LambdaQueryWrapper<>();
|
|
|
- priceWrapper.in(StorePrice::getId, priceIds)
|
|
|
- .eq(StorePrice::getDeleteFlag, 0);
|
|
|
- List<StorePrice> prices = storePriceMapper.selectList(priceWrapper);
|
|
|
- for (StorePrice price : prices) {
|
|
|
- if (price.getId() != null && price.getName() != null) {
|
|
|
- priceNameMap.put(price.getId(), price.getName());
|
|
|
+ if (!priceIds.isEmpty() && storeId != null) {
|
|
|
+ // 查询店铺信息,获取business_section
|
|
|
+ StoreInfo storeInfo = storeInfoMapper.selectById(storeId);
|
|
|
+ if (storeInfo != null && storeInfo.getBusinessSection() != null && storeInfo.getBusinessSection() == 1) {
|
|
|
+ // business_section = 1 表示美食,查询美食价目表
|
|
|
+ LambdaQueryWrapper<StoreCuisine> cuisineWrapper = new LambdaQueryWrapper<>();
|
|
|
+ cuisineWrapper.in(StoreCuisine::getId, priceIds)
|
|
|
+ .eq(StoreCuisine::getDeleteFlag, 0);
|
|
|
+ List<StoreCuisine> cuisines = storeCuisineMapper.selectList(cuisineWrapper);
|
|
|
+ for (StoreCuisine cuisine : cuisines) {
|
|
|
+ if (cuisine.getId() != null && cuisine.getName() != null) {
|
|
|
+ priceNameMap.put(cuisine.getId(), cuisine.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 其他情况查询通用价目表
|
|
|
+ LambdaQueryWrapper<StorePrice> priceWrapper = new LambdaQueryWrapper<>();
|
|
|
+ priceWrapper.in(StorePrice::getId, priceIds)
|
|
|
+ .eq(StorePrice::getDeleteFlag, 0);
|
|
|
+ List<StorePrice> prices = storePriceMapper.selectList(priceWrapper);
|
|
|
+ for (StorePrice price : prices) {
|
|
|
+ if (price.getId() != null && price.getName() != null) {
|
|
|
+ priceNameMap.put(price.getId(), price.getName());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2129,7 +2164,7 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
|
|
|
* 从JSON字符串转换为价目表排名数据VO
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
- private List<StoreOperationalStatisticsVo.PriceListRanking> convertToPriceListRankingVoFromJson(String priceRankingDataJson) {
|
|
|
+ private List<StoreOperationalStatisticsVo.PriceListRanking> convertToPriceListRankingVoFromJson(String priceRankingDataJson, Integer storeId) {
|
|
|
List<StoreOperationalStatisticsVo.PriceListRanking> result = new ArrayList<>();
|
|
|
|
|
|
try {
|
|
|
@@ -2148,14 +2183,30 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
|
|
|
}
|
|
|
|
|
|
Map<Integer, String> priceNameMap = new HashMap<>();
|
|
|
- if (!priceIds.isEmpty()) {
|
|
|
- LambdaQueryWrapper<StorePrice> priceWrapper = new LambdaQueryWrapper<>();
|
|
|
- priceWrapper.in(StorePrice::getId, priceIds)
|
|
|
- .eq(StorePrice::getDeleteFlag, 0);
|
|
|
- List<StorePrice> prices = storePriceMapper.selectList(priceWrapper);
|
|
|
- for (StorePrice price : prices) {
|
|
|
- if (price.getId() != null && price.getName() != null) {
|
|
|
- priceNameMap.put(price.getId(), price.getName());
|
|
|
+ if (!priceIds.isEmpty() && storeId != null) {
|
|
|
+ // 查询店铺信息,获取business_section
|
|
|
+ StoreInfo storeInfo = storeInfoMapper.selectById(storeId);
|
|
|
+ if (storeInfo != null && storeInfo.getBusinessSection() != null && storeInfo.getBusinessSection() == 1) {
|
|
|
+ // business_section = 1 表示美食,查询美食价目表
|
|
|
+ LambdaQueryWrapper<StoreCuisine> cuisineWrapper = new LambdaQueryWrapper<>();
|
|
|
+ cuisineWrapper.in(StoreCuisine::getId, priceIds)
|
|
|
+ .eq(StoreCuisine::getDeleteFlag, 0);
|
|
|
+ List<StoreCuisine> cuisines = storeCuisineMapper.selectList(cuisineWrapper);
|
|
|
+ for (StoreCuisine cuisine : cuisines) {
|
|
|
+ if (cuisine.getId() != null && cuisine.getName() != null) {
|
|
|
+ priceNameMap.put(cuisine.getId(), cuisine.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 其他情况查询通用价目表
|
|
|
+ LambdaQueryWrapper<StorePrice> priceWrapper = new LambdaQueryWrapper<>();
|
|
|
+ priceWrapper.in(StorePrice::getId, priceIds)
|
|
|
+ .eq(StorePrice::getDeleteFlag, 0);
|
|
|
+ List<StorePrice> prices = storePriceMapper.selectList(priceWrapper);
|
|
|
+ for (StorePrice price : prices) {
|
|
|
+ if (price.getId() != null && price.getName() != null) {
|
|
|
+ priceNameMap.put(price.getId(), price.getName());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2270,7 +2321,7 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
|
|
|
comparison.setCouponData(buildCouponDataComparison(currentStatistics.getCouponData(), previousStatistics.getCouponData()));
|
|
|
comparison.setVoucherData(buildVoucherDataComparison(currentStatistics.getVoucherData(), previousStatistics.getVoucherData()));
|
|
|
comparison.setServiceQualityData(buildServiceQualityDataComparison(currentStatistics.getServiceQualityData(), previousStatistics.getServiceQualityData()));
|
|
|
- comparison.setPriceListRanking(buildPriceListRankingComparison(currentStatistics.getPriceListRanking(), previousStatistics.getPriceListRanking()));
|
|
|
+ comparison.setPriceListRanking(buildPriceListRankingComparison(currentStatistics.getPriceListRanking(), previousStatistics.getPriceListRanking(), storeId));
|
|
|
|
|
|
// 不保存历史记录,由调用方决定是否保存
|
|
|
|