mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
feature(uniapp商品): 商品功能完善
This commit is contained in:
@ -1,14 +1,20 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.sku.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@ApiModel("管理后台 - 商品 SKU 创建/更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "商品 id 更新时须有", example = "1")
|
||||
private Long id;
|
||||
|
||||
}
|
||||
|
@ -65,10 +65,21 @@ public class ProductSpuBaseVO {
|
||||
@NotNull(message = "是否展示库存不能为空")
|
||||
private Boolean showStock;
|
||||
|
||||
@ApiModelProperty(value = "库存", required = true, example = "true")
|
||||
private Integer totalStock;
|
||||
|
||||
@ApiModelProperty(value = " 最小价格,单位使用:分", required = true, example = "1024")
|
||||
private Integer minPrice;
|
||||
|
||||
@ApiModelProperty(value = "最大价格,单位使用:分", required = true, example = "1024")
|
||||
private Integer maxPrice;
|
||||
|
||||
// ========== 统计相关字段 =========
|
||||
|
||||
@ApiModelProperty(value = "虚拟销量", required = true, example = "1024")
|
||||
@NotNull(message = "虚拟销量不能为空")
|
||||
private Integer virtualSalesCount;
|
||||
|
||||
@ApiModelProperty(value = "点击量", example = "1024")
|
||||
private Integer clickCount;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class SpuPageReqVO extends PageParam {
|
||||
private Integer quantity;
|
||||
|
||||
@ApiModelProperty(value = "上下架状态: 0 上架(开启) 1 下架(禁用)")
|
||||
private Boolean status;
|
||||
private Integer status;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
|
@ -19,16 +19,11 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ProductSpuDO>()
|
||||
.likeIfPresent(ProductSpuDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ProductSpuDO::getSellPoint, reqVO.getSellPoint())
|
||||
.eqIfPresent(ProductSpuDO::getDescription, reqVO.getDescription())
|
||||
.eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId())
|
||||
.eqIfPresent(ProductSpuDO::getPicUrls, reqVO.getPicUrls())
|
||||
.eqIfPresent(ProductSpuDO::getSort, reqVO.getSort())
|
||||
// .eqIfPresent(ProductSpuDO::getLikeCount, reqVO.getLikeCount())
|
||||
// .eqIfPresent(ProductSpuDO::getPrice, reqVO.getPrice())
|
||||
// .eqIfPresent(ProductSpuDO::getQuantity, reqVO.getQuantity())
|
||||
.eqIfPresent(ProductSpuDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ProductSpuDO::getId));
|
||||
.orderByDesc(ProductSpuDO::getSort));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -90,17 +90,19 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
validateSpuExists(updateReqVO.getId());
|
||||
// 校验分类
|
||||
categoryService.validateProductCategory(updateReqVO.getCategoryId());
|
||||
// TODO @luowenfeng:校验品牌
|
||||
// 校验品牌
|
||||
brandService.validateProductBrand(updateReqVO.getBrandId());
|
||||
// 校验SKU
|
||||
List<ProductSkuCreateOrUpdateReqVO> skuCreateReqList = updateReqVO.getSkus();
|
||||
// 多规格才需校验
|
||||
productSkuService.validateProductSkus(skuCreateReqList, updateReqVO.getSpecType());
|
||||
|
||||
// 更新 SPU
|
||||
ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO);
|
||||
// TODO @计算各种字段
|
||||
updateObj.setMarketPrice(CollectionUtils.getMaxValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getMarketPrice));
|
||||
updateObj.setMaxPrice(CollectionUtils.getMaxValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getPrice));
|
||||
updateObj.setMinPrice(CollectionUtils.getMinValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getPrice));
|
||||
updateObj.setTotalStock(CollectionUtils.getSumValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getStock, Integer::sum));
|
||||
ProductSpuMapper.updateById(updateObj);
|
||||
|
||||
// 更新 SKU
|
||||
productSkuService.updateProductSkus(updateObj.getId(), updateReqVO.getSkus());
|
||||
}
|
||||
@ -149,7 +151,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
ProductPropertyViewRespVO.Tuple2 tuple2 = new ProductPropertyViewRespVO.Tuple2(pv.getValueId(), propertyValueMaps.get(pv.getValueId()).getName());
|
||||
propertyValues.add(tuple2);
|
||||
});
|
||||
productPropertyViewRespVO.setPropertyValues(propertyValues);
|
||||
productPropertyViewRespVO.setPropertyValues(propertyValues.stream().distinct().collect(Collectors.toList()));
|
||||
productPropertyViews.add(productPropertyViewRespVO);
|
||||
});
|
||||
spuVO.setProductPropertyViews(productPropertyViews);
|
||||
|
Reference in New Issue
Block a user