Files
FrameTour-BE/src/main/java/com/ycwl/basic/pricing/dto/VoucherInfo.java
Jerry Yan 6006fe460c feat(pricing): 优惠券增加有效期时间范围功能
- 在VoucherBatchCreateReqV2、VoucherBatchResp、VoucherInfo 和 PriceVoucherBatchConfig 类中添加有效期开始时间和结束时间字段
- 实现有效期时间范围的验证和检查逻辑
- 更新 VoucherBatchServiceImpl 和 VoucherServiceImpl 以支持有效期时间范围功能
2025-09-16 23:49:39 +08:00

167 lines
3.0 KiB
Java

package com.ycwl.basic.pricing.dto;
import com.ycwl.basic.pricing.enums.ProductType;
import com.ycwl.basic.pricing.enums.VoucherDiscountType;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 券码信息DTO
*/
@Data
public class VoucherInfo {
/**
* 券码ID
*/
private Long voucherId;
/**
* 券码
*/
private String voucherCode;
/**
* 批次ID
*/
private Long batchId;
/**
* 批次名称
*/
private String batchName;
/**
* 景区ID
*/
private Long scenicId;
/**
* 推客ID
*/
private Long brokerId;
/**
* 优惠类型
*/
private VoucherDiscountType discountType;
/**
* 优惠值
*/
private BigDecimal discountValue;
/**
* 实际优惠金额
*/
private BigDecimal actualDiscountAmount;
/**
* 状态
*/
private Integer status;
/**
* 领取时间
*/
private Date claimedTime;
/**
* 使用时间
*/
private Date usedTime;
/**
* 是否可用
*/
private Boolean available;
/**
* 不可用原因
*/
private String unavailableReason;
/**
* 适用商品类型列表
* null表示适用所有商品类型
*/
private List<ProductType> applicableProducts;
/**
* 当前使用次数
*/
private Integer currentUseCount;
/**
* 最大使用次数
*/
private Integer maxUseCount;
/**
* 每个用户最大使用次数
*/
private Integer maxUsePerUser;
/**
* 使用间隔小时数
*/
private Integer useIntervalHours;
/**
* 剩余可使用次数
*/
private Integer remainingUseCount;
/**
* 是否还能使用
*/
private Boolean canUseMore;
/**
* 最后使用时间
*/
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());
}
}