From 730c70af018d50a6ca5a13be2d8fa25c6c42c357 Mon Sep 17 00:00:00 2001
From: rentaiming <806181062@qq.com>
Date: 星期五, 07 六月 2024 18:17:31 +0800
Subject: [PATCH] 用户端商品

---
 ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/MemberGoodsCollectionServiceImpl.java |   85 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 75 insertions(+), 10 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 48bb229..d9ebce2 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
@@ -5,13 +5,18 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.core.constant.SecurityConstants;
 import com.ruoyi.common.core.exception.ServiceException;
+import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.utils.page.PageDTO;
 import com.ruoyi.goods.domain.MemberGoodsCollection;
+import com.ruoyi.goods.mapper.GoodsGroupPurchaseMapper;
+import com.ruoyi.goods.mapper.GoodsSeckillMapper;
 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;
@@ -21,6 +26,8 @@
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -37,12 +44,19 @@
      @Resource
      private GoodsSkuMapper goodsSkuMapper;
 
+    @Resource
+    private GoodsSeckillMapper goodsSeckillMapper;
+
+
+    @Resource
+    private GoodsGroupPurchaseMapper goodsGroupPurchaseMapper;
+
     @Override
     public void saveGoodsCollection(AuctionCollectionDTO auctionCollectionDTO) {
-        if (auctionCollectionDTO.getMemberId()!=null) {
+        if (auctionCollectionDTO.getMemberId()==null) {
             throw new ServiceException("用户ID不能为空");
         }
-        if (auctionCollectionDTO.getState()!=null) {
+        if (auctionCollectionDTO.getState()==null) {
             throw new ServiceException("类型不能为空");
         }
 
@@ -70,23 +84,74 @@
 
     @Override
     public PageDTO<HomeGoodsSkuListVO> getGoodsCollectionList(AuctionCollectionDTO auctionCollectionDTO) {
+
+        Set<Long> goodsSkuIdList = null;
+        if (StringUtils.isNotEmpty(auctionCollectionDTO.getGoodsSkuName())) {
+            LambdaQueryWrapper<GoodsSku> wrapper= Wrappers.lambdaQuery();
+            wrapper.like(GoodsSku::getSkuName,auctionCollectionDTO.getGoodsSkuName());
+            wrapper.eq(GoodsSku::getDelFlag,0);
+            List<GoodsSku> page1 = goodsSkuMapper.selectList(wrapper);
+            goodsSkuIdList = page1.stream().map(GoodsSku::getId)
+                    .collect(Collectors.toSet());
+        }
+
+
         Page<HomeGoodsSkuListVO> page = new Page<>();
         page.setSize(auctionCollectionDTO.getPageSize());
         page.setCurrent(auctionCollectionDTO.getPageCurr());
         LambdaQueryWrapper< MemberGoodsCollection> wrapper= Wrappers.lambdaQuery();
         wrapper.eq(MemberGoodsCollection::getMemberId,auctionCollectionDTO.getMemberId());
+        if (StringUtils.isNotEmpty(auctionCollectionDTO.getGoodsSkuName())){
+            if (goodsSkuIdList.size()>0){
+                wrapper.in(MemberGoodsCollection::getTargetId,goodsSkuIdList);
+            }
+        }
         List<MemberGoodsCollection> list = this.list(wrapper);
 
         List<HomeGoodsSkuListVO> auctionGoodsVOS=new ArrayList<>();
         for (MemberGoodsCollection auctionCollection:list){
-            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);
+            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);
+                auctionGoodsVOS.add(auctionGoodsVO);
+            }   if(auctionCollection.getType()==2){
+                HomeGoodsSkuListVO auctionGoodsVO=new HomeGoodsSkuListVO();
+                GoodsSeckill goodsSeckill = goodsSeckillMapper.selectById(auctionCollection.getTargetId());
+                GoodsSku goodsSku = goodsSkuMapper.selectById(goodsSeckill.getGoodsSkuId());
+                auctionGoodsVO.setId(auctionCollection.getTargetId());
+                auctionGoodsVO.setPrice(goodsSku.getPrice());
+                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(goodsSeckill.getSeckillPrice());
+                auctionGoodsVOS.add(auctionGoodsVO);
+            }   if(auctionCollection.getType()==1){
+                GoodsGroupPurchase goodsGroupPurchase = goodsGroupPurchaseMapper.selectById(auctionCollection.getTargetId());
+                HomeGoodsSkuListVO auctionGoodsVO=new HomeGoodsSkuListVO();
+                GoodsSku goodsSku = goodsSkuMapper.selectById(goodsGroupPurchase.getGoodsSkuId());
+                auctionGoodsVO.setId(auctionCollection.getTargetId());
+                auctionGoodsVO.setPrice(goodsSku.getPrice());
+                auctionGoodsVO.setCoverPic(goodsSku.getCoverPic());
+                auctionGoodsVO.setSkuName(goodsSku.getSkuName());
+                auctionGoodsVO.setSoldQuantity(goodsSku.getSoldQuantity());
+                auctionGoodsVO.setIsCollection(2);
+                auctionGoodsVO.setXiaosPrice(goodsGroupPurchase.getGroupPurchasePrice());
+                auctionGoodsVO.setStartTime(goodsGroupPurchase.getStartTime());
+                auctionGoodsVO.setEndTime(goodsGroupPurchase.getEndTime());
+                auctionGoodsVO.setXiaosPrice(goodsGroupPurchase.getGroupPurchasePrice());
+                auctionGoodsVOS.add(auctionGoodsVO);
+            }
+
         }
         page.setRecords(auctionGoodsVOS);
         return PageDTO.of(page);

--
Gitblit v1.7.1