|
@@ -32,6 +32,8 @@ import shop.alien.mapper.StoreUserMapper;
|
|
|
import shop.alien.store.annotation.TrackEvent;
|
|
import shop.alien.store.annotation.TrackEvent;
|
|
|
import shop.alien.store.service.CommonRatingService;
|
|
import shop.alien.store.service.CommonRatingService;
|
|
|
import shop.alien.store.service.StoreImgService;
|
|
import shop.alien.store.service.StoreImgService;
|
|
|
|
|
+import shop.alien.store.service.StoreInfoService;
|
|
|
|
|
+import shop.alien.entity.store.vo.StoreBusinessStatusVo;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
|
|
|
import java.time.Instant;
|
|
import java.time.Instant;
|
|
@@ -65,6 +67,7 @@ public class AiSearchController {
|
|
|
private final StoreImgService storeImgService;
|
|
private final StoreImgService storeImgService;
|
|
|
private final CommonRatingService commonRatingService;
|
|
private final CommonRatingService commonRatingService;
|
|
|
private final CommonRatingMapper commonRatingMapper;
|
|
private final CommonRatingMapper commonRatingMapper;
|
|
|
|
|
+ private final StoreInfoService storeInfoService;
|
|
|
|
|
|
|
|
private final LifeBlacklistMapper lifeBlacklistMapper;
|
|
private final LifeBlacklistMapper lifeBlacklistMapper;
|
|
|
|
|
|
|
@@ -154,12 +157,13 @@ public class AiSearchController {
|
|
|
// 模糊搜索:从related_results和matched_results字段获取数据
|
|
// 模糊搜索:从related_results和matched_results字段获取数据
|
|
|
List<StoreInfoVo> result = convertToStoreInfoList(jsonObject.getJSONArray("results"),map.get("userId"));
|
|
List<StoreInfoVo> result = convertToStoreInfoList(jsonObject.getJSONArray("results"),map.get("userId"));
|
|
|
|
|
|
|
|
- // 并发处理图片和评论数据,提升性能
|
|
|
|
|
|
|
+ // 并发处理图片、评论数据和营业时间,提升性能
|
|
|
CompletableFuture<Void> imageFuture = CompletableFuture.runAsync(() -> fillStoreImages(result, 1));
|
|
CompletableFuture<Void> imageFuture = CompletableFuture.runAsync(() -> fillStoreImages(result, 1));
|
|
|
CompletableFuture<Void> ratingFuture = CompletableFuture.runAsync(() -> fillRatingCountBatch(result));
|
|
CompletableFuture<Void> ratingFuture = CompletableFuture.runAsync(() -> fillRatingCountBatch(result));
|
|
|
|
|
+ CompletableFuture<Void> businessHoursFuture = CompletableFuture.runAsync(() -> fillBusinessHours(result));
|
|
|
|
|
|
|
|
- // 等待两个任务完成
|
|
|
|
|
- CompletableFuture.allOf(imageFuture, ratingFuture).join();
|
|
|
|
|
|
|
+ // 等待所有任务完成
|
|
|
|
|
+ CompletableFuture.allOf(imageFuture, ratingFuture, businessHoursFuture).join();
|
|
|
|
|
|
|
|
jsonObject1.put("records", result);
|
|
jsonObject1.put("records", result);
|
|
|
|
|
|
|
@@ -349,6 +353,51 @@ public class AiSearchController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 批量填充营业时间到StoreInfoVo列表中
|
|
|
|
|
+ * 通过调用storeInfoService.getStoreBusinessStatus方法获取营业时间
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param result StoreInfoVo列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private void fillBusinessHours(List<StoreInfoVo> result) {
|
|
|
|
|
+ if (result == null || result.isEmpty()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 遍历result集合,为每个门店调用getStoreBusinessStatus方法
|
|
|
|
|
+ for (StoreInfoVo storeInfo : result) {
|
|
|
|
|
+ if (storeInfo.getId() != null) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 调用getStoreBusinessStatus方法获取营业时间
|
|
|
|
|
+ StoreBusinessStatusVo businessStatus = storeInfoService.getStoreBusinessStatus(String.valueOf(storeInfo.getId()));
|
|
|
|
|
+ if (businessStatus != null) {
|
|
|
|
|
+ // 设置营业时间信息到StoreInfoVo中
|
|
|
|
|
+ if (businessStatus.getStoreBusinessInfos() != null && !businessStatus.getStoreBusinessInfos().isEmpty()) {
|
|
|
|
|
+ storeInfo.setStoreBusinessInfos(businessStatus.getStoreBusinessInfos());
|
|
|
|
|
+ // 同时设置到openTime字段(格式化为字符串列表)
|
|
|
|
|
+ List<String> openTimeList = businessStatus.getStoreBusinessInfos().stream()
|
|
|
|
|
+ .map(info -> {
|
|
|
|
|
+ if (info.getBusinessDate() != null && info.getStartTime() != null && info.getEndTime() != null) {
|
|
|
|
|
+ return info.getBusinessDate() + " " + info.getStartTime() + "-" + info.getEndTime();
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ })
|
|
|
|
|
+ .filter(time -> time != null)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ storeInfo.setOpenTime(openTimeList);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 设置营业状态
|
|
|
|
|
+ if (businessStatus.getYyFlag() != null) {
|
|
|
|
|
+ storeInfo.setYyFlag(businessStatus.getYyFlag());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("获取门店营业时间失败,storeId: {}", storeInfo.getId(), e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 将下划线命名转换为驼峰命名
|
|
* 将下划线命名转换为驼峰命名
|
|
|
* 例如: store_tel -> storeTel, created_time -> createdTime
|
|
* 例如: store_tel -> storeTel, created_time -> createdTime
|
|
|
*/
|
|
*/
|