TASK:允许修改订阅结束时间到今天之后的日期

This commit is contained in:
2026-05-22 10:35:57 +08:00
parent 921d2d956e
commit 11073690e5
3 changed files with 18 additions and 3 deletions

View File

@@ -169,7 +169,7 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
}
/**
* 处理结束时间(只能延长)
* 处理结束时间,不允许订阅结束时间早于当前时间和订阅开始时间
*/
private void handlePeriodEnd(UpdateSubscriptionPlanDTO dto, SubscriptionPlan plan) {
Long newEnd = dto.getCurrentPeriodEnd();
@@ -177,9 +177,20 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
return;
}
if (newEnd < plan.getCurrentPeriodEnd()) {
long currentTimeSec = System.currentTimeMillis() / 1000;
long startTime = plan.getCurrentPeriodStart();
// 检查是否早于开始时间不能等于否则周期长度为0
if (newEnd <= startTime) {
throw new BusinessException(
"the.subscription.end.date.can.be.extended.only.not.reduced"
"end.time.cannot.be.earlier.than.or.equal.to.start.time"
);
}
// 检查是否早于当前时间(不能等于,否则立即过期)
if (newEnd <= currentTimeSec) {
throw new BusinessException(
"end.time.cannot.be.earlier.than.or.equal.to.the.current.time"
);
}