From 56d62d9edb0dda9ae678dcea2323144db5d11c22 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期六, 28 十二月 2024 18:06:58 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java |   35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 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 a45c0d6..4a11ead 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
@@ -74,6 +74,7 @@
     public List<GoodsVO> goodsList(Goods search) {
         List<Goods> goodsList = this.list(new LambdaQueryWrapper<Goods>()
                 .eq(Goods::getStatus, GoodsStatus.UP.getCode())
+                .eq(Goods::getDelFlag, 0)
                 .eq(Objects.nonNull(search.getGoodsCategoryId()), Goods::getGoodsCategoryId, search.getGoodsCategoryId())
                 .like(StringUtils.isNotEmpty(search.getName()), Goods::getName, search.getName()));
 
@@ -85,7 +86,7 @@
             goodsVO.setGoodsId(goods.getId());
             goodsVO.setGoodsName(goods.getName());
             R<Price> r = remoteOrderGoodsClient.getGoodsPrice(loginUserApplet.getUserid(), goods.getId(), null);
-            if (R.isSuccess(r)){
+            if (null != r.getData()){
                 Price price = r.getData();
                 goodsVO.setSellingPrice(price.getCash());
                 goodsVO.setIntegral(price.getPoint());
@@ -103,11 +104,12 @@
 
         LoginUser loginUserApplet = tokenService.getLoginUserApplet();
         AppUser appUser = appUserClient.getAppUserById(loginUserApplet.getUserid());
-        BigDecimal sellingPrice;
-        Integer integral;
+        BigDecimal sellingPrice = BigDecimal.ZERO;
+        Integer integral = 0;
 
         GoodsArea goodsArea = goodsAreaMapper.selectOne(new LambdaQueryWrapper<GoodsArea>()
                 .eq(GoodsArea::getGoodsId, goodsId)
+                .eq(GoodsArea::getVip, appUser.getVipId())
                 .eq(GoodsArea::getProvinceCode, appUser.getProvinceCode())
                 .eq(StringUtils.isNotEmpty(appUser.getCityCode()), GoodsArea::getCityCode, appUser.getCityCode())
                 .eq(StringUtils.isNotEmpty(appUser.getDistrictCode()), GoodsArea::getDistrictsCode, appUser.getDistrictCode()));
@@ -120,9 +122,10 @@
             GoodsVip goodsVip = goodsVipService.getOne(new LambdaQueryWrapper<GoodsVip>()
                     .eq(GoodsVip::getVip, vipSetting.getId())
                     .eq(GoodsVip::getGoodsId, goodsId));
-
-            sellingPrice = goodsVip.getSellingPrice();
-            integral = goodsVip.getIntegral();
+            if(null != goodsVip){
+                sellingPrice = goodsVip.getSellingPrice();
+                integral = goodsVip.getIntegral();
+            }
         }
 
         Goods goods = this.getById(goodsId);
@@ -133,14 +136,19 @@
         goodsVO.setSellingPrice(sellingPrice);
         goodsVO.setIntegral(integral);
 
-        List<GoodsShop> goodsShopList = goodsShopMapper.selectList(new LambdaQueryWrapper<GoodsShop>()
-                .eq(GoodsShop::getGoodsId, goodsId));
-        if (!CollectionUtils.isEmpty(goodsShopList)){
-            List<Integer> shopIds = goodsShopList.stream().map(GoodsShop::getShopId).collect(Collectors.toList());
+        if(goods.getAppointStore() == 2){
             List<Shop> shopList = shopMapper.selectList(new LambdaQueryWrapper<Shop>()
-                    .in(Shop::getId, shopIds));
-
+                    .in(Shop::getDelFlag, 0));
             goodsVO.setShopList(shopList);
+        }else{
+            List<GoodsShop> goodsShopList = goodsShopMapper.selectList(new LambdaQueryWrapper<GoodsShop>()
+                    .eq(GoodsShop::getGoodsId, goodsId));
+            if (!CollectionUtils.isEmpty(goodsShopList)){
+                List<Integer> shopIds = goodsShopList.stream().map(GoodsShop::getShopId).collect(Collectors.toList());
+                List<Shop> shopList = shopMapper.selectList(new LambdaQueryWrapper<Shop>()
+                        .in(Shop::getId, shopIds));
+                goodsVO.setShopList(shopList);
+            }
         }
         return goodsVO;
     }
@@ -167,7 +175,7 @@
 
         // 指定门店
         Integer appointStore = goods.getAppointStore();
-        if (appointStore == 1){
+        if (null != appointStore && appointStore == 1){
             List<GoodsShop> goodsShopList = goods.getGoodsShopList();
             if (CollectionUtils.isEmpty(goodsShopList)){
                 throw new NullPointerException("请选择指定门店");
@@ -220,6 +228,7 @@
             for (GoodsArea goodsArea : goodsAreaList) {
                 List<GoodsArea> goodsAreaList1 = goodsArea.getGoodsAreaList();
                 for (GoodsArea area : goodsAreaList1) {
+                    area.setId(null);
                     area.setGoodsId(id);
                     area.setProvince(goodsArea.getProvince());
                     area.setCity(goodsArea.getCity());

--
Gitblit v1.7.1