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 5b6b438e9..38bdd61bf 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 @@ -38,7 +38,6 @@ public class ProductSkuBaseVO { private Integer costPrice; @ApiModelProperty(value = "条形码", example = "haha") - @NotNull(message = "条形码不能为空") private String barCode; @ApiModelProperty(value = "图片地址") 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 d9e742a1b..c8172d157 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,11 +89,9 @@ 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()); + public void validateSkus(List list) { + 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); @@ -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-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 95831df5e..1ff0a0340 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 @@ -56,8 +56,10 @@ public class ProductSpuServiceImpl implements ProductSpuService { // 校验分类 categoryService.validateProductCategory(createReqVO.getCategoryId()); // 校验SKU - List skuCreateReqList = createReqVO.getSkus(); - productSkuService.validateSkus(skuCreateReqList); + List skuCreateReqList = createReqVO.getSkus(); + if(createReqVO.getSpecType() == 1) { + productSkuService.validateSkus(skuCreateReqList); + } // 插入SPU ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); ProductSpuMapper.insert(spu); @@ -76,8 +78,10 @@ public class ProductSpuServiceImpl implements ProductSpuService { // 校验分类 categoryService.validateProductCategory(updateReqVO.getCategoryId()); // 校验SKU - List skuCreateReqList = updateReqVO.getSkus(); - productSkuService.validateSkus(skuCreateReqList); + List skuCreateReqList = updateReqVO.getSkus(); + 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 5f5ca6d49..00ee1ed3f 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 @@