From 19df67e19f23cd2a04d1c7f355e1e656f4140af4 Mon Sep 17 00:00:00 2001 From: huliguo <2023611923@qq.com> Date: 星期四, 17 四月 2025 20:04:14 +0800 Subject: [PATCH] 后台:首页统计、系统管理、广告管理、用户管理、商品分类管理 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 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 bd15d65..5035619 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 @@ -37,7 +37,9 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -92,6 +94,12 @@ } //查找满足条件的商品 分类、名称、附近十家店 List<GoodsVO> list = this.baseMapper.goodsList(search.getGoodsCategoryId(), search.getName(),shopIds); + //去重 + Map<Integer, GoodsVO> uniqueGoodsMap = new LinkedHashMap<>(); + for (GoodsVO goods : list) { + uniqueGoodsMap.putIfAbsent(goods.getGoodsId(), goods); + } + list = new ArrayList<>(uniqueGoodsMap.values()); for (GoodsVO goods : list) { //计算所需价格和积分 @@ -189,6 +197,7 @@ } Goods goods = this.getById(goodsId); + if(null == goods || goods.getDelFlag() == 1){ throw new RuntimeException("商品不存在"); } @@ -219,12 +228,12 @@ GoodsShop goodsShop = goodsShopMapper.selectOne(new LambdaQueryWrapper<GoodsShop>() .eq(GoodsShop::getGoodsId, goodsId)); Shop shop1 = shopMapper.selectById(goodsShop.getShopId()); - ArrayList<Shop> shops = new ArrayList<>(); - shops.add(shop1); - goodsVO.setShopList(shops); + + goodsVO.setShop(shop1); //已售数量 Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 1).getData(); goodsVO.setSaleNum(integer); + return goodsVO; } @@ -234,6 +243,9 @@ public List<GoodsVO> getGoodsListByShopId(PageInfo<GoodsVO> pageInfo, Integer shopId) { //查询该门店商品 List<GoodsVO> goods = goodsMapper.selectListByShopId(pageInfo, shopId); + if (goods == null) { + return null; + } for (GoodsVO good : goods) { //价格 Price price = getPrice( good.getGoodsId()); -- Gitblit v1.7.1