mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 07:11:52 +08:00
fix:修复商品 review 提到的问题
This commit is contained in:
parent
c62da6a056
commit
b065a2a741
@ -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;
|
||||
}
|
||||
}
|
@ -61,7 +61,8 @@ public class ProductBrandController {
|
||||
public CommonResult<ProductBrandRespVO> 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<List<ProductBrandSimpleRespVO>> getSimpleUserList() {
|
||||
@ -70,6 +71,7 @@ public class ProductBrandController {
|
||||
// 排序后,返回给前端
|
||||
return success(ProductBrandConvert.INSTANCE.convertList1(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得品牌分页")
|
||||
@PreAuthorize("@ss.hasPermission('product:brand:query')")
|
||||
|
@ -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;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import lombok.Data;
|
||||
@Data
|
||||
public class ProductBrandListReqVO {
|
||||
|
||||
@Schema(description = "品牌名称", example = "芋道")
|
||||
@Schema(description = "品牌名称", example = "苹果")
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
@ -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")
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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<Property> 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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,10 +13,4 @@ import java.util.List;
|
||||
@ToString(callSuper = true)
|
||||
public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO {
|
||||
|
||||
// TODO @puhui999:是不是可以抽到父类里?
|
||||
/**
|
||||
* 属性数组
|
||||
*/
|
||||
private List<Property> properties;
|
||||
|
||||
}
|
||||
|
@ -15,9 +15,4 @@ public class ProductSkuRespVO extends ProductSkuBaseVO {
|
||||
@Schema(description = "主键", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 属性数组
|
||||
*/
|
||||
private List<Property> properties;
|
||||
|
||||
}
|
||||
|
@ -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<Map<Integer, Long>> getTabsCount() {
|
||||
public CommonResult<Map<Integer, Long>> getSpuCount() {
|
||||
return success(productSpuService.getTabsCount());
|
||||
}
|
||||
|
||||
|
@ -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<String> sliderPicUrls;
|
||||
|
||||
@Schema(description = "商品视频")
|
||||
@Schema(description = "商品视频", example = "https://www.iocoder.cn/xx.mp4")
|
||||
private String videoUrl;
|
||||
|
||||
@Schema(description = "单位", required = true, example = "1")
|
||||
|
@ -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 相关字段 =========
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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]")
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -67,8 +67,7 @@ public class AppProductSpuController {
|
||||
}
|
||||
|
||||
// 查询商品 SKU
|
||||
List<ProductSkuDO> skus = productSkuService.getSkuListBySpuIdAndStatus(spu.getId(),
|
||||
CommonStatusEnum.ENABLE.getStatus());
|
||||
List<ProductSkuDO> skus = productSkuService.getSkuListBySpuIdAndStatus(spu.getId());
|
||||
// 查询商品属性
|
||||
List<ProductPropertyValueDetailRespBO> propertyValues = productPropertyValueService
|
||||
.getPropertyValueDetailList(ProductSkuConvert.INSTANCE.convertPropertyValueIds(skus));
|
||||
|
@ -43,8 +43,6 @@ public interface ProductSkuConvert {
|
||||
|
||||
ProductSkuRespDTO convert02(ProductSkuDO bean);
|
||||
|
||||
List<ProductSkuRespVO> convertList03(List<ProductSkuDO> list);
|
||||
|
||||
List<ProductSkuRespDTO> convertList04(List<ProductSkuDO> list);
|
||||
|
||||
List<ProductSkuOptionRespVO> convertList05(List<ProductSkuDO> skus);
|
||||
|
@ -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<ProductSpuSimpleRespVO> convertList02(List<ProductSpuDO> list);
|
||||
|
||||
// TODO @puhui999:部分属性,可以通过 mapstruct 的 @Mapping(source = , target = , ) 映射转换,可以查下文档
|
||||
default List<ProductSpuExcelVO> convertList03(List<ProductSpuDO> list){
|
||||
ArrayList<ProductSpuExcelVO> 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<ProductSpuExcelVO> convertList03(List<ProductSpuDO> list) {
|
||||
List<ProductSpuExcelVO> spuExcelVOs = new ArrayList<>();
|
||||
list.forEach(spu -> {
|
||||
ProductSpuExcelVO spuExcelVO = convert(spu);
|
||||
spuExcelVOs.add(spuExcelVO);
|
||||
});
|
||||
return spuExcelVOs;
|
||||
}
|
||||
|
||||
ProductSpuDetailRespVO convert03(ProductSpuDO spu);
|
||||
|
||||
// TODO @puhui999:下面两个没用到,是不是删除呀?
|
||||
List<ProductSkuRespVO> convertList04(List<ProductSkuDO> skus);
|
||||
|
||||
ProductPropertyValueDetailRespVO convert04(ProductPropertyValueDetailRespBO propertyValue);
|
||||
|
||||
// ========== 用户 App 相关 ==========
|
||||
|
||||
default PageResult<AppProductSpuPageItemRespVO> convertPageForGetSpuPage(PageResult<ProductSpuDO> page) {
|
||||
@ -144,26 +129,15 @@ public interface ProductSpuConvert {
|
||||
|
||||
AppProductPropertyValueDetailRespVO convertForGetSpuDetail(ProductPropertyValueDetailRespBO propertyValue);
|
||||
|
||||
default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List<ProductSkuDO> skus,
|
||||
Function<Set<Long>, List<ProductPropertyValueDetailRespBO>> func) {
|
||||
default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List<ProductSkuDO> skus) {
|
||||
ProductSpuDetailRespVO productSpuDetailRespVO = convert03(spu);
|
||||
// TODO @puhui999:if return 哈,减少嵌套层数。
|
||||
if (CollUtil.isNotEmpty(skus)) {
|
||||
List<ProductSkuRespVO> skuVOs = ProductSkuConvert.INSTANCE.convertList(skus);
|
||||
// fix:统一模型,即使是单规格,也查询下,如若 Properties 为空报错则为单属性不做处理
|
||||
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);
|
||||
// skus 为空直接返回
|
||||
if (CollUtil.isEmpty(skus)) {
|
||||
return productSpuDetailRespVO;
|
||||
}
|
||||
List<ProductSkuRespVO> skuVOs = ProductSkuConvert.INSTANCE.convertList(skus);
|
||||
// fix: 因为现在已改为 sku 属性列表 属性 已包含 属性名字 属性值名字 所以不需要再额外处理,属性更新时更新 sku 中的属性相关冗余即可
|
||||
productSpuDetailRespVO.setSkus(skuVOs);
|
||||
return productSpuDetailRespVO;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -31,8 +31,7 @@ public interface ProductBrandMapper extends BaseMapperX<ProductBrandDO> {
|
||||
return selectOne(ProductBrandDO::getName, name);
|
||||
}
|
||||
|
||||
// TODO @puhui999:) { 中间要有空格哈。
|
||||
default List<ProductBrandDO> selectListByStatus(Integer status){
|
||||
return selectList(ProductBrandDO::getStatus,status);
|
||||
default List<ProductBrandDO> selectListByStatus(Integer status) {
|
||||
return selectList(ProductBrandDO::getStatus, status);
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,9 @@ public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
|
||||
return selectList(ProductSkuDO::getSpuId, spuId);
|
||||
}
|
||||
|
||||
default List<ProductSkuDO> selectListBySpuIdAndStatus(Long spuId,
|
||||
Integer status) {
|
||||
default List<ProductSkuDO> selectListBySpuIdAndStatus(Long spuId) {
|
||||
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) {
|
||||
@ -41,7 +39,7 @@ public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
|
||||
/**
|
||||
* 更新 SKU 库存(增加)
|
||||
*
|
||||
* @param id 编号
|
||||
* @param id 编号
|
||||
* @param incrCount 增加库存(正数)
|
||||
*/
|
||||
default void updateStockIncr(Long id, Integer incrCount) {
|
||||
@ -55,7 +53,7 @@ public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
|
||||
/**
|
||||
* 更新 SKU 库存(减少)
|
||||
*
|
||||
* @param id 编号
|
||||
* @param id 编号
|
||||
* @param incrCount 减少库存(负数)
|
||||
* @return 更新条数
|
||||
*/
|
||||
@ -68,8 +66,8 @@ public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
|
||||
return update(null, updateWrapper);
|
||||
}
|
||||
|
||||
default List<ProductSkuDO> selectListByAlarmStock(){
|
||||
return selectList(new QueryWrapper<ProductSkuDO>().apply("stock <= warn_stock"));
|
||||
default List<ProductSkuDO> selectListByAlarmStock() {
|
||||
return selectList(new QueryWrapper<ProductSkuDO>().apply("stock <= warn_stock"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,21 +35,21 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
|
||||
.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<ProductSpuDO> 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<ProductSpuDO> {
|
||||
* @param reqVO 查询条件
|
||||
* @return Spu 列表
|
||||
*/
|
||||
default List<ProductSpuDO> selectList(ProductSpuExportReqVO reqVO){
|
||||
default List<ProductSpuDO> selectList(ProductSpuExportReqVO reqVO) {
|
||||
Integer tabType = reqVO.getTabType();
|
||||
LambdaQueryWrapperX<ProductSpuDO> 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<ProductSpuDO> queryWrapper) {
|
||||
// 出售中商品 TODO puhui999:这样好点
|
||||
static void appendTabQuery(Integer tabType, LambdaQueryWrapperX<ProductSpuDO> 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());
|
||||
}
|
||||
}
|
||||
|
@ -88,14 +88,10 @@ public interface ProductSkuService {
|
||||
/**
|
||||
* 基于 SPU 编号和状态,获得商品 SKU 集合
|
||||
*
|
||||
* TODO @puhui999:SKU中已经不存在status属性;芋艿:那就去掉 status 哈
|
||||
*
|
||||
* @param spuId SPU 编号
|
||||
* @param status 状态
|
||||
* @return 商品 SKU 集合
|
||||
*/
|
||||
List<ProductSkuDO> getSkuListBySpuIdAndStatus(Long spuId,
|
||||
@Nullable Integer status);
|
||||
List<ProductSkuDO> getSkuListBySpuIdAndStatus(Long spuId);
|
||||
|
||||
/**
|
||||
* 获得 spu 对应的 SKU 集合
|
||||
|
@ -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<ProductSkuDO> getSkuListBySpuIdAndStatus(Long spuId, Integer status) {
|
||||
return productSkuMapper.selectListBySpuIdAndStatus(spuId, status);
|
||||
public List<ProductSkuDO> getSkuListBySpuIdAndStatus(Long spuId) {
|
||||
return productSkuMapper.selectListBySpuIdAndStatus(spuId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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<ProductSkuCreateOrUpdateReqVO> 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<ProductSkuCreateOrUpdateReqVO> 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<ProductSkuCreateOrUpdateReqVO> 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<ProductSkuDO> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user