From 9911eefd300c7f1a9bb1030b94d03d7562cf7858 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期二, 08 七月 2025 15:52:29 +0800
Subject: [PATCH] 商品发布
---
framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java | 35 ++++++++++++++++++++++++++++++++---
1 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java
index 6909add..48a6b24 100644
--- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java
@@ -41,6 +41,7 @@
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;
@@ -121,6 +122,9 @@
@Autowired
private Cache<GoodsVO> cache;
+ @Autowired
+ private COSUtil cosUtil;
+
@Override
public List<Goods> getByBrandIds(List<String> brandIds) {
LambdaQueryWrapper<Goods> lambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -172,7 +176,7 @@
//妫�鏌ュ晢鍝�
this.checkGoods(goods);
//鍚慻oods鍔犲叆鍥剧墖
- if (goodsOperationDTO.getGoodsGalleryList().size() > 0) {
+ if (goodsOperationDTO.getGoodsGalleryList()!=null&& !goodsOperationDTO.getGoodsGalleryList().isEmpty()) {
this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods);
}
//娣诲姞鍟嗗搧鍙傛暟
@@ -201,15 +205,23 @@
//妫�鏌ュ晢鍝佷俊鎭�
this.checkGoods(goods);
//鍚慻oods鍔犲叆鍥剧墖
- 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()));
}
+ Goods previousGoods = this.getById(goodsId);
//淇敼鍟嗗搧
this.updateById(goods);
//淇敼鍟嗗搧sku淇℃伅
- this.goodsSkuService.update(goods, goodsOperationDTO);
+ this.goodsSkuService.update(goods, goodsOperationDTO,previousGoods);
//娣诲姞鐩稿唽
if (goodsOperationDTO.getGoodsGalleryList() != null && !goodsOperationDTO.getGoodsGalleryList().isEmpty()) {
this.goodsGalleryService.add(goodsOperationDTO.getGoodsGalleryList(), goods.getId());
@@ -227,6 +239,17 @@
//缂撳瓨鑾峰彇锛屽鏋滄病鏈夊垯璇诲彇缂撳瓨
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;
}
//鏌ヨ鍟嗗搧淇℃伅
@@ -245,6 +268,12 @@
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璧嬪��
--
Gitblit v1.8.0