Coupon.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package cn.seecoder.courselearning.po;
  2. import cn.seecoder.courselearning.enums.CouponType;
  3. import cn.seecoder.courselearning.vo.CouponVO;
  4. import lombok.Data;
  5. import lombok.NoArgsConstructor;
  6. import java.time.LocalDateTime;
  7. @Data
  8. @NoArgsConstructor
  9. public class Coupon {
  10. /**
  11. * 优惠券id
  12. */
  13. private Integer id;
  14. /**
  15. * 优惠券类型
  16. */
  17. private CouponType type;
  18. /**
  19. * 优惠券名称
  20. */
  21. private String name;
  22. /**
  23. * 优惠券描述
  24. */
  25. private String description;
  26. /**
  27. * 如果为-1,表示对所有课程均有效
  28. */
  29. private Integer courseId;
  30. /**
  31. * 如果为-1,表示对所有用户均有效
  32. * 当前优惠券对 userId 对应的用户生效
  33. */
  34. private Integer validUserId;
  35. /**
  36. * 使用门槛
  37. */
  38. private Integer threshold;
  39. /**
  40. * 折扣型 - 折扣(介于0~1之间)
  41. */
  42. private double discount;
  43. /**
  44. * 减价金额
  45. */
  46. private Integer cutDown;
  47. /**
  48. * 生效时间
  49. */
  50. private LocalDateTime startTime;
  51. /**
  52. * 失效时间
  53. */
  54. private LocalDateTime endTime;
  55. /**
  56. * 优惠券是否可用 true可用 false失效(一次性的券使用后就失效 或 网站关闭活动)
  57. */
  58. private Boolean effective;
  59. /**
  60. * 能否与其他优惠券同时使用 true可同时使用 false不能同时使用
  61. */
  62. private Boolean sharable;
  63. public Coupon(CouponVO couponVO) {
  64. this.type = CouponType.valueOf(couponVO.getType());
  65. this.name = couponVO.getName();
  66. this.description = couponVO.getDescription();
  67. this.courseId = couponVO.getCourseId();
  68. this.validUserId = couponVO.getValidUserId();
  69. this.threshold = couponVO.getThreshold();
  70. this.discount = couponVO.getDiscount();
  71. this.cutDown = couponVO.getCutDown();
  72. this.startTime = couponVO.getStartTime();
  73. this.endTime = couponVO.getEndTime();
  74. this.effective = couponVO.getEffective();
  75. this.sharable = couponVO.getSharable();
  76. }
  77. }