fix:修复商品 review 提到的问题

This commit is contained in:
puhui999 2023-05-25 09:23:38 +08:00
parent c62da6a056
commit b065a2a741
30 changed files with 155 additions and 283 deletions

View File

@ -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;
}
}

View File

@ -61,7 +61,8 @@ public class ProductBrandController {
public CommonResult<ProductBrandRespVO> getBrand(@RequestParam("id") Long id) { public CommonResult<ProductBrandRespVO> getBrand(@RequestParam("id") Long id) {
ProductBrandDO brand = brandService.getBrand(id); ProductBrandDO brand = brandService.getBrand(id);
return success(ProductBrandConvert.INSTANCE.convert(brand)); return success(ProductBrandConvert.INSTANCE.convert(brand));
} // TODO @puhui999方法和方法之间要有空行 }
@GetMapping("/list-all-simple") @GetMapping("/list-all-simple")
@Operation(summary = "获取品牌精简信息列表", description = "主要用于前端的下拉选项") @Operation(summary = "获取品牌精简信息列表", description = "主要用于前端的下拉选项")
public CommonResult<List<ProductBrandSimpleRespVO>> getSimpleUserList() { public CommonResult<List<ProductBrandSimpleRespVO>> getSimpleUserList() {
@ -70,6 +71,7 @@ public class ProductBrandController {
// 排序后返回给前端 // 排序后返回给前端
return success(ProductBrandConvert.INSTANCE.convertList1(list)); return success(ProductBrandConvert.INSTANCE.convertList1(list));
} }
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得品牌分页") @Operation(summary = "获得品牌分页")
@PreAuthorize("@ss.hasPermission('product:brand:query')") @PreAuthorize("@ss.hasPermission('product:brand:query')")

View File

@ -12,7 +12,7 @@ import javax.validation.constraints.NotNull;
@Data @Data
public class ProductBrandBaseVO { public class ProductBrandBaseVO {
@Schema(description = "品牌名称", required = true, example = "芋道") @Schema(description = "品牌名称", required = true, example = "苹果")
@NotNull(message = "品牌名称不能为空") @NotNull(message = "品牌名称不能为空")
private String name; private String name;

View File

@ -7,7 +7,7 @@ import lombok.Data;
@Data @Data
public class ProductBrandListReqVO { public class ProductBrandListReqVO {
@Schema(description = "品牌名称", example = "芋道") @Schema(description = "品牌名称", example = "苹果")
private String name; private String name;
} }

View File

@ -17,7 +17,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true) @ToString(callSuper = true)
public class ProductBrandPageReqVO extends PageParam { public class ProductBrandPageReqVO extends PageParam {
@Schema(description = "品牌名称", example = "芋道") @Schema(description = "品牌名称", example = "苹果")
private String name; private String name;
@Schema(description = "状态", example = "0") @Schema(description = "状态", example = "0")

View File

@ -11,8 +11,11 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class ProductBrandSimpleRespVO { public class ProductBrandSimpleRespVO {
@Schema(description = "品牌编号", required = true, example = "1024") @Schema(description = "品牌编号", required = true, example = "1024")
private Long id; private Long id;
@Schema(description = "品牌名称", required = true, example = "芋道")
@Schema(description = "品牌名称", required = true, example = "苹果")
private String name; private String name;
} }

View File

@ -12,6 +12,8 @@ import javax.validation.constraints.NotBlank;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class ProductCategoryCreateReqVO extends ProductCategoryBaseVO { public class ProductCategoryCreateReqVO extends ProductCategoryBaseVO {
@Schema(description = "分类描述")
@Schema(description = "分类描述", example = "描述")
private String description; private String description;
} }

View File

@ -17,7 +17,8 @@ public class ProductCategoryUpdateReqVO extends ProductCategoryBaseVO {
@Schema(description = "分类编号", required = true, example = "2") @Schema(description = "分类编号", required = true, example = "2")
@NotNull(message = "分类编号不能为空") @NotNull(message = "分类编号不能为空")
private Long id; private Long id;
@Schema(description = "分类描述")
@Schema(description = "分类描述", example = "描述")
private String description; private String description;
} }

View File

@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List;
/** /**
* 商品 SKU Base VO提供给添加修改详细的子 VO 使用 * 商品 SKU Base VO提供给添加修改详细的子 VO 使用
@ -15,72 +16,67 @@ import javax.validation.constraints.NotNull;
@Data @Data
public class ProductSkuBaseVO { public class ProductSkuBaseVO {
@Schema(description = "商品 SKU 名字", required = true, example = "芋道") @Schema(description = "商品 SKU 名字", required = true, example = "清凉小短袖")
@NotEmpty(message = "商品 SKU 名字不能为空") @NotEmpty(message = "商品 SKU 名字不能为空")
private String name; private String name;
@Schema(description = "销售价格,单位:分", required = true, example = "1024") @Schema(description = "销售价格,单位:分", required = true, example = "1999")
@NotNull(message = "销售价格,单位:分不能为空") @NotNull(message = "销售价格,单位:分不能为空")
private Integer price; private Integer price;
@Schema(description = "市场价", example = "1024") @Schema(description = "市场价", example = "2999")
private Integer marketPrice; private Integer marketPrice;
@Schema(description = "成本价", example = "1024") @Schema(description = "成本价", example = "19")
private Integer costPrice; private Integer costPrice;
@Schema(description = "条形码", example = "haha") @Schema(description = "条形码", example = "15156165456")
private String barCode; private String barCode;
@Schema(description = "图片地址", required = true, example = "https://www.iocoder.cn/xx.png") @Schema(description = "图片地址", required = true, example = "https://www.iocoder.cn/xx.png")
@NotNull(message = "图片地址不能为空") @NotNull(message = "图片地址不能为空")
private String picUrl; private String picUrl;
@Schema(description = "库存", required = true, example = "1") @Schema(description = "库存", required = true, example = "200")
@NotNull(message = "库存不能为空") @NotNull(message = "库存不能为空")
private Integer stock; private Integer stock;
@Schema(description = "预警预存", example = "1") @Schema(description = "预警预存", example = "10")
private Integer warnStock; private Integer warnStock;
@Schema(description = "商品重量,单位kg 千克", example = "1") @Schema(description = "商品重量,单位kg 千克", example = "1.2")
private Double weight; private Double weight;
@Schema(description = "商品体积,单位m^3 平米", example = "1024") @Schema(description = "商品体积,单位m^3 平米", example = "2.5")
private Double volume; private Double volume;
@Schema(description = "一级分销的佣金,单位:分", example = "1024") @Schema(description = "一级分销的佣金,单位:分", example = "199")
private Integer subCommissionFirstPrice; private Integer subCommissionFirstPrice;
@Schema(description = "二级分销的佣金,单位:分", example = "1024") @Schema(description = "二级分销的佣金,单位:分", example = "19")
private Integer subCommissionSecondPrice; private Integer subCommissionSecondPrice;
// TODO @puhui999这里要写 swagger 注解哈 @Schema(description = "属性数组")
/** private List<Property> properties;
* 商品属性
*/ @Schema(description = "商品属性")
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public static class Property { public static class Property {
/** @Schema(description = "属性编号", example = "10")
* 属性编号
*/
private Long propertyId; private Long propertyId;
/**
* 属性名字 @Schema(description = "属性名字", example = "颜色")
*/
private String propertyName; private String propertyName;
/** @Schema(description = "属性值编号", example = "10")
* 属性值编号
*/
private Long valueId; private Long valueId;
/**
* 属性值名字 @Schema(description = "属性值名字", example = "红色")
*/
private String valueName; private String valueName;
} }
} }

View File

@ -13,10 +13,4 @@ import java.util.List;
@ToString(callSuper = true) @ToString(callSuper = true)
public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO { public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO {
// TODO @puhui999是不是可以抽到父类里
/**
* 属性数组
*/
private List<Property> properties;
} }

View File

@ -15,9 +15,4 @@ public class ProductSkuRespVO extends ProductSkuBaseVO {
@Schema(description = "主键", required = true, example = "1024") @Schema(description = "主键", required = true, example = "1024")
private Long id; private Long id;
/**
* 属性数组
*/
private List<Property> properties;
} }

View File

@ -94,11 +94,10 @@ public class ProductSpuController {
return success(ProductSpuConvert.INSTANCE.convertPage(productSpuService.getSpuPage(pageVO))); return success(ProductSpuConvert.INSTANCE.convertPage(productSpuService.getSpuPage(pageVO)));
} }
// TODO @puhui999方法名改成 getSpuCount只是用于 tab 这样更抽象一点
@GetMapping("/get-count") @GetMapping("/get-count")
@Operation(summary = "获得商品 SPU 分页 tab count") @Operation(summary = "获得商品 SPU 分页 tab count")
@PreAuthorize("@ss.hasPermission('product:spu:query')") @PreAuthorize("@ss.hasPermission('product:spu:query')")
public CommonResult<Map<Integer, Long>> getTabsCount() { public CommonResult<Map<Integer, Long>> getSpuCount() {
return success(productSpuService.getTabsCount()); return success(productSpuService.getTabsCount());
} }

View File

@ -16,19 +16,19 @@ import java.util.List;
@Data @Data
public class ProductSpuBaseVO { public class ProductSpuBaseVO {
@Schema(description = "商品名称", required = true, example = "芋道") @Schema(description = "商品名称", required = true, example = "清凉小短袖")
@NotEmpty(message = "商品名称不能为空") @NotEmpty(message = "商品名称不能为空")
private String name; private String name;
@Schema(description = "关键字", required = true, example = "芋道") @Schema(description = "关键字", required = true, example = "清凉丝滑不出汗")
@NotEmpty(message = "商品关键字不能为空") @NotEmpty(message = "商品关键字不能为空")
private String keyword; private String keyword;
@Schema(description = "商品简介", required = true, example = "芋道") @Schema(description = "商品简介", required = true, example = "清凉小短袖简介")
@NotEmpty(message = "商品简介不能为空") @NotEmpty(message = "商品简介不能为空")
private String introduction; private String introduction;
@Schema(description = "商品详情", required = true, example = "芋道") @Schema(description = "商品详情", required = true, example = "清凉小短袖详情")
@NotEmpty(message = "商品详情不能为空") @NotEmpty(message = "商品详情不能为空")
private String description; private String description;
@ -40,14 +40,14 @@ public class ProductSpuBaseVO {
@NotNull(message = "商品品牌不能为空") @NotNull(message = "商品品牌不能为空")
private Long brandId; private Long brandId;
@Schema(description = "商品封面图", required = true, example = "芋道") @Schema(description = "商品封面图", required = true, example = "https://www.iocoder.cn/xx.png")
@NotEmpty(message = "商品封面图不能为空") @NotEmpty(message = "商品封面图不能为空")
private String picUrl; 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<String> sliderPicUrls; private List<String> sliderPicUrls;
@Schema(description = "商品视频") @Schema(description = "商品视频", example = "https://www.iocoder.cn/xx.mp4")
private String videoUrl; private String videoUrl;
@Schema(description = "单位", required = true, example = "1") @Schema(description = "单位", required = true, example = "1")

View File

@ -20,18 +20,16 @@ import java.util.List;
@ToString(callSuper = true) @ToString(callSuper = true)
public class ProductSpuDetailRespVO extends ProductSpuBaseVO { public class ProductSpuDetailRespVO extends ProductSpuBaseVO {
// TODO @puhui999swagger required example 写下 @Schema(description = "商品 SPU 编号", required = true, example = "1212")
@Schema(description = "商品 SPU 编号")
private Long id; private Long id;
@Schema(description = "商品销量") @Schema(description = "商品销量", required = true, example = "10000")
private Integer salesCount; private Integer salesCount;
@Schema(description = "浏览量") @Schema(description = "浏览量", required = true, example = "20000")
private Integer browseCount; private Integer browseCount;
@Schema(description = "商品状态") @Schema(description = "商品状态", required = true, example = "1")
private Integer status; private Integer status;
// ========== SKU 相关字段 ========= // ========== SKU 相关字段 =========

View File

@ -16,6 +16,7 @@ import java.time.LocalDateTime;
*/ */
@Data @Data
public class ProductSpuExcelVO { public class ProductSpuExcelVO {
@ExcelProperty("商品编号") @ExcelProperty("商品编号")
private Long id; private Long id;
@ -116,4 +117,5 @@ public class ProductSpuExcelVO {
@ExcelProperty("创建时间") @ExcelProperty("创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;
} }

View File

@ -18,14 +18,14 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@AllArgsConstructor @AllArgsConstructor
public class ProductSpuExportReqVO { public class ProductSpuExportReqVO {
@Schema(description = "商品名称", example = "yutou") @Schema(description = "商品名称", example = "清凉小短袖")
private String name; private String name;
@Schema(description = "前端请求的tab类型", example = "1") @Schema(description = "前端请求的tab类型", example = "1")
@InEnum(ProductSpuPageTabEnum.class) @InEnum(ProductSpuPageTabEnum.class)
private Integer tabType; private Integer tabType;
@Schema(description = "商品分类编号") @Schema(description = "商品分类编号", example = "100")
private Long categoryId; 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]")

View File

@ -25,14 +25,14 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true) @ToString(callSuper = true)
public class ProductSpuPageReqVO extends PageParam { public class ProductSpuPageReqVO extends PageParam {
@Schema(description = "商品名称", example = "yutou") @Schema(description = "商品名称", example = "清凉小短袖")
private String name; private String name;
@Schema(description = "前端请求的tab类型", example = "1") @Schema(description = "前端请求的tab类型", required = true, example = "1")
@InEnum(ProductSpuPageTabEnum.class) @InEnum(ProductSpuPageTabEnum.class)
private Integer tabType; private Integer tabType;
@Schema(description = "商品分类编号") @Schema(description = "商品分类编号", example = "1")
private Long categoryId; 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]")

View File

@ -18,30 +18,28 @@ import java.time.LocalDateTime;
@ToString(callSuper = true) @ToString(callSuper = true)
public class ProductSpuRespVO extends ProductSpuBaseVO { public class ProductSpuRespVO extends ProductSpuBaseVO {
// TODO @puhui999swagger required example 写下 @Schema(description = "spuId", required = true, example = "111")
@Schema(description = "spuId")
private Long id; private Long id;
@Schema(description = "商品价格") @Schema(description = "商品价格", required = true, example = "1999")
private Integer price; private Integer price;
@Schema(description = "商品销量") @Schema(description = "商品销量", required = true, example = "2000")
private Integer salesCount; private Integer salesCount;
@Schema(description = "市场价,单位使用:分") @Schema(description = "市场价,单位使用:分", required = true, example = "199")
private Integer marketPrice; private Integer marketPrice;
@Schema(description = "成本价,单位使用:分") @Schema(description = "成本价,单位使用:分", required = true, example = "19")
private Integer costPrice; private Integer costPrice;
@Schema(description = "商品库存") @Schema(description = "商品库存", required = true, example = "10000")
private Integer stock; private Integer stock;
@Schema(description = "商品创建时间") @Schema(description = "商品创建时间", required = true, example = "2023-05-24 00:00:00")
private LocalDateTime createTime; private LocalDateTime createTime;
@Schema(description = "商品状态") @Schema(description = "商品状态", required = true, example = "1")
private Integer status; private Integer status;
} }

View File

@ -14,35 +14,33 @@ import lombok.ToString;
@ToString(callSuper = true) @ToString(callSuper = true)
public class ProductSpuSimpleRespVO { public class ProductSpuSimpleRespVO {
// TODO @puhui999swagger required example 写下 @Schema(description = "主键", required = true, example = "213")
@Schema(description = "主键")
private Long id; private Long id;
@Schema(description = "商品名称") @Schema(description = "商品名称", required = true, example = "清凉小短袖")
private String name; private String name;
@Schema(description = "商品价格,单位使用:分") @Schema(description = "商品价格,单位使用:分", required = true, example = "1999")
private Integer price; private Integer price;
@Schema(description = "商品市场价,单位使用:分") @Schema(description = "商品市场价,单位使用:分", required = true, example = "199")
private Integer marketPrice; private Integer marketPrice;
@Schema(description = "商品成本价,单位使用:分") @Schema(description = "商品成本价,单位使用:分", required = true, example = "19")
private Integer costPrice; private Integer costPrice;
@Schema(description = "商品库存") @Schema(description = "商品库存", required = true, example = "2000")
private Integer stock; private Integer stock;
// ========== 统计相关字段 ========= // ========== 统计相关字段 =========
@Schema(description = "商品销量") @Schema(description = "商品销量", required = true, example = "200")
private Integer salesCount; private Integer salesCount;
@Schema(description = "商品虚拟销量") @Schema(description = "商品虚拟销量", required = true, example = "20000")
private Integer virtualSalesCount; private Integer virtualSalesCount;
@Schema(description = "商品浏览量") @Schema(description = "商品浏览量", required = true, example = "2000")
private Integer browseCount; private Integer browseCount;
} }

View File

@ -23,19 +23,17 @@ import java.util.List;
@ToString(callSuper = true) @ToString(callSuper = true)
public class ProductSpuUpdateReqVO extends ProductSpuBaseVO { public class ProductSpuUpdateReqVO extends ProductSpuBaseVO {
// TODO @puhui999swagger required example 写下
@Schema(description = "商品编号", required = true, example = "1") @Schema(description = "商品编号", required = true, example = "1")
@NotNull(message = "商品编号不能为空") @NotNull(message = "商品编号不能为空")
private Long id; private Long id;
@Schema(description = "商品销量") @Schema(description = "商品销量", required = true, example = "1999")
private Integer salesCount; private Integer salesCount;
@Schema(description = "浏览量") @Schema(description = "浏览量", required = true, example = "1999")
private Integer browseCount; private Integer browseCount;
@Schema(description = "商品状态") @Schema(description = "商品状态", required = true, example = "1")
@InEnum(ProductSpuStatusEnum.class) @InEnum(ProductSpuStatusEnum.class)
private Integer status; private Integer status;

View File

@ -67,8 +67,7 @@ public class AppProductSpuController {
} }
// 查询商品 SKU // 查询商品 SKU
List<ProductSkuDO> skus = productSkuService.getSkuListBySpuIdAndStatus(spu.getId(), List<ProductSkuDO> skus = productSkuService.getSkuListBySpuIdAndStatus(spu.getId());
CommonStatusEnum.ENABLE.getStatus());
// 查询商品属性 // 查询商品属性
List<ProductPropertyValueDetailRespBO> propertyValues = productPropertyValueService List<ProductPropertyValueDetailRespBO> propertyValues = productPropertyValueService
.getPropertyValueDetailList(ProductSkuConvert.INSTANCE.convertPropertyValueIds(skus)); .getPropertyValueDetailList(ProductSkuConvert.INSTANCE.convertPropertyValueIds(skus));

View File

@ -43,8 +43,6 @@ public interface ProductSkuConvert {
ProductSkuRespDTO convert02(ProductSkuDO bean); ProductSkuRespDTO convert02(ProductSkuDO bean);
List<ProductSkuRespVO> convertList03(List<ProductSkuDO> list);
List<ProductSkuRespDTO> convertList04(List<ProductSkuDO> list); List<ProductSkuRespDTO> convertList04(List<ProductSkuDO> list);
List<ProductSkuOptionRespVO> convertList05(List<ProductSkuDO> skus); List<ProductSkuOptionRespVO> convertList05(List<ProductSkuDO> skus);

View File

@ -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.dal.dataobject.spu.ProductSpuDO;
import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import java.util.ArrayList; import java.util.ArrayList;
@ -52,55 +54,38 @@ public interface ProductSpuConvert {
List<ProductSpuSimpleRespVO> convertList02(List<ProductSpuDO> list); List<ProductSpuSimpleRespVO> convertList02(List<ProductSpuDO> list);
// TODO @puhui999部分属性可以通过 mapstruct @Mapping(source = , target = , ) 映射转换可以查下文档 /**
* 列表转字符串
*
* @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<ProductSpuExcelVO> convertList03(List<ProductSpuDO> list) { default List<ProductSpuExcelVO> convertList03(List<ProductSpuDO> list) {
ArrayList<ProductSpuExcelVO> spuExcelVOs = new ArrayList<>(); List<ProductSpuExcelVO> spuExcelVOs = new ArrayList<>();
list.forEach((spu)->{ list.forEach(spu -> {
ProductSpuExcelVO spuExcelVO = new ProductSpuExcelVO(); ProductSpuExcelVO spuExcelVO = convert(spu);
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());
spuExcelVOs.add(spuExcelVO); spuExcelVOs.add(spuExcelVO);
}); });
return spuExcelVOs; return spuExcelVOs;
} }
ProductSpuDetailRespVO convert03(ProductSpuDO spu); ProductSpuDetailRespVO convert03(ProductSpuDO spu);
// TODO @puhui999下面两个没用到是不是删除呀
List<ProductSkuRespVO> convertList04(List<ProductSkuDO> skus);
ProductPropertyValueDetailRespVO convert04(ProductPropertyValueDetailRespBO propertyValue);
// ========== 用户 App 相关 ========== // ========== 用户 App 相关 ==========
default PageResult<AppProductSpuPageItemRespVO> convertPageForGetSpuPage(PageResult<ProductSpuDO> page) { default PageResult<AppProductSpuPageItemRespVO> convertPageForGetSpuPage(PageResult<ProductSpuDO> page) {
@ -144,26 +129,15 @@ public interface ProductSpuConvert {
AppProductPropertyValueDetailRespVO convertForGetSpuDetail(ProductPropertyValueDetailRespBO propertyValue); AppProductPropertyValueDetailRespVO convertForGetSpuDetail(ProductPropertyValueDetailRespBO propertyValue);
default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List<ProductSkuDO> skus, default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List<ProductSkuDO> skus) {
Function<Set<Long>, List<ProductPropertyValueDetailRespBO>> func) {
ProductSpuDetailRespVO productSpuDetailRespVO = convert03(spu); ProductSpuDetailRespVO productSpuDetailRespVO = convert03(spu);
// TODO @puhui999if return 减少嵌套层数 // skus 为空直接返回
if (CollUtil.isNotEmpty(skus)) { if (CollUtil.isEmpty(skus)) {
return productSpuDetailRespVO;
}
List<ProductSkuRespVO> skuVOs = ProductSkuConvert.INSTANCE.convertList(skus); List<ProductSkuRespVO> skuVOs = ProductSkuConvert.INSTANCE.convertList(skus);
// fix:统一模型即使是单规格也查询下如若 Properties 为空报错则为单属性不做处理 // fix: 因为现在已改为 sku 属性列表 属性 已包含 属性名字 属性值名字 所以不需要再额外处理属性更新时更新 sku 中的属性相关冗余即可
try {
// 获取所有的属性值 id
Set<Long> valueIds = skus.stream().flatMap(p -> p.getProperties().stream())
.map(ProductSkuDO.Property::getValueId)
.collect(Collectors.toSet());
List<ProductPropertyValueDetailRespBO> valueDetailList = func.apply(valueIds);
Map<Long, String> 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); productSpuDetailRespVO.setSkus(skuVOs);
}
return productSpuDetailRespVO; return productSpuDetailRespVO;
} }

View File

@ -31,7 +31,6 @@ public interface ProductBrandMapper extends BaseMapperX<ProductBrandDO> {
return selectOne(ProductBrandDO::getName, name); return selectOne(ProductBrandDO::getName, name);
} }
// TODO @puhui999) { 中间要有空格哈
default List<ProductBrandDO> selectListByStatus(Integer status) { default List<ProductBrandDO> selectListByStatus(Integer status) {
return selectList(ProductBrandDO::getStatus, status); return selectList(ProductBrandDO::getStatus, status);
} }

View File

@ -23,11 +23,9 @@ public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
return selectList(ProductSkuDO::getSpuId, spuId); return selectList(ProductSkuDO::getSpuId, spuId);
} }
default List<ProductSkuDO> selectListBySpuIdAndStatus(Long spuId, default List<ProductSkuDO> selectListBySpuIdAndStatus(Long spuId) {
Integer status) {
return selectList(new LambdaQueryWrapperX<ProductSkuDO>() return selectList(new LambdaQueryWrapperX<ProductSkuDO>()
.eq(ProductSkuDO::getSpuId, spuId)// eqIfPresent(ProductSkuDO::getStatus, status) TODO ProductSkuDO已经没有status属性 .eq(ProductSkuDO::getSpuId, spuId));
);
} }
default List<ProductSkuDO> selectListBySpuId(Collection<Long> spuIds) { default List<ProductSkuDO> selectListBySpuId(Collection<Long> spuIds) {

View File

@ -35,21 +35,21 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
.eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()) .eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId())
.betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ProductSpuDO::getSort); .orderByDesc(ProductSpuDO::getSort);
validateTabType(tabType, queryWrapper); appendTabQuery(tabType, queryWrapper);
return selectPage(reqVO, queryWrapper); return selectPage(reqVO, queryWrapper);
} }
/** /**
* 获取库存小于 value 且状态不等于 status 的的个数 * 查询触发警戒库存的 SPU 数量
* *
* @return 个数 * @return 触发警戒库存的 SPU 数量
*/ */
default Long selectCountByStockAndStatus() { default Long selectCount() {
LambdaQueryWrapperX<ProductSpuDO> queryWrapper = new LambdaQueryWrapperX<>(); LambdaQueryWrapperX<ProductSpuDO> queryWrapper = new LambdaQueryWrapperX<>();
// 库存小于等于警戒库存
queryWrapper.le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK) queryWrapper.le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK)
// TODO @puhui999IN 另外两个状态会不会好点哈尽量不用 !=
// 如果库存触发警戒库存且状态为回收站的话则不计入触发警戒库存的个数 // 如果库存触发警戒库存且状态为回收站的话则不计入触发警戒库存的个数
.and(q -> q.ne(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus())); .notIn(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus());
return selectCount(queryWrapper); return selectCount(queryWrapper);
} }
@ -107,37 +107,37 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
queryWrapper.eqIfPresent(ProductSpuDO::getName, reqVO.getName()); queryWrapper.eqIfPresent(ProductSpuDO::getName, reqVO.getName());
queryWrapper.eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()); queryWrapper.eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId());
queryWrapper.betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime()); queryWrapper.betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime());
validateTabType(tabType, queryWrapper); appendTabQuery(tabType, queryWrapper);
return selectList(queryWrapper); return selectList(queryWrapper);
} }
// TODO @puhui999应该不太适合 validate 验证应该是补充条件例如说 appendTabQuery
/** /**
* 验证选项卡类型构建条件 * 验证选项卡类型构建条件
* *
* @param tabType 标签类型 * @param tabType 标签类型
* @param queryWrapper 查询条件 * @param queryWrapper 查询条件
*/ */
static void validateTabType(Integer tabType, LambdaQueryWrapperX<ProductSpuDO> queryWrapper) { static void appendTabQuery(Integer tabType, LambdaQueryWrapperX<ProductSpuDO> queryWrapper) {
// 出售中商品 TODO puhui999这样好点 // 出售中商品
if (ObjectUtil.equals(ProductSpuPageTabEnum.FOR_SALE.getType(), tabType)) { if (ObjectUtil.equals(ProductSpuPageTabEnum.FOR_SALE.getType(), tabType)) {
queryWrapper.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()); queryWrapper.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus());
} }
if (ObjectUtil.equals(ProductSpuPageTabEnum.IN_WAREHOUSE.getType(), tabType)) {
// 仓储中商品 // 仓储中商品
if (ObjectUtil.equals(ProductSpuPageTabEnum.IN_WAREHOUSE.getType(), tabType)) {
queryWrapper.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus()); queryWrapper.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus());
} }
if (ObjectUtil.equals(ProductSpuPageTabEnum.SOLD_OUT.getType(), tabType)) {
// 已售空商品 // 已售空商品
if (ObjectUtil.equals(ProductSpuPageTabEnum.SOLD_OUT.getType(), tabType)) {
queryWrapper.eqIfPresent(ProductSpuDO::getStock, 0); queryWrapper.eqIfPresent(ProductSpuDO::getStock, 0);
} }
// 警戒库存
if (ObjectUtil.equals(ProductSpuPageTabEnum.ALERT_STOCK.getType(), tabType)) { if (ObjectUtil.equals(ProductSpuPageTabEnum.ALERT_STOCK.getType(), tabType)) {
queryWrapper.le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK) 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)) {
// 回收站 // 回收站
if (ObjectUtil.equals(ProductSpuPageTabEnum.RECYCLE_BIN.getType(), tabType)) {
queryWrapper.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()); queryWrapper.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus());
} }
} }

View File

@ -88,14 +88,10 @@ public interface ProductSkuService {
/** /**
* 基于 SPU 编号和状态获得商品 SKU 集合 * 基于 SPU 编号和状态获得商品 SKU 集合
* *
* TODO @puhui999SKU中已经不存在status属性芋艿那就去掉 status
*
* @param spuId SPU 编号 * @param spuId SPU 编号
* @param status 状态
* @return 商品 SKU 集合 * @return 商品 SKU 集合
*/ */
List<ProductSkuDO> getSkuListBySpuIdAndStatus(Long spuId, List<ProductSkuDO> getSkuListBySpuIdAndStatus(Long spuId);
@Nullable Integer status);
/** /**
* 获得 spu 对应的 SKU 集合 * 获得 spu 对应的 SKU 集合

View File

@ -3,14 +3,12 @@ package cn.iocoder.yudao.module.product.service.sku;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; 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.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO;
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; 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.ProductPropertyDO;
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; 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.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; 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.ProductPropertyService;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
@ -140,8 +138,8 @@ public class ProductSkuServiceImpl implements ProductSkuService {
} }
@Override @Override
public List<ProductSkuDO> getSkuListBySpuIdAndStatus(Long spuId, Integer status) { public List<ProductSkuDO> getSkuListBySpuIdAndStatus(Long spuId) {
return productSkuMapper.selectListBySpuIdAndStatus(spuId, status); return productSkuMapper.selectListBySpuIdAndStatus(spuId);
} }
@Override @Override

View File

@ -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.enums.spu.ProductSpuStatusEnum;
import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; 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.category.ProductCategoryService;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -51,8 +50,6 @@ public class ProductSpuServiceImpl implements ProductSpuService {
private ProductBrandService brandService; private ProductBrandService brandService;
@Resource @Resource
private ProductCategoryService categoryService; private ProductCategoryService categoryService;
@Resource
private ProductPropertyValueService productPropertyValueService;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -63,10 +60,10 @@ public class ProductSpuServiceImpl implements ProductSpuService {
// 校验 SKU // 校验 SKU
List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = createReqVO.getSkus(); List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = createReqVO.getSkus();
productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType()); productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType());
ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO);
// 初始化 SPU SKU 相关属性 // 初始化 SPU SKU 相关属性
initSpuFromSkus(spu, skuSaveReqList); initSpuFromSkus(spu, skuSaveReqList);
// 插入 SPU // 插入 SPU
productSpuMapper.insert(spu); productSpuMapper.insert(spu);
// 插入 SKU // 插入 SKU
@ -86,7 +83,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
// 校验SKU // 校验SKU
List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = updateReqVO.getSkus(); List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = updateReqVO.getSkus();
productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType()); productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType());
// TODO @puhui999可以校验逻辑和更新逻辑中间有个空行这样会发现 这里到了关键逻辑啦更有层次感
// 更新 SPU // 更新 SPU
ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO); ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO);
initSpuFromSkus(updateObj, skuSaveReqList); initSpuFromSkus(updateObj, skuSaveReqList);
@ -103,20 +100,14 @@ public class ProductSpuServiceImpl implements ProductSpuService {
* @param skus 商品 SKU 数组 * @param skus 商品 SKU 数组
*/ */
private void initSpuFromSkus(ProductSpuDO spu, List<ProductSkuCreateOrUpdateReqVO> skus) { private void initSpuFromSkus(ProductSpuDO spu, List<ProductSkuCreateOrUpdateReqVO> skus) {
// 断言避免告警
assert skus.size() > 0;
// 获取 sku 单价最低的商品
// TODO @puhui999vo 改成 sku 会更好vo dto 只是我们用来区分的如果能区分的情况下用更明确的名字会更好
// CollectionUtils.getMinValue(); TODO @puhui999可以用这个方法常见的 stream 操作封装成方法让逻辑更简洁
ProductSkuCreateOrUpdateReqVO vo = skus.stream().min(Comparator.comparing(ProductSkuCreateOrUpdateReqVO::getPrice)).get();
// sku 单价最低的商品的价格 // sku 单价最低的商品的价格
spu.setPrice(vo.getPrice()); spu.setPrice(CollectionUtils.getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getPrice));
// sku 单价最低的商品的市场价格 // sku 单价最低的商品的市场价格
spu.setMarketPrice(vo.getMarketPrice()); spu.setMarketPrice(CollectionUtils.getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getMarketPrice));
// sku单价最低的商品的成本价格 // sku单价最低的商品的成本价格
spu.setCostPrice(vo.getCostPrice()); spu.setCostPrice(CollectionUtils.getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getCostPrice));
// sku单价最低的商品的条形码 // sku单价最低的商品的条形码
spu.setBarCode(vo.getBarCode()); spu.setBarCode(CollectionUtils.getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getBarCode));
// skus 库存总数 // skus 库存总数
spu.setStock(getSumValue(skus, ProductSkuCreateOrUpdateReqVO::getStock, Integer::sum)); spu.setStock(getSumValue(skus, ProductSkuCreateOrUpdateReqVO::getStock, Integer::sum));
// 若是 spu 已有状态则不处理 // 若是 spu 已有状态则不处理
@ -150,6 +141,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
validateSpuExists(id); validateSpuExists(id);
// 校验商品状态不是回收站不能删除 // 校验商品状态不是回收站不能删除
validateSpuStatus(id); validateSpuStatus(id);
// 删除 SPU // 删除 SPU
productSpuMapper.deleteById(id); productSpuMapper.deleteById(id);
// 删除关联的 SKU // 删除关联的 SKU
@ -229,8 +221,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
} }
// 查询商品 SKU // 查询商品 SKU
List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId()); List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId());
// TODO @puhui999感觉还是查询好 productPropertyValueService然后 propertyId 可以交给 convert 处理下即可 return ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus);
return ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus, productPropertyValueService::getPropertyValueDetailList);
} }
@Override @Override
@ -238,10 +229,10 @@ public class ProductSpuServiceImpl implements ProductSpuService {
public void updateStatus(ProductSpuUpdateStatusReqVO updateReqVO) { public void updateStatus(ProductSpuUpdateStatusReqVO updateReqVO) {
// 校验存在 // 校验存在
validateSpuExists(updateReqVO.getId()); validateSpuExists(updateReqVO.getId());
// 更新状态 // 更新状态
ProductSpuDO productSpuDO = productSpuMapper.selectById(updateReqVO.getId()).setStatus(updateReqVO.getStatus()); ProductSpuDO productSpuDO = productSpuMapper.selectById(updateReqVO.getId()).setStatus(updateReqVO.getStatus());
productSpuMapper.updateById(productSpuDO); productSpuMapper.updateById(productSpuDO);
} }
@Override @Override
@ -254,7 +245,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
// 查询售空的商品数量 // 查询售空的商品数量
counts.put(ProductSpuPageTabEnum.SOLD_OUT.getType(), productSpuMapper.selectCount(ProductSpuDO::getStock, 0)); 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())); counts.put(ProductSpuPageTabEnum.RECYCLE_BIN.getType(), productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()));
return counts; return counts;