| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | 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.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | |
| | | import com.ruoyi.system.api.domain.poji.shop.Shop; |
| | | import com.ruoyi.system.api.domain.vo.MerGoodsPriceListVo; |
| | | import com.ruoyi.system.api.domain.vo.MgtSelectGoodsPageVo; |
| | | import com.ruoyi.system.api.domain.vo.ShopRelUserVo; |
| | | import com.ruoyi.system.api.service.RemoteConfigService; |
| | | import com.ruoyi.system.api.service.RemoteShopService; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | List<String> goodsNameList = goodsMapper.listGoodsNameByGoodsClass(classId); |
| | | return goodsNameList; |
| | | } |
| | | |
| | | @Override |
| | | public List<PageShopMgtGoodsVO> pageShopMgtGoods(Page<PageShopMgtGoodsVO> page,PageShopMgtGoodsDTO pageShopMgtGoodsDTO) { |
| | | //1.查找门店 |
| | | Shop shop = remoteShopService.getShop(pageShopMgtGoodsDTO.getShopId()).getData(); |
| | | if (null == shop || shop.getDelFlag() != 0) { |
| | | return Collections.emptyList(); |
| | | } |
| | | List<Shop> shops = new ArrayList<>(); |
| | | //2.判断门店是否经销商 |
| | | if (shop.getShopType()==1){ |
| | | //经销商 获取下级-加盟商ids |
| | | shops = remoteShopService.getFranchiseeIdsBYDealerId(shop.getShopId()); |
| | | } |
| | | //将该门店加入 |
| | | shops.add(shop); |
| | | List<Long> shopIds = shops.stream().map(Shop::getShopId).collect(Collectors.toList()); |
| | | //查询信息 |
| | | pageShopMgtGoodsDTO.setShopIds(shopIds); |
| | | //3.根据shopId查询商品信息 |
| | | List<PageShopMgtGoodsVO> list= goodsMapper.pageShopMgtGoods(page,pageShopMgtGoodsDTO); |
| | | |
| | | if (list != null && !list.isEmpty()) { |
| | | //4.商品分类 |
| | | // 获取所有商品分类的ID |
| | | List<Long> goodsClassIds = list.stream() |
| | | .map(PageShopMgtGoodsVO::getGoodsClass) |
| | | .map(Long::valueOf) |
| | | .collect(Collectors.toList()); |
| | | // 通过远程服务获取商品分类 |
| | | Map<Long, SysClassification> sysClassificationMap = remoteConfigService.getSysClassificationList(goodsClassIds).getData(); |
| | | // 遍历所有商品 |
| | | list.forEach(mgtGoodsPageVo -> { |
| | | // 获取商品分类 |
| | | SysClassification sysClassification = sysClassificationMap.get(Long.valueOf(mgtGoodsPageVo.getGoodsClass())); |
| | | // 如果商品分类不为空,则设置商品分类名称 |
| | | if (sysClassification != null) { |
| | | mgtGoodsPageVo.setGoodsClass(sysClassification.getClassName()); |
| | | } |
| | | }); |
| | | Map<Long, Shop> shopMap = shops.stream() |
| | | .collect(Collectors.toMap( |
| | | Shop::getShopId, // 键映射函数 |
| | | shop1 -> shop1 // 值映射函数 |
| | | )); |
| | | //5.门店信息 |
| | | list.forEach(mgtGoodsPageVo -> { |
| | | // 获取门店信息 |
| | | Shop shopInfo = shopMap.get(Long.valueOf(mgtGoodsPageVo.getShopId())); |
| | | // 如果门店信息不为空,则设置门店信息 |
| | | if (shopInfo != null) { |
| | | mgtGoodsPageVo.setShopName(shopInfo.getShopName()); |
| | | mgtGoodsPageVo.setModifyPricePermission(shop.getModifyPricePermission()); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | return list; |
| | | } |
| | | } |