package com.ruoyi.common.utils;
|
|
import com.ruoyi.sales.pojo.SalesLedgerProduct;
|
|
import java.math.BigDecimal;
|
import java.math.RoundingMode;
|
|
/**
|
* 运费计算工具类
|
*/
|
public class FreightUtils {
|
|
private FreightUtils() {
|
// 私有构造函数,防止实例化
|
}
|
|
/**
|
* 计算总运费
|
* 总运费 = 数量 × 运费单价
|
*
|
* @param product 产品信息
|
*/
|
public static void fillFreightAmount(SalesLedgerProduct product) {
|
if (product == null) {
|
return;
|
}
|
if (product.getQuantity() == null || product.getFreightUnitPrice() == null) {
|
product.setTotalFreight(null);
|
return;
|
}
|
product.setTotalFreight(product.getQuantity().multiply(product.getFreightUnitPrice()).setScale(2, RoundingMode.HALF_UP));
|
}
|
}
|