zoujiajian 1 mese fa
parent
commit
c2782bb646

+ 8 - 4
netflix-service/src/main/java/com/cyksj/service/codex/impl/CodexServiceImpl.java

@@ -407,7 +407,6 @@ public class CodexServiceImpl implements CodexService {
 			if (orderMoney.compareTo(BigDecimal.ZERO) == 0) {
 				orderMoney = presentSku.getPrice();
 			}
-			Long betweenDay = DateUtil.betweenDay(now, renewExpiryTime, false) + 1;
 			//当天购买的按规格原价抵扣
 			BigDecimal renewDeductMoney;
 			if (now.toDateStr().equals(DateUtil.format(renewOrderDon.getCreatedTime(), "yyyy-MM-dd"))) {
@@ -419,13 +418,18 @@ public class CodexServiceImpl implements CodexService {
 					relationExpiryTime = DateUtil.offsetMonth(relationExpiryTime, -presentSku.getMonths());
 				}
 			} else {
+				// 续费天数追加在车票尾部,不能按“下单时间 + 规格天数”从购买当天开始折旧。
+				// 总到期时间覆盖完整续费周期时,该笔续费应按完整价值抵扣;只有进入该周期后才按剩余天数折算。
+				long skuDays = presentSku.getDays() != null ? presentSku.getDays() : presentSku.getMonths() * 30L;
+				long relationRemainDays = DateUtil.betweenDay(now, relationExpiryTime, false) + 1;
+				long renewRemainDays = Math.min(skuDays, relationRemainDays);
 				//此次续费规格单价
 				BigDecimal single = getPayOrderSingle(orderMoney, presentSku);
 				//该车票抵扣金额
-				renewDeductMoney = single.multiply(BigDecimal.valueOf(betweenDay));
+				renewDeductMoney = single.multiply(BigDecimal.valueOf(renewRemainDays));
 				log.info("codex车票id:{}目前续费升级规格可抵扣的金额为:{}", relationId, renewDeductMoney);
 				deductMoney = deductMoney.add(renewDeductMoney);
-				relationExpiryTime = DateUtil.offsetDay(relationExpiryTime, -betweenDay.intValue());
+				relationExpiryTime = DateUtil.offsetDay(relationExpiryTime, -(int) renewRemainDays);
 			}
 			//上一个续费升级规格
 			List<OrderDon> orderDOns = codexUserRenewExpiryRecordMapper.getOtherRenewSkus(renewOrderId, relationId, userIdList);
@@ -1190,4 +1194,4 @@ public class CodexServiceImpl implements CodexService {
 		}
 		return null;
 	}
-}
+}