diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductUnitEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductUnitEnum.java deleted file mode 100644 index 8753824dc..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductUnitEnum.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.spu; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -// TODO @puhui999:是不是放到数据字典里? -/** - * 产品单位枚举 - * - * @author HUIHUI - */ -@Getter -@AllArgsConstructor -public enum ProductUnitEnum implements IntArrayValuable { - - PIECE(1, "个"), - DOZEN(2, "打"), - BOX(3, "盒"), - BAG(4, "袋"), - CASE(5, "箱"), - SET(6, "套"), - PACK(7, "包"), - PAIR(8, "双"), - ROLL(9, "卷"), - SHEET(10, "张"), - WEIGHT(11, "克"), - KILOGRAM(12, "千克"), - MILLIGRAM(13, "毫克"), - MICROGRAM(14, "微克"), - TON(15, "吨"), - LITER(16, "升"), - MILLILITER(17, "毫升"), - SQUARE_METER(19, "平方米"), - SQUARE_KILOMETER(20, "平方千米"), - SQUARE_MILE(21, "平方英里"), - SQUARE_YARD(22, "平方码"), - SQUARE_FOOT(23, "平方英尺"), - CUBIC_METER(24, "立方米"), - CUBIC_CENTIMETER(25, "立方厘米"), - CUBIC_INCH(26, "立方英寸"), - METER(27, "米"), - CENTIMETER(29, "厘米"), - MILLIMETER(30, "毫米"), - INCH(31, "英寸"), - FOOT(32, "英尺"), - YARD(33, "码"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductUnitEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java index 24af006c8..9cc398169 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java @@ -61,7 +61,8 @@ public class ProductBrandController { public CommonResult getBrand(@RequestParam("id") Long id) { ProductBrandDO brand = brandService.getBrand(id); return success(ProductBrandConvert.INSTANCE.convert(brand)); - } // TODO @puhui999:方法和方法之间,要有空行。 + } + @GetMapping("/list-all-simple") @Operation(summary = "获取品牌精简信息列表", description = "主要用于前端的下拉选项") public CommonResult> getSimpleUserList() { @@ -70,6 +71,7 @@ public class ProductBrandController { // 排序后,返回给前端 return success(ProductBrandConvert.INSTANCE.convertList1(list)); } + @GetMapping("/page") @Operation(summary = "获得品牌分页") @PreAuthorize("@ss.hasPermission('product:brand:query')") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java index e8561fe07..4336c3cc8 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java @@ -12,7 +12,7 @@ import javax.validation.constraints.NotNull; @Data public class ProductBrandBaseVO { - @Schema(description = "品牌名称", required = true, example = "芋道") + @Schema(description = "品牌名称", required = true, example = "苹果") @NotNull(message = "品牌名称不能为空") private String name; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java index 63305810c..ed93ff090 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java @@ -7,7 +7,7 @@ import lombok.Data; @Data public class ProductBrandListReqVO { - @Schema(description = "品牌名称", example = "芋道") + @Schema(description = "品牌名称", example = "苹果") private String name; } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java index 81d470b1b..3a6efc93f 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java @@ -17,7 +17,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class ProductBrandPageReqVO extends PageParam { - @Schema(description = "品牌名称", example = "芋道") + @Schema(description = "品牌名称", example = "苹果") private String name; @Schema(description = "状态", example = "0") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandSimpleRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandSimpleRespVO.java index 93501ce51..14e74b946 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandSimpleRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandSimpleRespVO.java @@ -11,8 +11,11 @@ import lombok.NoArgsConstructor; @NoArgsConstructor @AllArgsConstructor public class ProductBrandSimpleRespVO { + @Schema(description = "品牌编号", required = true, example = "1024") private Long id; - @Schema(description = "品牌名称", required = true, example = "芋道") + + @Schema(description = "品牌名称", required = true, example = "苹果") private String name; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java index 616286674..cd02ddbd0 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java @@ -12,6 +12,8 @@ import javax.validation.constraints.NotBlank; @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class ProductCategoryCreateReqVO extends ProductCategoryBaseVO { - @Schema(description = "分类描述") + + @Schema(description = "分类描述", example = "描述") private String description; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java index 68cad0d30..2dee40d22 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java @@ -17,7 +17,8 @@ public class ProductCategoryUpdateReqVO extends ProductCategoryBaseVO { @Schema(description = "分类编号", required = true, example = "2") @NotNull(message = "分类编号不能为空") private Long id; - @Schema(description = "分类描述") + + @Schema(description = "分类描述", example = "描述") private String description; } 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 fb0554219..518428ca6 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 @@ -7,6 +7,7 @@ import lombok.NoArgsConstructor; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.util.List; /** * 商品 SKU Base VO,提供给添加、修改、详细的子 VO 使用 @@ -15,72 +16,67 @@ import javax.validation.constraints.NotNull; @Data public class ProductSkuBaseVO { - @Schema(description = "商品 SKU 名字", required = true, example = "芋道") + @Schema(description = "商品 SKU 名字", required = true, example = "清凉小短袖") @NotEmpty(message = "商品 SKU 名字不能为空") private String name; - @Schema(description = "销售价格,单位:分", required = true, example = "1024") + @Schema(description = "销售价格,单位:分", required = true, example = "1999") @NotNull(message = "销售价格,单位:分不能为空") private Integer price; - @Schema(description = "市场价", example = "1024") + @Schema(description = "市场价", example = "2999") private Integer marketPrice; - @Schema(description = "成本价", example = "1024") + @Schema(description = "成本价", example = "19") private Integer costPrice; - @Schema(description = "条形码", example = "haha") + @Schema(description = "条形码", example = "15156165456") private String barCode; @Schema(description = "图片地址", required = true, example = "https://www.iocoder.cn/xx.png") @NotNull(message = "图片地址不能为空") private String picUrl; - @Schema(description = "库存", required = true, example = "1") + @Schema(description = "库存", required = true, example = "200") @NotNull(message = "库存不能为空") private Integer stock; - @Schema(description = "预警预存", example = "1") + @Schema(description = "预警预存", example = "10") private Integer warnStock; - @Schema(description = "商品重量,单位:kg 千克", example = "1") + @Schema(description = "商品重量,单位:kg 千克", example = "1.2") private Double weight; - @Schema(description = "商品体积,单位:m^3 平米", example = "1024") + @Schema(description = "商品体积,单位:m^3 平米", example = "2.5") private Double volume; - @Schema(description = "一级分销的佣金,单位:分", example = "1024") + @Schema(description = "一级分销的佣金,单位:分", example = "199") private Integer subCommissionFirstPrice; - @Schema(description = "二级分销的佣金,单位:分", example = "1024") + @Schema(description = "二级分销的佣金,单位:分", example = "19") private Integer subCommissionSecondPrice; - // TODO @puhui999:这里要写 swagger 注解哈 - /** - * 商品属性 - */ + @Schema(description = "属性数组") + private List properties; + + @Schema(description = "商品属性") @Data @NoArgsConstructor @AllArgsConstructor public static class Property { - /** - * 属性编号 - */ + @Schema(description = "属性编号", example = "10") private Long propertyId; - /** - * 属性名字 - */ + + @Schema(description = "属性名字", example = "颜色") private String propertyName; - /** - * 属性值编号 - */ + @Schema(description = "属性值编号", example = "10") private Long valueId; - /** - * 属性值名字 - */ + + @Schema(description = "属性值名字", example = "红色") private String valueName; } + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java index 1287d8f8c..e750013d5 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java @@ -13,10 +13,4 @@ import java.util.List; @ToString(callSuper = true) public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO { - // TODO @puhui999:是不是可以抽到父类里? - /** - * 属性数组 - */ - private List properties; - } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java index ce0614152..27c66a295 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java @@ -15,9 +15,4 @@ public class ProductSkuRespVO extends ProductSkuBaseVO { @Schema(description = "主键", required = true, example = "1024") private Long id; - /** - * 属性数组 - */ - private List properties; - } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java index c03f08798..184a44f7e 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java @@ -94,11 +94,10 @@ public class ProductSpuController { return success(ProductSpuConvert.INSTANCE.convertPage(productSpuService.getSpuPage(pageVO))); } - // TODO @puhui999:方法名改成 getSpuCount,只是用于 tab 哈,这样更抽象一点。 @GetMapping("/get-count") @Operation(summary = "获得商品 SPU 分页 tab count") @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getTabsCount() { + public CommonResult> getSpuCount() { return success(productSpuService.getTabsCount()); } 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 1d4dccc5d..409a74518 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 @@ -16,19 +16,19 @@ import java.util.List; @Data public class ProductSpuBaseVO { - @Schema(description = "商品名称", required = true, example = "芋道") + @Schema(description = "商品名称", required = true, example = "清凉小短袖") @NotEmpty(message = "商品名称不能为空") private String name; - @Schema(description = "关键字", required = true, example = "芋道") + @Schema(description = "关键字", required = true, example = "清凉丝滑不出汗") @NotEmpty(message = "商品关键字不能为空") private String keyword; - @Schema(description = "商品简介", required = true, example = "芋道") + @Schema(description = "商品简介", required = true, example = "清凉小短袖简介") @NotEmpty(message = "商品简介不能为空") private String introduction; - @Schema(description = "商品详情", required = true, example = "芋道") + @Schema(description = "商品详情", required = true, example = "清凉小短袖详情") @NotEmpty(message = "商品详情不能为空") private String description; @@ -40,14 +40,14 @@ public class ProductSpuBaseVO { @NotNull(message = "商品品牌不能为空") private Long brandId; - @Schema(description = "商品封面图", required = true, example = "芋道") + @Schema(description = "商品封面图", required = true, example = "https://www.iocoder.cn/xx.png") @NotEmpty(message = "商品封面图不能为空") private String picUrl; - @Schema(description = "商品轮播图", required = true) + @Schema(description = "商品轮播图", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") private List sliderPicUrls; - @Schema(description = "商品视频") + @Schema(description = "商品视频", example = "https://www.iocoder.cn/xx.mp4") private String videoUrl; @Schema(description = "单位", required = true, example = "1") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java index dacd94b79..0c63e43b1 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java @@ -20,18 +20,16 @@ import java.util.List; @ToString(callSuper = true) public class ProductSpuDetailRespVO extends ProductSpuBaseVO { - // TODO @puhui999:swagger 的 required 和 example 写下 - - @Schema(description = "商品 SPU 编号") + @Schema(description = "商品 SPU 编号", required = true, example = "1212") private Long id; - @Schema(description = "商品销量") + @Schema(description = "商品销量", required = true, example = "10000") private Integer salesCount; - @Schema(description = "浏览量") + @Schema(description = "浏览量", required = true, example = "20000") private Integer browseCount; - @Schema(description = "商品状态") + @Schema(description = "商品状态", required = true, example = "1") private Integer status; // ========== SKU 相关字段 ========= diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExcelVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExcelVO.java index 56ae45deb..62da2747b 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExcelVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExcelVO.java @@ -16,6 +16,7 @@ import java.time.LocalDateTime; */ @Data public class ProductSpuExcelVO { + @ExcelProperty("商品编号") private Long id; @@ -116,4 +117,5 @@ public class ProductSpuExcelVO { @ExcelProperty("创建时间") private LocalDateTime createTime; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExportReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExportReqVO.java index 01e752377..11260c1b2 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExportReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExportReqVO.java @@ -18,14 +18,14 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @AllArgsConstructor public class ProductSpuExportReqVO { - @Schema(description = "商品名称", example = "yutou") + @Schema(description = "商品名称", example = "清凉小短袖") private String name; @Schema(description = "前端请求的tab类型", example = "1") @InEnum(ProductSpuPageTabEnum.class) private Integer tabType; - @Schema(description = "商品分类编号") + @Schema(description = "商品分类编号", example = "100") private Long categoryId; @Schema(description = "创建时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java index 3f0ad57a8..9dca61d69 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java @@ -25,17 +25,17 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class ProductSpuPageReqVO extends PageParam { - @Schema(description = "商品名称", example = "yutou") + @Schema(description = "商品名称", example = "清凉小短袖") private String name; - @Schema(description = "前端请求的tab类型", example = "1") + @Schema(description = "前端请求的tab类型", required = true, example = "1") @InEnum(ProductSpuPageTabEnum.class) private Integer tabType; - @Schema(description = "商品分类编号") + @Schema(description = "商品分类编号", example = "1") private Long categoryId; - @Schema(description = "创建时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]") + @Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] createTime; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java index adcc94100..39b35ae68 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java @@ -18,30 +18,28 @@ import java.time.LocalDateTime; @ToString(callSuper = true) public class ProductSpuRespVO extends ProductSpuBaseVO { - // TODO @puhui999:swagger 的 required 和 example 写下 - - @Schema(description = "spuId") + @Schema(description = "spuId", required = true, example = "111") private Long id; - @Schema(description = "商品价格") + @Schema(description = "商品价格", required = true, example = "1999") private Integer price; - @Schema(description = "商品销量") + @Schema(description = "商品销量", required = true, example = "2000") private Integer salesCount; - @Schema(description = "市场价,单位使用:分") + @Schema(description = "市场价,单位使用:分", required = true, example = "199") private Integer marketPrice; - @Schema(description = "成本价,单位使用:分") + @Schema(description = "成本价,单位使用:分", required = true, example = "19") private Integer costPrice; - @Schema(description = "商品库存") + @Schema(description = "商品库存", required = true, example = "10000") private Integer stock; - @Schema(description = "商品创建时间") + @Schema(description = "商品创建时间", required = true, example = "2023-05-24 00:00:00") private LocalDateTime createTime; - @Schema(description = "商品状态") + @Schema(description = "商品状态", required = true, example = "1") private Integer status; } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java index 4df865af0..4ab766129 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java @@ -14,35 +14,33 @@ import lombok.ToString; @ToString(callSuper = true) public class ProductSpuSimpleRespVO { - // TODO @puhui999:swagger 的 required 和 example 写下 - - @Schema(description = "主键") + @Schema(description = "主键", required = true, example = "213") private Long id; - @Schema(description = "商品名称") + @Schema(description = "商品名称", required = true, example = "清凉小短袖") private String name; - @Schema(description = "商品价格,单位使用:分") + @Schema(description = "商品价格,单位使用:分", required = true, example = "1999") private Integer price; - @Schema(description = "商品市场价,单位使用:分") + @Schema(description = "商品市场价,单位使用:分", required = true, example = "199") private Integer marketPrice; - @Schema(description = "商品成本价,单位使用:分") + @Schema(description = "商品成本价,单位使用:分", required = true, example = "19") private Integer costPrice; - @Schema(description = "商品库存") + @Schema(description = "商品库存", required = true, example = "2000") private Integer stock; // ========== 统计相关字段 ========= - @Schema(description = "商品销量") + @Schema(description = "商品销量", required = true, example = "200") private Integer salesCount; - @Schema(description = "商品虚拟销量") + @Schema(description = "商品虚拟销量", required = true, example = "20000") private Integer virtualSalesCount; - @Schema(description = "商品浏览量") + @Schema(description = "商品浏览量", required = true, example = "2000") private Integer browseCount; } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java index 61230242f..f4bd3cdae 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java @@ -23,19 +23,17 @@ import java.util.List; @ToString(callSuper = true) public class ProductSpuUpdateReqVO extends ProductSpuBaseVO { - // TODO @puhui999:swagger 的 required 和 example 写下 - @Schema(description = "商品编号", required = true, example = "1") @NotNull(message = "商品编号不能为空") private Long id; - @Schema(description = "商品销量") + @Schema(description = "商品销量", required = true, example = "1999") private Integer salesCount; - @Schema(description = "浏览量") + @Schema(description = "浏览量", required = true, example = "1999") private Integer browseCount; - @Schema(description = "商品状态") + @Schema(description = "商品状态", required = true, example = "1") @InEnum(ProductSpuStatusEnum.class) private Integer status; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java index fe1a8ee87..2a0f4cd68 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java @@ -67,8 +67,7 @@ public class AppProductSpuController { } // 查询商品 SKU - List skus = productSkuService.getSkuListBySpuIdAndStatus(spu.getId(), - CommonStatusEnum.ENABLE.getStatus()); + List skus = productSkuService.getSkuListBySpuIdAndStatus(spu.getId()); // 查询商品属性 List propertyValues = productPropertyValueService .getPropertyValueDetailList(ProductSkuConvert.INSTANCE.convertPropertyValueIds(skus)); 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 dd69646af..96cd7e41b 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 @@ -43,8 +43,6 @@ public interface ProductSkuConvert { ProductSkuRespDTO convert02(ProductSkuDO bean); - List convertList03(List list); - List convertList04(List list); List convertList05(List skus); diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java index 052ac287d..62c47bfb6 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java @@ -16,6 +16,8 @@ import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Named; import org.mapstruct.factory.Mappers; import java.util.ArrayList; @@ -52,55 +54,38 @@ public interface ProductSpuConvert { List convertList02(List list); - // TODO @puhui999:部分属性,可以通过 mapstruct 的 @Mapping(source = , target = , ) 映射转换,可以查下文档 - default List convertList03(List list){ - ArrayList spuExcelVOs = new ArrayList<>(); - list.forEach((spu)->{ - ProductSpuExcelVO spuExcelVO = new ProductSpuExcelVO(); - spuExcelVO.setId(spu.getId()); - spuExcelVO.setName(spu.getName()); - spuExcelVO.setKeyword(spu.getKeyword()); - spuExcelVO.setIntroduction(spu.getIntroduction()); - spuExcelVO.setDescription(spu.getDescription()); - spuExcelVO.setBarCode(spu.getBarCode()); - spuExcelVO.setCategoryId(spu.getCategoryId()); - spuExcelVO.setBrandId(spu.getBrandId()); - spuExcelVO.setPicUrl(spu.getPicUrl()); - spuExcelVO.setSliderPicUrls(StrUtil.toString(spu.getSliderPicUrls())); - spuExcelVO.setVideoUrl(spu.getVideoUrl()); - spuExcelVO.setUnit(spu.getUnit()); - spuExcelVO.setSort(spu.getSort()); - spuExcelVO.setStatus(spu.getStatus()); - spuExcelVO.setSpecType(spu.getSpecType()); - spuExcelVO.setPrice(spu.getPrice()/100); - spuExcelVO.setMarketPrice(spu.getMarketPrice()/100); - spuExcelVO.setCostPrice(spu.getCostPrice()/100); - spuExcelVO.setStock(spu.getStock()); - spuExcelVO.setDeliveryTemplateId(spu.getDeliveryTemplateId()); - spuExcelVO.setRecommendHot(spu.getRecommendHot()); - spuExcelVO.setRecommendBenefit(spu.getRecommendBenefit()); - spuExcelVO.setRecommendBest(spu.getRecommendBest()); - spuExcelVO.setRecommendNew(spu.getRecommendNew()); - spuExcelVO.setRecommendGood(spu.getRecommendGood()); - spuExcelVO.setGiveIntegral(spu.getGiveIntegral()); - spuExcelVO.setGiveCouponTemplateIds(StrUtil.toString(spu.getGiveCouponTemplateIds())); // TODO 暂定 - spuExcelVO.setSubCommissionType(spu.getSubCommissionType()); - spuExcelVO.setActivityOrders(StrUtil.toString(spu.getActivityOrders())); // TODO 暂定 - spuExcelVO.setSalesCount(spu.getSalesCount()); - spuExcelVO.setVirtualSalesCount(spu.getVirtualSalesCount()); - spuExcelVO.setBrowseCount(spu.getBrowseCount()); - spuExcelVO.setCreateTime(spu.getCreateTime()); + /** + * 列表转字符串 + * + * @param list 列表 + * @return 字符串 + */ + @Named("convertListToString") + default String convertListToString(List list) { + return StrUtil.toString(list); + } + + // TODO @puhui999:部分属性,可以通过 mapstruct 的 @Mapping(source = , target = , ) 映射转换,可以查下文档 fix:哈哈 这样确实丝滑哈 + + @Mapping(source = "sliderPicUrls", target = "sliderPicUrls", qualifiedByName = "convertListToString") + @Mapping(source = "giveCouponTemplateIds", target = "giveCouponTemplateIds", qualifiedByName = "convertListToString") + @Mapping(source = "activityOrders", target = "activityOrders", qualifiedByName = "convertListToString") + @Mapping(target = "price", expression = "java(spu.getPrice() / 100)") + @Mapping(target = "marketPrice", expression = "java(spu.getMarketPrice() / 100)") + @Mapping(target = "costPrice", expression = "java(spu.getCostPrice() / 100)") + ProductSpuExcelVO convert(ProductSpuDO spu); + + default List convertList03(List list) { + List spuExcelVOs = new ArrayList<>(); + list.forEach(spu -> { + ProductSpuExcelVO spuExcelVO = convert(spu); spuExcelVOs.add(spuExcelVO); }); return spuExcelVOs; } + ProductSpuDetailRespVO convert03(ProductSpuDO spu); - // TODO @puhui999:下面两个没用到,是不是删除呀? - List convertList04(List skus); - - ProductPropertyValueDetailRespVO convert04(ProductPropertyValueDetailRespBO propertyValue); - // ========== 用户 App 相关 ========== default PageResult convertPageForGetSpuPage(PageResult page) { @@ -144,26 +129,15 @@ public interface ProductSpuConvert { AppProductPropertyValueDetailRespVO convertForGetSpuDetail(ProductPropertyValueDetailRespBO propertyValue); - default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List skus, - Function, List> func) { + default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List skus) { ProductSpuDetailRespVO productSpuDetailRespVO = convert03(spu); - // TODO @puhui999:if return 哈,减少嵌套层数。 - if (CollUtil.isNotEmpty(skus)) { - List skuVOs = ProductSkuConvert.INSTANCE.convertList(skus); - // fix:统一模型,即使是单规格,也查询下,如若 Properties 为空报错则为单属性不做处理 - try { - // 获取所有的属性值 id - Set valueIds = skus.stream().flatMap(p -> p.getProperties().stream()) - .map(ProductSkuDO.Property::getValueId) - .collect(Collectors.toSet()); - List valueDetailList = func.apply(valueIds); - Map stringMap = valueDetailList.stream().collect(Collectors.toMap(ProductPropertyValueDetailRespBO::getValueId, ProductPropertyValueDetailRespBO::getValueName)); - // 设置属性值名称 - skuVOs.stream().flatMap(p -> p.getProperties().stream()).forEach(item -> item.setValueName(stringMap.get(item.getValueId()))); - } catch (Exception ignored) { - } - productSpuDetailRespVO.setSkus(skuVOs); + // skus 为空直接返回 + if (CollUtil.isEmpty(skus)) { + return productSpuDetailRespVO; } + List skuVOs = ProductSkuConvert.INSTANCE.convertList(skus); + // fix: 因为现在已改为 sku 属性列表 属性 已包含 属性名字 属性值名字 所以不需要再额外处理,属性更新时更新 sku 中的属性相关冗余即可 + productSpuDetailRespVO.setSkus(skuVOs); return productSpuDetailRespVO; } 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 6c3a9a020..fa576683b 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 @@ -19,7 +19,7 @@ import java.util.List; * * @author 芋道源码 */ -@TableName(value = "product_sku",autoResultMap = true) +@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/dal/mysql/brand/ProductBrandMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java index e66a6ed2b..b2c4bd5fb 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java @@ -31,8 +31,7 @@ public interface ProductBrandMapper extends BaseMapperX { return selectOne(ProductBrandDO::getName, name); } - // TODO @puhui999:) { 中间要有空格哈。 - default List selectListByStatus(Integer status){ - return selectList(ProductBrandDO::getStatus,status); + default List selectListByStatus(Integer status) { + return selectList(ProductBrandDO::getStatus, status); } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java index 96378faf7..75963e3e1 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java @@ -23,11 +23,9 @@ public interface ProductSkuMapper extends BaseMapperX { return selectList(ProductSkuDO::getSpuId, spuId); } - default List selectListBySpuIdAndStatus(Long spuId, - Integer status) { + default List selectListBySpuIdAndStatus(Long spuId) { return selectList(new LambdaQueryWrapperX() - .eq(ProductSkuDO::getSpuId, spuId)// eqIfPresent(ProductSkuDO::getStatus, status) TODO ProductSkuDO已经没有status属性 - ); + .eq(ProductSkuDO::getSpuId, spuId)); } default List selectListBySpuId(Collection spuIds) { @@ -41,7 +39,7 @@ public interface ProductSkuMapper extends BaseMapperX { /** * 更新 SKU 库存(增加) * - * @param id 编号 + * @param id 编号 * @param incrCount 增加库存(正数) */ default void updateStockIncr(Long id, Integer incrCount) { @@ -55,7 +53,7 @@ public interface ProductSkuMapper extends BaseMapperX { /** * 更新 SKU 库存(减少) * - * @param id 编号 + * @param id 编号 * @param incrCount 减少库存(负数) * @return 更新条数 */ @@ -68,8 +66,8 @@ public interface ProductSkuMapper extends BaseMapperX { return update(null, updateWrapper); } - default List selectListByAlarmStock(){ - return selectList(new QueryWrapper().apply("stock <= warn_stock")); + default List selectListByAlarmStock() { + return selectList(new QueryWrapper().apply("stock <= warn_stock")); } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java index 14f6fae58..abf357c24 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java @@ -35,21 +35,21 @@ public interface ProductSpuMapper extends BaseMapperX { .eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()) .betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(ProductSpuDO::getSort); - validateTabType(tabType, queryWrapper); + appendTabQuery(tabType, queryWrapper); return selectPage(reqVO, queryWrapper); } /** - * 获取库存小于 value ,且状态不等于 status 的的个数 + * 查询触发警戒库存的 SPU 数量 * - * @return 个数 + * @return 触发警戒库存的 SPU 数量 */ - default Long selectCountByStockAndStatus() { + default Long selectCount() { LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX<>(); + // 库存小于等于警戒库存 queryWrapper.le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK) - // TODO @puhui999:IN 另外两个状态,会不会好点哈。尽量不用 != // 如果库存触发警戒库存且状态为回收站的话则不计入触发警戒库存的个数 - .and(q -> q.ne(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus())); + .notIn(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()); return selectCount(queryWrapper); } @@ -101,43 +101,43 @@ public interface ProductSpuMapper extends BaseMapperX { * @param reqVO 查询条件 * @return Spu 列表 */ - default List selectList(ProductSpuExportReqVO reqVO){ + default List selectList(ProductSpuExportReqVO reqVO) { Integer tabType = reqVO.getTabType(); LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX<>(); - queryWrapper.eqIfPresent(ProductSpuDO::getName,reqVO.getName()); - queryWrapper.eqIfPresent(ProductSpuDO::getCategoryId,reqVO.getCategoryId()); - queryWrapper.betweenIfPresent(ProductSpuDO::getCreateTime,reqVO.getCreateTime()); - validateTabType(tabType, queryWrapper); + queryWrapper.eqIfPresent(ProductSpuDO::getName, reqVO.getName()); + queryWrapper.eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()); + queryWrapper.betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime()); + appendTabQuery(tabType, queryWrapper); return selectList(queryWrapper); } - // TODO @puhui999:应该不太适合 validate 验证,应该是补充条件,例如说 appendTabQuery /** * 验证选项卡类型构建条件 * * @param tabType 标签类型 * @param queryWrapper 查询条件 */ - static void validateTabType(Integer tabType, LambdaQueryWrapperX queryWrapper) { - // 出售中商品 TODO puhui999:这样好点 + static void appendTabQuery(Integer tabType, LambdaQueryWrapperX queryWrapper) { + // 出售中商品 if (ObjectUtil.equals(ProductSpuPageTabEnum.FOR_SALE.getType(), tabType)) { queryWrapper.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()); } + // 仓储中商品 if (ObjectUtil.equals(ProductSpuPageTabEnum.IN_WAREHOUSE.getType(), tabType)) { - // 仓储中商品 queryWrapper.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus()); } + // 已售空商品 if (ObjectUtil.equals(ProductSpuPageTabEnum.SOLD_OUT.getType(), tabType)) { - // 已售空商品 queryWrapper.eqIfPresent(ProductSpuDO::getStock, 0); } + // 警戒库存 if (ObjectUtil.equals(ProductSpuPageTabEnum.ALERT_STOCK.getType(), tabType)) { queryWrapper.le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK) // 如果库存触发警戒库存且状态为回收站的话则不在警戒库存列表展示 - .and(q -> q.ne(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus())); + .notIn(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()); } + // 回收站 if (ObjectUtil.equals(ProductSpuPageTabEnum.RECYCLE_BIN.getType(), tabType)) { - // 回收站 queryWrapper.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()); } } 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 0b34cc2d8..8438db684 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 @@ -88,14 +88,10 @@ public interface ProductSkuService { /** * 基于 SPU 编号和状态,获得商品 SKU 集合 * - * TODO @puhui999:SKU中已经不存在status属性;芋艿:那就去掉 status 哈 - * * @param spuId SPU 编号 - * @param status 状态 * @return 商品 SKU 集合 */ - List getSkuListBySpuIdAndStatus(Long spuId, - @Nullable Integer status); + List getSkuListBySpuIdAndStatus(Long spuId); /** * 获得 spu 对应的 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 a03c94240..1bb129876 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 @@ -3,14 +3,12 @@ package cn.iocoder.yudao.module.product.service.sku; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; -import cn.iocoder.yudao.module.product.enums.ErrorCodeConstants; import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; @@ -85,7 +83,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { } // 0、校验skus是否为空 - if (CollUtil.isEmpty(skus)){ + if (CollUtil.isEmpty(skus)) { throw exception(SKU_NOT_EXISTS); } @@ -140,8 +138,8 @@ public class ProductSkuServiceImpl implements ProductSkuService { } @Override - public List getSkuListBySpuIdAndStatus(Long spuId, Integer status) { - return productSkuMapper.selectListBySpuIdAndStatus(spuId, status); + public List getSkuListBySpuIdAndStatus(Long spuId) { + return productSkuMapper.selectListBySpuIdAndStatus(spuId); } @Override 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 12233d246..859450510 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 @@ -18,7 +18,6 @@ import cn.iocoder.yudao.module.product.enums.spu.ProductSpuPageTabEnum; import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -51,8 +50,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { private ProductBrandService brandService; @Resource private ProductCategoryService categoryService; - @Resource - private ProductPropertyValueService productPropertyValueService; @Override @Transactional(rollbackFor = Exception.class) @@ -63,10 +60,10 @@ public class ProductSpuServiceImpl implements ProductSpuService { // 校验 SKU List skuSaveReqList = createReqVO.getSkus(); productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType()); + ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); // 初始化 SPU 中 SKU 相关属性 initSpuFromSkus(spu, skuSaveReqList); - // 插入 SPU productSpuMapper.insert(spu); // 插入 SKU @@ -86,7 +83,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { // 校验SKU List skuSaveReqList = updateReqVO.getSkus(); productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType()); - // TODO @puhui999:可以校验逻辑,和更新逻辑,中间有个空行,这样会发现,哟 这里到了关键逻辑啦,更有层次感 + // 更新 SPU ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO); initSpuFromSkus(updateObj, skuSaveReqList); @@ -103,20 +100,14 @@ public class ProductSpuServiceImpl implements ProductSpuService { * @param skus 商品 SKU 数组 */ private void initSpuFromSkus(ProductSpuDO spu, List skus) { - // 断言,避免告警 - assert skus.size() > 0; - // 获取 sku 单价最低的商品 - // TODO @puhui999:vo 改成 sku 会更好。vo dto 只是我们用来区分的,如果能区分的情况下,用更明确的名字会更好。 -// CollectionUtils.getMinValue(); TODO @puhui999:可以用这个方法,常见的 stream 操作,封装成方法,让逻辑更简洁 - ProductSkuCreateOrUpdateReqVO vo = skus.stream().min(Comparator.comparing(ProductSkuCreateOrUpdateReqVO::getPrice)).get(); // sku 单价最低的商品的价格 - spu.setPrice(vo.getPrice()); + spu.setPrice(CollectionUtils.getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getPrice)); // sku 单价最低的商品的市场价格 - spu.setMarketPrice(vo.getMarketPrice()); + spu.setMarketPrice(CollectionUtils.getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getMarketPrice)); // sku单价最低的商品的成本价格 - spu.setCostPrice(vo.getCostPrice()); + spu.setCostPrice(CollectionUtils.getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getCostPrice)); // sku单价最低的商品的条形码 - spu.setBarCode(vo.getBarCode()); + spu.setBarCode(CollectionUtils.getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getBarCode)); // skus 库存总数 spu.setStock(getSumValue(skus, ProductSkuCreateOrUpdateReqVO::getStock, Integer::sum)); // 若是 spu 已有状态则不处理 @@ -150,6 +141,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { validateSpuExists(id); // 校验商品状态不是回收站不能删除 validateSpuStatus(id); + // 删除 SPU productSpuMapper.deleteById(id); // 删除关联的 SKU @@ -229,8 +221,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { } // 查询商品 SKU List skus = productSkuService.getSkuListBySpuId(spu.getId()); - // TODO @puhui999:感觉还是查询好 productPropertyValueService,然后 propertyId 可以交给 convert 处理下即可。 - return ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus, productPropertyValueService::getPropertyValueDetailList); + return ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus); } @Override @@ -238,10 +229,10 @@ public class ProductSpuServiceImpl implements ProductSpuService { public void updateStatus(ProductSpuUpdateStatusReqVO updateReqVO) { // 校验存在 validateSpuExists(updateReqVO.getId()); + // 更新状态 ProductSpuDO productSpuDO = productSpuMapper.selectById(updateReqVO.getId()).setStatus(updateReqVO.getStatus()); productSpuMapper.updateById(productSpuDO); - } @Override @@ -254,7 +245,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { // 查询售空的商品数量 counts.put(ProductSpuPageTabEnum.SOLD_OUT.getType(), productSpuMapper.selectCount(ProductSpuDO::getStock, 0)); // 查询触发警戒库存的商品数量 - counts.put(ProductSpuPageTabEnum.ALERT_STOCK.getType(), productSpuMapper.selectCountByStockAndStatus()); + counts.put(ProductSpuPageTabEnum.ALERT_STOCK.getType(), productSpuMapper.selectCount()); // 查询回收站中的商品数量 counts.put(ProductSpuPageTabEnum.RECYCLE_BIN.getType(), productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus())); return counts;