Explorar el Código

bugfix:2791搜索评价数量

刘云鑫 hace 2 meses
padre
commit
02632801bf

+ 19 - 0
alien-store/src/main/java/shop/alien/store/controller/AiSearchController.java

@@ -164,6 +164,7 @@ public class AiSearchController {
         List<LifeBlacklist> lifeBlacklists = lifeBlacklistMapper.selectList(queryWrapper);
         List<String> blockedIds = lifeBlacklists.stream().map(x -> x.getBlockedId()).collect(Collectors.toList());
         List<StoreInfoVo> storeInfoList = new ArrayList<>();
+
         if (results != null) {
             for (int i = 0; i < results.size(); i++) {
                 JSONObject item = results.getJSONObject(i);
@@ -189,6 +190,24 @@ public class AiSearchController {
                 if(blockedIds.contains(storeInfo.getId())){
                     continue;
                 }
+                Integer totalCount = 0;
+                double storeScore;
+                Object ratingObj =  commonRatingService.getRatingCount(storeInfo.getId(), 1);
+                if (ratingObj != null) {
+                    Map<String, Object> ratingMap = (Map<String, Object>) ratingObj;
+                    Object totalCountObj = ratingMap.get("totalCount");
+                    if (totalCountObj != null) {
+                        // 安全转换为整数
+                        try {
+                            totalCount = Integer.parseInt(totalCountObj.toString().trim());
+                        } catch (NumberFormatException e) {
+                            totalCount = 0; // 转换失败时默认值
+                        }
+                    } else {
+                        totalCount = 0;
+                    }
+                }
+                storeInfo.setTotalNum(totalCount.toString());
                 storeInfoList.add(storeInfo);
             }
         }