package cn.seecoder.courselearning.po; import cn.seecoder.courselearning.enums.CouponType; import cn.seecoder.courselearning.vo.CouponVO; import lombok.Data; import lombok.NoArgsConstructor; import java.time.LocalDateTime; @Data @NoArgsConstructor public class Coupon { /** * 优惠券id */ private Integer id; /** * 优惠券类型 */ private CouponType type; /** * 优惠券名称 */ private String name; /** * 优惠券描述 */ private String description; /** * 如果为-1,表示对所有课程均有效 */ private Integer courseId; /** * 如果为-1,表示对所有用户均有效 * 当前优惠券对 userId 对应的用户生效 */ private Integer validUserId; /** * 使用门槛 */ private Integer threshold; /** * 折扣型 - 折扣(介于0~1之间) */ private double discount; /** * 减价金额 */ private Integer cutDown; /** * 生效时间 */ private LocalDateTime startTime; /** * 失效时间 */ private LocalDateTime endTime; /** * 优惠券是否可用 true可用 false失效(一次性的券使用后就失效 或 网站关闭活动) */ private Boolean effective; /** * 能否与其他优惠券同时使用 true可同时使用 false不能同时使用 */ private Boolean sharable; public Coupon(CouponVO couponVO) { this.type = CouponType.valueOf(couponVO.getType()); this.name = couponVO.getName(); this.description = couponVO.getDescription(); this.courseId = couponVO.getCourseId(); this.validUserId = couponVO.getValidUserId(); this.threshold = couponVO.getThreshold(); this.discount = couponVO.getDiscount(); this.cutDown = couponVO.getCutDown(); this.startTime = couponVO.getStartTime(); this.endTime = couponVO.getEndTime(); this.effective = couponVO.getEffective(); this.sharable = couponVO.getSharable(); } }