From 984ebd301af36aac861711a5cb5c0166a7f4db3c Mon Sep 17 00:00:00 2001 From: liupopo Date: Tue, 9 Jan 2024 18:40:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E9=87=91=E9=A2=9D=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yyth/api/appletgiftbag/GiftBagGoods.java | 51 +++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/yxt/yyth/api/appletgiftbag/GiftBagGoods.java b/src/main/java/com/yxt/yyth/api/appletgiftbag/GiftBagGoods.java index 4f1f930..7a412e4 100644 --- a/src/main/java/com/yxt/yyth/api/appletgiftbag/GiftBagGoods.java +++ b/src/main/java/com/yxt/yyth/api/appletgiftbag/GiftBagGoods.java @@ -1,6 +1,7 @@ package com.yxt.yyth.api.appletgiftbag; import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; import com.yxt.common.base.utils.StringUtils; import lombok.Data; @@ -38,16 +39,20 @@ public class GiftBagGoods { public String getMefenPrice() { double dj = 0.0; - try { - dj = Double.parseDouble(price); - } catch (Exception e) { - e.printStackTrace(); + if (StrUtil.isNotBlank(price)) { + try { + dj = Double.parseDouble(price); + } catch (Exception e) { + e.printStackTrace(); + } } int js = 1; - try { - js = Integer.parseInt(weight); - } catch (Exception e) { - e.printStackTrace(); + if (StrUtil.isNotBlank(weight)) { + try { + js = Integer.parseInt(weight); + } catch (Exception e) { + e.printStackTrace(); + } } double mfjg = dj * js; return NumberUtil.decimalFormatMoney(mfjg); @@ -55,22 +60,28 @@ public class GiftBagGoods { public String getSubtotal() { double dj = 0.0; - try { - dj = Double.parseDouble(price); - } catch (Exception e) { - e.printStackTrace(); + if (StrUtil.isNotBlank(price)) { + try { + dj = Double.parseDouble(price); + } catch (Exception e) { + e.printStackTrace(); + } } int js = 1; - try { - js = Integer.parseInt(weight); - } catch (Exception e) { - e.printStackTrace(); + if (StrUtil.isNotBlank(weight)) { + try { + js = Integer.parseInt(weight); + } catch (Exception e) { + e.printStackTrace(); + } } int fs = 1; - try { - fs = Integer.parseInt(goodsNumber); - } catch (Exception e) { - e.printStackTrace(); + if (StrUtil.isNotBlank(goodsNumber)) { + try { + fs = Integer.parseInt(goodsNumber); + } catch (Exception e) { + e.printStackTrace(); + } } double mfjg = dj * js * fs; return NumberUtil.decimalFormatMoney(mfjg);