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] =?UTF-8?q?feature(uniapp=E5=88=86=E7=B1=BB):=20=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=9B=E5=BB=BA=E5=8A=9F=E8=83=BD=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD=E6=AD=A3=E5=B8=B8=E4=BD=BF?= =?UTF-8?q?=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 e61b217e8a..f6b3542e3b 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 cefab9a47c..7371ba4cce 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 e9c76805a6..33d11ccac3 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 9cb1a0da33..f650e90d90 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 d15aa5c477..58538ebc05 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 7b66f1f050..23e5020528 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 93e42f79fc..e05e651e4d 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 @@