小数点
This commit is contained in:
@@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2023/11/21 15:12
|
||||
@@ -25,4 +27,8 @@ public class AppletGiftBagVo implements Vo {
|
||||
private String remarks;
|
||||
private String count;//
|
||||
|
||||
public String getPrice() {
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#0.00");
|
||||
return price=decimalFormat.format(Double.valueOf(price));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.yxt.yyth.api.appletgiftbag;
|
||||
import com.yxt.common.base.utils.StringUtils;
|
||||
import lombok.Data;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description
|
||||
@@ -27,6 +29,7 @@ public class GiftBagGoods {
|
||||
if(StringUtils.isBlank(price)){
|
||||
price ="0";
|
||||
}
|
||||
return price;
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#0.00");
|
||||
return decimalFormat.format(Double.valueOf(price));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -198,6 +199,7 @@ public class AppletGiftBagService extends MybatisBaseService<AppletGiftBagMapper
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
List<AppletGiftBagVo> list=baseMapper.giftBagList();
|
||||
list.forEach(s->{
|
||||
// s.setPrice(Double.valueOf(aa(s.getPrice())));
|
||||
List<AppletGiftBagGoods> appletGiftBagGoods=appletGiftBagGoodsService.list(new QueryWrapper<AppletGiftBagGoods>().eq("giftbagSid",s.getSid()));
|
||||
s.setCount(appletGiftBagGoods.size()+"种蔬菜");
|
||||
s.setIconUrl(fileUploadComponent.getUrlPrefix() +s.getIconUrl());
|
||||
@@ -215,14 +217,18 @@ public class AppletGiftBagService extends MybatisBaseService<AppletGiftBagMapper
|
||||
for(GiftBagGoods goods:goodsList){
|
||||
i=i+Double.valueOf(goods.getPrice())*Double.valueOf(goods.getGoodsNumber());
|
||||
goods.setIconUrl(fileUploadComponent.getUrlPrefix() +goods.getIconUrl());
|
||||
goods.setTotalValue(String.valueOf(Double.valueOf(goods.getGoodsNumber())*Double.valueOf(goods.getPrice())));
|
||||
goods.setTotalValue(String.valueOf(decimalFormat.format(Double.valueOf(goods.getGoodsNumber())*Double.valueOf(goods.getPrice()))));
|
||||
goods.setJPrice(String.valueOf(decimalFormat.format(Double.valueOf(goods.getPrice())/Double.valueOf(goods.getWeight()))));
|
||||
}
|
||||
appletGiftBagVo.setPrice(String.valueOf(i));
|
||||
appletGiftBagVo.setPrice(decimalFormat.format(i));
|
||||
appletGiftBagVo.setGoods(goodsList);
|
||||
appletGiftBagVo.setName(s.getName());
|
||||
return rb.success().setData(appletGiftBagVo);
|
||||
}
|
||||
|
||||
public String aa(double a){
|
||||
BigDecimal d=new BigDecimal(a);
|
||||
double c= d.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
return String.valueOf(c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,7 +69,6 @@
|
||||
price,
|
||||
picUrl as iconUrl,
|
||||
specificationUnit,
|
||||
number as goodsNumber,
|
||||
isAppletGrounding,
|
||||
content as remark,
|
||||
weight
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.yxt.yyth.api.lpkgoods.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -154,12 +155,17 @@ public class LpkGoodsService extends MybatisBaseService<LpkGoodsMapper, LpkGoods
|
||||
public ResultBean<List<GiftBagGoods>> getAllGoodsApplet() {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
List<GiftBagGoods> list=baseMapper.getAllGoodsApplet();
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#0.00");
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#0.00");
|
||||
list.forEach(s->{
|
||||
s.setIconUrl(fileUploadComponent.getUrlPrefix() +s.getIconUrl());
|
||||
s.setTotalValue("0");
|
||||
s.setTotalValue(decimalFormat.format(0));
|
||||
s.setJPrice(String.valueOf(decimalFormat.format(Double.valueOf(s.getPrice())/Double.valueOf(s.getWeight()))));
|
||||
});
|
||||
return rb.success().setData(list);
|
||||
}
|
||||
public String aa(double a){
|
||||
BigDecimal d=new BigDecimal(a);
|
||||
double c= d.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
return String.valueOf(c);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user