Commit 1d753edf by 章家宝

fix: 客户消费力标签当获取两个值都是0的时候不入库

1 parent ac580393
......@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
......@@ -476,21 +477,24 @@ public class CustomerTagProfileService {
BigDecimal lowerPrice = carSeriesDetail.getLowerPrice();
BigDecimal higherPrice = carSeriesDetail.getHigherPrice();
if (lowerPrice == null && higherPrice == null) {
// 两个价格都无效(null或0)时返回null
boolean lowerInvalid = lowerPrice == null || lowerPrice.compareTo(BigDecimal.ZERO) == 0;
boolean higherInvalid = higherPrice == null || higherPrice.compareTo(BigDecimal.ZERO) == 0;
if (lowerInvalid && higherInvalid) {
return null;
}
// 如果只有一个价格,使用该价格
if (lowerPrice == null) {
// 只有一个有效价格,使用该价格
if (lowerInvalid) {
return higherPrice.multiply(new BigDecimal("10000"));
}
if (higherPrice == null) {
if (higherInvalid) {
return lowerPrice.multiply(new BigDecimal("10000"));
}
// 计算平均价格:((lowerPrice + higherPrice) / 2) * 10000
// 两个价格都有效,计算平均价格
return lowerPrice.add(higherPrice)
.divide(new BigDecimal("2"), 2, BigDecimal.ROUND_HALF_UP)
.divide(new BigDecimal("2"), 2, RoundingMode.HALF_UP)
.multiply(new BigDecimal("10000"));
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!