From 210828d1a6947596fe00ab30fcd8725c6714dde4 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期四, 02 一月 2025 21:04:16 +0800 Subject: [PATCH] 修改bug --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java | 93 +++++++++++++++++++++++++--------------------- 1 files changed, 51 insertions(+), 42 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 11aedc6..d647b1d 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 @@ -1,15 +1,20 @@ package com.ruoyi.other.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.account.api.feignClient.AppUserClient; import com.ruoyi.account.api.model.AppUser; +import com.ruoyi.common.core.constant.TokenConstants; import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.utils.ServletUtils; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.bean.BeanUtils; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.order.feignClient.RemoteOrderGoodsClient; import com.ruoyi.order.vo.Price; import com.ruoyi.other.api.domain.*; @@ -28,10 +33,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -71,28 +73,26 @@ private RemoteOrderGoodsClient remoteOrderGoodsClient; @Override - public List<GoodsVO> goodsList(Goods search) { - List<Goods> goodsList = this.list(new LambdaQueryWrapper<Goods>() - .eq(Goods::getStatus, GoodsStatus.UP.getCode()) - .eq(Objects.nonNull(search.getGoodsCategoryId()), Goods::getGoodsCategoryId, search.getGoodsCategoryId()) - .like(StringUtils.isNotEmpty(search.getName()), Goods::getName, search.getName())); - - List<GoodsVO> result = new ArrayList<>(); - LoginUser loginUserApplet = tokenService.getLoginUserApplet(); - for (Goods goods : goodsList) { - GoodsVO goodsVO = new GoodsVO(); - BeanUtils.copyBeanProp(goodsVO, goods); - goodsVO.setGoodsId(goods.getId()); - goodsVO.setGoodsName(goods.getName()); - R<Price> r = remoteOrderGoodsClient.getGoodsPrice(loginUserApplet.getUserid(), goods.getId(), null); - if (null != r.getData()){ - Price price = r.getData(); - goodsVO.setSellingPrice(price.getCash()); - goodsVO.setIntegral(price.getPoint()); - } - result.add(goodsVO); + public PageInfo<GoodsVO> goodsList(Goods search) { + PageInfo<GoodsVO> pageInfo = new PageInfo(search.getPageCurr(), search.getPageSize()); + List<GoodsVO> list = this.baseMapper.goodsList(pageInfo, search.getGoodsCategoryId(), search.getName()); + Long userId = null; + String token = SecurityUtils.getToken(ServletUtils.getRequest()); + if(StringUtils.isNotEmpty(token)){ + userId = tokenService.getLoginUserApplet().getUserid(); } - return result; + for (GoodsVO goods : list) { + //游客展示基础售价 + if(null != userId){ + R<Price> r = remoteOrderGoodsClient.getGoodsPrice(userId, goods.getGoodsId(), null); + if (null != r.getData()){ + Price price = r.getData(); + goods.setSellingPrice(price.getCash()); + goods.setIntegral(price.getPoint()); + } + } + } + return pageInfo.setRecords(list); } @Override @@ -108,6 +108,7 @@ GoodsArea goodsArea = goodsAreaMapper.selectOne(new LambdaQueryWrapper<GoodsArea>() .eq(GoodsArea::getGoodsId, goodsId) + .eq(GoodsArea::getVip, appUser.getVipId()) .eq(GoodsArea::getProvinceCode, appUser.getProvinceCode()) .eq(StringUtils.isNotEmpty(appUser.getCityCode()), GoodsArea::getCityCode, appUser.getCityCode()) .eq(StringUtils.isNotEmpty(appUser.getDistrictCode()), GoodsArea::getDistrictsCode, appUser.getDistrictCode())); @@ -134,29 +135,35 @@ goodsVO.setSellingPrice(sellingPrice); goodsVO.setIntegral(integral); - if(goods.getAppointStore() == 2){ + if(goods.getType() == 1){ + if(goods.getAppointStore() == 2){ + List<Shop> shopList = shopMapper.selectList(new LambdaQueryWrapper<Shop>() + .in(Shop::getDelFlag, 0)); + goodsVO.setShopList(shopList); + }else{ + List<GoodsShop> goodsShopList = goodsShopMapper.selectList(new LambdaQueryWrapper<GoodsShop>() + .eq(GoodsShop::getGoodsId, goodsId)); + if (!CollectionUtils.isEmpty(goodsShopList)){ + List<Integer> shopIds = goodsShopList.stream().map(GoodsShop::getShopId).collect(Collectors.toList()); + List<Shop> shopList = shopMapper.selectList(new LambdaQueryWrapper<Shop>() + .in(Shop::getId, shopIds)); + goodsVO.setShopList(shopList); + } + } + }else{ List<Shop> shopList = shopMapper.selectList(new LambdaQueryWrapper<Shop>() .in(Shop::getDelFlag, 0)); goodsVO.setShopList(shopList); - }else{ - List<GoodsShop> goodsShopList = goodsShopMapper.selectList(new LambdaQueryWrapper<GoodsShop>() - .eq(GoodsShop::getGoodsId, goodsId)); - if (!CollectionUtils.isEmpty(goodsShopList)){ - List<Integer> shopIds = goodsShopList.stream().map(GoodsShop::getShopId).collect(Collectors.toList()); - List<Shop> shopList = shopMapper.selectList(new LambdaQueryWrapper<Shop>() - .in(Shop::getId, shopIds)); - goodsVO.setShopList(shopList); - } } return goodsVO; } @Override - public List<Goods> getGoodsListByShopId(Integer shopId) { + public List<Goods> getGoodsListByShopId(PageInfo<Goods> pageInfo, Integer shopId) { LoginUser loginUserApplet = tokenService.getLoginUserApplet(); VipSetting vipSetting = vipSettingService.getVipSettingByUserId(loginUserApplet.getUserid()); - return goodsMapper.selectListByShopId(shopId, vipSetting.getId()); + return goodsMapper.selectListByShopId(pageInfo, shopId, vipSetting.getId()); } @Override @@ -173,7 +180,7 @@ // 指定门店 Integer appointStore = goods.getAppointStore(); - if (appointStore == 1){ + if (null != appointStore && appointStore == 1){ List<GoodsShop> goodsShopList = goods.getGoodsShopList(); if (CollectionUtils.isEmpty(goodsShopList)){ throw new NullPointerException("请选择指定门店"); @@ -286,10 +293,12 @@ for (GoodsShop goodsShop : goodsShops) { Shop shop = shopMapper.selectById(goodsShop.getShopId()); - goodsShop.setShopName(shop.getName()); - goodsShop.setOwnerName(shop.getShopManager()); - goodsShop.setPhone(shop.getPhone()); - goodsShop.setAddress(shop.getAddress()); + if(null != shop){ + goodsShop.setShopName(shop.getName()); + goodsShop.setOwnerName(shop.getShopManager()); + goodsShop.setPhone(shop.getPhone()); + goodsShop.setAddress(shop.getAddress()); + } } goods.setGoodsShopList(goodsShops); -- Gitblit v1.7.1