商品金额判断

This commit is contained in:
liupopo
2024-01-09 18:40:40 +08:00
parent 698e6b4708
commit 984ebd301a

View File

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