From 07e5e1b59f6dc19315f7092fa996777afb9472b8 Mon Sep 17 00:00:00 2001
From: luowenfeng <1092164058@qq.com>
Date: Thu, 18 Aug 2022 22:38:51 +0800
Subject: [PATCH 1/3] =?UTF-8?q?feature(=E7=AE=A1=E7=90=86=E5=90=8E?=
=?UTF-8?q?=E5=8F=B0):=20=E5=95=86=E5=93=81=E5=BC=B9=E7=AA=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/views/mall/product/spu/index.vue | 718 +++++++++++-------
.../src/views/mall/product/spu/save.vue | 417 ++++++++++
2 files changed, 869 insertions(+), 266 deletions(-)
create mode 100644 yudao-ui-admin/src/views/mall/product/spu/save.vue
diff --git a/yudao-ui-admin/src/views/mall/product/spu/index.vue b/yudao-ui-admin/src/views/mall/product/spu/index.vue
index 5f5ca6d49..7b66f1f05 100644
--- a/yudao-ui-admin/src/views/mall/product/spu/index.vue
+++ b/yudao-ui-admin/src/views/mall/product/spu/index.vue
@@ -1,36 +1,81 @@
-
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
- 搜索
+ 搜索
重置
@@ -38,95 +83,150 @@
- 新增
+ 新增
- 导出
+ 导出
-
+
-
-
+
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
{{ parseTime(scope.row.createTime) }}
-
+
- 修改
+ 修改
- 删除
+ 删除
-
+
+
+
+
+
-
+
@@ -136,134 +236,178 @@
-
+
From 617573a59bf811605e5700813a197189158b629e Mon Sep 17 00:00:00 2001
From: luowenfeng <1092164058@qq.com>
Date: Mon, 22 Aug 2022 20:43:12 +0800
Subject: [PATCH 2/3] =?UTF-8?q?feature(uniapp=E5=88=86=E7=B1=BB):=20?=
=?UTF-8?q?=E5=95=86=E5=93=81=E5=88=9B=E5=BB=BA=E5=8A=9F=E8=83=BD=E4=BB=A5?=
=?UTF-8?q?=E5=8F=8A=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD=E6=AD=A3=E5=B8=B8?=
=?UTF-8?q?=E4=BD=BF=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sql/optional/mall/mall.sql | 24 ++
.../admin/sku/vo/ProductSkuBaseVO.java | 20 +-
.../admin/spu/vo/ProductSpuBaseVO.java | 85 +++++-
.../property/ProductPropertyServiceImpl.java | 4 +-
.../service/sku/ProductSkuServiceImpl.java | 12 +-
.../src/views/mall/product/spu/index.vue | 240 ---------------
.../src/views/mall/product/spu/save.vue | 280 ++++++++++--------
7 files changed, 275 insertions(+), 390 deletions(-)
diff --git a/sql/optional/mall/mall.sql b/sql/optional/mall/mall.sql
index e61b217e8..f6b3542e3 100644
--- a/sql/optional/mall/mall.sql
+++ b/sql/optional/mall/mall.sql
@@ -298,3 +298,27 @@ INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `
INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2027, 'Banner创建', 'market:banner:create', 3, 2, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0');
INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2028, 'Banner更新', 'market:banner:update', 3, 3, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0');
INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2029, 'Banner删除', 'market:banner:delete', 3, 4, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0');
+
+alter table product_spu add `code` varchar(128) COMMENT '商品编码';
+alter table product_spu add total_stock int COMMENT '总库存';
+alter table product_spu add warn_stock int COMMENT '预警预存';
+alter table product_spu add show_stock int COMMENT '是否展示库存';
+alter table product_spu add sales_count int COMMENT '商品销量';
+alter table product_spu add virtual_sales_count int COMMENT '虚拟销量';
+alter table product_spu add click_count int COMMENT '商品点击量';
+alter table product_spu add banner_url varchar(128) COMMENT '主图地址';
+alter table product_spu add spec_type int COMMENT '规格类型';
+alter table product_spu add brand_id int COMMENT '商品品牌编号';
+alter table product_spu add video_url varchar(128) COMMENT '商品视频';
+alter table product_spu add min_price int COMMENT '最小价格,单位使用:分';
+alter table product_spu add max_price int COMMENT '最大价格,单位使用:分';
+alter table product_spu add market_price int COMMENT '市场价,单位使用:分';
+
+
+alter table product_sku add `name` varchar(128) COMMENT '商品 SKU 名字';
+alter table product_sku add `stock` int COMMENT '库存';
+alter table product_sku add `weight` double COMMENT '商品重量';
+alter table product_sku add `volume` double COMMENT '商品体积';
+
+
+alter table product_sku DROP `original_price`;
\ No newline at end of file
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java
index cefab9a47..7371ba4cc 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java
@@ -27,16 +27,16 @@ public class ProductSkuBaseVO {
@NotNull(message = "销售价格,单位:分不能为空")
private Integer price;
- @ApiModelProperty(value = "原价, 单位: 分", required = true)
- @NotNull(message = "原价, 单位: 分不能为空")
- private Integer originalPrice;
+ @ApiModelProperty(value = "市场价, 单位: 分", required = true)
+ @NotNull(message = "市场价, 单位: 分不能为空")
+ private Integer marketPrice;
@ApiModelProperty(value = "成本价,单位: 分", required = true)
@NotNull(message = "成本价,单位: 分不能为空")
private Integer costPrice;
- @ApiModelProperty(value = "条形码", required = true)
- @NotNull(message = "条形码不能为空")
+ @ApiModelProperty(value = "条形码")
+// @NotNull(message = "条形码不能为空")
private String barCode;
@ApiModelProperty(value = "图片地址", required = true)
@@ -46,7 +46,15 @@ public class ProductSkuBaseVO {
@ApiModelProperty(value = "状态: 0-正常 1-禁用")
private Integer status;
- // TODO @franky 要有 swagger 注解
+ @ApiModelProperty(value = "库存")
+ private Integer stock;
+
+ @ApiModelProperty(value = "商品重量,单位:kg 千克")
+ private Double weight;
+
+ @ApiModelProperty(value = "商品体积,单位:m^3 平米")
+ private Double volume;
+
@Data
public static class Property {
@NotNull(message = "规格属性名id不能为空")
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java
index e9c76805a..33d11ccac 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java
@@ -1,5 +1,8 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
+import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO;
+import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
+import cn.iocoder.yudao.module.product.enums.spu.ProductSpuSpecTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -16,6 +19,11 @@ public class ProductSpuBaseVO {
@ApiModelProperty(value = "商品名称")
private String name;
+ /**
+ * 商品编码
+ */
+ private String code;
+
@ApiModelProperty(value = "卖点", required = true)
@NotNull(message = "卖点不能为空")
private String sellPoint;
@@ -24,28 +32,87 @@ public class ProductSpuBaseVO {
@NotNull(message = "描述不能为空")
private String description;
+ /**
+ * 商品品牌编号
+ *
+ * 关联 {@link ProductBrandDO#getId()}
+ */
+ private Long brandId;
+
@ApiModelProperty(value = "分类id", required = true)
@NotNull(message = "分类id不能为空")
private Long categoryId;
+ /**
+ * 商品主图
+ */
+ private String bannerUrl;
+
@ApiModelProperty(value = "商品主图地址,* 数组,以逗号分隔,最多上传15张", required = true)
@NotNull(message = "商品主图地址,* 数组,以逗号分隔,最多上传15张不能为空")
private List picUrls;
+ /**
+ * 商品视频
+ */
+ private String videoUrl;
+
+ /**
+ * 规格类型
+ *
+ * 枚举 {@link ProductSpuSpecTypeEnum}
+ */
+ private Integer specType;
+
@ApiModelProperty(value = "排序字段", required = true)
@NotNull(message = "排序字段不能为空")
private Integer sort;
-
- @ApiModelProperty(value = "点赞初始人数")
- private Integer likeCount;
-
- @ApiModelProperty(value = "价格 单位使用:分")
- private Integer price;
-
- @ApiModelProperty(value = "库存数量")
- private Integer quantity;
+ /**
+ * 最小价格,单位使用:分
+ *
+ * 基于其对应的 {@link ProductSkuDO#getPrice()} 最小值
+ */
+ private Integer minPrice;
+ /**
+ * 最大价格,单位使用:分
+ *
+ * 基于其对应的 {@link ProductSkuDO#getPrice()} 最大值
+ */
+ private Integer maxPrice;
+ /**
+ * 市场价,单位使用:分
+ *
+ * 基于其对应的 {@link ProductSkuDO#getMarketPrice()} 最大值
+ */
+ private Integer marketPrice;
+ /**
+ * 总库存
+ *
+ * 基于其对应的 {@link ProductSkuDO#getStock()} 求和
+ */
+ private Integer totalStock;
+ /**
+ * 预警预存
+ */
+ private Integer warnStock;
+ /**
+ * 是否展示库存
+ */
+ private Boolean showStock;
@ApiModelProperty(value = "上下架状态: 0 上架(开启) 1 下架(禁用)")
private Integer status;
+ /**
+ * 商品销量
+ */
+ private Integer salesCount;
+ /**
+ * 虚拟销量
+ */
+ private Integer virtualSalesCount;
+ /**
+ * 商品点击量
+ */
+ private Integer clickCount;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java
index 9cb1a0da3..f650e90d9 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java
@@ -49,7 +49,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
//插入属性值
List propertyValueList = createReqVO.getPropertyValueList();
List productPropertyValueDOList = ProductPropertyValueConvert.INSTANCE.convertList03(propertyValueList);
- productPropertyValueDOList.stream().forEach(x-> x.setPropertyId(property.getId()));
+ productPropertyValueDOList.forEach(x-> x.setPropertyId(property.getId()));
productPropertyValueMapper.insertBatch(productPropertyValueDOList);
// 返回
return property.getId();
@@ -67,7 +67,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
productPropertyValueMapper.deletePropertyValueByPropertyId(updateReqVO.getId());
List propertyValueList = updateReqVO.getPropertyValueList();
List productPropertyValueDOList = ProductPropertyValueConvert.INSTANCE.convertList03(propertyValueList);
- productPropertyValueDOList.stream().forEach(x-> x.setPropertyId(updateReqVO.getId()));
+ productPropertyValueDOList.forEach(x-> x.setPropertyId(updateReqVO.getId()));
productPropertyValueMapper.insertBatch(productPropertyValueDOList);
}
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 d15aa5c47..58538ebc0 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
@@ -2,9 +2,14 @@ package cn.iocoder.yudao.module.product.service.sku;
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyCreateReqVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyRespVO;
+import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueCreateReqVO;
import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueRespVO;
-import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*;
+import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO;
+import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateReqVO;
+import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO;
+import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO;
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper;
@@ -84,8 +89,6 @@ public class ProductSkuServiceImpl implements ProductSkuService {
return productSkuMapper.selectPage(pageReqVO);
}
- // TODO @franky:这个方法,貌似实现的还是有点问题哈。例如说,throw 异常,后面还执行逻辑~
- // TODO @艿艿 咳咳,throw 那里我是偷懒省略了{},哈哈,我加上,然后我调试下,在优化下
@Override
public void validateSkus(List list) {
List skuPropertyList = list.stream().flatMap(p -> p.getProperties().stream()).collect(Collectors.toList());
@@ -99,8 +102,9 @@ public class ProductSkuServiceImpl implements ProductSkuService {
skuPropertyList.forEach(p -> {
ProductPropertyRespVO productPropertyRespVO = propertyMap.get(p.getPropertyId());
// 如果对应的属性名不存在或属性名下的属性值集合为空,给出提示
- if (null == productPropertyRespVO || productPropertyRespVO.getPropertyValueList().isEmpty())
+ if (null == productPropertyRespVO || productPropertyRespVO.getPropertyValueList().isEmpty()) {
throw ServiceExceptionUtil.exception(PROPERTY_NOT_EXISTS);
+ }
// 判断改属性名对应的属性值是否存在,不存在,给出提示
if (!productPropertyRespVO.getPropertyValueList().stream().map(ProductPropertyValueRespVO::getId).collect(Collectors.toSet()).contains(p.getValueId())) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.PROPERTY_VALUE_NOT_EXISTS);
diff --git a/yudao-ui-admin/src/views/mall/product/spu/index.vue b/yudao-ui-admin/src/views/mall/product/spu/index.vue
index 7b66f1f05..23e502052 100644
--- a/yudao-ui-admin/src/views/mall/product/spu/index.vue
+++ b/yudao-ui-admin/src/views/mall/product/spu/index.vue
@@ -181,246 +181,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
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 93e42f79f..e05e651e4 100644
--- a/yudao-ui-admin/src/views/mall/product/spu/save.vue
+++ b/yudao-ui-admin/src/views/mall/product/spu/save.vue
@@ -1,26 +1,6 @@
-
-
-
-
-
-
-
+
@@ -40,11 +20,11 @@
clearable
>
-
-
+
+
-
-
+
+
@@ -80,29 +60,28 @@
-
-
+
+
-
+ > -->
- 添加规格项目
@@ -111,22 +90,24 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
+
@@ -177,40 +158,40 @@
-
+
-
-
-
-
-
- 上架
- 下架
-
-
+
+
+
+
+
+ 上架
+ 下架
+
+
-
- 取消
- 确认
-
+
+ 取消
+ 确认
+
@@ -349,7 +365,7 @@ export default {
.spec-header {
padding: 30px;
- padding-bottom: 0;
+ padding-bottom: 20px;
.spec-name {
display: inline;
@@ -364,6 +380,7 @@ export default {
width: 84%;
padding: 25px;
margin: auto;
+ padding-top: 5px;
.spec-value {
display: inline-block;
@@ -381,35 +398,40 @@ export default {
}
}
-.tabs{
+.tabs {
height: 500px;
border-bottom: 2px solid #f2f2f2;
- .el-tab-pane{
+
+ .el-tab-pane {
height: 445px;
overflow-y: auto;
}
}
// 库存价格图片样式修改
-.rates{
-.component-upload-image{
- margin: auto;
+.rates {
+ .component-upload-image {
+ margin: auto;
+ }
+
+ .el-upload--picture-card {
+ width: 100px;
+ height: 50px;
+ line-height: 60px;
+ margin: auto;
+ }
+
+ .el-upload-list__item {
+ width: 100px !important;
+ height: 50px !important;
+ }
}
-.el-upload--picture-card{
- width: 100px;
- height: 50px;
- line-height: 60px;
- margin: auto;
-}
-.el-upload-list__item{
- width: 100px !important;
- height: 50px !important;
-}
-}
-.buttons{
+
+.buttons {
margin-top: 20px;
height: 36px;
- button{
+
+ button {
float: right;
margin-left: 15px;
}
From 8de29d302c386758385d0a251e6480e4e239ead6 Mon Sep 17 00:00:00 2001
From: luowenfeng <1092164058@qq.com>
Date: Mon, 22 Aug 2022 21:20:49 +0800
Subject: [PATCH 3/3] =?UTF-8?q?feature(uniapp=E5=95=86=E5=93=81):=20?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E5=93=81=E6=95=B0=E6=8D=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admin/sku/vo/ProductSkuBaseVO.java | 3 +--
.../service/sku/ProductSkuServiceImpl.java | 2 +-
.../service/spu/ProductSpuServiceImpl.java | 8 ++++--
.../src/views/mall/product/spu/index.vue | 6 ++---
.../src/views/mall/product/spu/save.vue | 27 ++++++++++++-------
5 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java
index 7371ba4cc..f2636efe6 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java
@@ -19,8 +19,7 @@ public class ProductSkuBaseVO {
// TODO @franky:类似这种字段,有额外说明的。可以写成; @ApiModelProperty(value = "规格值数组", required = true, notes = "json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]")
- @ApiModelProperty(value = "规格值数组-json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]", required = true)
- @NotNull(message = "规格值数组-json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]不能为空")
+ @ApiModelProperty(value = "规格值数组-json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]")
private List properties;
@ApiModelProperty(value = "销售价格,单位:分", required = true)
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 58538ebc0..36549eb3f 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
@@ -91,7 +91,7 @@ public class ProductSkuServiceImpl implements ProductSkuService {
@Override
public void validateSkus(List list) {
- List skuPropertyList = list.stream().flatMap(p -> p.getProperties().stream()).collect(Collectors.toList());
+ List skuPropertyList = list.stream().flatMap(p -> Optional.of(p.getProperties()).orElse(new ArrayList<>()).stream()).collect(Collectors.toList());
// 校验规格属性以及规格值是否存在
List propertyIds = skuPropertyList.stream().map(ProductSkuBaseVO.Property::getPropertyId).collect(Collectors.toList());
List propertyAndValueList = productPropertyService.selectByIds(propertyIds);
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 49847f720..c3a05ce9b 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
@@ -57,7 +57,9 @@ public class ProductSpuServiceImpl implements ProductSpuService {
categoryService.validateProductCategory(createReqVO.getCategoryId());
// 校验SKU
List skuCreateReqList = createReqVO.getSkus();
- productSkuService.validateSkus(skuCreateReqList);
+ if(createReqVO.getSpecType() == 1) {
+ productSkuService.validateSkus(skuCreateReqList);
+ }
// 插入SPU
ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO);
ProductSpuMapper.insert(spu);
@@ -81,7 +83,9 @@ public class ProductSpuServiceImpl implements ProductSpuService {
categoryService.validateProductCategory(updateReqVO.getCategoryId());
// 校验SKU
List skuCreateReqList = updateReqVO.getSkus();
- productSkuService.validateSkus(skuCreateReqList);
+ if(updateReqVO.getSpecType() == 1) {
+ productSkuService.validateSkus(skuCreateReqList);
+ }
// 更新
ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO);
ProductSpuMapper.updateById(updateObj);
diff --git a/yudao-ui-admin/src/views/mall/product/spu/index.vue b/yudao-ui-admin/src/views/mall/product/spu/index.vue
index 23e502052..00ee1ed3f 100644
--- a/yudao-ui-admin/src/views/mall/product/spu/index.vue
+++ b/yudao-ui-admin/src/views/mall/product/spu/index.vue
@@ -178,9 +178,9 @@
/>
-
-
-
+
+
+
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 e05e651e4..556bd816b 100644
--- a/yudao-ui-admin/src/views/mall/product/spu/save.vue
+++ b/yudao-ui-admin/src/views/mall/product/spu/save.vue
@@ -309,26 +309,33 @@ export default {
if (this.ratesForm.spec == 1) {
rates.forEach(r => {
let properties = []
- r.spec.forEach((v, i) => {
- let specValue = this.dynamicSpec[i].specValue.find(o => o.name == v);
- let propertie = {};
- propertie.propertyId = this.dynamicSpec[i].specId;
- propertie.valueId = specValue.id;
- properties.push(propertie);
- })
+ if(r.spec instanceof Array){
+ r.spec.forEach((v, i) => {
+ let specValue = this.dynamicSpec[i].specValue.find(o => o.name == v);
+ let propertie = {};
+ propertie.propertyId = this.dynamicSpec[i].specId;
+ propertie.valueId = specValue.id;
+ properties.push(propertie);
+ })
+ }else{
+ let specValue = this.dynamicSpec[0].specValue.find(o => o.name == r.spec);
+ let propertie = {};
+ propertie.propertyId = this.dynamicSpec[0].specId;
+ propertie.valueId = specValue.id;
+ properties.push(propertie);
+ }
r.properties = properties;
})
}
this.baseForm.skus = rates;
this.baseForm.specType = this.ratesForm.spec;
this.baseForm.categoryId = this.baseForm.categoryIds[this.baseForm.categoryIds.length - 1];
- console.log(this.baseForm)
createSpu(this.baseForm).then((response) => {
+ console.log(response)
this.$modal.msgSuccess("新增成功");
- this.open = false;
- this.getList();
this.$emit("closeDialog");
});
+
},
/** 查询规格 */
getPropertyPageList() {