From 7fd053651ac11db87fe4f6c57e65eed3b9a59452 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期三, 23 七月 2025 10:47:24 +0800 Subject: [PATCH] yml活动管理代码 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 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 dee2baf..d8b5290 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 @@ -20,11 +20,13 @@ import com.ruoyi.other.api.domain.*; import com.ruoyi.other.dto.AddGoodsDTO; import com.ruoyi.other.enums.GoodsStatus; +import com.ruoyi.other.mapper.GoodsEvaluateMapper; import com.ruoyi.other.mapper.GoodsMapper; import com.ruoyi.other.mapper.GoodsShopMapper; import com.ruoyi.other.mapper.ShopMapper; import com.ruoyi.other.service.*; import com.ruoyi.other.util.GeodesyUtil; +import com.ruoyi.other.vo.GoodsEvaluateVO; import com.ruoyi.other.vo.GoodsVO; import com.ruoyi.other.vo.NearbyShopVO; import com.ruoyi.system.api.domain.SysConfig; @@ -77,6 +79,8 @@ @Resource private ShopService shopService; + @Resource + private GoodsEvaluateMapper goodsEvaluateMapper; /** * 热门商品列表 @@ -88,9 +92,11 @@ public PageInfo<GoodsVO> goodsList(Goods search) { List<Long> shopIds=null; if (null!=search.getLongitude()&&null!=search.getLatitude()){ + //获取最近十家店的id List<NearbyShopVO> nearbyShopVOS = shopService.nearbyShopList(search.getLongitude(), search.getLatitude(), new Shop()); - shopIds = nearbyShopVOS.subList(0, 10).stream().map(NearbyShopVO::getId).collect(Collectors.toList()); + int endIndex = Math.min(10, nearbyShopVOS.size()); + shopIds = nearbyShopVOS.subList(0, endIndex).stream().map(NearbyShopVO::getId).collect(Collectors.toList()); } //查找满足条件的商品 分类、名称、附近十家店 List<GoodsVO> list = this.baseMapper.goodsList(search.getGoodsCategoryId(), search.getName(),shopIds); @@ -112,9 +118,6 @@ goods.setEndTime(price.getEndTime()); goods.setPurchaseLimit(price.getPurchaseLimit()); } - //已售数量 - Integer data = orderClient.getGoodsSaleNum(goods.getGoodsId(), 1).getData(); - goods.setSaleNum(data); } //手动排序 if(StringUtils.isNotEmpty(search.getOrderByColumn())){ @@ -234,6 +237,14 @@ Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 1).getData(); goodsVO.setSaleNum(integer); + //商品评价 + GoodsEvaluate goodsEvaluate=goodsEvaluateMapper.getGoodsEvaluateOne(goods.getId()); + if (null != goodsEvaluate){ + AppUser appUserById = appUserClient.getAppUserById(goodsEvaluate.getAppUserId()); + goodsEvaluate.setAvatar(appUserById.getAvatar()); + goodsEvaluate.setUserName(appUserById.getName()); + goodsVO.setGoodsEvaluate(goodsEvaluate); + } return goodsVO; } -- Gitblit v1.7.1