mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
首次订购总额不需要折算直接使用填入价格问题修复;
This commit is contained in:
+5
-31
@@ -146,45 +146,19 @@ public class PurchaseServiceImpl implements PurchaseService {
|
|||||||
// 月均单价
|
// 月均单价
|
||||||
BigDecimal monthAverageAmount;
|
BigDecimal monthAverageAmount;
|
||||||
// 计算后总价
|
// 计算后总价
|
||||||
BigDecimal totalAmount;
|
BigDecimal totalAmount = price;
|
||||||
/**
|
/**
|
||||||
* ①:首次订购满1年:
|
* ①:首次订购满1年:
|
||||||
* 总价 = 输入金额 / 12 * (10 * duration)
|
* 总价 = 输入金额
|
||||||
* 月均单价 = 输入金额 / (10 * duration)
|
* 月均单价 = 输入金额 / (12 * duration)
|
||||||
* ②:不满1年按月份计算
|
* ②:不满1年按月份计算
|
||||||
* 总价 = 输入金额
|
* 总价 = 输入金额
|
||||||
* 月均单价 = 输入金额 / duration
|
* 月均单价 = 输入金额 / duration
|
||||||
*/
|
*/
|
||||||
Integer duration = productsDetailDO.getDuration();
|
Integer duration = productsDetailDO.getDuration();
|
||||||
switch (ProductDurationUnitEnum.fromStatus(productsDetailDO.getDurationUnit())) {
|
switch (ProductDurationUnitEnum.fromStatus(productsDetailDO.getDurationUnit())) {
|
||||||
case YEAR -> {
|
case YEAR -> monthAverageAmount = price.divide(new BigDecimal(duration * 12), 2, RoundingMode.DOWN);
|
||||||
totalAmount = price.divide(new BigDecimal(1.2), 2, RoundingMode.DOWN);
|
case MONTH -> monthAverageAmount = price.divide(new BigDecimal(duration), 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);
|
|
||||||
}
|
|
||||||
default -> throw new ServiceException(PRODUCTS_DETAIL_DURATION_UNIT_NOT_SUPPORT);
|
default -> throw new ServiceException(PRODUCTS_DETAIL_DURATION_UNIT_NOT_SUPPORT);
|
||||||
}
|
}
|
||||||
long purchaseId = IdUtil.getSnowflake(mybatisIdProperties.getWorkerId(), mybatisIdProperties.getDatacenterId()).nextId();
|
long purchaseId = IdUtil.getSnowflake(mybatisIdProperties.getWorkerId(), mybatisIdProperties.getDatacenterId()).nextId();
|
||||||
|
|||||||
Reference in New Issue
Block a user