const.js 974 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const PromotionDiscountTypeEnum = {
  4. PRICE: {
  5. type: 1,
  6. name: "满减"
  7. },
  8. PERCENT: {
  9. type: 2,
  10. name: "折扣"
  11. }
  12. };
  13. const CouponTemplateValidityTypeEnum = {
  14. DATE: {
  15. type: 1,
  16. name: "固定日期可用"
  17. },
  18. TERM: {
  19. type: 2,
  20. name: "领取之后可用"
  21. }
  22. };
  23. const TimeStatusEnum = {
  24. WAIT_START: "即将开始",
  25. STARTED: "进行中",
  26. END: "已结束"
  27. };
  28. const getTimeStatusEnum = (startTime, endTime) => {
  29. const now = common_vendor.dayjs();
  30. if (now.isBefore(startTime)) {
  31. return TimeStatusEnum.WAIT_START;
  32. } else if (now.isAfter(endTime)) {
  33. return TimeStatusEnum.END;
  34. } else {
  35. return TimeStatusEnum.STARTED;
  36. }
  37. };
  38. exports.CouponTemplateValidityTypeEnum = CouponTemplateValidityTypeEnum;
  39. exports.PromotionDiscountTypeEnum = PromotionDiscountTypeEnum;
  40. exports.TimeStatusEnum = TimeStatusEnum;
  41. exports.getTimeStatusEnum = getTimeStatusEnum;