From af71a19241c37271ec5241cd6b9908ff8ea8cb79 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 19 Nov 2022 12:25:53 +0800 Subject: [PATCH] =?UTF-8?q?trade=EF=BC=9A=E3=80=90=E5=95=86=E5=93=81?= =?UTF-8?q?=E3=80=91sku=20=E8=A1=A8=E5=A2=9E=E5=8A=A0=20spu=5Fname=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=EF=BC=8C=E5=86=97=E4=BD=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/product/api/sku/dto/ProductSkuRespDTO.java | 2 +- .../module/product/convert/sku/ProductSkuConvert.java | 8 +++++++- .../product/dal/dataobject/sku/ProductSkuDO.java | 11 ++++++----- .../module/product/service/sku/ProductSkuService.java | 6 ++++-- .../product/service/sku/ProductSkuServiceImpl.java | 8 ++++---- .../product/service/spu/ProductSpuServiceImpl.java | 4 ++-- yudao-ui-admin/src/views/mall/product/spu/save.vue | 9 --------- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java index 4b324149b..909a54efa 100644 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java +++ b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java @@ -19,7 +19,7 @@ public class ProductSkuRespDTO { */ private Long id; /** - * 商品 SKU 名字 + * SPU 名字 */ private String name; /** diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java index b29d612be..ce46bb4fd 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java @@ -32,7 +32,13 @@ public interface ProductSkuConvert { List convertList(List list); - List convertSkuDOList(List list); + List convertList06(List list); + + default List convertList06(List list, String spuName) { + List result = convertList06(list); + result.forEach(item -> item.setSpuName(spuName)); + return result; + } ProductSkuRespDTO convert02(ProductSkuDO bean); diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java index 019edf2bf..b801863ff 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java @@ -35,17 +35,18 @@ public class ProductSkuDO extends BaseDO { */ @TableId private Long id; - /** - * 商品 SKU 名字 - */ - @Deprecated // TODO 芋艿:参考有赞,不需要 sku 的标题 - private String name; /** * SPU 编号 *

* 关联 {@link ProductSpuDO#getId()} */ private Long spuId; + /** + * SPU 名字 + * + * 冗余 {@link ProductSkuDO#getSpuName()} + */ + private String spuName; /** * 规格值数组,JSON 格式 */ diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java index 1036d8348..3f9dde1d9 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java @@ -55,17 +55,19 @@ public interface ProductSkuService { * 批量创建 SKU * * @param spuId 商品 SPU 编号 + * @para spuName 商品 SPU 名称 * @param list SKU 对象集合 */ - void createSkus(Long spuId, List list); + void createSkus(Long spuId, String spuName, List list); /** * 根据 SPU 编号,批量更新它的 SKU 信息 * * @param spuId SPU 编码 + * @para spuName 商品 SPU 名称 * @param skus SKU 的集合 */ - void updateSkus(Long spuId, List skus); + void updateSkus(Long spuId, String spuName, List skus); /** * 更新 SKU 库存(增量) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java index 2791ae5d3..2cc80b7ab 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java @@ -119,9 +119,9 @@ public class ProductSkuServiceImpl implements ProductSkuService { } @Override - public void createSkus(Long spuId, List skuCreateReqList) { + public void createSkus(Long spuId, String spuName, List skuCreateReqList) { // 批量插入 SKU - List skuDOList = ProductSkuConvert.INSTANCE.convertSkuDOList(skuCreateReqList); + List skuDOList = ProductSkuConvert.INSTANCE.convertList06(skuCreateReqList, spuName); skuDOList.forEach(v -> v.setSpuId(spuId)); productSkuMapper.insertBatch(skuDOList); } @@ -148,7 +148,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { @Override @Transactional - public void updateSkus(Long spuId, List skus) { + public void updateSkus(Long spuId, String spuName, List skus) { // 查询 SPU 下已经存在的 SKU 的集合 List existsSkus = productSkuMapper.selectListBySpuId(spuId); // 构建规格与 SKU 的映射关系; @@ -168,7 +168,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { List updateSkus = new ArrayList<>(); List deleteSkus = new ArrayList<>(); - List allUpdateSkus = ProductSkuConvert.INSTANCE.convertSkuDOList(skus); + List allUpdateSkus = ProductSkuConvert.INSTANCE.convertList06(skus, spuName); allUpdateSkus.forEach(p -> { String propertiesKey = p.getProperties() == null? "null": p.getProperties().stream().map(m -> String.valueOf(m.getValueId())).collect(Collectors.joining()); // 1、找得到的,进行更新 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java index 4880d4948..d9f8ec8dc 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java @@ -79,7 +79,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { spu.setTotalStock(CollectionUtils.getSumValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getStock, Integer::sum)); productSpuMapper.insert(spu); // 插入 SKU - productSkuService.createSkus(spu.getId(), skuCreateReqList); + productSkuService.createSkus(spu.getId(), spu.getName(), skuCreateReqList); // 返回 return spu.getId(); } @@ -105,7 +105,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { updateObj.setTotalStock(CollectionUtils.getSumValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getStock, Integer::sum)); productSpuMapper.updateById(updateObj); // 批量更新 SKU - productSkuService.updateSkus(updateObj.getId(), updateReqVO.getSkus()); + productSkuService.updateSkus(updateObj.getId(), updateObj.getName(), updateReqVO.getSkus()); } @Override diff --git a/yudao-ui-admin/src/views/mall/product/spu/save.vue b/yudao-ui-admin/src/views/mall/product/spu/save.vue index ca344bf8c..5eee696d3 100644 --- a/yudao-ui-admin/src/views/mall/product/spu/save.vue +++ b/yudao-ui-admin/src/views/mall/product/spu/save.vue @@ -80,15 +80,6 @@ -