Răsfoiți Sursa

推荐图片为空修复

zhangchen 1 săptămână în urmă
părinte
comite
8af8977a4b

+ 1 - 3
alien-entity/src/main/java/shop/alien/mapper/StoreInfoMapper.java

@@ -138,7 +138,7 @@ public interface StoreInfoMapper extends BaseMapper<StoreInfo> {
      * @param position 经纬度位置(格式:经度,纬度)
      * @return List<StoreInfoVo>
      */
-    @Select("select a.*, img.img_url entranceImage,img1.img_url foodLicenceImageUrl,b.name store_contact, b.phone store_phone, b.id_card idCard, b.password, c.dict_detail store_status_str, d.dict_detail business_status_str, e.dict_detail store_type_str,  " +
+    @Select("select a.*,b.name store_contact, b.phone store_phone, b.id_card idCard, b.password, c.dict_detail store_status_str, d.dict_detail business_status_str, e.dict_detail store_type_str,  " +
             "( " +
             " select ifnull(round(avg(score), 1), 0) " +
             " from store_evaluation eval " +
@@ -147,8 +147,6 @@ public interface StoreInfoMapper extends BaseMapper<StoreInfo> {
             "ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(', REPLACE(#{position}, ',', ' '), ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(a.store_position, ',', ' '), ')' ))), 0) distance3 " +
             "from store_info a " +
             "left join store_user b on a.id = b.store_id and a.delete_flag = 0 and b.delete_flag = 0 " +
-            "left join store_img img on img.store_id = a.id and img.img_type = 1 and img.delete_flag = 0 " +
-            "left join store_img img1 on img1.store_id = a.id and img1.img_type = 24 and img1.delete_flag = 0 " +
             "left join store_dictionary c on a.store_status = c.dict_id and c.type_name = 'storeState' and c.delete_flag = 0 " +
             "left join store_dictionary d on a.business_status = d.dict_id and d.type_name = 'businessStatus' and d.delete_flag = 0 " +
             "left join store_dictionary e on e.type_name = 'storeType' and e.dict_id = a.store_type and e.delete_flag = 0 " +

+ 20 - 0
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -3027,6 +3027,16 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         commentMap = storeCommentMapper.selectList(new QueryWrapper<StoreComment>().eq("business_type", "5").eq("delete_flag", 0)).stream().collect(Collectors.groupingBy(StoreComment::getStoreId));
 
 
+        // 查询入口头图
+        List<Integer> storeIds = storeInfoVoList.stream()
+                .map(StoreInfoVo::getId)  // 假设 StoreImg 有 getStoreUrl() 方法
+                .collect(Collectors.toList());
+
+        List<StoreImg> storeImgList = storeImgMapper.selectList(new QueryWrapper<StoreImg>().in("store_id", storeIds).eq("img_type", 1));
+        Map<Integer, List<StoreImg>>  storeCollect = storeImgList.stream()
+                .collect(Collectors.groupingBy(StoreImg::getStoreId));
+
+
         for (StoreInfoVo record : storeInfoVoList) {
             //处理类型
             if (StringUtils.isNotEmpty(record.getStoreType())) {
@@ -3035,6 +3045,16 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 record.setStoreTypeStr(String.join(",", typeDetails));
                 record.setStoreTypeList(Arrays.asList(types));
             }
+
+
+            // 加入头图
+            if(!CollectionUtils.isEmpty(storeCollect) && storeCollect.containsKey(record.getId())){
+                List<StoreImg> storeImgs = storeCollect.get(record.getId());
+                if(!CollectionUtils.isEmpty(storeImgs)){
+                    record.setEntranceImage(storeImgs.get(0).getImgUrl());
+                }
+            }
+
             //写经纬度
             String[] split = record.getStorePosition().split(",");
             record.setStorePositionLongitude(split[0]);