diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java index 5087459f..acf79d3d 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java @@ -240,8 +240,11 @@ public class Goods extends BaseEntity { if (StringUtil.isEmpty(sku.get("cost").toString()) || Integer.parseInt( sku.get("cost").toString()) <= 0) { throw new ServiceException(ResultCode.GOODS_SKU_COST_ERROR); } - if (StringUtil.isEmpty(sku.get("weight").toString()) || Integer.parseInt( sku.get("weight").toString()) < 0) { - throw new ServiceException(ResultCode.GOODS_SKU_WEIGHT_ERROR); + //虚拟商品没有重量字段 + if(sku.containsKey("weight")) { + if (StringUtil.isEmpty(sku.get("weight").toString()) || Integer.parseInt(sku.get("weight").toString()) < 0) { + throw new ServiceException(ResultCode.GOODS_SKU_WEIGHT_ERROR); + } } if (StringUtil.isEmpty(sku.get("quantity").toString()) || Integer.parseInt( sku.get("quantity").toString()) < 0) { throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_ERROR); diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java index 7b9231f4..056e587d 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java @@ -164,6 +164,13 @@ public class GoodsSku extends BaseEntity { @ApiModelProperty(value = "商品类型", required = true) private String goodsType; + public Double getWeight() { + if (weight == null) { + return 0d; + } + return weight; + } + @Override public Date getUpdateTime() { if (super.getUpdateTime() == null) {