Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/sit' into uat-20260202

dujian 2 giorni fa
parent
commit
f07535111b

+ 24 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreClockInDeleteFlagVo.java

@@ -0,0 +1,24 @@
+package shop.alien.entity.store.vo;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 打卡记录删除标记及关联门店营业状态
+ */
+@Data
+@JsonInclude
+@ApiModel(value = "StoreClockInDeleteFlagVo", description = "打卡删除标记与门店营业状态")
+public class StoreClockInDeleteFlagVo {
+
+    @ApiModelProperty(value = "删除标记, 0:未删除, 1:已删除")
+    private Integer deleteFlag;
+
+    @ApiModelProperty(value = "商铺id")
+    private Integer storeId;
+
+    @ApiModelProperty(value = "营业状态(-1:注销中, 0:正常营业, 1:暂停营业, 2:筹建中, 99:永久关门)")
+    private Integer businessStatus;
+}

+ 10 - 0
alien-entity/src/main/java/shop/alien/mapper/StoreClockInMapper.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import shop.alien.entity.store.StoreClockIn;
+import shop.alien.entity.store.vo.StoreClockInDeleteFlagVo;
 import shop.alien.entity.store.vo.StoreClockInVo;
 
 import java.util.List;
@@ -128,4 +129,13 @@ public interface StoreClockInMapper extends BaseMapper<StoreClockIn> {
                                                  @Param("year") Integer year,
                                                  @Param("month") Integer month,
                                                  @Param("city") String city);
+
+    /**
+     * 按主键查询删除标记、门店 id 及门店营业状态(打卡含已逻辑删除;门店左连接不过滤 delete_flag)
+     */
+    @Select("SELECT clock.delete_flag AS deleteFlag, clock.store_id AS storeId, store.business_status AS businessStatus " +
+            "FROM store_clock_in clock " +
+            "LEFT JOIN store_info store ON store.id = clock.store_id " +
+            "WHERE clock.id = #{id} LIMIT 1")
+    StoreClockInDeleteFlagVo selectDeleteFlagAndBusinessStatusById(@Param("id") Integer id);
 }

+ 7 - 7
alien-entity/src/main/resources/mapper/LifeAppealManageMapper.xml

@@ -39,11 +39,11 @@
         WHEN 2 THEN
         "失败"
         END AS appeal_type_name,
-        `comment`.source_type AS sourceType,
+        `comment`.business_type AS sourceType,
         CASE
-        `comment`.source_type
+        `comment`.business_type
         WHEN 1 THEN
-        "动态的评"
+        "动态的评"
         WHEN 2 THEN
         "动态社区评论"
         WHEN 3 THEN
@@ -58,7 +58,7 @@
         store_comment_appeal appeal
         LEFT JOIN store_info store ON appeal.store_id = store.id
         LEFT JOIN store_user su ON su.store_id = store.id and su.delete_flag = 0
-        LEFT JOIN common_comment `comment` ON `comment`.id = appeal.comment_id
+        LEFT JOIN common_rating `comment` ON `comment`.id = appeal.comment_id
         LEFT JOIN life_user lu ON `comment`.user_id = lu.id
         LEFT JOIN store_img si ON appeal.img_id = si.id
         WHERE
@@ -101,9 +101,9 @@
         WHEN 2 THEN
         "失败"
         END AS appeal_type_name,
-        `comment`.source_type,
+        `comment`.business_type AS sourceType,
         CASE
-        `comment`.source_type
+        `comment`.business_type
         WHEN 1 THEN
             "动态的评论"
         WHEN 2 THEN
@@ -120,7 +120,7 @@
         store_comment_appeal appeal
         LEFT JOIN store_info store ON appeal.store_id = store.id
         LEFT JOIN store_user su ON su.store_id = store.id and su.delete_flag = 0
-        LEFT JOIN common_comment `comment` ON `comment`.id = appeal.comment_id
+        LEFT JOIN common_rating `comment` ON `comment`.id = appeal.comment_id
         LEFT JOIN life_user lu ON `comment`.user_id = lu.id
         LEFT JOIN store_img si ON appeal.img_id = si.id
         WHERE

+ 22 - 8
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/PlatformStoreOperationalStatisticsServiceImpl.java

@@ -527,6 +527,7 @@ public class PlatformStoreOperationalStatisticsServiceImpl implements PlatformSt
                 // business_section = 1 表示美食,查询美食价目表
                 LambdaQueryWrapper<StoreCuisine> cuisineWrapper = new LambdaQueryWrapper<>();
                 cuisineWrapper.in(StoreCuisine::getId, needQueryPriceIds)
+                        .eq(StoreCuisine::getStoreId, storeId)
                         .eq(StoreCuisine::getDeleteFlag, 0);
                 List<StoreCuisine> cuisines = storeCuisineMapper.selectList(cuisineWrapper);
                 for (StoreCuisine cuisine : cuisines) {
@@ -538,6 +539,7 @@ public class PlatformStoreOperationalStatisticsServiceImpl implements PlatformSt
                 // 其他情况查询通用价目表
                 LambdaQueryWrapper<StorePrice> priceWrapper = new LambdaQueryWrapper<>();
                 priceWrapper.in(StorePrice::getId, needQueryPriceIds)
+                        .eq(StorePrice::getStoreId, storeId)
                         .eq(StorePrice::getDeleteFlag, 0);
                 List<StorePrice> prices = storePriceMapper.selectList(priceWrapper);
                 for (StorePrice price : prices) {
@@ -555,12 +557,15 @@ public class PlatformStoreOperationalStatisticsServiceImpl implements PlatformSt
 
             comparison.setPriceId(curr.getPriceId());
 
-            // 设置价目表名称,如果为空则从查询结果中获取
+            // 设置价目表名称,如果为空则从查询结果中获取(与 convert 一致:有 storeId 时不展示无有效名称的条目)
             String priceListItemName = curr.getPriceListItemName();
             if (priceListItemName == null || priceListItemName.trim().isEmpty()) {
                 priceListItemName = priceNameMap.get(curr.getPriceId());
             }
-            comparison.setPriceListItemName(priceListItemName);
+            if (storeId != null && (priceListItemName == null || priceListItemName.trim().isEmpty())) {
+                continue;
+            }
+            comparison.setPriceListItemName(priceListItemName != null ? priceListItemName.trim() : null);
 
             // 获取上期对应的价目表数据
             StoreOperationalStatisticsVo.PriceListRanking prev = previousMap.get(curr.getPriceId());
@@ -1404,6 +1409,7 @@ public class PlatformStoreOperationalStatisticsServiceImpl implements PlatformSt
                     // business_section = 1 表示美食,查询美食价目表
                     LambdaQueryWrapper<StoreCuisine> cuisineWrapper = new LambdaQueryWrapper<>();
                     cuisineWrapper.in(StoreCuisine::getId, priceIds)
+                            .eq(StoreCuisine::getStoreId, storeId)
                             .eq(StoreCuisine::getDeleteFlag, 0);
                     List<StoreCuisine> cuisines = storeCuisineMapper.selectList(cuisineWrapper);
                     for (StoreCuisine cuisine : cuisines) {
@@ -1415,6 +1421,7 @@ public class PlatformStoreOperationalStatisticsServiceImpl implements PlatformSt
                     // 其他情况查询通用价目表
                     LambdaQueryWrapper<StorePrice> priceWrapper = new LambdaQueryWrapper<>();
                     priceWrapper.in(StorePrice::getId, priceIds)
+                            .eq(StorePrice::getStoreId, storeId)
                             .eq(StorePrice::getDeleteFlag, 0);
                     List<StorePrice> prices = storePriceMapper.selectList(priceWrapper);
                     for (StorePrice price : prices) {
@@ -1425,18 +1432,25 @@ public class PlatformStoreOperationalStatisticsServiceImpl implements PlatformSt
                 }
             }
 
-            // 转换为VO列表
+            // 转换为VO列表(能按店铺查库时:仅保留仍有效的价目/菜品;已删除或查无此条的不展示)
             for (Map<String, Object> item : dataList) {
-                StoreOperationalStatisticsVo.PriceListRanking ranking = new StoreOperationalStatisticsVo.PriceListRanking();
                 Integer priceId = getIntegerValue(item, "priceId");
+                if (priceId == null) {
+                    continue;
+                }
+                String priceListItemName = priceNameMap.get(priceId);
+                if (storeId != null) {
+                    if (priceListItemName == null || priceListItemName.trim().isEmpty()) {
+                        continue;
+                    }
+                }
+
+                StoreOperationalStatisticsVo.PriceListRanking ranking = new StoreOperationalStatisticsVo.PriceListRanking();
                 ranking.setPriceId(priceId);
                 ranking.setPageViews(getLongValue(item, "viewCount"));
                 ranking.setVisitors(getLongValue(item, "visitorCount"));
                 ranking.setShares(getLongValue(item, "shareCount"));
-
-                if (priceId != null) {
-                    ranking.setPriceListItemName(priceNameMap.get(priceId));
-                }
+                ranking.setPriceListItemName(priceListItemName != null ? priceListItemName.trim() : null);
 
                 result.add(ranking);
             }

+ 10 - 0
alien-store/src/main/java/shop/alien/store/controller/StoreClockInController.java

@@ -10,6 +10,7 @@ import shop.alien.entity.result.R;
 import shop.alien.entity.store.StoreClockIn;
 import shop.alien.entity.store.UserLoginInfo;
 import shop.alien.entity.store.vo.ClockInRecordValidateVo;
+import shop.alien.entity.store.vo.StoreClockInDeleteFlagVo;
 import shop.alien.entity.store.vo.StoreClockInVo;
 import shop.alien.store.annotation.TrackEvent;
 import shop.alien.store.service.StoreClockInService;
@@ -139,4 +140,13 @@ public class StoreClockInController {
         log.info("StoreClockInController.getClockInRecordValidate?userId={},year={},city={}", userId, year, city);
         return R.data(storeClockInService.getClockInRecordValidate(userId, year, city));
     }
+
+    @ApiOperation("根据主键查询删除标记及门店营业状态")
+    @ApiOperationSupport(order = 8)
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键id", dataType = "Integer", paramType = "query")})
+    @GetMapping("/getDeleteFlagById")
+    public R<StoreClockInDeleteFlagVo> getDeleteFlagById(Integer id) {
+        log.info("StoreClockInController.getDeleteFlagById?id={}", id);
+        return R.data(storeClockInService.getDeleteFlagById(id));
+    }
 }

+ 43 - 10
alien-store/src/main/java/shop/alien/store/service/LifeUserDynamicsService.java

@@ -553,6 +553,10 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
 
         LifeUser lifeUser = new LifeUser();
         StoreUser storeUser = new StoreUser();
+        // 商户 phoneId 时在 resultMap 与每条动态上填充店铺展示字段
+        String profileStoreName = null;
+        Double profileScoreAvg = null;
+        String profileRatingCount = null;
 
         String[] split = myselfPhoneId.split("_");
 //        if ("store".equals(split[0])) {
@@ -573,20 +577,40 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
             // 根据storeId查询店铺信息,获取店铺名称
             if (storeUser != null) {
                 if (storeUser.getStoreId() != null) {
+                    String storeIdStr = String.valueOf(storeUser.getStoreId());
+                    Map<String, Integer> ratingCountMap = batchGetRatingCount(Collections.singletonList(storeIdStr));
+                    int ratingCnt = ratingCountMap.getOrDefault(storeIdStr, 0);
+                    profileRatingCount = String.valueOf(ratingCnt);
+                    resultMap.put("ratingCount", profileRatingCount);
+
                     StoreInfo storeInfo = storeInfoMapper.selectById(storeUser.getStoreId());
-                    resultMap.put("businessSection",storeInfo.getBusinessSection());
-                    resultMap.put("scoreAvg",storeInfo.getScoreAvg());
-                    if (storeInfo != null && storeInfo.getStoreName() != null) {
-                        // 使用店铺名称作为昵称
-                        storeUser.setUserName(storeInfo.getStoreName());
-                        storeUser.setNickName(storeInfo.getStoreName());
+                    if (storeInfo != null) {
+                        resultMap.put("businessSection", storeInfo.getBusinessSection());
+                        double score = storeInfo.getScoreAvg() != null ? storeInfo.getScoreAvg() : 0.0;
+                        resultMap.put("scoreAvg", score);
+                        profileScoreAvg = score;
+                        String sn = StringUtils.hasText(storeInfo.getStoreName()) ? storeInfo.getStoreName() : storeUser.getNickName();
+                        resultMap.put("storeName", sn);
+                        profileStoreName = sn;
+                        storeUser.setUserName(sn);
+                        storeUser.setNickName(sn);
                     } else {
-                        // 如果没有店铺信息,使用原来的nickName
-                        storeUser.setUserName(storeUser.getNickName());
+                        resultMap.put("scoreAvg", 0.0);
+                        profileScoreAvg = 0.0;
+                        String nick = storeUser.getNickName();
+                        resultMap.put("storeName", nick);
+                        profileStoreName = nick;
+                        storeUser.setUserName(nick);
                     }
                 } else {
-                    // 如果没有storeId,使用原来的nickName
-                    storeUser.setUserName(storeUser.getNickName());
+                    resultMap.put("scoreAvg", 0.0);
+                    resultMap.put("ratingCount", "0");
+                    String nick = storeUser.getNickName();
+                    resultMap.put("storeName", nick);
+                    profileScoreAvg = 0.0;
+                    profileRatingCount = "0";
+                    profileStoreName = nick;
+                    storeUser.setUserName(nick);
                 }
                 storeUser.setUserImage(storeUser.getHeadImg());
                 storeUser.setJianjie(storeUser.getAccountBlurb());
@@ -642,6 +666,15 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
 
         // 我是否点赞,并且查询每条动态的评论数量
         for (LifeUserDynamicsVo dynamicsVo : lifeUserDynamicsVoList) {
+            if (profileStoreName != null) {
+                dynamicsVo.setStoreName(profileStoreName);
+            }
+            if (profileScoreAvg != null) {
+                dynamicsVo.setScoreAvg(profileScoreAvg);
+            }
+            if (profileRatingCount != null) {
+                dynamicsVo.setRatingCount(profileRatingCount);
+            }
             if (likeList.contains(String.valueOf(dynamicsVo.getId()))) {
                 dynamicsVo.setIsLike("1");
             } else {

+ 6 - 0
alien-store/src/main/java/shop/alien/store/service/StoreClockInService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import shop.alien.entity.store.StoreClockIn;
 import shop.alien.entity.store.vo.ClockInRecordValidateVo;
+import shop.alien.entity.store.vo.StoreClockInDeleteFlagVo;
 import shop.alien.entity.store.vo.StoreClockInVo;
 
 import java.util.List;
@@ -56,4 +57,9 @@ public interface StoreClockInService extends IService<StoreClockIn> {
      */
     ClockInRecordValidateVo getClockInRecordValidate(Integer userId, Integer year, String city);
 
+    /**
+     * 按主键查询删除标记、门店 id 及门店营业状态;无此打卡记录时返回 null。
+     */
+    StoreClockInDeleteFlagVo getDeleteFlagById(Integer id);
+
 }

+ 10 - 1
alien-store/src/main/java/shop/alien/store/service/impl/LicenseAuditAsyncService.java

@@ -7,7 +7,10 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.*;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
 import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
@@ -21,6 +24,8 @@ import shop.alien.mapper.storePlantform.StoreLicenseHistoryMapper;
 import shop.alien.store.util.ai.AiAuthTokenUtil;
 
 import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
 import java.util.*;
 
 /**
@@ -121,6 +126,8 @@ public class LicenseAuditAsyncService {
             Integer remainingDays = (Integer) dataMap.get("remaining_days");
             String reason = (String) dataMap.get("reason");
             String licenseType = (String) dataMap.get("license_type");
+            String auditTime = (String) dataMap.get("audit_time");
+            Date reviewDate = Date.from(LocalDateTime.parse(auditTime).atZone(ZoneId.systemDefault()).toInstant());
 
             String licenseTypeName = licenseStatus == 1 ? "营业执照" : "其他资质证明";
             log.info("{}证照审核结果,门店ID:{},图片URL:{},is_valid={},expiry_date={},is_expired={},remaining_days={},license_type={}",
@@ -268,6 +275,7 @@ public class LicenseAuditAsyncService {
                     storeInfoMapper.update(null, new LambdaUpdateWrapper<StoreInfo>()
                             .eq(StoreInfo::getId, storeId)
                             .set(StoreInfo::getBusinessLicenseStatus, 3)
+                            .set(StoreInfo::getReviewDate, reviewDate)
                             .set(StoreInfo::getBusinessLicenseReason, rejectReason)
                     );
                     // 审核拒绝时,不需要操作store_img表
@@ -281,6 +289,7 @@ public class LicenseAuditAsyncService {
                     storeInfoMapper.update(null, new LambdaUpdateWrapper<StoreInfo>()
                             .eq(StoreInfo::getId, storeId)
                             .set(StoreInfo::getBusinessLicenseStatus, 1)
+                            .set(StoreInfo::getReviewDate,reviewDate)
                             .set(StoreInfo::getUpdateBusinessLicenseTime, new Date())
                     );
 

+ 10 - 1
alien-store/src/main/java/shop/alien/store/service/impl/StoreClockInServiceImpl.java

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import shop.alien.entity.store.*;
 import shop.alien.entity.store.vo.ClockInRecordValidateVo;
+import shop.alien.entity.store.vo.StoreClockInDeleteFlagVo;
 import shop.alien.entity.store.vo.MonthClockInItem;
 import shop.alien.entity.store.vo.StoreClockInPageVo;
 import shop.alien.entity.store.vo.StoreClockInVo;
@@ -491,7 +492,7 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
         storeClockInVo.setStoreName(storeInfo.getStoreName());
         storeClockInVo.setStoreBlurb(storeInfo.getStoreBlurb());
         // 店铺头像
-        LambdaQueryWrapper<StoreImg> eq = new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 10).eq(StoreImg::getStoreId, storeInfo.getId());
+        LambdaQueryWrapper<StoreImg> eq = new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 1).eq(StoreImg::getStoreId, storeInfo.getId());
         StoreImg storeImg = storeImgMapper.selectOne(eq);
         storeClockInVo.setEntranceImage(storeImg != null ? storeImg.getImgUrl() : "");
         // 店铺评分
@@ -550,4 +551,12 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
         vo.setMonths(monthItems);
         return vo;
     }
+
+    @Override
+    public StoreClockInDeleteFlagVo getDeleteFlagById(Integer id) {
+        if (id == null) {
+            return null;
+        }
+        return storeClockInMapper.selectDeleteFlagAndBusinessStatusById(id);
+    }
 }

+ 40 - 15
alien-store/src/main/java/shop/alien/store/service/impl/StoreOperationalStatisticsServiceImpl.java

@@ -978,6 +978,7 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
                 // business_section = 1 表示美食,查询美食价目表
                 LambdaQueryWrapper<StoreCuisine> cuisineWrapper = new LambdaQueryWrapper<>();
                 cuisineWrapper.in(StoreCuisine::getId, needQueryPriceIds)
+                            .eq(StoreCuisine::getStoreId, storeId)
                             .eq(StoreCuisine::getDeleteFlag, 0);
                 List<StoreCuisine> cuisines = storeCuisineMapper.selectList(cuisineWrapper);
                 for (StoreCuisine cuisine : cuisines) {
@@ -989,6 +990,7 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
                 // 其他情况查询通用价目表
                 LambdaQueryWrapper<StorePrice> priceWrapper = new LambdaQueryWrapper<>();
                 priceWrapper.in(StorePrice::getId, needQueryPriceIds)
+                            .eq(StorePrice::getStoreId, storeId)
                             .eq(StorePrice::getDeleteFlag, 0);
                 List<StorePrice> prices = storePriceMapper.selectList(priceWrapper);
                 for (StorePrice price : prices) {
@@ -1006,12 +1008,15 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
             
             comparison.setPriceId(curr.getPriceId());
             
-            // 设置价目表名称,如果为空则从查询结果中获取
+            // 设置价目表名称,如果为空则从查询结果中获取(与 convert 一致:有 storeId 时不展示无有效名称的条目)
             String priceListItemName = curr.getPriceListItemName();
             if (priceListItemName == null || priceListItemName.trim().isEmpty()) {
                 priceListItemName = priceNameMap.get(curr.getPriceId());
             }
-            comparison.setPriceListItemName(priceListItemName);
+            if (storeId != null && (priceListItemName == null || priceListItemName.trim().isEmpty())) {
+                continue;
+            }
+            comparison.setPriceListItemName(priceListItemName != null ? priceListItemName.trim() : null);
             
             // 获取上期对应的价目表数据
             StoreOperationalStatisticsVo.PriceListRanking prev = previousMap.get(curr.getPriceId());
@@ -1831,6 +1836,7 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
                 // business_section = 1 表示美食,查询美食价目表
                 LambdaQueryWrapper<StoreCuisine> cuisineWrapper = new LambdaQueryWrapper<>();
                 cuisineWrapper.in(StoreCuisine::getId, priceIds)
+                            .eq(StoreCuisine::getStoreId, storeId)
                             .eq(StoreCuisine::getDeleteFlag, 0);
                 List<StoreCuisine> cuisines = storeCuisineMapper.selectList(cuisineWrapper);
                 for (StoreCuisine cuisine : cuisines) {
@@ -1842,6 +1848,7 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
                 // 其他情况查询通用价目表
                 LambdaQueryWrapper<StorePrice> priceWrapper = new LambdaQueryWrapper<>();
                 priceWrapper.in(StorePrice::getId, priceIds)
+                            .eq(StorePrice::getStoreId, storeId)
                             .eq(StorePrice::getDeleteFlag, 0);
                 List<StorePrice> prices = storePriceMapper.selectList(priceWrapper);
                 for (StorePrice price : prices) {
@@ -1852,18 +1859,27 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
             }
         }
         
-        // 转换为列表并按浏览量降序排序
+        // 转换为列表:有 storeId 时仅保留本店未删除且能解析到名称的价目/菜品
         for (Map.Entry<Integer, Map<String, Long>> entry : accumulator.entrySet()) {
+            Integer priceId = entry.getKey();
+            if (priceId == null) {
+                continue;
+            }
+            String itemName = priceNameMap.get(priceId);
+            if (storeId != null) {
+                if (itemName == null || itemName.trim().isEmpty()) {
+                    continue;
+                }
+            }
+
             StoreOperationalStatisticsVo.PriceListRanking ranking = new StoreOperationalStatisticsVo.PriceListRanking();
-            ranking.setPriceId(entry.getKey());
+            ranking.setPriceId(priceId);
             Map<String, Long> data = entry.getValue();
             ranking.setPageViews(data.getOrDefault("viewCount", 0L));
             ranking.setVisitors(data.getOrDefault("visitorCount", 0L));
             ranking.setShares(data.getOrDefault("shareCount", 0L));
-            
-            // 根据id查询价目表名称
-            ranking.setPriceListItemName(priceNameMap.getOrDefault(entry.getKey(), null));
-            
+            ranking.setPriceListItemName(itemName != null ? itemName.trim() : null);
+
             result.add(ranking);
         }
         
@@ -2316,6 +2332,7 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
                     // business_section = 1 表示美食,查询美食价目表
                     LambdaQueryWrapper<StoreCuisine> cuisineWrapper = new LambdaQueryWrapper<>();
                     cuisineWrapper.in(StoreCuisine::getId, priceIds)
+                                .eq(StoreCuisine::getStoreId, storeId)
                                 .eq(StoreCuisine::getDeleteFlag, 0);
                     List<StoreCuisine> cuisines = storeCuisineMapper.selectList(cuisineWrapper);
                     for (StoreCuisine cuisine : cuisines) {
@@ -2327,6 +2344,7 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
                     // 其他情况查询通用价目表
                     LambdaQueryWrapper<StorePrice> priceWrapper = new LambdaQueryWrapper<>();
                     priceWrapper.in(StorePrice::getId, priceIds)
+                                .eq(StorePrice::getStoreId, storeId)
                                 .eq(StorePrice::getDeleteFlag, 0);
                     List<StorePrice> prices = storePriceMapper.selectList(priceWrapper);
                     for (StorePrice price : prices) {
@@ -2337,19 +2355,26 @@ public class StoreOperationalStatisticsServiceImpl implements StoreOperationalSt
                 }
             }
             
-            // 转换为VO列表
+            // 转换为VO列表(能按店铺查库时:仅保留仍有效的价目/菜品;已删除或查无此条的不展示)
             for (Map<String, Object> item : dataList) {
-                StoreOperationalStatisticsVo.PriceListRanking ranking = new StoreOperationalStatisticsVo.PriceListRanking();
                 Integer priceId = getIntegerValue(item, "priceId");
+                if (priceId == null) {
+                    continue;
+                }
+                String priceListItemName = priceNameMap.get(priceId);
+                if (storeId != null) {
+                    if (priceListItemName == null || priceListItemName.trim().isEmpty()) {
+                        continue;
+                    }
+                }
+
+                StoreOperationalStatisticsVo.PriceListRanking ranking = new StoreOperationalStatisticsVo.PriceListRanking();
                 ranking.setPriceId(priceId);
                 ranking.setPageViews(getLongValue(item, "viewCount"));
                 ranking.setVisitors(getLongValue(item, "visitorCount"));
                 ranking.setShares(getLongValue(item, "shareCount"));
-                
-                if (priceId != null) {
-                    ranking.setPriceListItemName(priceNameMap.get(priceId));
-                }
-                
+                ranking.setPriceListItemName(priceListItemName != null ? priceListItemName.trim() : null);
+
                 result.add(ranking);
             }