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