1/24
This commit is contained in:
@@ -21,6 +21,7 @@ import com.yxt.yythmall.api.shoppingcart.ShoppingCartVo;
|
|||||||
import com.yxt.yythmall.biz.shoppingcart.ShoppingCartService;
|
import com.yxt.yythmall.biz.shoppingcart.ShoppingCartService;
|
||||||
import com.yxt.yythmall.mallplus.biz.pms.service.IPmsBrandService;
|
import com.yxt.yythmall.mallplus.biz.pms.service.IPmsBrandService;
|
||||||
import com.yxt.yythmall.mallplus.mbg.pms.entity.brand.BrandVo;
|
import com.yxt.yythmall.mallplus.mbg.pms.entity.brand.BrandVo;
|
||||||
|
import com.yxt.yythmall.utils.DoubleUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -266,7 +267,8 @@ public class LpkGoodsService extends MybatisBaseService<LpkGoodsMapper, LpkGoods
|
|||||||
if(l.size()==0){
|
if(l.size()==0){
|
||||||
giftBagGoodss.forEach(d->{
|
giftBagGoodss.forEach(d->{
|
||||||
// d.setIconUrl(fileUploadComponent.getUrlPrefix()+d.getIconUrl());
|
// d.setIconUrl(fileUploadComponent.getUrlPrefix()+d.getIconUrl());
|
||||||
d.setMefenPrice(removeZeros(String.valueOf((Double.valueOf(d.getPrice())* Double.valueOf(d.getWeight())))));
|
d.setMefenPrice(removeZeros(String.valueOf((DoubleUtils.mul(Double.valueOf(d.getPrice()), Double.valueOf(d.getWeight()))))));
|
||||||
|
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
l.forEach(s->{
|
l.forEach(s->{
|
||||||
@@ -275,13 +277,20 @@ public class LpkGoodsService extends MybatisBaseService<LpkGoodsMapper, LpkGoods
|
|||||||
d.setGoodsNumber(s.getGoodsNumber());
|
d.setGoodsNumber(s.getGoodsNumber());
|
||||||
}
|
}
|
||||||
// d.setIconUrl(fileUploadComponent.getUrlPrefix()+d.getIconUrl());
|
// d.setIconUrl(fileUploadComponent.getUrlPrefix()+d.getIconUrl());
|
||||||
d.setMefenPrice(removeZeros(String.valueOf((Double.valueOf(d.getPrice())* Double.valueOf(d.getWeight())))));
|
// d.setMefenPrice(removeZeros(String.valueOf((Double.valueOf(d.getPrice())* Double.valueOf(d.getWeight())))));
|
||||||
|
d.setMefenPrice(removeZeros(String.valueOf((DoubleUtils.mul(Double.valueOf(d.getPrice()), Double.valueOf(d.getWeight()))))));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return rb.success().setData(giftBagGoodss);
|
return rb.success().setData(giftBagGoodss);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
double a =1.88;
|
||||||
|
double b =10;
|
||||||
|
System.out.println(a*b);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 去除多余.0
|
* 去除多余.0
|
||||||
* @param num
|
* @param num
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
|
|||||||
// "3.20-100斤加10%附加额。\n" +
|
// "3.20-100斤加10%附加额。\n" +
|
||||||
// "4.101斤-200斤加5%附加额。");
|
// "4.101斤-200斤加5%附加额。");
|
||||||
vo.setCustomerSid(query.getCustomerSid());
|
vo.setCustomerSid(query.getCustomerSid());
|
||||||
vo.setTotalPrice(String.valueOf((int) price));
|
vo.setTotalPrice(removeZeros(String.valueOf(price)));
|
||||||
vo.setTotalWeight(String.valueOf((int)weight));
|
vo.setTotalWeight(removeZeros(String.valueOf(weight)));
|
||||||
vo=price(vo);
|
vo=price(vo);
|
||||||
return rb.success().setData(vo);
|
return rb.success().setData(vo);
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
|
|||||||
LpkCustomer lpkCustomer=lpkCustomerService.getOne(new QueryWrapper<LpkCustomer>().eq("sid",vo.getCustomerSid()));
|
LpkCustomer lpkCustomer=lpkCustomerService.getOne(new QueryWrapper<LpkCustomer>().eq("sid",vo.getCustomerSid()));
|
||||||
vo.setRemarks("已减免附加费");
|
vo.setRemarks("已减免附加费");
|
||||||
if(weight<=99){
|
if(weight<=99){
|
||||||
if(weight<=20){
|
if(weight<20){
|
||||||
vo.setRemarks("不足20斤,请继续选菜");
|
vo.setRemarks("不足20斤,请继续选菜");
|
||||||
}else{
|
}else{
|
||||||
double a =1.1;
|
double a =1.1;
|
||||||
|
|||||||
80
src/main/java/com/yxt/yythmall/utils/DoubleUtils.java
Normal file
80
src/main/java/com/yxt/yythmall/utils/DoubleUtils.java
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package com.yxt.yythmall.utils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wangpengfei
|
||||||
|
* @date 2024/1/24 8:53
|
||||||
|
*/
|
||||||
|
public class DoubleUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对double数据进行取精度.
|
||||||
|
* @param value double数据.
|
||||||
|
* @param scale 精度位数(保留的小数位数).
|
||||||
|
* @param roundingMode 精度取值方式.
|
||||||
|
* @return 精度计算后的数据.
|
||||||
|
*/
|
||||||
|
public static double round(double value, int scale,
|
||||||
|
int roundingMode) {
|
||||||
|
BigDecimal bd = BigDecimal.valueOf(value);
|
||||||
|
bd = bd.setScale(scale, roundingMode);
|
||||||
|
double d = bd.doubleValue();
|
||||||
|
bd = null;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* double 相加
|
||||||
|
* @param d1
|
||||||
|
* @param d2
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static double sum(double d1,double d2){
|
||||||
|
BigDecimal bd1 = BigDecimal.valueOf(d1);
|
||||||
|
BigDecimal bd2 = BigDecimal.valueOf(d2);
|
||||||
|
return bd1.add(bd2).doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* double 相减
|
||||||
|
* @param d1
|
||||||
|
* @param d2
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static double sub(double d1,double d2){
|
||||||
|
BigDecimal bd1 = BigDecimal.valueOf(d1);
|
||||||
|
BigDecimal bd2 = BigDecimal.valueOf(d2);
|
||||||
|
return bd1.subtract(bd2).doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* double 乘法
|
||||||
|
* @param d1
|
||||||
|
* @param d2
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static double mul(double d1, double d2){
|
||||||
|
BigDecimal bd1 = BigDecimal.valueOf(d1);
|
||||||
|
BigDecimal bd2 = BigDecimal.valueOf(d2);
|
||||||
|
return bd1.multiply(bd2).doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* double 除法
|
||||||
|
* @param d1
|
||||||
|
* @param d2
|
||||||
|
* @param scale 四舍五入 小数点位数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static double div(double d1,double d2,int scale){
|
||||||
|
BigDecimal bd1 = BigDecimal.valueOf(d1);
|
||||||
|
BigDecimal bd2 = BigDecimal.valueOf(d2);
|
||||||
|
return bd1.divide
|
||||||
|
(bd2,scale,BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user