价格修改int

This commit is contained in:
zjf committed 2025-09-09 11:29:15 +08:00
1 parent 1699a33b1e
commit fa8f937b14
3 files changed
+13 -13

No files matched your search

@@ -83,13 +83,13 @@ public class MallProductCreateDTO {
* SPU售价(当price_type=2有效)
*/
@Schema(description = "SPU售价(当price_type=2有效)")
private BigDecimal spuPrice;
private Integer spuPrice;
/**
* 划线价
*/
@Schema(description = "划线价")
private BigDecimal originalPrice;
private Integer originalPrice;
/**
* 计量单位
@@ -36,20 +36,20 @@ public class MallProductSkuCreateDTO {
*/
@NotNull(message = "售价不能为空")
@Schema(description = "售价")
private BigDecimal price;
private Integer price;
/**
* 成本价
*/
@Schema(description = "成本价")
private BigDecimal costPrice;
private Integer costPrice;
/**
* 库存
*/
@NotNull(message = "库存不能为空")
@Schema(description = "库存")
private Integer stock;
private Double stock;
/**
* 条码
@@ -88,18 +88,18 @@ public class MallProductServiceImpl extends ServiceImpl<MallProductMapper, MallP
}
// 计算总库存
int totalStock = skuList.stream()
.mapToInt(sku -> sku.getStock() != null ? sku.getStock() : 0)
Double totalStock = skuList.stream()
.mapToDouble(sku -> sku.getStock() != null ? sku.getStock() : 0D)
.sum();
product.setTotalStock(totalStock);
this.updateById(product);
} else if (productCreateDTO.getPriceType() == 2) {
// 单价SPU模式,设置总库存为0(或根据业务需求设置)
product.setTotalStock(0);
product.setTotalStock(0D);
this.updateById(product);
} else {
// 没有SKU信息,设置总库存为0
product.setTotalStock(0);
product.setTotalStock(0D);
this.updateById(product);
}
@@ -151,8 +151,8 @@ public class MallProductServiceImpl extends ServiceImpl<MallProductMapper, MallP
Wrappers.<MallProductSkuEntity>lambdaQuery()
.eq(MallProductSkuEntity::getProductId, product.getId())
);
int totalStock = currentSkus.stream()
.mapToInt(sku -> sku.getStock() != null ? sku.getStock() : 0)
Double totalStock = currentSkus.stream()
.mapToDouble(sku -> sku.getStock() != null ? sku.getStock() : 0D)
.sum();
product.setTotalStock(totalStock);
this.updateById(product);
@@ -162,7 +162,7 @@ public class MallProductServiceImpl extends ServiceImpl<MallProductMapper, MallP
deleteWrapper.eq(MallProductSkuEntity::getProductId, product.getId());
mallProductSkuService.remove(deleteWrapper);
product.setTotalStock(0);
product.setTotalStock(0D);
this.updateById(product);
}
@@ -357,7 +357,7 @@ public class MallProductServiceImpl extends ServiceImpl<MallProductMapper, MallP
// 单价SPU模式验证
if (productCreateDTO.getPriceType() == 2) {
if (productCreateDTO.getSpuPrice() == null || productCreateDTO.getSpuPrice().compareTo(BigDecimal.ZERO) <= 0) {
if (productCreateDTO.getSpuPrice() == null || productCreateDTO.getSpuPrice() <= 0) {
throw new RuntimeException("单价SPU模式下必须设置有效的SPU价格");
}
}