From fe2d5b14031edbe43238770fb1fc21e8a322b51a Mon Sep 17 00:00:00 2001
From: rentaiming <806181062@qq.com>
Date: 星期四, 13 六月 2024 18:18:08 +0800
Subject: [PATCH] 用户端商品

---
 ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSkuServiceImpl.java |  381 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 370 insertions(+), 11 deletions(-)

diff --git a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSkuServiceImpl.java b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSkuServiceImpl.java
index 5e5fca8..9b144d1 100644
--- a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSkuServiceImpl.java
+++ b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSkuServiceImpl.java
@@ -1,30 +1,60 @@
 package com.ruoyi.goods.service.impl;
 
+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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.ruoyi.common.core.constant.SecurityConstants;
+import com.ruoyi.common.core.enums.ListingStatusEnum;
 import com.ruoyi.common.core.exception.ServiceException;
 import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.utils.page.BeanUtils;
 import com.ruoyi.common.core.utils.page.Checker;
 import com.ruoyi.common.core.utils.page.CollUtils;
 import com.ruoyi.common.core.utils.page.PageDTO;
-import com.ruoyi.goods.domain.dto.GoodsInfoTitleValueDTO;
-import com.ruoyi.goods.domain.dto.GoodsSkuDTO;
-import com.ruoyi.goods.domain.pojo.GoodsInfoTitleValue;
-import com.ruoyi.goods.domain.pojo.GoodsSku;
-import com.ruoyi.goods.domain.query.GoodsSkuQuery;
-import com.ruoyi.goods.domain.vo.GoodsSkuVO;
+import com.ruoyi.goods.controller.management.dto.GoodsInfoTitleValueDTO;
+import com.ruoyi.goods.controller.management.dto.GoodsSkuDTO;
+import com.ruoyi.goods.controller.management.dto.GoodsSkuQuery;
+import com.ruoyi.goods.controller.management.vo.GoodsInfoTitleValueVO;
+import com.ruoyi.goods.controller.management.vo.GoodsSkuVO;
+import com.ruoyi.goods.domain.GoodsInfoTitleValue;
+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.service.IGoodsInfoTitleValueService;
 import com.ruoyi.goods.service.IGoodsSkuService;
+import com.ruoyi.goods.service.IMemberGoodsCollectionService;
+import com.ruoyi.system.api.domain.GoodsBrand;
+import com.ruoyi.system.api.domain.GoodsCategory;
+import com.ruoyi.system.api.domain.GoodsFlavorType;
+import com.ruoyi.system.api.domain.GoodsGroupPurchase;
+import com.ruoyi.system.api.domain.GoodsSeckill;
+import com.ruoyi.system.api.domain.GoodsSeries;
+import com.ruoyi.system.api.domain.GoodsSku;
+import com.ruoyi.system.api.domain.dto.GoodsStockUpdDTO;
+import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO;
 import com.ruoyi.system.api.domain.dto.ListStatusDTO;
-import java.util.List;
-import java.util.Objects;
+import com.ruoyi.system.api.domain.vo.HomeGoodsSkuInfoVO;
+import com.ruoyi.system.api.domain.vo.HomeGoodsSkuListVO;
+import com.ruoyi.system.api.domain.vo.getHomeGoodsSkuXxiVO;
+import com.ruoyi.system.api.feignClient.GoodsSkuClient;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+import javax.annotation.Resource;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -41,6 +71,17 @@
 public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> implements IGoodsSkuService {
 
     private final IGoodsInfoTitleValueService goodsInfoTitleValueService;
+    private final GoodsSeckillMapper goodsSeckillMapper;
+    private final GoodsGroupPurchaseMapper goodsGroupPurchaseMapper;
+    private final RedissonClient redissonClient;
+
+    @Resource
+    private  GoodsSkuClient goodsSkuClient;
+
+    @Resource
+    private IMemberGoodsCollectionService iMemberGoodsCollectionService;
+
+
     private static final ObjectMapper objectMapper = new ObjectMapper();
 
     /**
@@ -64,6 +105,10 @@
         if (Objects.isNull(dto.getId())) {
             this.save(goodsSku);
         } else {
+            GoodsSku goodsSkuOrg = this.getById(dto.getId());
+            if (StringUtils.isNull(goodsSkuOrg)) {
+                throw new ServiceException("商品不存在");
+            }
             this.updateById(goodsSku);
         }
 
@@ -140,8 +185,9 @@
                         query.getSkuName())
                 .eq(StringUtils.isNotNull(query.getListingStatus()
                 ), GoodsSku::getListingStatus, query.getListingStatus())
-                .page(new Page<GoodsSku>(query.getPageCurr(), query.getPageSize()));
-
+                .eq(query.getQueryType().equals(1), GoodsSku::getListingStatus,
+                        ListingStatusEnum.ON_SHELVES)
+                .page(new Page<>(query.getPageCurr(), query.getPageSize()));
         return PageDTO.of(page, GoodsSkuVO.class);
     }
 
@@ -149,13 +195,326 @@
      * 更新商品SKU的状态。
      *
      * @param dto 数据传输对象,包含需要更新的SKU的ID和新的上架状态。 其中,ID用于指定要更新的具体SKU,listingStatus用于指定新的上架状态。
-     * @return 无返回值。
      */
     @Override
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
     public void updStatus(ListStatusDTO dto) {
         this.lambdaUpdate()
                 .eq(GoodsSku::getId, dto.getId())
                 .set(GoodsSku::getListingStatus, dto.getListingStatus())
                 .update();
+        //关联的秒杀商品和团购商品同步下架
+        if (dto.getListingStatus().equals(ListingStatusEnum.REMOVED_FROM_THE_SHELF)) {
+            updateGoodsStatus(dto);
+        }
+    }
+
+    private void updateGoodsStatus(ListStatusDTO dto) {
+        LambdaQueryWrapper<GoodsSeckill> queryWrapper =new LambdaQueryWrapper<>();
+        queryWrapper.eq(GoodsSeckill::getListingStatus, ListingStatusEnum.ON_SHELVES)
+                .eq(GoodsSeckill::getGoodsSkuId, dto.getId());
+        List<GoodsSeckill> goodsSeckillList = goodsSeckillMapper.selectList(queryWrapper);
+        if (StringUtils.isNotNull(goodsSeckillList)) {
+            for (GoodsSeckill goodsSeckill : goodsSeckillList) {
+                goodsSeckill.setListingStatus(ListingStatusEnum.REMOVED_FROM_THE_SHELF);
+                goodsSeckillMapper.updateById(goodsSeckill);
+            }
+        }
+
+        LambdaQueryWrapper<GoodsGroupPurchase> queryWrapper1 =new LambdaQueryWrapper<>();
+        queryWrapper1.eq(GoodsGroupPurchase::getListingStatus,
+                        ListingStatusEnum.ON_SHELVES)
+                .eq(GoodsGroupPurchase::getGoodsSkuId, dto.getId());
+        GoodsGroupPurchase goodsGroupPurchase = goodsGroupPurchaseMapper.selectOne(queryWrapper1);
+        if (StringUtils.isNotNull(goodsGroupPurchase)) {
+            goodsGroupPurchase.setListingStatus(ListingStatusEnum.REMOVED_FROM_THE_SHELF);
+            goodsGroupPurchaseMapper.updateById(goodsGroupPurchase);
+        }
+    }
+
+    /**
+     * 根据商品名称查询商品SKU列表。
+     *
+     * @param goodsSkuName 商品名称
+     * @return List<GoodsSku>商品SKU列表
+     */
+    @Override
+    public List<GoodsSku> getGoodsByName(String goodsSkuName) {
+        return this.lambdaQuery()
+                .like(StringUtils.isNotEmpty(goodsSkuName), GoodsSku::getSkuName, goodsSkuName)
+                .list();
+    }
+
+
+    /**
+     * 批量更新商品库存 auctionStock 负数则为减库存,正数为加库存
+     *
+     * @param goodsStockUpdDTOS 商品库存修改数据传输对象
+     */
+    @Override
+    @Transactional(propagation = Propagation.REQUIRES_NEW)
+    public void updGoodsStock(List<GoodsStockUpdDTO> goodsStockUpdDTOS) {
+        List<Long> goodsSkuIdList = goodsStockUpdDTOS.stream()
+                .map(GoodsStockUpdDTO::getGoodsSkuId)
+                .collect(Collectors.toList());
+        List<GoodsSku> goodsSkus = this.listByIds(goodsSkuIdList);
+
+        if (StringUtils.isEmpty(goodsSkus)) {
+            throw new ServiceException("商品不存在");
+        }
+        Map<Long, Integer> stockMap = goodsStockUpdDTOS.stream()
+                .collect(Collectors.toMap(GoodsStockUpdDTO::getGoodsSkuId,
+                        GoodsStockUpdDTO::getAuctionStock));
+        for (GoodsSku skus : goodsSkus) {
+            String goodsLock = "goods_lock:" + skus.getId();
+            RLock redissonLock = redissonClient.getLock(goodsLock);
+            try {
+                redissonLock.lock(30, TimeUnit.SECONDS);
+                Integer auctionStock = stockMap.get(skus.getId());
+                if (StringUtils.isNotNull(auctionStock) && auctionStock > 0) {
+                    // 更新商品库存,更新五次失败抛出异常
+                    boolean isUpdated = false;
+                    for (int i = 0; i < 5; i++) {
+                        isUpdated = updateGoodsStock(skus, auctionStock);
+                        if (isUpdated) {
+                            break;
+                        } else {
+                            skus = this.getById(skus.getId());
+                        }
+                    }
+                    if (!isUpdated) {
+                        throw new ServiceException("商品库存回退失败");
+                    }
+                }
+            } finally {
+                redissonLock.unlock();
+            }
+        }
+
+    }
+
+    @Override
+    public PageDTO<HomeGoodsSkuListVO> getHomeGoodsSkuVOList(HomeGoodsSkuDTO homeGoodsSkuDTO) {
+        Page<GoodsSku> page = new Page<>();
+        page.setSize(homeGoodsSkuDTO.getPageSize());
+        page.setCurrent(homeGoodsSkuDTO.getPageCurr());
+
+        LambdaQueryWrapper<GoodsSku> wrapper3= Wrappers.lambdaQuery();
+        wrapper3.eq(GoodsSku::getDelFlag,0);
+        wrapper3.eq(GoodsSku::getListingStatus,0);
+        if (homeGoodsSkuDTO.getSkuName()!=null){
+            wrapper3.like(GoodsSku::getSkuName,homeGoodsSkuDTO.getSkuName());
+        }
+        if (homeGoodsSkuDTO.getBrandId()!=null){
+            wrapper3.eq(GoodsSku::getBrandId,homeGoodsSkuDTO.getBrandId());
+        }
+        if (homeGoodsSkuDTO.getCategoryId()!=null){
+            wrapper3.eq(GoodsSku::getCategoryId,homeGoodsSkuDTO.getCategoryId());
+        }
+
+        if (homeGoodsSkuDTO.getSeriesId()!=null){
+            wrapper3.eq(GoodsSku::getSeriesId,homeGoodsSkuDTO.getSeriesId());
+        }
+        if (homeGoodsSkuDTO.getFlavorTypeId()!=null){
+            wrapper3.eq(GoodsSku::getFlavorTypeId,homeGoodsSkuDTO.getFlavorTypeId());
+        }
+        if (homeGoodsSkuDTO.getSort()==2){
+            wrapper3.orderByAsc(GoodsSku::getPrice);
+        }
+        if (homeGoodsSkuDTO.getSort()==3){
+            wrapper3.orderByDesc(GoodsSku::getPrice);
+        }
+        if (homeGoodsSkuDTO.getSort()==4){
+            wrapper3.orderByAsc(GoodsSku::getSoldQuantity);
+        }
+        if (homeGoodsSkuDTO.getSort()==5){
+            wrapper3.orderByDesc(GoodsSku::getSoldQuantity);
+        }
+        if(homeGoodsSkuDTO.getYear()==2){
+            LocalDateTime now = LocalDateTime.now();
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            LocalDateTime newTime7 = now.minusYears(30);
+            String formattedDate7 = newTime7.format(formatter);
+            LocalDateTime parseTime7 = LocalDate.parse(formattedDate7).atStartOfDay();
+            wrapper3.le(GoodsSku::getYears,parseTime7);
+        }
+        if(homeGoodsSkuDTO.getYear()==3){
+            LocalDateTime now = LocalDateTime.now();
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            LocalDateTime newTime7 = now.minusYears(30);
+            String formattedDate7 = newTime7.format(formatter);
+            LocalDateTime parseTime7 = LocalDate.parse(formattedDate7).atStartOfDay();
+
+            LocalDateTime newTime15 = now.minusYears(15);
+            String formattedDate15 = newTime15.format(formatter);
+            LocalDateTime parseTime15= LocalDate.parse(formattedDate15).atStartOfDay();
+            wrapper3.le(GoodsSku::getYears, parseTime15)
+                    .gt(GoodsSku::getYears, parseTime7);
+        }
+
+        if(homeGoodsSkuDTO.getYear()==4){
+            LocalDateTime now = LocalDateTime.now();
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            LocalDateTime newTime7 = now.minusYears(5);
+            String formattedDate7 = newTime7.format(formatter);
+            LocalDateTime parseTime7 = LocalDate.parse(formattedDate7).atStartOfDay();
+
+            LocalDateTime newTime15 = now.minusYears(15);
+            String formattedDate15 = newTime15.format(formatter);
+            LocalDateTime parseTime15= LocalDate.parse(formattedDate15).atStartOfDay();
+            wrapper3.le(GoodsSku::getYears, parseTime7)
+                    .gt(GoodsSku::getYears, parseTime15);
+        }
+
+        if(homeGoodsSkuDTO.getYear()==5){
+            LocalDateTime now = LocalDateTime.now();
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            LocalDateTime newTime7 = now.minusYears(1);
+            String formattedDate7 = newTime7.format(formatter);
+            LocalDateTime parseTime7 = LocalDate.parse(formattedDate7).atStartOfDay();
+
+            LocalDateTime newTime15 = now.minusYears(5);
+            String formattedDate15 = newTime15.format(formatter);
+            LocalDateTime parseTime15= LocalDate.parse(formattedDate15).atStartOfDay();
+            wrapper3.le(GoodsSku::getYears, parseTime7)
+                    .ge(GoodsSku::getYears, parseTime15);
+        }
+        wrapper3.orderByAsc(GoodsSku::getSortNum);
+        Page<GoodsSku> page1 = this.page(page, wrapper3);
+        PageDTO<HomeGoodsSkuListVO> articleCommentsVOPageDTO = PageDTO.of(page1, HomeGoodsSkuListVO.class);
+        return  articleCommentsVOPageDTO;
+
+    }
+
+    @Override
+    public HomeGoodsSkuInfoVO getHomeGoodsSkuInfo(HomeGoodsSkuDTO homeGoodsSkuDTO) {
+        GoodsSku byId = this.getById(homeGoodsSkuDTO.getGoodsSkuId());
+        HomeGoodsSkuInfoVO homeGoodsSkuInfoVO=new HomeGoodsSkuInfoVO();
+        homeGoodsSkuInfoVO.setId(byId.getId());
+        homeGoodsSkuInfoVO.setSkuName(byId.getSkuName());
+        homeGoodsSkuInfoVO.setYears(String.valueOf(byId.getYears().getYear()));
+        GoodsBrand data = goodsSkuClient.getBrandOne(byId.getBrandId(), SecurityConstants.INNER).getData();
+        GoodsCategory data1 = goodsSkuClient.getCategoryOne(byId.getCategoryId(), SecurityConstants.INNER).getData();
+        GoodsSeries data2 = goodsSkuClient.getSeriesOne(byId.getSeriesId(), SecurityConstants.INNER).getData();
+        GoodsFlavorType data3 = goodsSkuClient.getFlavorTypeOne(byId.getFlavorTypeId(), SecurityConstants.INNER).getData();
+        homeGoodsSkuInfoVO.setBrand(data.getBrandName());
+        homeGoodsSkuInfoVO.setCategory(data1.getCategoryName());
+        homeGoodsSkuInfoVO.setSeries(data2.getSeriesName());
+        homeGoodsSkuInfoVO.setFlavorType(data3.getFlavorTypeName());
+        homeGoodsSkuInfoVO.setPrice(byId.getPrice());
+        homeGoodsSkuInfoVO.setSoldQuantity(byId.getSoldQuantity());
+        homeGoodsSkuInfoVO.setUnit(byId.getUnit());
+        homeGoodsSkuInfoVO.setSpec(byId.getSpec());
+        homeGoodsSkuInfoVO.setSpecUnit(byId.getSpecUnit());
+        homeGoodsSkuInfoVO.setCoverPic(byId.getCoverPic());
+        homeGoodsSkuInfoVO.setAlbum(byId.getAlbum());
+        homeGoodsSkuInfoVO.setDescription(byId.getDescription());
+        homeGoodsSkuInfoVO.setDetail(byId.getDetail());
+        homeGoodsSkuInfoVO.setShareTitle(byId.getShareTitle());
+        homeGoodsSkuInfoVO.setSharePic(byId.getSharePic());
+        LambdaQueryWrapper<GoodsGroupPurchase> queryWrapper1 =new LambdaQueryWrapper<>();
+        queryWrapper1.eq(GoodsGroupPurchase::getListingStatus,
+                        ListingStatusEnum.ON_SHELVES)
+                .eq(GoodsGroupPurchase::getGoodsSkuId, byId.getId());
+        GoodsGroupPurchase goodsGroupPurchase = goodsGroupPurchaseMapper.selectOne(queryWrapper1);
+        if(goodsGroupPurchase!=null){
+            homeGoodsSkuInfoVO.setGroupPurchaseGoods(2);
+        }else {
+            homeGoodsSkuInfoVO.setGroupPurchaseGoods(1);
+        }
+
+        LambdaQueryWrapper<MemberGoodsCollection> wrapper3= Wrappers.lambdaQuery();
+        wrapper3.eq(MemberGoodsCollection::getDelFlag,0);
+        wrapper3.eq(MemberGoodsCollection::getMemberId,homeGoodsSkuDTO.getMemberId());
+        wrapper3.eq(MemberGoodsCollection::getTargetId,homeGoodsSkuDTO.getGoodsSkuId());
+        List<MemberGoodsCollection> list = iMemberGoodsCollectionService.list(wrapper3);
+        if (list.size()>0){
+            homeGoodsSkuInfoVO.setIsCollection(2);
+        }else{
+            homeGoodsSkuInfoVO.setIsCollection(1);
+        }
+        LambdaQueryWrapper<GoodsGroupPurchase> queryWrapper1 =new LambdaQueryWrapper<>();
+        queryWrapper1.eq(GoodsGroupPurchase::getListingStatus,
+                        ListingStatusEnum.ON_SHELVES)
+                .eq(GoodsGroupPurchase::getGoodsSkuId, byId.getId());
+        GoodsGroupPurchase goodsGroupPurchase = goodsGroupPurchaseMapper.selectOne(queryWrapper1);
+        if (goodsGroupPurchase!=null){
+            homeGoodsSkuInfoVO.setIsGoodsGroupPurchase(2);
+        }else{
+            homeGoodsSkuInfoVO.setIsGoodsGroupPurchase(1);
+        }
+        return homeGoodsSkuInfoVO;
+    }
+
+    @Override
+    public List<getHomeGoodsSkuXxiVO> getHomeGoodsSkuXxi(HomeGoodsSkuDTO homeGoodsSkuDTO) {
+        List<getHomeGoodsSkuXxiVO> homeGoodsSkuXxiVOS=new ArrayList<>();
+        GoodsSku byId = this.getById(homeGoodsSkuDTO.getGoodsSkuId());
+        GoodsBrand data = goodsSkuClient.getBrandOne(byId.getBrandId(), SecurityConstants.INNER).getData();
+        GoodsCategory data1 = goodsSkuClient.getCategoryOne(byId.getCategoryId(), SecurityConstants.INNER).getData();
+        GoodsSeries data2 = goodsSkuClient.getSeriesOne(byId.getSeriesId(), SecurityConstants.INNER).getData();
+        GoodsFlavorType data3 = goodsSkuClient.getFlavorTypeOne(byId.getFlavorTypeId(), SecurityConstants.INNER).getData();
+
+
+        getHomeGoodsSkuXxiVO getHomeGoodsSkuXxiVO1=new getHomeGoodsSkuXxiVO();
+        getHomeGoodsSkuXxiVO1.setContent(data1.getCategoryName());
+        getHomeGoodsSkuXxiVO1.setTitleName("分类");
+        homeGoodsSkuXxiVOS.add(getHomeGoodsSkuXxiVO1);
+
+        getHomeGoodsSkuXxiVO getHomeGoodsSkuXxiVO2=new getHomeGoodsSkuXxiVO();
+        getHomeGoodsSkuXxiVO2.setContent(data2.getSeriesName());
+        getHomeGoodsSkuXxiVO2.setTitleName("系列");
+        homeGoodsSkuXxiVOS.add(getHomeGoodsSkuXxiVO2);
+
+        getHomeGoodsSkuXxiVO getHomeGoodsSkuXxiVO=new getHomeGoodsSkuXxiVO();
+        getHomeGoodsSkuXxiVO.setContent(data.getBrandName());
+        getHomeGoodsSkuXxiVO.setTitleName("品牌");
+        homeGoodsSkuXxiVOS.add(getHomeGoodsSkuXxiVO);
+
+        getHomeGoodsSkuXxiVO getHomeGoodsSkuXxiVO3=new getHomeGoodsSkuXxiVO();
+        getHomeGoodsSkuXxiVO3.setContent(data3.getFlavorTypeName());
+        getHomeGoodsSkuXxiVO3.setTitleName("香型");
+        homeGoodsSkuXxiVOS.add(getHomeGoodsSkuXxiVO3);
+
+
+        List<GoodsInfoTitleValueVO> goodsInfoTitleValueVOList = goodsInfoTitleValueService.listByGoodsId(homeGoodsSkuDTO.getGoodsSkuId());
+        Collections.sort(goodsInfoTitleValueVOList, Comparator.comparingInt(GoodsInfoTitleValueVO::getSortNum));
+        for (GoodsInfoTitleValueVO goodsInfoTitleValueVO:goodsInfoTitleValueVOList){
+            getHomeGoodsSkuXxiVO getHomeGoodsSkuXxiVOs=new getHomeGoodsSkuXxiVO();
+            getHomeGoodsSkuXxiVOs.setContent(goodsInfoTitleValueVO.getContent());
+            getHomeGoodsSkuXxiVOs.setTitleName(goodsInfoTitleValueVO.getTitleName());
+            homeGoodsSkuXxiVOS.add(getHomeGoodsSkuXxiVOs);
+        }
+
+
+        return homeGoodsSkuXxiVOS;
+    }
+
+    private boolean updateGoodsStock(GoodsSku skus, Integer auctionStock) {
+        return this.lambdaUpdate()
+                .set(skus.getStock() + auctionStock > 0, GoodsSku::getStock,
+                        skus.getStock() + auctionStock)
+                .eq(GoodsSku::getId, skus.getId())
+                .eq(GoodsSku::getStock, skus.getStock())
+                .update();
+    }
+
+    /**
+     * 根据商品id查询信息标题列表
+     *
+     * @param id 商品id
+     * @return List<GoodsInfoTitleValueVO>
+     */
+    @Override
+    public GoodsSkuVO getGoodsDetail(Long id) {
+        GoodsSku goodsSku = this.getById(id);
+        if (StringUtils.isNull(goodsSku)) {
+            throw new ServiceException("商品不存在");
+        }
+        GoodsSkuVO goodsSkuVO = BeanUtils.copyBean(goodsSku, GoodsSkuVO.class);
+        List<GoodsInfoTitleValueVO> goodsInfoTitleValueVOList = goodsInfoTitleValueService.listByGoodsId(
+                id);
+        goodsSkuVO.setGoodsInfoTitleValueVOList(goodsInfoTitleValueVOList);
+        return goodsSkuVO;
     }
 }

--
Gitblit v1.7.1