huminmin
2 天以前 8674fd3d10dba263a6606758ceddf20a9d694098
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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));
    }
}