|
@@ -1385,6 +1385,122 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public IPage<StoreInfo> getScreeningNew(ScreeningOfEightMajorCategoriesVO vo) {
|
|
|
+ // 参数校验
|
|
|
+ if (vo == null) {
|
|
|
+ throw new IllegalArgumentException("筛选参数不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建分页对象
|
|
|
+ IPage<StoreInfo> page = new Page<>(vo.getPageNum(), vo.getPageSize());
|
|
|
+
|
|
|
+ // 获取筛选条件
|
|
|
+ String screeningId = vo.getScreeningId();
|
|
|
+ Double lon = vo.getLon();
|
|
|
+ Double lat = vo.getLat();
|
|
|
+ Double distance = vo.getDistance();
|
|
|
+ Boolean flag = vo.getFlag();
|
|
|
+ String startTime = vo.getStartTime();
|
|
|
+ String endTime = vo.getEndTime();
|
|
|
+ Double priceStr = vo.getPriceStr();
|
|
|
+ Double priceEnd = vo.getPriceEnd();
|
|
|
+
|
|
|
+ String storeId = "";
|
|
|
+
|
|
|
+ /*// 验证经纬度和距离参数
|
|
|
+ if (flag != null && flag) {
|
|
|
+ if (lon == null || lat == null || distance == null) {
|
|
|
+ throw new IllegalArgumentException("启用距离筛选时,经纬度和距离参数不能为空");
|
|
|
+ }
|
|
|
+ if (distance <= 0) {
|
|
|
+ throw new IllegalArgumentException("距离参数必须大于0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 通过经纬度距离获取商家id
|
|
|
+ if (lat != null && lon != null && distance != null) {
|
|
|
+ List<NearMeDto> nearMeDtos = nearMeService.nearbyMerchants(lon, lat, distance, flag);
|
|
|
+ if (nearMeDtos != null && !nearMeDtos.isEmpty()) {
|
|
|
+ storeId = nearMeDtos.stream()
|
|
|
+ .map(item -> String.valueOf(item.getConent()))
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ if (lon == null || lat == null) {
|
|
|
+ throw new IllegalArgumentException("经纬度参数不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 通过筛选id获取商家id
|
|
|
+ if (StringUtils.isNotEmpty(screeningId)) {
|
|
|
+ String[] list = screeningId.split(",");
|
|
|
+ for (String id : list) {
|
|
|
+ if (StringUtils.isEmpty(storeId)) {
|
|
|
+ storeId = baseRedisService.getString(id);
|
|
|
+ } else {
|
|
|
+ String redisStoreId = baseRedisService.getString(id);
|
|
|
+ if (redisStoreId != null) {
|
|
|
+ storeId = findCommon(storeId, redisStoreId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 通过商家id获取商家信息
|
|
|
+ IPage<StoreInfo> storeInfoIPage = new Page<>();
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(storeId)) {
|
|
|
+ List<String> storeIds = Arrays.asList(storeId.split(","));
|
|
|
+ if (StringUtils.isNotEmpty(startTime) && StringUtils.isNotEmpty(endTime)) {
|
|
|
+ List<StoreBusinessInfo> storeBusinessInfos = storeBusinessInfoMapper.selectList(new LambdaQueryWrapper<StoreBusinessInfo>().in(StoreBusinessInfo::getStoreId, storeIds));
|
|
|
+ DateTimeFormatter formatter = new DateTimeFormatterBuilder()
|
|
|
+ .appendValue(ChronoField.HOUR_OF_DAY, 1, 2, java.time.format.SignStyle.NOT_NEGATIVE)
|
|
|
+ .appendLiteral(':')
|
|
|
+ .appendValue(ChronoField.MINUTE_OF_HOUR, 2)
|
|
|
+ .toFormatter();
|
|
|
+ List<StoreBusinessInfo> list = storeBusinessInfos.stream()
|
|
|
+ .filter(item -> {
|
|
|
+ // 商家开门时间
|
|
|
+ LocalTime timeStart = LocalTime.parse(item.getEndTime(), formatter);
|
|
|
+ // 商家关门时间
|
|
|
+ LocalTime timeEnd = LocalTime.parse(item.getEndTime(), formatter);
|
|
|
+ // 开始时间
|
|
|
+ LocalTime time1 = LocalTime.parse(startTime);
|
|
|
+ // 结束时间
|
|
|
+ LocalTime time2 = LocalTime.parse(endTime);
|
|
|
+ return !time1.isBefore(timeStart) && !time2.isAfter(timeEnd);
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ storeIds = list.stream()
|
|
|
+ .map(item -> String.valueOf(item.getStoreId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ storeIds.stream()
|
|
|
+ .filter(Objects::nonNull) // 确保 storeId 不为 null
|
|
|
+ .distinct() // 去重
|
|
|
+ .map(String::valueOf)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (priceStr != null && priceEnd != null) {
|
|
|
+ List<LifeCoupon> lifeCoupons = lifeCouponMapper.selectList(new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getStoreId, storeIds));
|
|
|
+ List<LifeCoupon> list = lifeCoupons.stream()
|
|
|
+ .filter(item -> Double.parseDouble(item.getPrice()) >= priceStr && Double.parseDouble(item.getPrice()) < priceEnd)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ storeIds = list.stream()
|
|
|
+ .map(item -> String.valueOf(item.getStoreId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(storeIds)) {
|
|
|
+ QueryWrapper<StoreInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.in("id", storeIds);
|
|
|
+ queryWrapper.orderByAsc("dist");
|
|
|
+ storeInfoIPage = storeInfoMapper.getPageForDistance(queryWrapper, page, lon + "," + lat);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return storeInfoIPage;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public List<StoreInfo> getBusinessTypesName(String businessTypesNames) {
|
|
|
String[] businessTypesName = businessTypesNames.split(",");
|
|
|
List<StoreInfo> storeInfos = new ArrayList<>();
|