Commit 87d265ea by 章家宝

feat:合同佣金,车款计算,保留两位小数,向上取整

1 parent 6718593f
......@@ -7,6 +7,7 @@ import com.glsx.usedcar.module.vehicle.entity.Vehicle;
import com.glsx.usedcar.util.NumberToChinese;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
......@@ -69,10 +70,20 @@ public record DocTemplateRequest(String docTemplateId, String fileName, List<Com
}
}
double totalAmount = actualOrderPrice + actualCommissionPrice;
// 1. 车款 - 两位小数+向上取整
String hammerPrice = new BigDecimal(String.valueOf(actualOrderPrice)).setScale(2, RoundingMode.CEILING).max(BigDecimal.ZERO).toString();
// 2. 佣金 - 两位小数+向上取整
String otherFees = new BigDecimal(String.valueOf(actualCommissionPrice)).setScale(2, RoundingMode.CEILING).max(BigDecimal.ZERO).toString();
components.add(new Component("hammerPrice", actualOrderPrice + ""));
components.add(new Component("otherFees", actualCommissionPrice + ""));
double totalAmount = new BigDecimal(hammerPrice)
.add(new BigDecimal(otherFees))
.setScale(2, RoundingMode.DOWN)
.max(BigDecimal.ZERO)
.doubleValue();
// 放入组件
components.add(new Component("hammerPrice", hammerPrice));
components.add(new Component("otherFees", otherFees));
components.add(new Component("totalAmount", totalAmount + ""));
components.add(new Component("totalAmountInWords", NumberToChinese.toChinese(totalAmount)));
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!