feat(pricing): 优惠券增加有效期时间范围功能

- 在VoucherBatchCreateReqV2、VoucherBatchResp、VoucherInfo 和 PriceVoucherBatchConfig 类中添加有效期开始时间和结束时间字段
- 实现有效期时间范围的验证和检查逻辑
- 更新 VoucherBatchServiceImpl 和 VoucherServiceImpl 以支持有效期时间范围功能
This commit is contained in:
2025-09-16 23:49:39 +08:00
parent 1506ae95b8
commit 6006fe460c
6 changed files with 132 additions and 2 deletions

View File

@@ -123,4 +123,45 @@ public class VoucherInfo {
* 最后使用时间
*/
private Date lastUsedTime;
/**
* 有效期开始时间
*/
private Date validStartTime;
/**
* 有效期结束时间
*/
private Date validEndTime;
/**
* 检查指定时间是否在有效期内
* @param checkTime 待检查的时间
* @return true-在有效期内,false-不在有效期内
*/
public boolean isWithinValidTimeRange(Date checkTime) {
if (checkTime == null) {
return false;
}
// 检查开始时间
if (validStartTime != null && checkTime.before(validStartTime)) {
return false;
}
// 检查结束时间
if (validEndTime != null && checkTime.after(validEndTime)) {
return false;
}
return true;
}
/**
* 检查当前时间是否在有效期内
* @return true-在有效期内,false-不在有效期内
*/
public boolean isWithinValidTimeRange() {
return isWithinValidTimeRange(new Date());
}
}