mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 05:12:07 +08:00
首次订购总额不需要折算直接使用填入价格问题修复;
This commit is contained in:
+5
-31
@@ -146,45 +146,19 @@ public class PurchaseServiceImpl implements PurchaseService {
|
||||
// 月均单价
|
||||
BigDecimal monthAverageAmount;
|
||||
// 计算后总价
|
||||
BigDecimal totalAmount;
|
||||
BigDecimal totalAmount = price;
|
||||
/**
|
||||
* ①:首次订购满1年:
|
||||
* 总价 = 输入金额 / 12 * (10 * duration)
|
||||
* 月均单价 = 输入金额 / (10 * duration)
|
||||
* 总价 = 输入金额
|
||||
* 月均单价 = 输入金额 / (12 * duration)
|
||||
* ②:不满1年按月份计算
|
||||
* 总价 = 输入金额
|
||||
* 月均单价 = 输入金额 / duration
|
||||
*/
|
||||
Integer duration = productsDetailDO.getDuration();
|
||||
switch (ProductDurationUnitEnum.fromStatus(productsDetailDO.getDurationUnit())) {
|
||||
case YEAR -> {
|
||||
totalAmount = price.divide(new BigDecimal(1.2), 2, RoundingMode.DOWN);
|
||||
monthAverageAmount = price.divide(new BigDecimal(duration * 12), 2, RoundingMode.DOWN);
|
||||
}
|
||||
case MONTH -> {
|
||||
if (duration >= 12) {
|
||||
// 转换成年 + 剩余月
|
||||
int years = duration / 12;
|
||||
int remainMonths = duration % 12;
|
||||
|
||||
// 整年部分(走年折扣逻辑)
|
||||
BigDecimal yearAmount = price
|
||||
.multiply(new BigDecimal(years))
|
||||
.divide(new BigDecimal("1.2"), 2, RoundingMode.DOWN);
|
||||
|
||||
// 剩余月份部分(走月逻辑)
|
||||
BigDecimal monthAmount = remainMonths == 0
|
||||
? BigDecimal.ZERO
|
||||
: price.multiply(new BigDecimal(remainMonths))
|
||||
.divide(new BigDecimal(12), 2, RoundingMode.DOWN);
|
||||
|
||||
totalAmount = yearAmount.add(monthAmount);
|
||||
} else {
|
||||
// 月份
|
||||
totalAmount = price;
|
||||
}
|
||||
monthAverageAmount = price.divide(new BigDecimal(duration), 2, RoundingMode.DOWN);
|
||||
}
|
||||
case YEAR -> monthAverageAmount = price.divide(new BigDecimal(duration * 12), 2, RoundingMode.DOWN);
|
||||
case MONTH -> monthAverageAmount = price.divide(new BigDecimal(duration), 2, RoundingMode.DOWN);
|
||||
default -> throw new ServiceException(PRODUCTS_DETAIL_DURATION_UNIT_NOT_SUPPORT);
|
||||
}
|
||||
long purchaseId = IdUtil.getSnowflake(mybatisIdProperties.getWorkerId(), mybatisIdProperties.getDatacenterId()).nextId();
|
||||
|
||||
Reference in New Issue
Block a user