|
|
@@ -35,6 +35,7 @@ import shop.alien.mapper.*;
|
|
|
import shop.alien.store.config.BaseRedisService;
|
|
|
import shop.alien.store.config.GaoDeMapUtil;
|
|
|
import shop.alien.store.service.NearMeService;
|
|
|
+import shop.alien.store.service.StoreClockInService;
|
|
|
import shop.alien.store.service.StoreInfoService;
|
|
|
import shop.alien.store.util.FileUploadUtil;
|
|
|
import shop.alien.store.util.GroupConstant;
|
|
|
@@ -111,6 +112,8 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
|
|
|
private final LifeGroupBuyMainMapper lifeGroupBuyMainMapper;
|
|
|
|
|
|
+ private final StoreClockInService storeClockInService;
|
|
|
+
|
|
|
@Value("${spring.web.resources.excel-path}")
|
|
|
private String excelPath;
|
|
|
|
|
|
@@ -1388,7 +1391,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<StoreInfo> getScreeningNew(ScreeningOfEightMajorCategoriesVO vo) {
|
|
|
+ public IPage<StoreInfoVo> getScreeningNew(ScreeningOfEightMajorCategoriesVO vo) {
|
|
|
// 参数校验
|
|
|
if (vo == null) {
|
|
|
throw new IllegalArgumentException("筛选参数不能为空");
|
|
|
@@ -1409,7 +1412,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
throw new IllegalArgumentException("经纬度参数不能为空");
|
|
|
}
|
|
|
// 创建分页对象
|
|
|
- IPage<StoreInfo> page = new Page<>(vo.getPageNum(), vo.getPageSize());
|
|
|
+ IPage<StoreInfoVo> page = new Page<>(vo.getPageNum(), vo.getPageSize());
|
|
|
|
|
|
String storeId = "";
|
|
|
|
|
|
@@ -1429,8 +1432,8 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
}
|
|
|
|
|
|
// 通过商家id获取商家信息
|
|
|
- IPage<StoreInfo> storeInfoIPage = new Page<>();
|
|
|
- QueryWrapper<StoreInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ IPage<StoreInfoVo> storeInfoIPage = new Page<>();
|
|
|
+ QueryWrapper<StoreInfoVo> queryWrapper = new QueryWrapper<>();
|
|
|
if (StringUtils.isNotEmpty(storeId)) {
|
|
|
List<String> storeIds = Arrays.asList(storeId.split(","));
|
|
|
if (StringUtils.isNotEmpty(startTime) && StringUtils.isNotEmpty(endTime)) {
|
|
|
@@ -1473,12 +1476,13 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(storeIds)) {
|
|
|
- queryWrapper.in("id", storeIds);
|
|
|
+ queryWrapper.in("a.id", storeIds);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- queryWrapper.like(StringUtils.isNotEmpty(vo.getFoodType()), "business_types_name", vo.getFoodType());
|
|
|
- queryWrapper.like(StringUtils.isNotEmpty(vo.getStoreName()), "store_name", vo.getStoreName());
|
|
|
+ queryWrapper.eq("a.delete_flag",0);
|
|
|
+ queryWrapper.like(StringUtils.isNotEmpty(vo.getFoodType()), "a.business_types_name", vo.getFoodType());
|
|
|
+ queryWrapper.like(StringUtils.isNotEmpty(vo.getStoreName()), "a.store_name", vo.getStoreName());
|
|
|
|
|
|
if (ObjectUtils.isNotEmpty(vo.getRqyx())) {
|
|
|
if (vo.getRqyx() == 1) {
|
|
|
@@ -1486,7 +1490,107 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
}
|
|
|
}
|
|
|
queryWrapper.orderByAsc("dist");
|
|
|
- storeInfoIPage = storeInfoMapper.getPageForDistance(page, queryWrapper, lon + "," + lat);
|
|
|
+ storeInfoIPage = storeInfoMapper.getPageForDistance(page,lon + "," + lat, queryWrapper);
|
|
|
+ List<StoreInfoVo> storeInfoVoList = storeInfoIPage.getRecords();
|
|
|
+
|
|
|
+ // 提取所有符合条件的门店ID
|
|
|
+ List<Integer> storeIds = storeInfoVoList.stream().map(StoreInfoVo::getId).collect(Collectors.toList());
|
|
|
+ // 构建查询优惠券的条件对象
|
|
|
+ LambdaUpdateWrapper<LifeCoupon> quanWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ // 添加门店ID筛选条件
|
|
|
+ quanWrapper.in(LifeCoupon::getStoreId, storeIds)
|
|
|
+ // 添加优惠券状态筛选条件
|
|
|
+ .eq(LifeCoupon::getStatus, 1)
|
|
|
+ // 按照创建时间降序排序
|
|
|
+ .orderByDesc(LifeCoupon::getCreatedTime);
|
|
|
+ // 查询符合条件的优惠券列表
|
|
|
+ List<LifeCoupon> quanList = lifeCouponMapper.selectList(quanWrapper);
|
|
|
+ // 获取全部店铺的评分与平均花销
|
|
|
+ Map<Object, List<Map<String, Object>>> avgScoreMap = storeEvaluationMapper.allStoreAvgScore().stream().collect(Collectors.groupingBy(o -> o.get("store_id")));
|
|
|
+ // 获取用户订单信息,用于计算平均消费
|
|
|
+ Map<Object, List<Map<String, Object>>> avgPriceMap = lifeUserOrderMapper.allStoreAvgPrice().stream().collect(Collectors.groupingBy(o -> o.get("store_id")));
|
|
|
+ // 获取所有店铺的打卡次数
|
|
|
+ List<Map<Integer, Integer>> storeClockInCountList = storeClockInService.getStoreClockInCount();
|
|
|
+ // 遍历所有门店信息,构造返回结果
|
|
|
+ for (StoreInfoVo store : storeInfoVoList) {
|
|
|
+ Map<String, Object> storeMap = new HashMap<>();
|
|
|
+ storeMap.put("dist",store.getDist());
|
|
|
+ // 添加门店的业务状态及其描述
|
|
|
+ storeMap.put("businessStatus", store.getBusinessStatus());
|
|
|
+ storeMap.put("businessStatusStr", store.getBusinessStatusStr());
|
|
|
+ // 添加门店ID
|
|
|
+ storeMap.put("storeId", store.getId());
|
|
|
+ // 如果存在评分数据,则添加评分、平均消费及评价总数
|
|
|
+ if (avgScoreMap.containsKey(String.valueOf(store.getId()))) {
|
|
|
+ store.setAvgScore(avgScoreMap.get(String.valueOf(store.getId())).get(0).get("avg_score").toString());
|
|
|
+ store.setAvgPrice(avgPriceMap.get(String.valueOf(store.getId())).get(0).get("avg_price").toString());
|
|
|
+ store.setTotalNum(avgScoreMap.get(String.valueOf(store.getId())).get(0).get("total_num").toString());
|
|
|
+ /*storeMap.put("avgScore", avgScoreMap.get(String.valueOf(store.getId())).get(0).get("avg_score"));
|
|
|
+ storeMap.put("avgPrice", avgPriceMap.get(String.valueOf(store.getId())).get(0).get("avg_price"));
|
|
|
+ // 条数
|
|
|
+ storeMap.put("totalNum", avgScoreMap.get(String.valueOf(store.getId())).get(0).get("total_num"));*/
|
|
|
+ } else {
|
|
|
+ // 否则,设置默认值
|
|
|
+ /*storeMap.put("avgScore", 0);
|
|
|
+ storeMap.put("avgPrice", 0);
|
|
|
+ storeMap.put("totalNum", 0);*/
|
|
|
+ store.setAvgScore("0");
|
|
|
+ store.setAvgPrice("0");
|
|
|
+ store.setTotalNum("0");
|
|
|
+ }
|
|
|
+ // 添加门店名称
|
|
|
+ storeMap.put("storeName", store.getStoreName());
|
|
|
+ // 添加门店地址
|
|
|
+ storeMap.put("storeAddress", store.getStoreAddress());
|
|
|
+ // 添加门店类型
|
|
|
+ storeMap.put("storeType", store.getStoreType());
|
|
|
+ // 添加门店入口图片
|
|
|
+ storeMap.put("entranceImage", store.getEntranceImage());
|
|
|
+ // 添加门店图片
|
|
|
+ storeMap.put("storeImage", store.getImgUrl());
|
|
|
+ // 解析并添加门店经纬度
|
|
|
+ String[] position = store.getStorePosition().split(",");
|
|
|
+ storeMap.put("longitude", position.length == 2 ? position[0] : "");
|
|
|
+ storeMap.put("latitude", position.length == 2 ? position[1] : "");
|
|
|
+ // 构造该门店的优惠券列表
|
|
|
+ List<Map<String, Object>> quanMapList = new ArrayList<>();
|
|
|
+ if (!quanList.isEmpty()) {
|
|
|
+ for (LifeCoupon quan : quanList) {
|
|
|
+ // 如果优惠券的门店ID与当前门店ID匹配,则添加到优惠券列表中
|
|
|
+ if (store.getId().toString().equals(quan.getStoreId())) {
|
|
|
+ Map<String, Object> quanMap = new HashMap<>();
|
|
|
+ quanMap.put("quanType", quan.getType());
|
|
|
+ quanMap.put("name", quan.getName());
|
|
|
+ quanMap.put("price", quan.getPrice());
|
|
|
+ // 折扣价
|
|
|
+ quanMap.put("offprice", quan.getOffprice());
|
|
|
+ quanMap.put("quanId", quan.getId());
|
|
|
+ quanMapList.add(quanMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 将优惠券列表添加到门店信息中
|
|
|
+ storeMap.put("quanList", quanMapList);
|
|
|
+ store.setQuanList(quanMapList);
|
|
|
+ }
|
|
|
+ // 添加门店类型的描述
|
|
|
+ storeMap.put("storeTypeStr", store.getStoreTypeStr());
|
|
|
+ // 遍历打卡次数列表,找到当前门店的打卡次数并添加到门店信息中
|
|
|
+ storeClockInCountList.forEach(b -> {
|
|
|
+ Integer stId = b.get("storeId");
|
|
|
+ if (Objects.equals(stId, store.getId())) {
|
|
|
+ storeMap.put("storeClockInCount", b.get("count"));
|
|
|
+ store.setStoreClockInCount(String.valueOf(b.get("count")));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 如果未找到打卡次数,则设置为0
|
|
|
+ if (null == storeMap.get("storeClockInCount")) {
|
|
|
+ storeMap.put("storeClockInCount", 0);
|
|
|
+ store.setStoreClockInCount("0");
|
|
|
+ }
|
|
|
+ // 将当前门店的信息添加到返回结果列表中
|
|
|
+ //returnMaps.add(storeMap);
|
|
|
+ }
|
|
|
+
|
|
|
return storeInfoIPage;
|
|
|
}
|
|
|
|