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/GoodsServiceImpl.java |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
index 90916e8..d647b1d 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
@@ -7,11 +7,14 @@
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.account.api.feignClient.AppUserClient;
 import com.ruoyi.account.api.model.AppUser;
+import com.ruoyi.common.core.constant.TokenConstants;
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.ServletUtils;
 import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.utils.bean.BeanUtils;
 import com.ruoyi.common.core.web.page.PageInfo;
 import com.ruoyi.common.security.service.TokenService;
+import com.ruoyi.common.security.utils.SecurityUtils;
 import com.ruoyi.order.feignClient.RemoteOrderGoodsClient;
 import com.ruoyi.order.vo.Price;
 import com.ruoyi.other.api.domain.*;
@@ -73,13 +76,20 @@
     public PageInfo<GoodsVO> goodsList(Goods search) {
         PageInfo<GoodsVO> pageInfo = new PageInfo(search.getPageCurr(), search.getPageSize());
         List<GoodsVO> list = this.baseMapper.goodsList(pageInfo, search.getGoodsCategoryId(), search.getName());
-        LoginUser loginUserApplet = tokenService.getLoginUserApplet();
+        Long userId = null;
+        String token = SecurityUtils.getToken(ServletUtils.getRequest());
+        if(StringUtils.isNotEmpty(token)){
+            userId = tokenService.getLoginUserApplet().getUserid();
+        }
         for (GoodsVO goods : list) {
-            R<Price> r = remoteOrderGoodsClient.getGoodsPrice(loginUserApplet.getUserid(), goods.getGoodsId(), null);
-            if (null != r.getData()){
-                Price price = r.getData();
-                goods.setSellingPrice(price.getCash());
-                goods.setIntegral(price.getPoint());
+            //游客展示基础售价
+            if(null != userId){
+                R<Price> r = remoteOrderGoodsClient.getGoodsPrice(userId, goods.getGoodsId(), null);
+                if (null != r.getData()){
+                    Price price = r.getData();
+                    goods.setSellingPrice(price.getCash());
+                    goods.setIntegral(price.getPoint());
+                }
             }
         }
         return pageInfo.setRecords(list);
@@ -283,10 +293,12 @@
 
         for (GoodsShop goodsShop : goodsShops) {
             Shop shop = shopMapper.selectById(goodsShop.getShopId());
-            goodsShop.setShopName(shop.getName());
-            goodsShop.setOwnerName(shop.getShopManager());
-            goodsShop.setPhone(shop.getPhone());
-            goodsShop.setAddress(shop.getAddress());
+            if(null != shop){
+                goodsShop.setShopName(shop.getName());
+                goodsShop.setOwnerName(shop.getShopManager());
+                goodsShop.setPhone(shop.getPhone());
+                goodsShop.setAddress(shop.getAddress());
+            }
         }
         goods.setGoodsShopList(goodsShops);
 

--
Gitblit v1.7.1