mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-19 20:51:53 +08:00
feature(uniapp分类): 商品创建功能以及查询功能正常使用
This commit is contained in:
@@ -27,16 +27,16 @@ public class ProductSkuBaseVO {
|
||||
@NotNull(message = "销售价格,单位:分不能为空")
|
||||
private Integer price;
|
||||
|
||||
@ApiModelProperty(value = "原价, 单位: 分", required = true)
|
||||
@NotNull(message = "原价, 单位: 分不能为空")
|
||||
private Integer originalPrice;
|
||||
@ApiModelProperty(value = "市场价, 单位: 分", required = true)
|
||||
@NotNull(message = "市场价, 单位: 分不能为空")
|
||||
private Integer marketPrice;
|
||||
|
||||
@ApiModelProperty(value = "成本价,单位: 分", required = true)
|
||||
@NotNull(message = "成本价,单位: 分不能为空")
|
||||
private Integer costPrice;
|
||||
|
||||
@ApiModelProperty(value = "条形码", required = true)
|
||||
@NotNull(message = "条形码不能为空")
|
||||
@ApiModelProperty(value = "条形码")
|
||||
// @NotNull(message = "条形码不能为空")
|
||||
private String barCode;
|
||||
|
||||
@ApiModelProperty(value = "图片地址", required = true)
|
||||
@@ -46,7 +46,15 @@ public class ProductSkuBaseVO {
|
||||
@ApiModelProperty(value = "状态: 0-正常 1-禁用")
|
||||
private Integer status;
|
||||
|
||||
// TODO @franky 要有 swagger 注解
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "商品重量,单位:kg 千克")
|
||||
private Double weight;
|
||||
|
||||
@ApiModelProperty(value = "商品体积,单位:m^3 平米")
|
||||
private Double volume;
|
||||
|
||||
@Data
|
||||
public static class Property {
|
||||
@NotNull(message = "规格属性名id不能为空")
|
||||
|
@@ -1,5 +1,8 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuSpecTypeEnum;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -16,6 +19,11 @@ public class ProductSpuBaseVO {
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 商品编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "卖点", required = true)
|
||||
@NotNull(message = "卖点不能为空")
|
||||
private String sellPoint;
|
||||
@@ -24,28 +32,87 @@ public class ProductSpuBaseVO {
|
||||
@NotNull(message = "描述不能为空")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 商品品牌编号
|
||||
*
|
||||
* 关联 {@link ProductBrandDO#getId()}
|
||||
*/
|
||||
private Long brandId;
|
||||
|
||||
@ApiModelProperty(value = "分类id", required = true)
|
||||
@NotNull(message = "分类id不能为空")
|
||||
private Long categoryId;
|
||||
|
||||
/**
|
||||
* 商品主图
|
||||
*/
|
||||
private String bannerUrl;
|
||||
|
||||
@ApiModelProperty(value = "商品主图地址,* 数组,以逗号分隔,最多上传15张", required = true)
|
||||
@NotNull(message = "商品主图地址,* 数组,以逗号分隔,最多上传15张不能为空")
|
||||
private List<String> picUrls;
|
||||
|
||||
/**
|
||||
* 商品视频
|
||||
*/
|
||||
private String videoUrl;
|
||||
|
||||
/**
|
||||
* 规格类型
|
||||
*
|
||||
* 枚举 {@link ProductSpuSpecTypeEnum}
|
||||
*/
|
||||
private Integer specType;
|
||||
|
||||
@ApiModelProperty(value = "排序字段", required = true)
|
||||
@NotNull(message = "排序字段不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "点赞初始人数")
|
||||
private Integer likeCount;
|
||||
|
||||
@ApiModelProperty(value = "价格 单位使用:分")
|
||||
private Integer price;
|
||||
|
||||
@ApiModelProperty(value = "库存数量")
|
||||
private Integer quantity;
|
||||
/**
|
||||
* 最小价格,单位使用:分
|
||||
*
|
||||
* 基于其对应的 {@link ProductSkuDO#getPrice()} 最小值
|
||||
*/
|
||||
private Integer minPrice;
|
||||
/**
|
||||
* 最大价格,单位使用:分
|
||||
*
|
||||
* 基于其对应的 {@link ProductSkuDO#getPrice()} 最大值
|
||||
*/
|
||||
private Integer maxPrice;
|
||||
/**
|
||||
* 市场价,单位使用:分
|
||||
*
|
||||
* 基于其对应的 {@link ProductSkuDO#getMarketPrice()} 最大值
|
||||
*/
|
||||
private Integer marketPrice;
|
||||
/**
|
||||
* 总库存
|
||||
*
|
||||
* 基于其对应的 {@link ProductSkuDO#getStock()} 求和
|
||||
*/
|
||||
private Integer totalStock;
|
||||
/**
|
||||
* 预警预存
|
||||
*/
|
||||
private Integer warnStock;
|
||||
/**
|
||||
* 是否展示库存
|
||||
*/
|
||||
private Boolean showStock;
|
||||
|
||||
@ApiModelProperty(value = "上下架状态: 0 上架(开启) 1 下架(禁用)")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 商品销量
|
||||
*/
|
||||
private Integer salesCount;
|
||||
/**
|
||||
* 虚拟销量
|
||||
*/
|
||||
private Integer virtualSalesCount;
|
||||
/**
|
||||
* 商品点击量
|
||||
*/
|
||||
private Integer clickCount;
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
||||
//插入属性值
|
||||
List<ProductPropertyValueCreateReqVO> propertyValueList = createReqVO.getPropertyValueList();
|
||||
List<ProductPropertyValueDO> productPropertyValueDOList = ProductPropertyValueConvert.INSTANCE.convertList03(propertyValueList);
|
||||
productPropertyValueDOList.stream().forEach(x-> x.setPropertyId(property.getId()));
|
||||
productPropertyValueDOList.forEach(x-> x.setPropertyId(property.getId()));
|
||||
productPropertyValueMapper.insertBatch(productPropertyValueDOList);
|
||||
// 返回
|
||||
return property.getId();
|
||||
@@ -67,7 +67,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
||||
productPropertyValueMapper.deletePropertyValueByPropertyId(updateReqVO.getId());
|
||||
List<ProductPropertyValueCreateReqVO> propertyValueList = updateReqVO.getPropertyValueList();
|
||||
List<ProductPropertyValueDO> productPropertyValueDOList = ProductPropertyValueConvert.INSTANCE.convertList03(propertyValueList);
|
||||
productPropertyValueDOList.stream().forEach(x-> x.setPropertyId(updateReqVO.getId()));
|
||||
productPropertyValueDOList.forEach(x-> x.setPropertyId(updateReqVO.getId()));
|
||||
productPropertyValueMapper.insertBatch(productPropertyValueDOList);
|
||||
}
|
||||
|
||||
|
@@ -2,9 +2,14 @@ package cn.iocoder.yudao.module.product.service.sku;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper;
|
||||
@@ -84,8 +89,6 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
||||
return productSkuMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
// TODO @franky:这个方法,貌似实现的还是有点问题哈。例如说,throw 异常,后面还执行逻辑~
|
||||
// TODO @艿艿 咳咳,throw 那里我是偷懒省略了{},哈哈,我加上,然后我调试下,在优化下
|
||||
@Override
|
||||
public void validateSkus(List<ProductSkuCreateReqVO> list) {
|
||||
List<ProductSkuBaseVO.Property> skuPropertyList = list.stream().flatMap(p -> p.getProperties().stream()).collect(Collectors.toList());
|
||||
@@ -99,8 +102,9 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
||||
skuPropertyList.forEach(p -> {
|
||||
ProductPropertyRespVO productPropertyRespVO = propertyMap.get(p.getPropertyId());
|
||||
// 如果对应的属性名不存在或属性名下的属性值集合为空,给出提示
|
||||
if (null == productPropertyRespVO || productPropertyRespVO.getPropertyValueList().isEmpty())
|
||||
if (null == productPropertyRespVO || productPropertyRespVO.getPropertyValueList().isEmpty()) {
|
||||
throw ServiceExceptionUtil.exception(PROPERTY_NOT_EXISTS);
|
||||
}
|
||||
// 判断改属性名对应的属性值是否存在,不存在,给出提示
|
||||
if (!productPropertyRespVO.getPropertyValueList().stream().map(ProductPropertyValueRespVO::getId).collect(Collectors.toSet()).contains(p.getValueId())) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.PROPERTY_VALUE_NOT_EXISTS);
|
||||
|
Reference in New Issue
Block a user