From 4beed66d31755142dd69f0294fd8521f7797b66a Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期三, 03 九月 2025 16:39:36 +0800 Subject: [PATCH] bug修改 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java | 93 +++++++++++++++++++++++++++------------------- 1 files changed, 54 insertions(+), 39 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 82b3273..605581e 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); @@ -102,19 +108,18 @@ list = new ArrayList<>(uniqueGoodsMap.values()); for (GoodsVO goods : list) { - //计算所需价格和积分 - Price price = getPrice( goods.getGoodsId()); - if(null != price){ - //秒杀活动 - goods.setSellingPrice(price.getCash()); - goods.setIntegral(price.getPoint()); - goods.setStartTime(price.getStartTime()); - goods.setEndTime(price.getEndTime()); - goods.setPurchaseLimit(price.getPurchaseLimit()); - } - //已售数量 - Integer data = orderClient.getGoodsSaleNum(goods.getGoodsId(), 1).getData(); - goods.setSaleNum(data); + Integer point = getPoint(goods.getSellingPrice()); + goods.setIntegral(point); +// //计算所需价格和积分 +// Price price = getPrice( goods.getGoodsId()); +// if(null != price){ +// //秒杀活动 +// goods.setSellingPrice(price.getCash()); +// goods.setIntegral(price.getPoint()); +// goods.setStartTime(price.getStartTime()); +// goods.setEndTime(price.getEndTime()); +// goods.setPurchaseLimit(price.getPurchaseLimit()); +// } } //手动排序 if(StringUtils.isNotEmpty(search.getOrderByColumn())){ @@ -211,15 +216,17 @@ goodsVO.setGoodsName(goods.getName()); //计算所需价格和积分 - Price price = getPrice( goods.getId()); - if(null != price){ - //秒杀活动 - goodsVO.setSellingPrice(price.getCash()); - goodsVO.setIntegral(price.getPoint()); - goodsVO.setStartTime(price.getStartTime()); - goodsVO.setEndTime(price.getEndTime()); - goodsVO.setPurchaseLimit(price.getPurchaseLimit()); - } +// Price price = getPrice( goods.getId()); +// if(null != price){ +// //秒杀活动 +// goodsVO.setSellingPrice(price.getCash()); +// goodsVO.setIntegral(price.getPoint()); +// goodsVO.setStartTime(price.getStartTime()); +// goodsVO.setEndTime(price.getEndTime()); +// goodsVO.setPurchaseLimit(price.getPurchaseLimit()); +// } + Integer point = getPoint(goodsVO.getSellingPrice()); + goodsVO.setIntegral(point); //已售数量 Integer data = orderClient.getGoodsSaleNum(goods.getId(), 1).getData(); goodsVO.setSaleNum(data); @@ -234,6 +241,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; } @@ -248,15 +263,17 @@ } for (GoodsVO good : goods) { //价格 - Price price = getPrice( good.getGoodsId()); - if(null != price){ - //秒杀活动 - good.setSellingPrice(price.getCash()); - good.setIntegral(price.getPoint()); - good.setPurchaseLimit(price.getPurchaseLimit()); - good.setStartTime(price.getStartTime()); - good.setEndTime(price.getEndTime()); - } +// Price price = getPrice( good.getGoodsId()); +// if(null != price){ +// //秒杀活动 +// good.setSellingPrice(price.getCash()); +// good.setIntegral(price.getPoint()); +// good.setPurchaseLimit(price.getPurchaseLimit()); +// good.setStartTime(price.getStartTime()); +// good.setEndTime(price.getEndTime()); +// } + Integer point = getPoint(good.getSellingPrice()); + good.setIntegral(point); Integer data = orderClient.getGoodsSaleNum(good.getGoodsId(), 1).getData(); good.setSaleNum(data); } @@ -264,13 +281,11 @@ } @Override - public IPage<Goods> getManageGoodsList(Page<Goods> page, Goods goods) { - IPage<Goods> goodsIPage = goodsMapper.selectManageGoodsList(page, goods); - /* goodsIPage.getRecords().forEach(goods1 -> { - Integer data = orderClient.getGoodsSaleNum(goods1.getId(), 1).getData(); - goods1.setSaleNum(data); - });*/ - return goodsIPage; + public R getManageGoodsList(Integer pageNum,Integer pageSize, Goods goods) { + PageInfo<Goods> pageInfo = new PageInfo<>(pageNum,pageSize); + List<Goods> list = goodsMapper.selectManageGoodsList(pageInfo, goods); + pageInfo.setRecords(list); + return R.ok(pageInfo); } @Override -- Gitblit v1.7.1