| | |
| | | import cn.lili.mybatis.util.PageUtil; |
| | | import cn.lili.rocketmq.RocketmqSendCallbackBuilder; |
| | | import cn.lili.rocketmq.tags.GoodsTagsEnum; |
| | | import cn.lili.utils.COSUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.rocketmq.spring.core.RocketMQTemplate; |
| | |
| | | @Autowired |
| | | private Cache<GoodsVO> cache; |
| | | |
| | | @Autowired |
| | | private COSUtil cosUtil; |
| | | |
| | | @Override |
| | | public List<Goods> getByBrandIds(List<String> brandIds) { |
| | | LambdaQueryWrapper<Goods> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | //检查商品 |
| | | this.checkGoods(goods); |
| | | //向goods加入图片 |
| | | if (goodsOperationDTO.getGoodsGalleryList().size() > 0) { |
| | | if (goodsOperationDTO.getGoodsGalleryList()!=null&& !goodsOperationDTO.getGoodsGalleryList().isEmpty()) { |
| | | this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods); |
| | | } |
| | | //添加商品参数 |
| | |
| | | //检查商品信息 |
| | | this.checkGoods(goods); |
| | | //向goods加入图片 |
| | | this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods); |
| | | if (goodsOperationDTO.getGoodsGalleryList() != null&& !goodsOperationDTO.getGoodsGalleryList().isEmpty()) { |
| | | this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods); |
| | | }else { |
| | | goods.setOriginal(null); |
| | | goods.setSmall(null); |
| | | goods.setThumbnail(null); |
| | | goodsGalleryService.removeByGoodsId(goodsId); |
| | | } |
| | | //添加商品参数 |
| | | if (goodsOperationDTO.getGoodsParamsDTOList() != null && !goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) { |
| | | goods.setParams(JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList())); |
| | |
| | | //缓存获取,如果没有则读取缓存 |
| | | GoodsVO goodsVO = cache.get(CachePrefix.GOODS.getPrefix() + goodsId); |
| | | if (goodsVO != null) { |
| | | // List<String> goodsGalleryList = goodsVO.getGoodsGalleryList(); |
| | | // if (goodsGalleryList != null && !goodsGalleryList.isEmpty()) { |
| | | // List<String> galleryList = goodsGalleryList.stream().map(item -> { |
| | | // if (StringUtils.isNotBlank(item)&&!item.contains("http")) { |
| | | // return cosUtil.getPreviewUrl(item); |
| | | // }else { |
| | | // return item; |
| | | // } |
| | | // }).collect(Collectors.toList()); |
| | | // goodsVO.setGoodsGalleryList(galleryList); |
| | | // } |
| | | return goodsVO; |
| | | } |
| | | //查询商品信息 |
| | |
| | | List<GoodsGallery> galleryList = goodsGalleryService.goodsGalleryList(goodsId); |
| | | for (GoodsGallery goodsGallery : galleryList) { |
| | | images.add(goodsGallery.getOriginal()); |
| | | // String original = goodsGallery.getOriginal(); |
| | | // if (StringUtils.isNotBlank(original)&&!original.contains("http")) { |
| | | // images.add(cosUtil.getPreviewUrl(original)); |
| | | // }else { |
| | | // images.add(goodsGallery.getOriginal()); |
| | | // } |
| | | } |
| | | goodsVO.setGoodsGalleryList(images); |
| | | //商品sku赋值 |