From 19154aa2b8b541355838fe7c36cd9132852b15e5 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 22 Jun 2021 15:08:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=99=9A=E6=8B=9F=E5=95=86=E5=93=81=E9=87=8D?= =?UTF-8?q?=E9=87=8F=E5=AD=97=E6=AE=B5=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/lili/modules/goods/entity/dos/Goods.java | 7 +++++-- .../java/cn/lili/modules/goods/entity/dos/GoodsSku.java | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) 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) {