From 198b1189e896e97fa3f08f874d991e8f1bb8f922 Mon Sep 17 00:00:00 2001 From: luowenfeng <1092164058@qq.com> Date: Thu, 1 Sep 2022 11:00:40 +0800 Subject: [PATCH] =?UTF-8?q?feature(uniapp=E5=95=86=E5=93=81):=20=E5=95=86?= =?UTF-8?q?=E5=93=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../property/vo/ProductPropertyViewRespVO.java | 15 ++++++++------- .../dal/dataobject/sku/ProductSkuDO.java | 2 +- .../service/spu/ProductSpuServiceImpl.java | 3 ++- .../src/views/mall/product/spu/save.vue | 17 +++++++++++++++++ 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyViewRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyViewRespVO.java index 0499138a9..9bdc70bd7 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyViewRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyViewRespVO.java @@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.ToString; -import java.util.Set; +import java.util.List; /** * @Description: ProductPropertyViewRespVO @@ -25,16 +25,17 @@ public class ProductPropertyViewRespVO { public String name; @ApiModelProperty(value = "规格属性值集合", example = "[{\"v1\":11,\"v2\":\"64G\"},{\"v1\":10,\"v2\":\"32G\"}]") - public Set propertyValues; + public List propertyValues; @Data @ApiModel(value = "规格属性值元组") public static class Tuple2 { - private final long v1; - private final String v2; - public Tuple2(Long v1, String v2) { - this.v1 = v1; - this.v2 = v2; + private final long id; + private final String name; + + public Tuple2(Long id, String name) { + this.id = id; + this.name = name; } } 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 72daba257..fc7bbe9ec 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 @@ -20,7 +20,7 @@ import java.util.List; * * @author 芋道源码 */ -@TableName("product_sku") +@TableName(value = "product_sku",autoResultMap = true) @KeySequence("product_sku_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data @EqualsAndHashCode(callSuper = true) 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 253fb93ae..df6d3171f 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 @@ -30,6 +30,7 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -142,7 +143,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { ProductPropertyViewRespVO productPropertyViewRespVO = new ProductPropertyViewRespVO(); productPropertyViewRespVO.setPropertyId(p.getId()); productPropertyViewRespVO.setName(p.getName()); - Set propertyValues = new HashSet<>(); + List propertyValues = new ArrayList<>(); Map propertyValueMaps = p.getPropertyValueList().stream().collect(Collectors.toMap(ProductPropertyValueRespVO::getId, pv -> pv)); propertyMaps.get(p.getId()).forEach(pv -> { ProductPropertyViewRespVO.Tuple2 tuple2 = new ProductPropertyViewRespVO.Tuple2(pv.getValueId(), propertyValueMaps.get(pv.getValueId()).getName()); 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 089b2d128..9c619be3e 100644 --- a/yudao-ui-admin/src/views/mall/product/spu/save.vue +++ b/yudao-ui-admin/src/views/mall/product/spu/save.vue @@ -471,6 +471,23 @@ export default { this.baseForm.showStock=data.showStock; this.baseForm.brandId=data.brandId; this.ratesForm.spec=data.specType; + if(this.ratesForm.spec == 2){ + data.productPropertyViews.forEach(p=>{ + let obj = {}; + obj.specId = p.propertyId; + obj.specName = p.name; + obj.specValue = p.propertyValues; + this.dynamicSpec.push(obj); + }) + data.skus.forEach(s=>{ + s.spec = []; + s.properties.forEach(sp=>{ + let spec = data.productPropertyViews.find(o=>o.propertyId == sp.propertyId).propertyValues.find(v=>v.id == sp.valueId).name; + s.spec.push(spec) + }) + }) + } + console.log(data.skus); this.ratesForm.rates=data.skus }) }