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);