From 2baa90c11d0ee7284d127f3a96c0f8452292d150 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期四, 02 一月 2025 16:41:27 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java
index 1ada38b..16b42b6 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java
@@ -9,7 +9,10 @@
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.exception.ServiceException;
 import com.ruoyi.common.core.utils.GeodesyUtil;
+import com.ruoyi.common.core.utils.ServletUtils;
+import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.security.service.TokenService;
+import com.ruoyi.common.security.utils.SecurityUtils;
 import com.ruoyi.other.api.domain.Shop;
 import com.ruoyi.other.api.domain.ShopScore;
 import com.ruoyi.other.mapper.ShopMapper;
@@ -58,11 +61,17 @@
 
     @Override
     public List<NearbyShopVO> nearbyShopList(BigDecimal longitude, BigDecimal latitude) {
-        Long userid = tokenService.getLoginUserApplet().getUserid();
-        AppUser appUser = appUserClient.getAppUserById(userid);
+        String token = SecurityUtils.getToken(ServletUtils.getRequest());
+        AppUser appUser = null;
+        if(StringUtils.isNotEmpty(token)){
+            Long userid = tokenService.getLoginUserApplet().getUserid();
+            appUser = appUserClient.getAppUserById(userid);
+        }
+
         List<NearbyShopVO> nearbyShopVOS = shopMapper.selectNearbyShopList(longitude, longitude);
-        if(null != appUser.getShopId()){
-            NearbyShopVO nearbyShopVO = nearbyShopVOS.stream().filter(s -> s.getId().equals(appUser.getShopId().longValue())).findFirst().get();
+        if(null != appUser && null != appUser.getShopId()){
+            AppUser finalAppUser = appUser;
+            NearbyShopVO nearbyShopVO = nearbyShopVOS.stream().filter(s -> s.getId().equals(finalAppUser.getShopId().longValue())).findFirst().get();
             if(null != nearbyShopVO){
                 nearbyShopVOS.remove(nearbyShopVO);
             }

--
Gitblit v1.7.1