From 1a77b3cec7f0291a7e26841e688dc58dee4cdcd6 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Wed, 30 Jun 2021 15:46:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=95=86=E5=93=81=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E9=97=AE=E9=A2=98?= 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 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 e4f8eefa..efa1b8af 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 @@ -234,15 +234,15 @@ public class Goods extends BaseEntity { if (sku.get("sn") == null) { throw new ServiceException(ResultCode.GOODS_SKU_SN_ERROR); } - if (StringUtil.isEmpty(sku.get("price").toString()) || Integer.parseInt( sku.get("price").toString()) <= 0) { + if (StringUtil.isEmpty(sku.get("price").toString()) || Double.parseDouble( sku.get("price").toString()) <= 0) { throw new ServiceException(ResultCode.GOODS_SKU_PRICE_ERROR); } - if (StringUtil.isEmpty(sku.get("cost").toString()) || Integer.parseInt( sku.get("cost").toString()) <= 0) { + if (StringUtil.isEmpty(sku.get("cost").toString()) || Double.parseDouble( sku.get("cost").toString()) <= 0) { throw new ServiceException(ResultCode.GOODS_SKU_COST_ERROR); } //虚拟商品没有重量字段 if(sku.containsKey("weight")) { - if (StringUtil.isEmpty(sku.get("weight").toString()) || Integer.parseInt(sku.get("weight").toString()) < 0) { + if (StringUtil.isEmpty(sku.get("weight").toString()) || Double.parseDouble(sku.get("weight").toString()) < 0) { throw new ServiceException(ResultCode.GOODS_SKU_WEIGHT_ERROR); } } From d7ce709ce6120ed877910843453e84b80f8d58d6 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Wed, 30 Jun 2021 16:29:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8hutool=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/goods/entity/dos/Goods.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 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 efa1b8af..142c2298 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 @@ -1,5 +1,6 @@ package cn.lili.modules.goods.entity.dos; +import cn.hutool.core.convert.Convert; import cn.hutool.json.JSONUtil; import cn.lili.base.BaseEntity; import cn.lili.common.enums.ResultCode; @@ -234,19 +235,19 @@ public class Goods extends BaseEntity { if (sku.get("sn") == null) { throw new ServiceException(ResultCode.GOODS_SKU_SN_ERROR); } - if (StringUtil.isEmpty(sku.get("price").toString()) || Double.parseDouble( sku.get("price").toString()) <= 0) { + if (StringUtil.isEmpty(sku.get("price").toString()) || Convert.toDouble(sku.get("price")) <= 0) { throw new ServiceException(ResultCode.GOODS_SKU_PRICE_ERROR); } - if (StringUtil.isEmpty(sku.get("cost").toString()) || Double.parseDouble( sku.get("cost").toString()) <= 0) { + if (StringUtil.isEmpty(sku.get("cost").toString()) || Convert.toDouble(sku.get("cost")) <= 0) { throw new ServiceException(ResultCode.GOODS_SKU_COST_ERROR); } //虚拟商品没有重量字段 - if(sku.containsKey("weight")) { - if (StringUtil.isEmpty(sku.get("weight").toString()) || Double.parseDouble(sku.get("weight").toString()) < 0) { + if (sku.containsKey("weight")) { + if (StringUtil.isEmpty(sku.get("weight").toString()) || Convert.toDouble(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) { + if (StringUtil.isEmpty(sku.get("quantity").toString()) || Convert.toInt(sku.get("quantity").toString()) < 0) { throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_ERROR); }