| | |
| | | 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.common.core.utils.uuid.IdUtils; |
| | | import com.ruoyi.common.security.utils.CodeFactoryUtil; |
| | | import com.ruoyi.goods.domain.dto.*; |
| | | import com.ruoyi.system.api.domain.poji.activity.Activity; |
| | | import com.ruoyi.goods.domain.pojo.goods.GoodsTotal; |
| | | import com.ruoyi.goods.domain.vo.*; |
| | | import com.ruoyi.goods.mapper.goods.GoodsMapper; |
| | |
| | | import com.ruoyi.system.api.domain.dto.MerGoodsPriceListDto; |
| | | import com.ruoyi.system.api.domain.dto.MgtBaseGetDto; |
| | | import com.ruoyi.system.api.domain.dto.MgtClassNumDto; |
| | | import com.ruoyi.system.api.domain.poji.activity.Activity; |
| | | import com.ruoyi.system.api.domain.poji.activity.ActivityGoods; |
| | | import com.ruoyi.system.api.domain.poji.config.SysClassification; |
| | | import com.ruoyi.system.api.domain.poji.goods.Goods; |
| | | import com.ruoyi.system.api.domain.poji.goods.GoodsFile; |
| | | import com.ruoyi.system.api.domain.poji.goods.ShopGoods; |
| | | 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; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @Resource |
| | | private ActivityRecordService activityRecordService; |
| | | |
| | | @Resource |
| | | private RemoteShopService remoteShopService; |
| | | |
| | | |
| | | /** |
| | | * @description 获取推荐商品列表 |
| | | * @param page shopId |
| | | * @return List<AppSimpleGoodsVo> |
| | | * @description 获取推荐商品列表 |
| | | * @author jqs34 |
| | | * @date 2023/6/4 16:27 |
| | | */ |
| | |
| | | if(shopGoods!=null){ |
| | | appGoodsInfoVo.setSalesPrice(shopGoods.getSalesPrice()); |
| | | appGoodsInfoVo.setServiceNum(shopGoods.getServiceNum()); |
| | | } else { |
| | | //经销商定制价格 |
| | | Shop shop = remoteShopService.getShop(appGoodsInfoGetDto.getShopId()).getData(); |
| | | Shop belongShop = remoteShopService.getShop(shop.getBelongShopId()).getData(); |
| | | shopGoods = shopGoodsService.getByShopIdAndGoodsId(belongShop.getShopId(), goods.getGoodsId()); |
| | | if (1 == belongShop.getModifyPricePermission() && null != shopGoods) { |
| | | appGoodsInfoVo.setSalesPrice(shopGoods.getSalesPrice()); |
| | | appGoodsInfoVo.setServiceNum(shopGoods.getServiceNum()); |
| | | } |
| | | } |
| | | |
| | | |
| | | GoodsTotal goodsTotal = goodsTotalService.getById(goods.getGoodsId()); |
| | | appGoodsInfoVo.setSalesNum(goodsTotal.getBuyNumCount()); |
| | | //活动商品判断 |
| | |
| | | |
| | | /** |
| | | * 修改商户商品 |
| | | * |
| | | * @param merShopGoodsEditDto |
| | | */ |
| | | @Override |
| | | public void editMerShopGoods(MerShopGoodsEditDto merShopGoodsEditDto){ |
| | | Shop shop = remoteShopService.getShop(merShopGoodsEditDto.getShopId()).getData(); |
| | | if (2 == shop.getShopType()) { |
| | | Shop belongShop = remoteShopService.getShop(shop.getBelongShopId()).getData(); |
| | | ShopGoods shopGoods = shopGoodsService.getByShopIdAndGoodsId(shop.getBelongShopId(), merShopGoodsEditDto.getGoodsId()); |
| | | if (1 == belongShop.getModifyPricePermission() && null != shopGoods) { |
| | | throw new ServiceException("经销商开启了统一价格管理"); |
| | | } |
| | | } |
| | | |
| | | Goods goods = this.getById(merShopGoodsEditDto.getGoodsId()); |
| | | if(merShopGoodsEditDto.getSalePrice().compareTo(goods.getMininumPrice())<0){ |
| | | throw new ServiceException(AppErrorConstant.SALESPRICE_MIN+goods.getMininumPrice().toString()+"元"); |
| | |
| | | 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; |
| | | } |
| | | } |