From d7dc4db8d005a58f51d21d35147317762a16373f Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期五, 16 八月 2024 13:40:11 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/MemberGoodsCollectionServiceImpl.java |  102 +++++++++++++++++++++++++++------------------------
 1 files changed, 54 insertions(+), 48 deletions(-)

diff --git a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/MemberGoodsCollectionServiceImpl.java b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/MemberGoodsCollectionServiceImpl.java
index 1aa37c2..cfb4ae3 100644
--- a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/MemberGoodsCollectionServiceImpl.java
+++ b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/MemberGoodsCollectionServiceImpl.java
@@ -3,9 +3,10 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.ruoyi.common.core.constant.SecurityConstants;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.core.exception.ServiceException;
 import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.core.utils.page.CollUtils;
 import com.ruoyi.common.core.utils.page.PageDTO;
 import com.ruoyi.goods.domain.MemberGoodsCollection;
 import com.ruoyi.goods.mapper.GoodsGroupPurchaseMapper;
@@ -13,22 +14,19 @@
 import com.ruoyi.goods.mapper.GoodsSkuMapper;
 import com.ruoyi.goods.mapper.MemberGoodsCollectionMapper;
 import com.ruoyi.goods.service.IMemberGoodsCollectionService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.system.api.domain.AuctionGoods;
 import com.ruoyi.system.api.domain.GoodsGroupPurchase;
 import com.ruoyi.system.api.domain.GoodsSeckill;
 import com.ruoyi.system.api.domain.GoodsSku;
 import com.ruoyi.system.api.domain.dto.AuctionCollectionDTO;
-import com.ruoyi.system.api.domain.vo.AuctionGoodsListVO;
 import com.ruoyi.system.api.domain.vo.HomeGoodsSkuListVO;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
+import javax.annotation.Resource;
+import org.springframework.stereotype.Service;
 
 /**
  * <p>
@@ -116,59 +114,67 @@
             }
         }
         List<MemberGoodsCollection> list = this.list(wrapper);
-
-        List<HomeGoodsSkuListVO> auctionGoodsVOS=new ArrayList<>();
-        for (MemberGoodsCollection auctionCollection:list){
-            if(auctionCollection.getType()==1){
-                HomeGoodsSkuListVO auctionGoodsVO=new HomeGoodsSkuListVO();
-                GoodsSku goodsSku = goodsSkuMapper.selectById(auctionCollection.getTargetId());
-                auctionGoodsVO.setId(goodsSku.getId());
-                auctionGoodsVO.setPrice(goodsSku.getPrice());
-                auctionGoodsVO.setCoverPic(goodsSku.getCoverPic());
-                auctionGoodsVO.setSkuName(goodsSku.getSkuName());
-                auctionGoodsVO.setSoldQuantity(goodsSku.getSoldQuantity());
-                auctionGoodsVO.setIsCollection(2);
-                auctionGoodsVO.setType(auctionCollection.getType());
-                auctionGoodsVOS.add(auctionGoodsVO);
-            }   if(auctionCollection.getType()==3){
-                HomeGoodsSkuListVO auctionGoodsVO=new HomeGoodsSkuListVO();
-                GoodsSeckill goodsSeckill = goodsSeckillMapper.selectById(auctionCollection.getTargetId());
-                GoodsSku goodsSku = goodsSkuMapper.selectById(goodsSeckill.getGoodsSkuId());
-                auctionGoodsVO.setId(auctionCollection.getTargetId());
-                auctionGoodsVO.setPrice( goodsSeckill.getSeckillPrice());
-                auctionGoodsVO.setCoverPic(goodsSku.getCoverPic());
-                auctionGoodsVO.setSkuName(goodsSku.getSkuName());
-                auctionGoodsVO.setSoldQuantity(goodsSku.getSoldQuantity());
-                auctionGoodsVO.setIsCollection(2);
-                auctionGoodsVO.setStartStatus(goodsSeckill.getStartStatus());
-                auctionGoodsVO.setStartTime(goodsSeckill.getStartTime());
-                auctionGoodsVO.setEndTime(goodsSeckill.getEndTime());
-                auctionGoodsVO.setXiaosPrice(goodsSku.getPrice());
-                auctionGoodsVO.setType(auctionCollection.getType());
-                auctionGoodsVOS.add(auctionGoodsVO);
-            }   if(auctionCollection.getType()==2){
-                GoodsGroupPurchase goodsGroupPurchase = goodsGroupPurchaseMapper.selectById(auctionCollection.getTargetId());
-                HomeGoodsSkuListVO auctionGoodsVO=new HomeGoodsSkuListVO();
-                if(goodsGroupPurchase!=null){
-                    GoodsSku goodsSku = goodsSkuMapper.selectById(goodsGroupPurchase.getGoodsSkuId());
+        if (CollUtils.isNotEmpty(list)) {
+            List<HomeGoodsSkuListVO> auctionGoodsVOS = new ArrayList<>();
+            for (MemberGoodsCollection auctionCollection : list) {
+                if (auctionCollection.getType() == 1) {
+                    HomeGoodsSkuListVO auctionGoodsVO = new HomeGoodsSkuListVO();
+                    GoodsSku goodsSku = goodsSkuMapper.selectById(auctionCollection.getTargetId());
+                    if (Objects.nonNull(goodsSku)) {
+                        auctionGoodsVO.setId(goodsSku.getId());
+                        auctionGoodsVO.setPrice(goodsSku.getPrice());
+                        auctionGoodsVO.setCoverPic(goodsSku.getCoverPic());
+                        auctionGoodsVO.setSkuName(goodsSku.getSkuName());
+                        auctionGoodsVO.setSoldQuantity(goodsSku.getSoldQuantity());
+                        auctionGoodsVO.setIsCollection(2);
+                        auctionGoodsVO.setType(auctionCollection.getType());
+                        auctionGoodsVOS.add(auctionGoodsVO);
+                    }
+                }
+                if (auctionCollection.getType() == 3) {
+                    HomeGoodsSkuListVO auctionGoodsVO = new HomeGoodsSkuListVO();
+                    GoodsSeckill goodsSeckill = goodsSeckillMapper.selectById(
+                            auctionCollection.getTargetId());
+                    GoodsSku goodsSku = goodsSkuMapper.selectById(goodsSeckill.getGoodsSkuId());
                     auctionGoodsVO.setId(auctionCollection.getTargetId());
-                    auctionGoodsVO.setPrice(goodsGroupPurchase.getGroupPurchasePrice());
+                    auctionGoodsVO.setPrice(goodsSeckill.getSeckillPrice());
                     auctionGoodsVO.setCoverPic(goodsSku.getCoverPic());
                     auctionGoodsVO.setSkuName(goodsSku.getSkuName());
                     auctionGoodsVO.setSoldQuantity(goodsSku.getSoldQuantity());
                     auctionGoodsVO.setIsCollection(2);
+                    auctionGoodsVO.setStartStatus(goodsSeckill.getStartStatus());
+                    auctionGoodsVO.setStartTime(goodsSeckill.getStartTime());
+                    auctionGoodsVO.setEndTime(goodsSeckill.getEndTime());
                     auctionGoodsVO.setXiaosPrice(goodsSku.getPrice());
-                    auctionGoodsVO.setStartTime(goodsGroupPurchase.getStartTime());
-                    auctionGoodsVO.setEndTime(goodsGroupPurchase.getEndTime());
-                    auctionGoodsVO.setXiaosPrice(goodsGroupPurchase.getGroupPurchasePrice());
                     auctionGoodsVO.setType(auctionCollection.getType());
                     auctionGoodsVOS.add(auctionGoodsVO);
                 }
+                if (auctionCollection.getType() == 2) {
+                    GoodsGroupPurchase goodsGroupPurchase = goodsGroupPurchaseMapper.selectById(
+                            auctionCollection.getTargetId());
+                    HomeGoodsSkuListVO auctionGoodsVO = new HomeGoodsSkuListVO();
+                    if (goodsGroupPurchase != null) {
+                        GoodsSku goodsSku = goodsSkuMapper.selectById(
+                                goodsGroupPurchase.getGoodsSkuId());
+                        auctionGoodsVO.setId(auctionCollection.getTargetId());
+                        auctionGoodsVO.setPrice(goodsGroupPurchase.getGroupPurchasePrice());
+                        auctionGoodsVO.setCoverPic(goodsSku.getCoverPic());
+                        auctionGoodsVO.setSkuName(goodsSku.getSkuName());
+                        auctionGoodsVO.setSoldQuantity(goodsSku.getSoldQuantity());
+                        auctionGoodsVO.setIsCollection(2);
+                        auctionGoodsVO.setXiaosPrice(goodsSku.getPrice());
+                        auctionGoodsVO.setStartTime(goodsGroupPurchase.getStartTime());
+                        auctionGoodsVO.setEndTime(goodsGroupPurchase.getEndTime());
+                        auctionGoodsVO.setXiaosPrice(goodsGroupPurchase.getGroupPurchasePrice());
+                        auctionGoodsVO.setType(auctionCollection.getType());
+                        auctionGoodsVOS.add(auctionGoodsVO);
+                    }
+
+                }
 
             }
-
+            page.setRecords(auctionGoodsVOS);
         }
-        page.setRecords(auctionGoodsVOS);
         return PageDTO.of(page);
     }
 }

--
Gitblit v1.7.1