| | |
| | | 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.common.core.domain.R; |
| | | 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.order.feignClient.RemoteOrderGoodsClient; |
| | | import com.ruoyi.order.vo.Price; |
| | |
| | | |
| | | 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; |
| | | |
| | |
| | | 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<>(); |
| | | 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()); |
| | | 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); |
| | | for (GoodsVO goods : list) { |
| | | R<Price> r = remoteOrderGoodsClient.getGoodsPrice(loginUserApplet.getUserid(), goods.getGoodsId(), null); |
| | | if (null != r.getData()){ |
| | | Price price = r.getData(); |
| | | goodsVO.setSellingPrice(price.getCash()); |
| | | goodsVO.setIntegral(price.getPoint()); |
| | | goods.setSellingPrice(price.getCash()); |
| | | goods.setIntegral(price.getPoint()); |
| | | } |
| | | result.add(goodsVO); |
| | | } |
| | | return result; |
| | | return pageInfo.setRecords(list); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | 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())); |
| | |
| | | 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 |
| | |
| | | |
| | | // 指定门店 |
| | | Integer appointStore = goods.getAppointStore(); |
| | | if (appointStore == 1){ |
| | | if (null != appointStore && appointStore == 1){ |
| | | List<GoodsShop> goodsShopList = goods.getGoodsShopList(); |
| | | if (CollectionUtils.isEmpty(goodsShopList)){ |
| | | throw new NullPointerException("请选择指定门店"); |