@lyxa.ai/marketing 1.0.60 → 1.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/event/event-initializations.d.ts.map +1 -1
- package/dist/lib/event/event-initializations.js +2 -0
- package/dist/lib/event/event-initializations.js.map +1 -1
- package/dist/lib/event/event-listeners/event-listeners.d.ts +2 -0
- package/dist/lib/event/event-listeners/event-listeners.d.ts.map +1 -1
- package/dist/lib/event/event-listeners/event-listeners.js +69 -12
- package/dist/lib/event/event-listeners/event-listeners.js.map +1 -1
- package/dist/lib/event/events/marketing-product-seed.event.d.ts +1 -2
- package/dist/lib/event/events/marketing-product-seed.event.d.ts.map +1 -1
- package/dist/lib/event/events/marketing-product-seed.event.js.map +1 -1
- package/dist/lib/event/events/marketing-product-sync.event.d.ts +11 -0
- package/dist/lib/event/events/marketing-product-sync.event.d.ts.map +1 -0
- package/dist/lib/event/events/marketing-product-sync.event.js +12 -0
- package/dist/lib/event/events/marketing-product-sync.event.js.map +1 -0
- package/dist/lib/index.d.ts +8175 -33
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +4 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +7630 -2
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +0 -7
- package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +0 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +3 -4
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js +2 -2
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +6 -6
- package/dist/lib/modules/coupon/validations/coupon.validation.js +2 -2
- package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/create-coupon.validation.js +4 -1
- package/dist/lib/modules/coupon/validations/create-coupon.validation.js.map +1 -1
- package/dist/lib/modules/deal-setting/services/deal-setting.service.d.ts.map +1 -1
- package/dist/lib/modules/deal-setting/services/deal-setting.service.js +4 -1
- package/dist/lib/modules/deal-setting/services/deal-setting.service.js.map +1 -1
- package/dist/lib/modules/featured-setting/services/featured-setting.service.d.ts.map +1 -1
- package/dist/lib/modules/featured-setting/services/featured-setting.service.js +3 -0
- package/dist/lib/modules/featured-setting/services/featured-setting.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +54 -8
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +11 -0
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/index.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/index.js +6 -0
- package/dist/lib/modules/limited-time-offer/campaign/jobs/index.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js +2 -6
- package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +16 -3
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js +22 -3
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts +2 -0
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.js +12 -0
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +242 -35
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js +19 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts +8 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.js +64 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts +3 -0
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.js +66 -8
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js +37 -19
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +249 -18
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts +2 -0
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js +15 -3
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +1 -1
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js +1 -1
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts +24 -3
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js +19 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +10 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +43 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +195 -10
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js +29 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +428 -33
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js +16 -6
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +7 -4
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js +42 -7
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +14 -3
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +76 -16
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts +13 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts.map +1 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.js +75 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.js.map +1 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts +21 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts.map +1 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.js +83 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.js.map +1 -0
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts +1 -0
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js +29 -0
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts +14 -0
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.js +5 -0
- package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
- package/dist/lib/modules/marketing/services/index.d.ts +3 -0
- package/dist/lib/modules/marketing/services/index.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/index.js +3 -0
- package/dist/lib/modules/marketing/services/index.js.map +1 -1
- package/dist/lib/modules/marketing/services/marketing-conflict.repository.d.ts +9 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.repository.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.repository.js +63 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.repository.js.map +1 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.service.d.ts +27 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.service.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.service.js +135 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.service.js.map +1 -0
- package/dist/lib/modules/marketing/services/marketing.service.d.ts +7 -2
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +97 -51
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts +2 -3
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.js +42 -13
- package/dist/lib/modules/marketing/services/product-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.d.ts +14 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.js +82 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.js.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.d.ts +11 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.js +99 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.js.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.d.ts +9 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.js +69 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.js.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts +31 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js +123 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js.map +1 -0
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js +95 -27
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/validations/all-marketings.validation.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/all-marketings.validation.js +3 -0
- package/dist/lib/modules/marketing/validations/all-marketings.validation.js.map +1 -1
- package/dist/lib/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +3 -3
- package/dist/lib/modules/marketing/validations/discount-marketing.validation.d.ts +3 -3
- package/dist/lib/modules/marketing/validations/index.d.ts +1 -0
- package/dist/lib/modules/marketing/validations/index.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/index.js +1 -0
- package/dist/lib/modules/marketing/validations/index.js.map +1 -1
- package/dist/lib/modules/marketing/validations/marketing.validation.d.ts +17 -0
- package/dist/lib/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/marketing.validation.js +7 -1
- package/dist/lib/modules/marketing/validations/marketing.validation.js.map +1 -1
- package/dist/lib/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.d.ts +617 -0
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.d.ts.map +1 -0
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.js +119 -0
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.js.map +1 -0
- package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +0 -1
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js +2 -49
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js.map +1 -1
- package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
- package/dist/lib/modules/spend-to-get-history/routers/index.d.ts +2 -0
- package/dist/lib/modules/spend-to-get-history/routers/index.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/routers/index.js +18 -0
- package/dist/lib/modules/spend-to-get-history/routers/index.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/routers/spend-to-get-history.router.js +62 -0
- package/dist/lib/modules/spend-to-get-history/routers/spend-to-get-history.router.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/services/index.d.ts +2 -0
- package/dist/lib/modules/spend-to-get-history/services/index.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/services/index.js +18 -0
- package/dist/lib/modules/spend-to-get-history/services/index.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts +24 -0
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.js +136 -0
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +24 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js +97 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts +271 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.js +62 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts +24 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.js +116 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +232 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js +30 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/validations/index.d.ts +2 -0
- package/dist/lib/modules/spend-to-get-history/validations/index.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/validations/index.js +18 -0
- package/dist/lib/modules/spend-to-get-history/validations/index.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts +232 -0
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.js +30 -0
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.js.map +1 -0
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts +2 -0
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.js +15 -0
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.js.map +1 -0
- package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts +14 -0
- package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/events/match-ended.event.js +12 -0
- package/dist/lib/modules/tournament/match/events/match-ended.event.js.map +1 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +10 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +23 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +1 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +9 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.js +82 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts +10 -0
- package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.schedule.config.js +15 -0
- package/dist/lib/modules/tournament/notification/notification.schedule.config.js.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +10 -0
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.js +73 -0
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.js.map +1 -0
- package/dist/types/event/event-initializations.d.ts.map +1 -1
- package/dist/types/event/event-listeners/event-listeners.d.ts +2 -0
- package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -1
- package/dist/types/event/events/marketing-product-seed.event.d.ts +1 -2
- package/dist/types/event/events/marketing-product-seed.event.d.ts.map +1 -1
- package/dist/types/event/events/marketing-product-sync.event.d.ts +11 -0
- package/dist/types/event/events/marketing-product-sync.event.d.ts.map +1 -0
- package/dist/types/events/event-initializations.d.ts +2 -0
- package/dist/types/events/event-initializations.d.ts.map +1 -0
- package/dist/types/index.d.ts +8175 -33
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +7630 -2
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +0 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +6 -6
- package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/deal-setting/services/deal-setting.service.d.ts.map +1 -1
- package/dist/types/modules/featured-setting/services/featured-setting.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +54 -8
- package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/jobs/index.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
- package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +16 -3
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts +2 -0
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +242 -35
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts +8 -1
- package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts +3 -0
- package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +1 -1
- package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +249 -18
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts +2 -0
- package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts +24 -3
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +10 -0
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +195 -10
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +1 -0
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +428 -33
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +7 -4
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +14 -3
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts +13 -0
- package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts +21 -0
- package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts.map +1 -0
- package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts +1 -0
- package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
- package/dist/types/modules/marketing/routers/marketing.router.d.ts +14 -0
- package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/index.d.ts +3 -0
- package/dist/types/modules/marketing/services/index.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/marketing-conflict.repository.d.ts +9 -0
- package/dist/types/modules/marketing/services/marketing-conflict.repository.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/marketing-conflict.service.d.ts +41 -0
- package/dist/types/modules/marketing/services/marketing-conflict.service.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/marketing.service.d.ts +7 -2
- package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/product-marketing.service.d.ts +7 -3
- package/dist/types/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/spend-to-get-marketing.repository.d.ts +14 -0
- package/dist/types/modules/marketing/services/spend-to-get-marketing.repository.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/spend-to-get-marketing.service.d.ts +20 -0
- package/dist/types/modules/marketing/services/spend-to-get-marketing.service.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/spend-to-get-progress.repository.d.ts +9 -0
- package/dist/types/modules/marketing/services/spend-to-get-progress.repository.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts +37 -0
- package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/all-marketings.validation.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +3 -3
- package/dist/types/modules/marketing/validations/discount-marketing.validation.d.ts +3 -3
- package/dist/types/modules/marketing/validations/index.d.ts +1 -0
- package/dist/types/modules/marketing/validations/index.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/marketing.validation.d.ts +17 -0
- package/dist/types/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
- package/dist/types/modules/marketing/validations/spend-to-get-marketing.validation.d.ts +630 -0
- package/dist/types/modules/marketing/validations/spend-to-get-marketing.validation.d.ts.map +1 -0
- package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
- package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +0 -5
- package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
- package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
- package/dist/types/modules/spend-to-get-history/routers/index.d.ts +2 -0
- package/dist/types/modules/spend-to-get-history/routers/index.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/services/index.d.ts +2 -0
- package/dist/types/modules/spend-to-get-history/services/index.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts +56 -0
- package/dist/types/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +24 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts +271 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts +56 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +241 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/validations/index.d.ts +2 -0
- package/dist/types/modules/spend-to-get-history/validations/index.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts +241 -0
- package/dist/types/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts.map +1 -0
- package/dist/types/modules/tournament/config/tournament-config.validation.d.ts +201 -0
- package/dist/types/modules/tournament/config/tournament-config.validation.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts +2 -0
- package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/events/match-ended.event.d.ts +14 -0
- package/dist/types/modules/tournament/match/events/match-ended.event.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +10 -0
- package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +9 -0
- package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +10 -0
- package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +10 -0
- package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpendToGetTierSchema = exports.UpdateSpendToGetMarketingSchema = exports.SpendToGetMarketingIdValidationSchema = exports.SpendToGetMarketingSchema = exports.SpendToGetMarketingValidationSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const global_validation_1 = require("@lyxa.ai/core/dist/utilities/validation/global-validation");
|
|
6
|
+
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
7
|
+
const marketing_validation_1 = require("./marketing.validation");
|
|
8
|
+
const SpendToGetTierSchema = zod_1.z
|
|
9
|
+
.object({
|
|
10
|
+
minSpend: global_validation_1.ZodValidation.number('Minimum spend', { isNonnegative: true }),
|
|
11
|
+
rewardType: global_validation_1.ZodValidation.enumType(enum_1.SpendToGetRewardType, 'Reward type'),
|
|
12
|
+
rewardValue: global_validation_1.ZodValidation.number('Reward value').optional(),
|
|
13
|
+
maxDiscountCap: global_validation_1.ZodValidation.number('Maximum discount cap').optional(),
|
|
14
|
+
isMaxDiscountCapEnabled: global_validation_1.ZodValidation.boolean('Is maximum discount cap enabled').default(false),
|
|
15
|
+
})
|
|
16
|
+
.superRefine((tier, ctx) => {
|
|
17
|
+
if (tier.rewardType === enum_1.SpendToGetRewardType.FREE_DELIVERY) {
|
|
18
|
+
if (tier.rewardValue !== undefined) {
|
|
19
|
+
ctx.addIssue({
|
|
20
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
21
|
+
message: 'Reward value is not applicable for Free Delivery',
|
|
22
|
+
path: ['rewardValue'],
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else if (tier.rewardValue === undefined) {
|
|
27
|
+
ctx.addIssue({
|
|
28
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
29
|
+
message: 'Reward value is required',
|
|
30
|
+
path: ['rewardValue'],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else if (tier.rewardType === enum_1.SpendToGetRewardType.PERCENTAGE) {
|
|
34
|
+
if (tier.rewardValue < 1 || tier.rewardValue > 100) {
|
|
35
|
+
ctx.addIssue({
|
|
36
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
37
|
+
message: 'Percentage reward value must be between 1 and 100',
|
|
38
|
+
path: ['rewardValue'],
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (tier.rewardType === enum_1.SpendToGetRewardType.FIXED) {
|
|
43
|
+
if (tier.rewardValue <= 0) {
|
|
44
|
+
ctx.addIssue({
|
|
45
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
46
|
+
message: 'Fixed reward value must be greater than 0',
|
|
47
|
+
path: ['rewardValue'],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (tier.rewardValue >= tier.minSpend) {
|
|
51
|
+
ctx.addIssue({
|
|
52
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
53
|
+
message: "Fixed reward value must be less than the tier's minimum spend",
|
|
54
|
+
path: ['rewardValue'],
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (tier.maxDiscountCap !== undefined && tier.rewardType !== enum_1.SpendToGetRewardType.PERCENTAGE) {
|
|
59
|
+
ctx.addIssue({
|
|
60
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
61
|
+
message: 'Maximum discount cap only applies to Percentage rewards',
|
|
62
|
+
path: ['maxDiscountCap'],
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
exports.SpendToGetTierSchema = SpendToGetTierSchema;
|
|
67
|
+
const baseFields = {
|
|
68
|
+
...marketing_validation_1.baseMarketingFields,
|
|
69
|
+
marketingType: zod_1.z.literal(enum_1.MarketingType.SPEND_TO_GET),
|
|
70
|
+
tiers: global_validation_1.ZodValidation.array(SpendToGetTierSchema, 'Tiers', 1),
|
|
71
|
+
perUserLimit: global_validation_1.ZodValidation.number('Per user limit', { isPositive: true }).optional(),
|
|
72
|
+
isPerUserLimitEnabled: global_validation_1.ZodValidation.boolean('Is per user limit enabled').default(false),
|
|
73
|
+
spendLimit: global_validation_1.ZodValidation.number('Spend limit').default(0),
|
|
74
|
+
isSpendLimitEnabled: global_validation_1.ZodValidation.boolean('Is spend limit enabled').default(false),
|
|
75
|
+
};
|
|
76
|
+
const schemaBuilder = (0, global_validation_1.createSchemaBuilder)(baseFields);
|
|
77
|
+
const { BaseSchema: SpendToGetMarketingValidationSchemaWithoutRefinement, EntitySchema: SpendToGetMarketingSchema, IdSchema: SpendToGetMarketingIdSchema, UpdateSchema: UpdateSpendToGetMarketingSchemaWithoutRefinement, } = schemaBuilder.getAllSchemas({ createdAt: true });
|
|
78
|
+
exports.SpendToGetMarketingSchema = SpendToGetMarketingSchema;
|
|
79
|
+
exports.SpendToGetMarketingIdValidationSchema = SpendToGetMarketingIdSchema;
|
|
80
|
+
function addAscendingTierIssues(tiers, ctx) {
|
|
81
|
+
for (let i = 1; i < tiers.length; i++) {
|
|
82
|
+
if (tiers[i].minSpend <= tiers[i - 1].minSpend) {
|
|
83
|
+
ctx.addIssue({
|
|
84
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
85
|
+
message: "Each tier's minimum spend must be higher than the previous tier.",
|
|
86
|
+
path: ['tiers', i, 'minSpend'],
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function addLimitIssues(data, ctx) {
|
|
92
|
+
if (data.isSpendLimitEnabled && (!data.spendLimit || data.spendLimit <= 0)) {
|
|
93
|
+
ctx.addIssue({
|
|
94
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
95
|
+
message: 'Spend limit must be greater than 0 when enabled',
|
|
96
|
+
path: ['spendLimit', 'isSpendLimitEnabled'],
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (data.isPerUserLimitEnabled && (!data.perUserLimit || data.perUserLimit <= 0)) {
|
|
100
|
+
ctx.addIssue({
|
|
101
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
102
|
+
message: 'Per user limit must be greater than 0 when enabled',
|
|
103
|
+
path: ['perUserLimit', 'isPerUserLimitEnabled'],
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const SpendToGetMarketingValidationSchema = SpendToGetMarketingValidationSchemaWithoutRefinement.superRefine((data, ctx) => {
|
|
108
|
+
addAscendingTierIssues(data.tiers, ctx);
|
|
109
|
+
addLimitIssues(data, ctx);
|
|
110
|
+
});
|
|
111
|
+
exports.SpendToGetMarketingValidationSchema = SpendToGetMarketingValidationSchema;
|
|
112
|
+
const UpdateSpendToGetMarketingSchema = UpdateSpendToGetMarketingSchemaWithoutRefinement.superRefine((data, ctx) => {
|
|
113
|
+
if (data.tiers) {
|
|
114
|
+
addAscendingTierIssues(data.tiers, ctx);
|
|
115
|
+
}
|
|
116
|
+
addLimitIssues(data, ctx);
|
|
117
|
+
});
|
|
118
|
+
exports.UpdateSpendToGetMarketingSchema = UpdateSpendToGetMarketingSchema;
|
|
119
|
+
//# sourceMappingURL=spend-to-get-marketing.validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spend-to-get-marketing.validation.js","sourceRoot":"/","sources":["modules/marketing/validations/spend-to-get-marketing.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,iGAImE;AACnE,4DAAwF;AACxF,iEAA6D;AAM7D,MAAM,oBAAoB,GAAG,OAAC;KAC5B,MAAM,CAAC;IACP,QAAQ,EAAE,iCAAa,CAAC,MAAM,CAAC,eAAe,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IACxE,UAAU,EAAE,iCAAa,CAAC,QAAQ,CAAC,2BAAoB,EAAE,aAAa,CA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YAC3B,OAAO,EAAE,iDAAiD;YAC1D,IAAI,EAAE,CAAC,YAAY,EAAE,qBAAqB,CAAC;SAC3C,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,CAAC,qBAAqB,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,EAAE,CAAC;QAClF,GAAG,CAAC,QAAQ,CAAC;YACZ,IAAI,EAAE,OAAC,CAAC,YAAY,CAAC,MAAM;YAC3B,OAAO,EAAE,oDAAoD;YAC7D,IAAI,EAAE,CAAC,cAAc,EAAE,uBAAuB,CAAC;SAC/C,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAED,MAAM,mCAAmC,GAAG,oDAAoD,CAAC,WAAW,CAC3G,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IACb,sBAAsB,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACxC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC3B,CAAC,CACD,CAAC;AAeD,kFAAmC;AAbpC,MAAM,+BAA+B,GAAG,gDAAgD,CAAC,WAAW,CACnG,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IACb,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAChB,sBAAsB,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IACD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC3B,CAAC,CACD,CAAC;AASD,0EAA+B","sourcesContent":["import { z } from 'zod';\nimport {\n\tZodValidation,\n\tcreateSchemaBuilder,\n\tDTO,\n} from '@lyxa.ai/core/dist/utilities/validation/global-validation';\nimport { MarketingType, SpendToGetRewardType } from '@lyxa.ai/core/dist/utilities/enum';\nimport { baseMarketingFields } from './marketing.validation';\n\n/**\n * Single spend tier: minimum spend + reward. Reward value is required for\n * PERCENTAGE/FIXED and forbidden for FREE_DELIVERY; maxDiscountCap only applies to PERCENTAGE.\n */\nconst SpendToGetTierSchema = z\n\t.object({\n\t\tminSpend: ZodValidation.number('Minimum spend', { isNonnegative: true }),\n\t\trewardType: ZodValidation.enumType(SpendToGetRewardType, 'Reward type'),\n\t\trewardValue: ZodValidation.number('Reward value').optional(),\n\t\tmaxDiscountCap: ZodValidation.number('Maximum discount cap').optional(),\n\t\tisMaxDiscountCapEnabled: ZodValidation.boolean('Is maximum discount cap enabled').default(false),\n\t})\n\t.superRefine((tier, ctx) => {\n\t\tif (tier.rewardType === SpendToGetRewardType.FREE_DELIVERY) {\n\t\t\tif (tier.rewardValue !== undefined) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\tmessage: 'Reward value is not applicable for Free Delivery',\n\t\t\t\t\tpath: ['rewardValue'],\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (tier.rewardValue === undefined) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\tmessage: 'Reward value is required',\n\t\t\t\tpath: ['rewardValue'],\n\t\t\t});\n\t\t} else if (tier.rewardType === SpendToGetRewardType.PERCENTAGE) {\n\t\t\tif (tier.rewardValue < 1 || tier.rewardValue > 100) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\tmessage: 'Percentage reward value must be between 1 and 100',\n\t\t\t\t\tpath: ['rewardValue'],\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (tier.rewardType === SpendToGetRewardType.FIXED) {\n\t\t\tif (tier.rewardValue <= 0) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\tmessage: 'Fixed reward value must be greater than 0',\n\t\t\t\t\tpath: ['rewardValue'],\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (tier.rewardValue >= tier.minSpend) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\tmessage: \"Fixed reward value must be less than the tier's minimum spend\",\n\t\t\t\t\tpath: ['rewardValue'],\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (tier.maxDiscountCap !== undefined && tier.rewardType !== SpendToGetRewardType.PERCENTAGE) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\tmessage: 'Maximum discount cap only applies to Percentage rewards',\n\t\t\t\tpath: ['maxDiscountCap'],\n\t\t\t});\n\t\t}\n\t});\n\n/**\n * Define the base parent schema fields\n */\nconst baseFields = {\n\t...baseMarketingFields,\n\tmarketingType: z.literal(MarketingType.SPEND_TO_GET),\n\ttiers: ZodValidation.array(SpendToGetTierSchema, 'Tiers', 1),\n\tperUserLimit: ZodValidation.number('Per user limit', { isPositive: true }).optional(),\n\tisPerUserLimitEnabled: ZodValidation.boolean('Is per user limit enabled').default(false),\n\tspendLimit: ZodValidation.number('Spend limit').default(0),\n\tisSpendLimitEnabled: ZodValidation.boolean('Is spend limit enabled').default(false),\n};\n\n/**\n * Create schema builder for Parent entity\n * - Includes timestamps\n * - Excludes 'createdAt' from update operations\n */\nconst schemaBuilder = createSchemaBuilder(baseFields);\n\n/**\n * Get all schemas for the Parent entity\n */\nconst {\n\tBaseSchema: SpendToGetMarketingValidationSchemaWithoutRefinement,\n\tEntitySchema: SpendToGetMarketingSchema,\n\tIdSchema: SpendToGetMarketingIdSchema,\n\tUpdateSchema: UpdateSpendToGetMarketingSchemaWithoutRefinement,\n} = schemaBuilder.getAllSchemas({ createdAt: true });\n\nfunction addAscendingTierIssues(tiers: { minSpend: number }[], ctx: z.RefinementCtx): void {\n\tfor (let i = 1; i < tiers.length; i++) {\n\t\tif (tiers[i].minSpend <= tiers[i - 1].minSpend) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\tmessage: \"Each tier's minimum spend must be higher than the previous tier.\",\n\t\t\t\tpath: ['tiers', i, 'minSpend'],\n\t\t\t});\n\t\t}\n\t}\n}\n\nfunction addLimitIssues(\n\tdata: {\n\t\tisSpendLimitEnabled?: boolean;\n\t\tspendLimit?: number;\n\t\tisPerUserLimitEnabled?: boolean;\n\t\tperUserLimit?: number;\n\t},\n\tctx: z.RefinementCtx\n): void {\n\tif (data.isSpendLimitEnabled && (!data.spendLimit || data.spendLimit <= 0)) {\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: 'Spend limit must be greater than 0 when enabled',\n\t\t\tpath: ['spendLimit', 'isSpendLimitEnabled'],\n\t\t});\n\t}\n\n\tif (data.isPerUserLimitEnabled && (!data.perUserLimit || data.perUserLimit <= 0)) {\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: 'Per user limit must be greater than 0 when enabled',\n\t\t\tpath: ['perUserLimit', 'isPerUserLimitEnabled'],\n\t\t});\n\t}\n}\n\nconst SpendToGetMarketingValidationSchema = SpendToGetMarketingValidationSchemaWithoutRefinement.superRefine(\n\t(data, ctx) => {\n\t\taddAscendingTierIssues(data.tiers, ctx);\n\t\taddLimitIssues(data, ctx);\n\t}\n);\n\nconst UpdateSpendToGetMarketingSchema = UpdateSpendToGetMarketingSchemaWithoutRefinement.superRefine(\n\t(data, ctx) => {\n\t\tif (data.tiers) {\n\t\t\taddAscendingTierIssues(data.tiers, ctx);\n\t\t}\n\t\taddLimitIssues(data, ctx);\n\t}\n);\n\n/**\n * Export schemas\n */\nexport {\n\tSpendToGetMarketingValidationSchema,\n\tSpendToGetMarketingSchema,\n\tSpendToGetMarketingIdSchema as SpendToGetMarketingIdValidationSchema,\n\tUpdateSpendToGetMarketingSchema,\n\tSpendToGetTierSchema,\n};\n\n/**\n * Export DTO types\n */\nexport type CreateSpendToGetMarketingDTO = DTO<typeof SpendToGetMarketingValidationSchema>;\nexport type SpendToGetMarketingDTO = DTO<typeof SpendToGetMarketingSchema>;\nexport type UpdateSpendToGetMarketingDTO = DTO<typeof UpdateSpendToGetMarketingSchema>;\nexport type SpendToGetTierDTO = DTO<typeof SpendToGetTierSchema>;\n"]}
|
package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts
CHANGED
|
@@ -18,8 +18,8 @@ export declare const punchMarketingHistoryRouter: import("@trpc/server").TRPCBui
|
|
|
18
18
|
input: {
|
|
19
19
|
user: string | import("mongoose").Types.ObjectId;
|
|
20
20
|
shop: string | import("mongoose").Types.ObjectId;
|
|
21
|
-
minimumOrderValue: number;
|
|
22
21
|
marketing: string | import("mongoose").Types.ObjectId;
|
|
22
|
+
minimumOrderValue: number;
|
|
23
23
|
targetOrder: number;
|
|
24
24
|
couponValueType: import("@lyxa.ai/core/dist/utilities/enum").ValueType;
|
|
25
25
|
couponValue: number;
|
package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export declare class PunchMarketingHistoryService {
|
|
|
19
19
|
private createNewHistory;
|
|
20
20
|
applyPunchDiscountToOrder(userId: mongoose.Types.ObjectId, orderId: mongoose.Types.ObjectId): Promise<void>;
|
|
21
21
|
getPunchDiscount(data: ValidateCouponDTO): Promise<CouponValidationOutputDTO>;
|
|
22
|
-
getPunchDiscountForAdjust(data: ValidateCouponDTO): Promise<CouponValidationOutputDTO>;
|
|
23
22
|
getPunchCoupon(user: mongoose.Types.ObjectId, shop: mongoose.Types.ObjectId): Promise<any>;
|
|
24
23
|
returnPunchCoupon(orderId: mongoose.Types.ObjectId): Promise<void>;
|
|
25
24
|
}
|
package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"punch-marketing-history.service.d.ts","sourceRoot":"/","sources":["modules/punch-marketing-history/services/punch-marketing-history.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AAC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AAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"punch-marketing-history.service.d.ts","sourceRoot":"/","sources":["modules/punch-marketing-history/services/punch-marketing-history.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAElG,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAEN,qBAAqB,IAAI,KAAK,EAK9B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACN,8BAA8B,IAAI,SAAS,EAC3C,mBAAmB,EACnB,8BAA8B,IAAI,SAAS,EAC3C,MAAM,8CAA8C,CAAC;AAWtD,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAO3F,qBACa,4BAA4B;IACxC,OAAO,CAAC,KAAK,CAA6D;IAC1E,OAAO,CAAC,cAAc,CAA+D;IACrF,OAAO,CAAC,UAAU,CAA2D;;IAYhE,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAQrD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAkB5E,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAyB3F,gBAAgB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC;IAuCzD,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IA2BjE,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IAmB5C,oBAAoB,CAChC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAC9B,OAAO,CAAC,MAAM,CAAC;YA0DJ,gBAAgB;IA+CjB,yBAAyB,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ;IA0C3F,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IA2D7E,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IA6C1F,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAkB/E;AAED,eAAO,MAAM,4BAA4B,8BAA8C,CAAC"}
|
package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js
CHANGED
|
@@ -172,8 +172,7 @@ let PunchMarketingHistoryService = class PunchMarketingHistoryService {
|
|
|
172
172
|
status: enum_1.PunchMarketingStatus.ACTIVE,
|
|
173
173
|
});
|
|
174
174
|
if (existingHistory) {
|
|
175
|
-
if (
|
|
176
|
-
existingHistory.minimumOrderValue) {
|
|
175
|
+
if (order.finance.pricing.subtotal ?? 0 >= existingHistory.minimumOrderValue) {
|
|
177
176
|
const completedAt = existingHistory.targetOrder == existingHistory.completedOrder + 1 ? new Date() : null;
|
|
178
177
|
const couponExpiryDate = completedAt
|
|
179
178
|
? (0, dayjs_1.dayjs)(completedAt).add(existingHistory.couponDurationInDays, 'day').toDate()
|
|
@@ -226,8 +225,7 @@ let PunchMarketingHistoryService = class PunchMarketingHistoryService {
|
|
|
226
225
|
const couponExpiryDate = completedAt
|
|
227
226
|
? (0, dayjs_1.dayjs)(completedAt).add(marketing.couponDurationInDays, 'day').toDate()
|
|
228
227
|
: null;
|
|
229
|
-
if (
|
|
230
|
-
marketing.minimumOrderValue) {
|
|
228
|
+
if (order.finance.pricing.subtotal ?? 0 >= marketing.minimumOrderValue) {
|
|
231
229
|
const data = {
|
|
232
230
|
user: userId,
|
|
233
231
|
shop: order.shop,
|
|
@@ -322,51 +320,6 @@ let PunchMarketingHistoryService = class PunchMarketingHistoryService {
|
|
|
322
320
|
},
|
|
323
321
|
};
|
|
324
322
|
}
|
|
325
|
-
async getPunchDiscountForAdjust(data) {
|
|
326
|
-
const punchHistory = await this.model.findOne({
|
|
327
|
-
user: data.user,
|
|
328
|
-
shop: data.shop,
|
|
329
|
-
couponExpiryDate: { $gte: new Date() },
|
|
330
|
-
status: enum_1.PunchMarketingStatus.COUPON_USED,
|
|
331
|
-
});
|
|
332
|
-
if (!punchHistory) {
|
|
333
|
-
return {
|
|
334
|
-
isValid: false,
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
if (data.scheduledAt &&
|
|
338
|
-
Boolean(punchHistory.couponExpiryDate) &&
|
|
339
|
-
(0, dayjs_1.dayjs)(punchHistory.couponExpiryDate).isBefore(data.scheduledAt)) {
|
|
340
|
-
return {
|
|
341
|
-
isValid: false,
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
let discountAmount = punchHistory.couponValueType == enum_1.ValueType.FIXED
|
|
345
|
-
? punchHistory.couponValue
|
|
346
|
-
: (0, shared_1.roundBaseCurrency)((punchHistory.couponValue / 100) * data.amountBeforeCoupon);
|
|
347
|
-
let secondaryDiscountAmount = punchHistory.couponValueType == enum_1.ValueType.FIXED
|
|
348
|
-
? await (0, currency_1.convertToSecondary)(punchHistory.couponValue)
|
|
349
|
-
: (0, shared_1.roundSecondaryCurrency)((punchHistory.couponValue / 100) * data.secondaryAmountBeforeCoupon);
|
|
350
|
-
if (discountAmount > data.amountBeforeCoupon) {
|
|
351
|
-
discountAmount = data.amountBeforeCoupon;
|
|
352
|
-
}
|
|
353
|
-
if (secondaryDiscountAmount > data.secondaryAmountBeforeCoupon) {
|
|
354
|
-
secondaryDiscountAmount = data.secondaryAmountBeforeCoupon;
|
|
355
|
-
}
|
|
356
|
-
return {
|
|
357
|
-
isValid: true,
|
|
358
|
-
discountAmount,
|
|
359
|
-
secondaryDiscountAmount,
|
|
360
|
-
amountAfterCoupon: Math.max(0, (0, shared_1.roundBaseCurrency)(data.amountBeforeCoupon - discountAmount)),
|
|
361
|
-
secondaryAmountAfterCoupon: Math.max(0, (0, shared_1.roundSecondaryCurrency)(data.secondaryAmountBeforeCoupon - secondaryDiscountAmount)),
|
|
362
|
-
discountCut: {
|
|
363
|
-
companyCut: 0,
|
|
364
|
-
secondaryCompanyCut: 0,
|
|
365
|
-
shopCut: discountAmount,
|
|
366
|
-
secondaryShopCut: secondaryDiscountAmount,
|
|
367
|
-
},
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
323
|
async getPunchCoupon(user, shop) {
|
|
371
324
|
const punchHistory = await this.model.findOne({
|
|
372
325
|
user: user,
|
package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"punch-marketing-history.service.js","sourceRoot":"/","sources":["modules/punch-marketing-history/services/punch-marketing-history.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAA0E;AAC1E,iDAA4C;AAC5C,yCAAyC;AAGzC,wEAA6G;AAE7G,sEAOmD;AAOnD,4DAM2C;AAC3C,8DAA2D;AAG3D,oEAA2E;AAC3E,gEAAgG;AAChG,wCAA6C;AAC7C,8FAA+I;AAC/I,6JAAsI;AAG/H,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAChC,KAAK,CAA6D;IAClE,cAAc,CAA+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\nimport Container, { Service } from 'typedi';\nimport { TRPCError } from '@trpc/server';\nimport { DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';\nimport { FilterDTO, PaginatedResponse, DeleteDTO } from '@lyxa.ai/core/dist/utilities/validation';\nimport { createRawDocumentPaginatorObject, PaginatorOptions } from '@lyxa.ai/core/dist/utilities/pagination';\nimport { ModelType } from '@typegoose/typegoose/lib/types';\nimport {\n\tPunchMarketingHistoryModel,\n\tPunchMarketingHistory as Model,\n\tPunchMarketingModel,\n\tPunchMarketing,\n\tRegularOrder,\n\tRegularOrderModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {\n\tCreatePunchMarketingHistoryDTO as CreateDTO,\n\tGetByUserAndShopDTO,\n\tUpdatePunchMarketingHistoryDTO as UpdateDTO,\n} from '@modules/punch-marketing-history/validations';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {\n\tCouponType,\n\tMarketingType,\n\tPunchMarketingStatus,\n\tStatus,\n\tValueType,\n} from '@lyxa.ai/core/dist/utilities/enum';\nimport { dayjs } from '@lyxa.ai/core/dist/utilities/dayjs';\nimport { PunchMarketingSchema, PunchMarketingValidationSchema } from '@modules/marketing/validations';\nimport { CouponValidationOutputDTO, ValidateCouponDTO } from '@modules/coupon/validations';\nimport { convertToSecondary } from '@lyxa.ai/core/dist/utilities/currency';\nimport { roundBaseCurrency, roundSecondaryCurrency } from '@lyxa.ai/core/dist/utilities/shared';\nimport { getLibraries } from '@lyxa.ai/core';\nimport { publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent } from '@lyxa.ai/core/dist/utilities/events-common-methods';\nimport { ChangeStreamOperationTypes } from '@lyxa.ai/core/dist/libraries/event/events/mongo-stream-changes-batch-process-shops-event';\n\n@Service()\nexport class PunchMarketingHistoryService {\n\tprivate model: typeof PunchMarketingHistoryModel & SoftDeleteModel<Model>;\n\tprivate marketingModel: typeof PunchMarketingModel & SoftDeleteModel<PunchMarketing>;\n\tprivate orderModel: typeof RegularOrderModel & SoftDeleteModel<RegularOrder>;\n\n\tconstructor() {\n\t\tthis.model = PunchMarketingHistoryModel as typeof PunchMarketingHistoryModel & SoftDeleteModel<Model>;\n\t\tthis.marketingModel = PunchMarketingModel as typeof PunchMarketingModel & SoftDeleteModel<PunchMarketing>;\n\t\tthis.orderModel = RegularOrderModel as typeof RegularOrderModel & SoftDeleteModel<RegularOrder>;\n\t}\n\n\t/**\n\t * Create a new record\n\t * @param data Data for the new record\n\t */\n\tpublic async create(data: CreateDTO): Promise<DocumentType<Model>> {\n\t\treturn await this.model.create(data);\n\t}\n\n\t/**\n\t * Get record by ID\n\t * @param id ID of the record\n\t */\n\tpublic async findById(id: string | mongoose.Types.ObjectId): Promise<DocumentType<Model>> {\n\t\tconst result = await this.model.findOne({\n\t\t\t_id: id,\n\t\t\tdeletedAt: null,\n\t\t});\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get records\n\t * @param query Query to find records\n\t */\n\tpublic async find(data?: Partial<FilterDTO>): Promise<PaginatedResponse<DocumentType<ModelType<Model>>>> {\n\t\ttry {\n\t\t\tconst paginate = createRawDocumentPaginatorObject(this.model as ReturnModelType<typeof this.model>);\n\t\t\tconst options: PaginatorOptions<typeof Model> = {\n\t\t\t\tpage: data?.page,\n\t\t\t\tsize: data?.size,\n\t\t\t\tsort: data?.sort,\n\t\t\t\tquery: data?.query,\n\t\t\t\tselect: data?.select,\n\t\t\t\tpopulate: data?.populate,\n\t\t\t};\n\t\t\tconst paginatedResult = await paginate(options);\n\t\t\treturn paginatedResult;\n\t\t} catch (err) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: `err: ${err}`,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get Record\n\t * @param UserId ShopId to find records\n\t */\n\tpublic async getByUserAndShop(data: GetByUserAndShopDTO): Promise<any> {\n\t\tlet result = await this.model.findOne({\n\t\t\tuser: data.userId,\n\t\t\tshop: data.shopId,\n\t\t\texpiryDate: { $gt: new Date() },\n\t\t\tcompletedAt: null,\n\t\t\tstatus: PunchMarketingStatus.ACTIVE,\n\t\t});\n\n\t\tif (result) return result;\n\n\t\tconst marketing = await this.marketingModel.findOne({\n\t\t\tmarketingType: MarketingType.PUNCH_MARKETING,\n\t\t\tshop: data.shopId,\n\t\t\tstatus: Status.ACTIVE,\n\t\t\t'duration.start': { $lt: new Date() },\n\t\t\t'duration.end': { $gt: new Date() },\n\t\t});\n\n\t\tif (!marketing) notFoundError('No Punch Marketing is Active For This Shop...');\n\n\t\treturn {\n\t\t\tuser: data.userId,\n\t\t\tshop: data.shopId,\n\t\t\tmarketing: marketing!._id,\n\t\t\ttargetOrder: marketing.targetOrders,\n\t\t\tminimumOrderValue: marketing.minimumOrderValue,\n\t\t\tcompletedOrder: 0,\n\t\t\tcouponValueType: marketing.couponValueType,\n\t\t\tcouponValue: marketing.couponValue,\n\t\t\tcouponDurationInDays: marketing.couponDurationInDays,\n\t\t};\n\t}\n\n\t/**\n\t * Update record\n\t * @param id ID of the record\n\t * @param data Data to update\n\t */\n\tpublic async update(id: string, data: UpdateDTO): Promise<DocumentType<Model>> {\n\t\tconst record = await this.model.findOneAndUpdate(\n\t\t\t{\n\t\t\t\t_id: id,\n\t\t\t\tdeletedAt: null,\n\t\t\t},\n\t\t\tdata,\n\t\t\t{\n\t\t\t\tnew: true,\n\t\t\t\trunValidators: true,\n\t\t\t}\n\t\t);\n\n\t\tif (!record) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: `Record not found`,\n\t\t\t});\n\t\t}\n\n\t\treturn record;\n\t}\n\n\t/**\n\t * Delete record\n\t * @param data Data for delete\n\t */\n\tpublic async deleteById(data: DeleteDTO): Promise<string> {\n\t\tconst { _id, softDelete } = data;\n\n\t\tconst result = await this.model.deleteRecord({ _id, deletedAt: null }, softDelete);\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\n\t\treturn 'Record deleted successfully';\n\t}\n\n\t/**\n\t * Increment punch history for user\n\t * @param userId User ID\n\t * @param orderId Order ID\n\t */\n\tpublic async incrementUserHistory(\n\t\tuserId: mongoose.Types.ObjectId,\n\t\torderId: mongoose.Types.ObjectId\n\t): Promise<string> {\n\t\tconst order = await this.orderModel.findById(orderId);\n\n\t\tif (!order || order.user.toString != userId.toString) {\n\t\t\tnotFoundError('Order not found');\n\t\t}\n\n\t\tconst existingHistory = await this.model.findOne({\n\t\t\tuser: userId,\n\t\t\tshop: order.shop,\n\t\t\texpiryDate: { $gt: new Date() },\n\t\t\tcompletedAt: null,\n\t\t\tstatus: PunchMarketingStatus.ACTIVE,\n\t\t});\n\n\t\tif (existingHistory) {\n\t\t\tif (\n\t\t\t\troundBaseCurrency((order.finance.pricing.subtotal ?? 0) - (order.finance.pricing.discount ?? 0)) >=\n\t\t\t\texistingHistory.minimumOrderValue\n\t\t\t) {\n\t\t\t\tconst completedAt =\n\t\t\t\t\texistingHistory.targetOrder == existingHistory.completedOrder + 1 ? new Date() : null;\n\t\t\t\tconst couponExpiryDate = completedAt\n\t\t\t\t\t? dayjs(completedAt).add(existingHistory.couponDurationInDays, 'day').toDate()\n\t\t\t\t\t: null;\n\t\t\t\tconst status = completedAt ? PunchMarketingStatus.COMPLETED : PunchMarketingStatus.ACTIVE;\n\n\t\t\t\tawait this.model.findByIdAndUpdate(\n\t\t\t\t\texistingHistory._id,\n\t\t\t\t\t{\n\t\t\t\t\t\t$inc: {\n\t\t\t\t\t\t\tcompletedOrder: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcompletedAt,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t\tcouponExpiryDate,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tnew: true,\n\t\t\t\t\t\trunValidators: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tawait this.createNewHistory(userId, order);\n\t\t}\n\n\t\tawait publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent({\n\t\t\tuserId,\n\t\t\tshopId: order.shop._id,\n\t\t\toperation: ChangeStreamOperationTypes.UPDATE,\n\t\t});\n\n\t\treturn 'Record updated successfully';\n\t}\n\n\t/**\n\t * Create new history with current punch marketing of the shop\n\t * @param userId User ID\n\t * @param order Order document\n\t */\n\tprivate async createNewHistory(userId: mongoose.Types.ObjectId, order: DocumentType<RegularOrder>) {\n\t\tconst marketing = await this.marketingModel.findOne({\n\t\t\tmarketingType: MarketingType.PUNCH_MARKETING,\n\t\t\tshop: order.shop,\n\t\t\tstatus: Status.ACTIVE,\n\t\t\t'duration.start': { $lt: new Date() },\n\t\t\t'duration.end': { $gt: new Date() },\n\t\t});\n\n\t\tif (!marketing) notFoundError('Marketing Not Found');\n\n\t\tconst expiryDate = dayjs().add(marketing.dayLimit, 'day').toDate();\n\t\tconst couponDurationInDays = marketing!.couponDurationInDays;\n\t\tconst couponValue = marketing!.couponValue;\n\t\tconst couponValueType = marketing!.couponValueType;\n\t\tconst targetOrder = marketing!.targetOrders;\n\t\tconst minimumOrderValue = marketing!.minimumOrderValue;\n\t\tconst completedOrder = 1;\n\t\tconst status =\n\t\t\tmarketing!.targetOrders == completedOrder\n\t\t\t\t? PunchMarketingStatus.COMPLETED\n\t\t\t\t: PunchMarketingStatus.ACTIVE;\n\t\tconst completedAt = marketing!.targetOrders == completedOrder ? new Date() : null;\n\t\tconst couponExpiryDate = completedAt\n\t\t\t? dayjs(completedAt).add(marketing!.couponDurationInDays, 'day').toDate()\n\t\t\t: null;\n\n\t\tif (\n\t\t\troundBaseCurrency((order.finance.pricing.subtotal ?? 0) - (order.finance.pricing.discount ?? 0)) >=\n\t\t\tmarketing.minimumOrderValue\n\t\t) {\n\t\t\tconst data: CreateDTO = {\n\t\t\t\tuser: userId as mongoose.Types.ObjectId,\n\t\t\t\tshop: order!.shop as mongoose.Types.ObjectId,\n\t\t\t\tmarketing: marketing!._id as mongoose.Types.ObjectId,\n\t\t\t\ttargetOrder,\n\t\t\t\tminimumOrderValue,\n\t\t\t\tcompletedOrder,\n\t\t\t\tstatus,\n\t\t\t\tcouponValueType,\n\t\t\t\tcouponValue,\n\t\t\t\tcouponDurationInDays,\n\t\t\t\texpiryDate,\n\t\t\t\t...(completedAt && { completedAt }),\n\t\t\t\t...(couponExpiryDate && { couponExpiryDate }),\n\t\t\t};\n\t\t\tawait this.create(data);\n\t\t}\n\t}\n\n\tpublic async applyPunchDiscountToOrder(userId: mongoose.Types.ObjectId, orderId: mongoose.Types.ObjectId) {\n\t\tconst order = await this.orderModel.findById(orderId);\n\t\tif (!order) notFoundError('Order not found');\n\n\t\tconst punchHistory = await this.model.findOneAndUpdate(\n\t\t\t{\n\t\t\t\tuser: userId,\n\t\t\t\tshop: order.shop,\n\t\t\t\tcouponExpiryDate: { $gte: new Date() },\n\t\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t\t},\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\torder: orderId,\n\t\t\t\t\tstatus: PunchMarketingStatus.COUPON_USED,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tnew: true,\n\t\t\t\trunValidators: true,\n\t\t\t}\n\t\t);\n\n\t\tif (!punchHistory) notFoundError('No valid punch coupon available');\n\n\t\tawait this.orderModel.findByIdAndUpdate(orderId, {\n\t\t\t$push: {\n\t\t\t\tmarketings: punchHistory.marketing,\n\t\t\t},\n\t\t});\n\n\t\tawait publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent({\n\t\t\tuserId,\n\t\t\tshopId: order.shop._id,\n\t\t\toperation: ChangeStreamOperationTypes.DELETE,\n\t\t});\n\t}\n\n\t/**\n\t * Get punch discount\n\t * @param data Data to use for validating discount\n\t */\n\tpublic async getPunchDiscount(data: ValidateCouponDTO): Promise<CouponValidationOutputDTO> {\n\t\tconst punchHistory = await this.model.findOne({\n\t\t\tuser: data.user,\n\t\t\tshop: data.shop,\n\t\t\tcouponExpiryDate: { $gte: new Date() },\n\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t});\n\n\t\tif (!punchHistory) {\n\t\t\treturn {\n\t\t\t\tisValid: false,\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tdata.scheduledAt &&\n\t\t\tBoolean(punchHistory.couponExpiryDate) &&\n\t\t\tdayjs(punchHistory.couponExpiryDate).isBefore(data.scheduledAt)\n\t\t) {\n\t\t\treturn {\n\t\t\t\tisValid: false,\n\t\t\t};\n\t\t}\n\n\t\tlet discountAmount =\n\t\t\tpunchHistory.couponValueType == ValueType.FIXED\n\t\t\t\t? punchHistory.couponValue\n\t\t\t\t: roundBaseCurrency((punchHistory.couponValue / 100) * data.amountBeforeCoupon);\n\n\t\tlet secondaryDiscountAmount =\n\t\t\tpunchHistory.couponValueType == ValueType.FIXED\n\t\t\t\t? await convertToSecondary(punchHistory.couponValue)\n\t\t\t\t: roundSecondaryCurrency((punchHistory.couponValue / 100) * data.secondaryAmountBeforeCoupon);\n\n\t\tif (discountAmount > data.amountBeforeCoupon) {\n\t\t\tdiscountAmount = data.amountBeforeCoupon;\n\t\t}\n\t\tif (secondaryDiscountAmount > data.secondaryAmountBeforeCoupon) {\n\t\t\tsecondaryDiscountAmount = data.secondaryAmountBeforeCoupon;\n\t\t}\n\n\t\treturn {\n\t\t\tisValid: true,\n\t\t\tdiscountAmount,\n\t\t\tsecondaryDiscountAmount,\n\t\t\tamountAfterCoupon: Math.max(0, roundBaseCurrency(data.amountBeforeCoupon - discountAmount)),\n\t\t\tsecondaryAmountAfterCoupon: Math.max(\n\t\t\t\t0,\n\t\t\t\troundSecondaryCurrency(data.secondaryAmountBeforeCoupon - secondaryDiscountAmount)\n\t\t\t),\n\t\t\tdiscountCut: {\n\t\t\t\tcompanyCut: 0,\n\t\t\t\tsecondaryCompanyCut: 0,\n\t\t\t\tshopCut: discountAmount,\n\t\t\t\tsecondaryShopCut: secondaryDiscountAmount,\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Get punch discount for adjust order\n\t * @param data Data to use for validating discount\n\t */\n\tpublic async getPunchDiscountForAdjust(data: ValidateCouponDTO): Promise<CouponValidationOutputDTO> {\n\t\tconst punchHistory = await this.model.findOne({\n\t\t\tuser: data.user,\n\t\t\tshop: data.shop,\n\t\t\tcouponExpiryDate: { $gte: new Date() },\n\t\t\tstatus: PunchMarketingStatus.COUPON_USED,\n\t\t});\n\t\tif (!punchHistory) {\n\t\t\treturn {\n\t\t\t\tisValid: false,\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tdata.scheduledAt &&\n\t\t\tBoolean(punchHistory.couponExpiryDate) &&\n\t\t\tdayjs(punchHistory.couponExpiryDate).isBefore(data.scheduledAt)\n\t\t) {\n\t\t\treturn {\n\t\t\t\tisValid: false,\n\t\t\t};\n\t\t}\n\n\t\tlet discountAmount =\n\t\t\tpunchHistory.couponValueType == ValueType.FIXED\n\t\t\t\t? punchHistory.couponValue\n\t\t\t\t: roundBaseCurrency((punchHistory.couponValue / 100) * data.amountBeforeCoupon);\n\n\t\tlet secondaryDiscountAmount =\n\t\t\tpunchHistory.couponValueType == ValueType.FIXED\n\t\t\t\t? await convertToSecondary(punchHistory.couponValue)\n\t\t\t\t: roundSecondaryCurrency((punchHistory.couponValue / 100) * data.secondaryAmountBeforeCoupon);\n\n\t\tif (discountAmount > data.amountBeforeCoupon) {\n\t\t\tdiscountAmount = data.amountBeforeCoupon;\n\t\t}\n\t\tif (secondaryDiscountAmount > data.secondaryAmountBeforeCoupon) {\n\t\t\tsecondaryDiscountAmount = data.secondaryAmountBeforeCoupon;\n\t\t}\n\n\t\treturn {\n\t\t\tisValid: true,\n\t\t\tdiscountAmount,\n\t\t\tsecondaryDiscountAmount,\n\t\t\tamountAfterCoupon: Math.max(0, roundBaseCurrency(data.amountBeforeCoupon - discountAmount)),\n\t\t\tsecondaryAmountAfterCoupon: Math.max(\n\t\t\t\t0,\n\t\t\t\troundSecondaryCurrency(data.secondaryAmountBeforeCoupon - secondaryDiscountAmount)\n\t\t\t),\n\t\t\tdiscountCut: {\n\t\t\t\tcompanyCut: 0,\n\t\t\t\tsecondaryCompanyCut: 0,\n\t\t\t\tshopCut: discountAmount,\n\t\t\t\tsecondaryShopCut: secondaryDiscountAmount,\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic async getPunchCoupon(user: mongoose.Types.ObjectId, shop: mongoose.Types.ObjectId): Promise<any> {\n\t\tconst punchHistory = await this.model.findOne({\n\t\t\tuser: user,\n\t\t\tshop: shop,\n\t\t\tcouponExpiryDate: { $gte: new Date() },\n\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t});\n\t\tif (!punchHistory) return null;\n\n\t\tconst settings = await getLibraries().getCachedSettingsService().getSettings();\n\t\tconst exchangeRate = settings?.currencySetting?.exchangeRate ?? 0;\n\n\t\tconst punchCoupon = {\n\t\t\t_id: null,\n\t\t\tcode: 'punch',\n\t\t\tcouponType: CouponType.INDIVIDUAL_USER,\n\t\t\torderLimitPerUser: 1,\n\t\t\tcreatedBy: null,\n\t\t\tdeletedAt: null,\n\t\t\tvalueType: punchHistory.couponValueType,\n\t\t\tvalue: punchHistory.couponValue,\n\t\t\tmaxDiscountLimit: null,\n\t\t\tduration: {\n\t\t\t\tstart: punchHistory.completedAt,\n\t\t\t\tend: punchHistory.couponExpiryDate,\n\t\t\t},\n\t\t\tshops: [shop],\n\t\t\tspendLimit: null,\n\t\t\ttotalOrderLimit: 1,\n\t\t\tminOrderValue: null,\n\t\t\tforNewUserOnly: false,\n\t\t\tstatus: Status.ACTIVE,\n\t\t\texpirationReason: null,\n\t\t\tcreatedAt: punchHistory.completedAt,\n\t\t\tupdatedAt: punchHistory.completedAt,\n\t\t\tsecondaryCurrencyValue:\n\t\t\t\tpunchHistory.couponValueType === ValueType.FIXED\n\t\t\t\t\t? roundSecondaryCurrency(punchHistory.couponValue * exchangeRate)\n\t\t\t\t\t: null,\n\t\t\tsecondaryCurrencyMaxDiscountLimit: null,\n\t\t\tsecondaryCurrencyMinOrderValue: null,\n\t\t};\n\t\treturn punchCoupon;\n\t}\n\n\tpublic async returnPunchCoupon(orderId: mongoose.Types.ObjectId): Promise<void> {\n\t\tawait this.model.findOneAndUpdate(\n\t\t\t{\n\t\t\t\torder: orderId,\n\t\t\t\tstatus: PunchMarketingStatus.COUPON_USED,\n\t\t\t},\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t\t\t\torder: null,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tnew: true,\n\t\t\t\trunValidators: true,\n\t\t\t}\n\t\t);\n\t}\n}\n\nexport const punchMarketingHistoryService = Container.get(PunchMarketingHistoryService);\n"]}
|
|
1
|
+
{"version":3,"file":"punch-marketing-history.service.js","sourceRoot":"/","sources":["modules/punch-marketing-history/services/punch-marketing-history.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAA0E;AAC1E,iDAA4C;AAC5C,yCAAyC;AAGzC,wEAA6G;AAE7G,sEAOmD;AAOnD,4DAM2C;AAC3C,8DAA2D;AAG3D,oEAA2E;AAC3E,gEAAgG;AAChG,wCAA6C;AAC7C,8FAA+I;AAC/I,6JAAsI;AAG/H,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAChC,KAAK,CAA6D;IAClE,cAAc,CAA+D;IAC7E,UAAU,CAA2D;IAE7E;QACC,IAAI,CAAC,KAAK,GAAG,mCAAwF,CAAC;QACtG,IAAI,CAAC,cAAc,GAAG,4B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oB,CAAC,SAAS;gBACtC,KAAK,EAAE,IAAI;aACX;SACD,EACD;YACC,GAAG,EAAE,IAAI;YACT,aAAa,EAAE,IAAI;SACnB,CACD,CAAC;IACH,CAAC;CACD,CAAA;AAvaY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,gBAAO,GAAE;;GACG,4BAA4B,CAuaxC;AAEY,QAAA,4BAA4B,GAAG,gBAAS,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC","sourcesContent":["import { notFoundError } from '@lyxa.ai/core/dist/utilities/error-common';\nimport Container, { Service } from 'typedi';\nimport { TRPCError } from '@trpc/server';\nimport { DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';\nimport { FilterDTO, PaginatedResponse, DeleteDTO } from '@lyxa.ai/core/dist/utilities/validation';\nimport { createRawDocumentPaginatorObject, PaginatorOptions } from '@lyxa.ai/core/dist/utilities/pagination';\nimport { ModelType } from '@typegoose/typegoose/lib/types';\nimport {\n\tPunchMarketingHistoryModel,\n\tPunchMarketingHistory as Model,\n\tPunchMarketingModel,\n\tPunchMarketing,\n\tRegularOrder,\n\tRegularOrderModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {\n\tCreatePunchMarketingHistoryDTO as CreateDTO,\n\tGetByUserAndShopDTO,\n\tUpdatePunchMarketingHistoryDTO as UpdateDTO,\n} from '@modules/punch-marketing-history/validations';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {\n\tCouponType,\n\tMarketingType,\n\tPunchMarketingStatus,\n\tStatus,\n\tValueType,\n} from '@lyxa.ai/core/dist/utilities/enum';\nimport { dayjs } from '@lyxa.ai/core/dist/utilities/dayjs';\nimport { PunchMarketingSchema, PunchMarketingValidationSchema } from '@modules/marketing/validations';\nimport { CouponValidationOutputDTO, ValidateCouponDTO } from '@modules/coupon/validations';\nimport { convertToSecondary } from '@lyxa.ai/core/dist/utilities/currency';\nimport { roundBaseCurrency, roundSecondaryCurrency } from '@lyxa.ai/core/dist/utilities/shared';\nimport { getLibraries } from '@lyxa.ai/core';\nimport { publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent } from '@lyxa.ai/core/dist/utilities/events-common-methods';\nimport { ChangeStreamOperationTypes } from '@lyxa.ai/core/dist/libraries/event/events/mongo-stream-changes-batch-process-shops-event';\n\n@Service()\nexport class PunchMarketingHistoryService {\n\tprivate model: typeof PunchMarketingHistoryModel & SoftDeleteModel<Model>;\n\tprivate marketingModel: typeof PunchMarketingModel & SoftDeleteModel<PunchMarketing>;\n\tprivate orderModel: typeof RegularOrderModel & SoftDeleteModel<RegularOrder>;\n\n\tconstructor() {\n\t\tthis.model = PunchMarketingHistoryModel as typeof PunchMarketingHistoryModel & SoftDeleteModel<Model>;\n\t\tthis.marketingModel = PunchMarketingModel as typeof PunchMarketingModel & SoftDeleteModel<PunchMarketing>;\n\t\tthis.orderModel = RegularOrderModel as typeof RegularOrderModel & SoftDeleteModel<RegularOrder>;\n\t}\n\n\t/**\n\t * Create a new record\n\t * @param data Data for the new record\n\t */\n\tpublic async create(data: CreateDTO): Promise<DocumentType<Model>> {\n\t\treturn await this.model.create(data);\n\t}\n\n\t/**\n\t * Get record by ID\n\t * @param id ID of the record\n\t */\n\tpublic async findById(id: string | mongoose.Types.ObjectId): Promise<DocumentType<Model>> {\n\t\tconst result = await this.model.findOne({\n\t\t\t_id: id,\n\t\t\tdeletedAt: null,\n\t\t});\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get records\n\t * @param query Query to find records\n\t */\n\tpublic async find(data?: Partial<FilterDTO>): Promise<PaginatedResponse<DocumentType<ModelType<Model>>>> {\n\t\ttry {\n\t\t\tconst paginate = createRawDocumentPaginatorObject(this.model as ReturnModelType<typeof this.model>);\n\t\t\tconst options: PaginatorOptions<typeof Model> = {\n\t\t\t\tpage: data?.page,\n\t\t\t\tsize: data?.size,\n\t\t\t\tsort: data?.sort,\n\t\t\t\tquery: data?.query,\n\t\t\t\tselect: data?.select,\n\t\t\t\tpopulate: data?.populate,\n\t\t\t};\n\t\t\tconst paginatedResult = await paginate(options);\n\t\t\treturn paginatedResult;\n\t\t} catch (err) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: `err: ${err}`,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get Record\n\t * @param UserId ShopId to find records\n\t */\n\tpublic async getByUserAndShop(data: GetByUserAndShopDTO): Promise<any> {\n\t\tlet result = await this.model.findOne({\n\t\t\tuser: data.userId,\n\t\t\tshop: data.shopId,\n\t\t\texpiryDate: { $gt: new Date() },\n\t\t\tcompletedAt: null,\n\t\t\tstatus: PunchMarketingStatus.ACTIVE,\n\t\t});\n\n\t\tif (result) return result;\n\n\t\tconst marketing = await this.marketingModel.findOne({\n\t\t\tmarketingType: MarketingType.PUNCH_MARKETING,\n\t\t\tshop: data.shopId,\n\t\t\tstatus: Status.ACTIVE,\n\t\t\t'duration.start': { $lt: new Date() },\n\t\t\t'duration.end': { $gt: new Date() },\n\t\t});\n\n\t\tif (!marketing) notFoundError('No Punch Marketing is Active For This Shop...');\n\n\t\treturn {\n\t\t\tuser: data.userId,\n\t\t\tshop: data.shopId,\n\t\t\tmarketing: marketing!._id,\n\t\t\ttargetOrder: marketing.targetOrders,\n\t\t\tminimumOrderValue: marketing.minimumOrderValue,\n\t\t\tcompletedOrder: 0,\n\t\t\tcouponValueType: marketing.couponValueType,\n\t\t\tcouponValue: marketing.couponValue,\n\t\t\tcouponDurationInDays: marketing.couponDurationInDays,\n\t\t};\n\t}\n\n\t/**\n\t * Update record\n\t * @param id ID of the record\n\t * @param data Data to update\n\t */\n\tpublic async update(id: string, data: UpdateDTO): Promise<DocumentType<Model>> {\n\t\tconst record = await this.model.findOneAndUpdate(\n\t\t\t{\n\t\t\t\t_id: id,\n\t\t\t\tdeletedAt: null,\n\t\t\t},\n\t\t\tdata,\n\t\t\t{\n\t\t\t\tnew: true,\n\t\t\t\trunValidators: true,\n\t\t\t}\n\t\t);\n\n\t\tif (!record) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: `Record not found`,\n\t\t\t});\n\t\t}\n\n\t\treturn record;\n\t}\n\n\t/**\n\t * Delete record\n\t * @param data Data for delete\n\t */\n\tpublic async deleteById(data: DeleteDTO): Promise<string> {\n\t\tconst { _id, softDelete } = data;\n\n\t\tconst result = await this.model.deleteRecord({ _id, deletedAt: null }, softDelete);\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\n\t\treturn 'Record deleted successfully';\n\t}\n\n\t/**\n\t * Increment punch history for user\n\t * @param userId User ID\n\t * @param orderId Order ID\n\t */\n\tpublic async incrementUserHistory(\n\t\tuserId: mongoose.Types.ObjectId,\n\t\torderId: mongoose.Types.ObjectId\n\t): Promise<string> {\n\t\tconst order = await this.orderModel.findById(orderId);\n\n\t\tif (!order || order.user.toString != userId.toString) {\n\t\t\tnotFoundError('Order not found');\n\t\t}\n\n\t\tconst existingHistory = await this.model.findOne({\n\t\t\tuser: userId,\n\t\t\tshop: order.shop,\n\t\t\texpiryDate: { $gt: new Date() },\n\t\t\tcompletedAt: null,\n\t\t\tstatus: PunchMarketingStatus.ACTIVE,\n\t\t});\n\n\t\tif (existingHistory) {\n\t\t\tif (order.finance.pricing.subtotal ?? 0 >= existingHistory.minimumOrderValue) {\n\t\t\t\tconst completedAt =\n\t\t\t\t\texistingHistory.targetOrder == existingHistory.completedOrder + 1 ? new Date() : null;\n\t\t\t\tconst couponExpiryDate = completedAt\n\t\t\t\t\t? dayjs(completedAt).add(existingHistory.couponDurationInDays, 'day').toDate()\n\t\t\t\t\t: null;\n\t\t\t\tconst status = completedAt ? PunchMarketingStatus.COMPLETED : PunchMarketingStatus.ACTIVE;\n\n\t\t\t\tawait this.model.findByIdAndUpdate(\n\t\t\t\t\texistingHistory._id,\n\t\t\t\t\t{\n\t\t\t\t\t\t$inc: {\n\t\t\t\t\t\t\tcompletedOrder: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcompletedAt,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t\tcouponExpiryDate,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tnew: true,\n\t\t\t\t\t\trunValidators: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tawait this.createNewHistory(userId, order);\n\t\t}\n\n\t\tawait publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent({\n\t\t\tuserId,\n\t\t\tshopId: order.shop._id,\n\t\t\toperation: ChangeStreamOperationTypes.UPDATE,\n\t\t});\n\n\t\treturn 'Record updated successfully';\n\t}\n\n\t/**\n\t * Create new history with current punch marketing of the shop\n\t * @param userId User ID\n\t * @param order Order document\n\t */\n\tprivate async createNewHistory(userId: mongoose.Types.ObjectId, order: DocumentType<RegularOrder>) {\n\t\tconst marketing = await this.marketingModel.findOne({\n\t\t\tmarketingType: MarketingType.PUNCH_MARKETING,\n\t\t\tshop: order.shop,\n\t\t\tstatus: Status.ACTIVE,\n\t\t\t'duration.start': { $lt: new Date() },\n\t\t\t'duration.end': { $gt: new Date() },\n\t\t});\n\n\t\tif (!marketing) notFoundError('Marketing Not Found');\n\n\t\tconst expiryDate = dayjs().add(marketing.dayLimit, 'day').toDate();\n\t\tconst couponDurationInDays = marketing!.couponDurationInDays;\n\t\tconst couponValue = marketing!.couponValue;\n\t\tconst couponValueType = marketing!.couponValueType;\n\t\tconst targetOrder = marketing!.targetOrders;\n\t\tconst minimumOrderValue = marketing!.minimumOrderValue;\n\t\tconst completedOrder = 1;\n\t\tconst status =\n\t\t\tmarketing!.targetOrders == completedOrder\n\t\t\t\t? PunchMarketingStatus.COMPLETED\n\t\t\t\t: PunchMarketingStatus.ACTIVE;\n\t\tconst completedAt = marketing!.targetOrders == completedOrder ? new Date() : null;\n\t\tconst couponExpiryDate = completedAt\n\t\t\t? dayjs(completedAt).add(marketing!.couponDurationInDays, 'day').toDate()\n\t\t\t: null;\n\n\t\tif (order.finance.pricing.subtotal ?? 0 >= marketing.minimumOrderValue) {\n\t\t\tconst data: CreateDTO = {\n\t\t\t\tuser: userId as mongoose.Types.ObjectId,\n\t\t\t\tshop: order!.shop as mongoose.Types.ObjectId,\n\t\t\t\tmarketing: marketing!._id as mongoose.Types.ObjectId,\n\t\t\t\ttargetOrder,\n\t\t\t\tminimumOrderValue,\n\t\t\t\tcompletedOrder,\n\t\t\t\tstatus,\n\t\t\t\tcouponValueType,\n\t\t\t\tcouponValue,\n\t\t\t\tcouponDurationInDays,\n\t\t\t\texpiryDate,\n\t\t\t\t...(completedAt && { completedAt }),\n\t\t\t\t...(couponExpiryDate && { couponExpiryDate }),\n\t\t\t};\n\t\t\tawait this.create(data);\n\t\t}\n\t}\n\n\tpublic async applyPunchDiscountToOrder(userId: mongoose.Types.ObjectId, orderId: mongoose.Types.ObjectId) {\n\t\tconst order = await this.orderModel.findById(orderId);\n\t\tif (!order) notFoundError('Order not found');\n\n\t\tconst punchHistory = await this.model.findOneAndUpdate(\n\t\t\t{\n\t\t\t\tuser: userId,\n\t\t\t\tshop: order.shop,\n\t\t\t\tcouponExpiryDate: { $gte: new Date() },\n\t\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t\t},\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\torder: orderId,\n\t\t\t\t\tstatus: PunchMarketingStatus.COUPON_USED,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tnew: true,\n\t\t\t\trunValidators: true,\n\t\t\t}\n\t\t);\n\n\t\tif (!punchHistory) notFoundError('No valid punch coupon available');\n\n\t\tawait this.orderModel.findByIdAndUpdate(orderId, {\n\t\t\t$push: {\n\t\t\t\tmarketings: punchHistory.marketing,\n\t\t\t},\n\t\t});\n\n\t\tawait publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent({\n\t\t\tuserId,\n\t\t\tshopId: order.shop._id,\n\t\t\toperation: ChangeStreamOperationTypes.DELETE,\n\t\t});\n\t}\n\n\t/**\n\t * Get punch discount\n\t * @param data Data to use for validating discount\n\t */\n\tpublic async getPunchDiscount(data: ValidateCouponDTO): Promise<CouponValidationOutputDTO> {\n\t\tconst punchHistory = await this.model.findOne({\n\t\t\tuser: data.user,\n\t\t\tshop: data.shop,\n\t\t\tcouponExpiryDate: { $gte: new Date() },\n\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t});\n\n\t\tif (!punchHistory) {\n\t\t\treturn {\n\t\t\t\tisValid: false,\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tdata.scheduledAt &&\n\t\t\tBoolean(punchHistory.couponExpiryDate) &&\n\t\t\tdayjs(punchHistory.couponExpiryDate).isBefore(data.scheduledAt)\n\t\t) {\n\t\t\treturn {\n\t\t\t\tisValid: false,\n\t\t\t};\n\t\t}\n\n\t\tlet discountAmount =\n\t\t\tpunchHistory.couponValueType == ValueType.FIXED\n\t\t\t\t? punchHistory.couponValue\n\t\t\t\t: roundBaseCurrency((punchHistory.couponValue / 100) * data.amountBeforeCoupon);\n\n\t\tlet secondaryDiscountAmount =\n\t\t\tpunchHistory.couponValueType == ValueType.FIXED\n\t\t\t\t? await convertToSecondary(punchHistory.couponValue)\n\t\t\t\t: roundSecondaryCurrency((punchHistory.couponValue / 100) * data.secondaryAmountBeforeCoupon);\n\n\t\tif (discountAmount > data.amountBeforeCoupon) {\n\t\t\tdiscountAmount = data.amountBeforeCoupon;\n\t\t}\n\t\tif (secondaryDiscountAmount > data.secondaryAmountBeforeCoupon) {\n\t\t\tsecondaryDiscountAmount = data.secondaryAmountBeforeCoupon;\n\t\t}\n\n\t\treturn {\n\t\t\tisValid: true,\n\t\t\tdiscountAmount,\n\t\t\tsecondaryDiscountAmount,\n\t\t\tamountAfterCoupon: Math.max(0, roundBaseCurrency(data.amountBeforeCoupon - discountAmount)),\n\t\t\tsecondaryAmountAfterCoupon: Math.max(\n\t\t\t\t0,\n\t\t\t\troundSecondaryCurrency(data.secondaryAmountBeforeCoupon - secondaryDiscountAmount)\n\t\t\t),\n\t\t\tdiscountCut: {\n\t\t\t\tcompanyCut: 0,\n\t\t\t\tsecondaryCompanyCut: 0,\n\t\t\t\tshopCut: discountAmount,\n\t\t\t\tsecondaryShopCut: secondaryDiscountAmount,\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic async getPunchCoupon(user: mongoose.Types.ObjectId, shop: mongoose.Types.ObjectId): Promise<any> {\n\t\tconst punchHistory = await this.model.findOne({\n\t\t\tuser: user,\n\t\t\tshop: shop,\n\t\t\tcouponExpiryDate: { $gte: new Date() },\n\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t});\n\t\tif (!punchHistory) return null;\n\n\t\tconst settings = await getLibraries().getCachedSettingsService().getSettings();\n\t\tconst exchangeRate = settings?.currencySetting?.exchangeRate ?? 0;\n\n\t\tconst punchCoupon = {\n\t\t\t_id: null,\n\t\t\tcode: 'punch',\n\t\t\tcouponType: CouponType.INDIVIDUAL_USER,\n\t\t\torderLimitPerUser: 1,\n\t\t\tcreatedBy: null,\n\t\t\tdeletedAt: null,\n\t\t\tvalueType: punchHistory.couponValueType,\n\t\t\tvalue: punchHistory.couponValue,\n\t\t\tmaxDiscountLimit: null,\n\t\t\tduration: {\n\t\t\t\tstart: punchHistory.completedAt,\n\t\t\t\tend: punchHistory.couponExpiryDate,\n\t\t\t},\n\t\t\tshops: [shop],\n\t\t\tspendLimit: null,\n\t\t\ttotalOrderLimit: 1,\n\t\t\tminOrderValue: null,\n\t\t\tforNewUserOnly: false,\n\t\t\tstatus: Status.ACTIVE,\n\t\t\texpirationReason: null,\n\t\t\tcreatedAt: punchHistory.completedAt,\n\t\t\tupdatedAt: punchHistory.completedAt,\n\t\t\tsecondaryCurrencyValue:\n\t\t\t\tpunchHistory.couponValueType === ValueType.FIXED\n\t\t\t\t\t? roundSecondaryCurrency(punchHistory.couponValue * exchangeRate)\n\t\t\t\t\t: null,\n\t\t\tsecondaryCurrencyMaxDiscountLimit: null,\n\t\t\tsecondaryCurrencyMinOrderValue: null,\n\t\t};\n\t\treturn punchCoupon;\n\t}\n\n\tpublic async returnPunchCoupon(orderId: mongoose.Types.ObjectId): Promise<void> {\n\t\tawait this.model.findOneAndUpdate(\n\t\t\t{\n\t\t\t\torder: orderId,\n\t\t\t\tstatus: PunchMarketingStatus.COUPON_USED,\n\t\t\t},\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t\t\t\torder: null,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tnew: true,\n\t\t\t\trunValidators: true,\n\t\t\t}\n\t\t);\n\t}\n}\n\nexport const punchMarketingHistoryService = Container.get(PunchMarketingHistoryService);\n"]}
|
package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ declare const PunchMarketingHistoryValidationSchema: z.ZodObject<{
|
|
|
19
19
|
}, "strict", z.ZodTypeAny, {
|
|
20
20
|
user: import("mongoose").Types.ObjectId;
|
|
21
21
|
shop: import("mongoose").Types.ObjectId;
|
|
22
|
-
minimumOrderValue: number;
|
|
23
22
|
marketing: import("mongoose").Types.ObjectId;
|
|
23
|
+
minimumOrderValue: number;
|
|
24
24
|
targetOrder: number;
|
|
25
25
|
couponValueType: ValueType;
|
|
26
26
|
couponValue: number;
|
|
@@ -34,8 +34,8 @@ declare const PunchMarketingHistoryValidationSchema: z.ZodObject<{
|
|
|
34
34
|
}, {
|
|
35
35
|
user: string | import("mongoose").Types.ObjectId;
|
|
36
36
|
shop: string | import("mongoose").Types.ObjectId;
|
|
37
|
-
minimumOrderValue: number;
|
|
38
37
|
marketing: string | import("mongoose").Types.ObjectId;
|
|
38
|
+
minimumOrderValue: number;
|
|
39
39
|
targetOrder: number;
|
|
40
40
|
couponValueType: ValueType;
|
|
41
41
|
couponValue: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/spend-to-get-history/routers/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./spend-to-get-history.router"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/spend-to-get-history/routers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C","sourcesContent":["export * from './spend-to-get-history.router';\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.spendToGetHistoryRouter = void 0;
|
|
4
|
+
const trpc_1 = require("@lyxa.ai/core/dist/libraries/trpc");
|
|
5
|
+
const services_1 = require("../../spend-to-get-history/services");
|
|
6
|
+
const validations_1 = require("../../spend-to-get-history/validations");
|
|
7
|
+
const validation_1 = require("@lyxa.ai/core/dist/utilities/validation");
|
|
8
|
+
const error_handler_1 = require("@lyxa.ai/core/dist/utilities/error-handler");
|
|
9
|
+
const response_1 = require("@lyxa.ai/core/dist/utilities/response");
|
|
10
|
+
exports.spendToGetHistoryRouter = (0, trpc_1.createTRPCRouter)({
|
|
11
|
+
create: trpc_1.publicProcedure
|
|
12
|
+
.input(validations_1.SpendToGetHistoryValidationSchema)
|
|
13
|
+
.output(validations_1.SpendToGetHistoryResponseSchema)
|
|
14
|
+
.mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
15
|
+
await services_1.spendToGetHistoryService.create(input);
|
|
16
|
+
return (0, response_1.response)('Spend to get history created successfully');
|
|
17
|
+
})),
|
|
18
|
+
getById: trpc_1.publicProcedure
|
|
19
|
+
.input(validation_1.IdSchema)
|
|
20
|
+
.output(validations_1.SpendToGetHistoryResponseSchema)
|
|
21
|
+
.query(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
22
|
+
const result = await services_1.spendToGetHistoryService.findById(input);
|
|
23
|
+
return (0, response_1.response)('Spend to get history fetched successfully', validations_1.SpendToGetHistorySchema.parse(result));
|
|
24
|
+
})),
|
|
25
|
+
get: trpc_1.publicProcedure
|
|
26
|
+
.input(validation_1.FilterSchema)
|
|
27
|
+
.output(validations_1.SpendToGetHistoryResponseSchema)
|
|
28
|
+
.query(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
29
|
+
const result = await services_1.spendToGetHistoryService.find(input);
|
|
30
|
+
return (0, response_1.response)('Spend to get history fetched successfully', result);
|
|
31
|
+
})),
|
|
32
|
+
update: trpc_1.publicProcedure
|
|
33
|
+
.input(validations_1.UpdateSpendToGetHistorySchema)
|
|
34
|
+
.output(validations_1.SpendToGetHistoryResponseSchema)
|
|
35
|
+
.mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
36
|
+
const { _id, ...rest } = input;
|
|
37
|
+
await services_1.spendToGetHistoryService.update(String(_id), rest);
|
|
38
|
+
return (0, response_1.response)('Spend to get history updated successfully');
|
|
39
|
+
})),
|
|
40
|
+
deleteById: trpc_1.publicProcedure
|
|
41
|
+
.input(validation_1.DeleteSchema)
|
|
42
|
+
.output(validations_1.SpendToGetHistoryResponseSchema)
|
|
43
|
+
.mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
44
|
+
await services_1.spendToGetHistoryService.deleteById(input);
|
|
45
|
+
return (0, response_1.response)('Spend to get history deleted successfully');
|
|
46
|
+
})),
|
|
47
|
+
recordRedemption: trpc_1.publicProcedure
|
|
48
|
+
.input(validations_1.RecordSpendToGetRedemptionSchema)
|
|
49
|
+
.output(validations_1.SpendToGetHistoryResponseSchema)
|
|
50
|
+
.mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
51
|
+
await services_1.spendToGetHistoryService.recordRedemption(input);
|
|
52
|
+
return (0, response_1.response)('Spend to get redemption recorded successfully');
|
|
53
|
+
})),
|
|
54
|
+
returnRedemption: trpc_1.publicProcedure
|
|
55
|
+
.input(validations_1.ReturnSpendToGetRedemptionSchema)
|
|
56
|
+
.output(validations_1.SpendToGetHistoryResponseSchema)
|
|
57
|
+
.mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
58
|
+
await services_1.spendToGetHistoryService.returnRedemption(input.order);
|
|
59
|
+
return (0, response_1.response)('Spend to get redemption returned successfully');
|
|
60
|
+
})),
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=spend-to-get-history.router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spend-to-get-history.router.js","sourceRoot":"/","sources":["modules/spend-to-get-history/routers/spend-to-get-history.router.ts"],"names":[],"mappings":";;;AAAA,4DAAsF;AACtF,qEAA6F;AAC7F,2EAOmD;AACnD,wEAA+F;AAC/F,8EAA0E;AAC1E,oEAAiE;AAEpD,QAAA,uBAAuB,GAAG,IAAA,uBAAgB,EAAC;IACvD,MAAM,EAAE,sBAAe;SACrB,KAAK,CAAC,+CAAY,CAAC;SACnB,MAAM,CAAC,6CAAc,CAAC;SACtB,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC7B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,mCAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5B,OAAO,IAAA,mBAAQ,EAAC,2CAA2C,CAAC,CAAC;IAC9D,CAAC,CAAC,CACF;IAEF,OAAO,EAAE,sBAAe;SACtB,KAAK,CAAC,qBAAQ,CAAC;SACf,MAAM,CAAC,6CAAc,CAAC;SACtB,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC1B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,MAAM,GAAG,MAAM,mCAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC7C,OAAO,IAAA,mBAAQ,EAAC,2CAA2C,EAAE,qCAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACpF,CAAC,CAAC,CACF;IAEF,GAAG,EAAE,sBAAe;SAClB,KAAK,CAAC,yBAAY,CAAC;SACnB,MAAM,CAAC,6CAAc,CAAC;SACtB,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC1B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,MAAM,GAAG,MAAM,mCAAO,CAAC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,EAAE,sBAAe;SAC/B,KAAK,CAAC,8CAAgC,CAAC;SACvC,MAAM,CAAC,6CAAc,CAAC;SACtB,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC7B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,mCAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5C,OAAO,IAAA,mBAAQ,EAAC,+CAA+C,CAAC,CAAC;IAClE,CAAC,CAAC,CACF;CACF,CAAC,CAAC","sourcesContent":["import { createTRPCRouter, publicProcedure } from '@lyxa.ai/core/dist/libraries/trpc';\nimport { spendToGetHistoryService as service } from '@modules/spend-to-get-history/services';\nimport {\n\tSpendToGetHistorySchema as Schema,\n\tSpendToGetHistoryValidationSchema as CreateSchema,\n\tUpdateSpendToGetHistorySchema as UpdateSchema,\n\tSpendToGetHistoryResponseSchema as ResponseSchema,\n\tRecordSpendToGetRedemptionSchema,\n\tReturnSpendToGetRedemptionSchema,\n} from '@modules/spend-to-get-history/validations';\nimport { FilterSchema, DeleteSchema, IdSchema } from '@lyxa.ai/core/dist/utilities/validation';\nimport { ErrorHandler } from '@lyxa.ai/core/dist/utilities/error-handler';\nimport { response } from '@lyxa.ai/core/dist/utilities/response';\n\nexport const spendToGetHistoryRouter = createTRPCRouter({\n\tcreate: publicProcedure\n\t\t.input(CreateSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.create(input);\n\t\t\t\treturn response('Spend to get history created successfully');\n\t\t\t})\n\t\t),\n\n\tgetById: publicProcedure\n\t\t.input(IdSchema)\n\t\t.output(ResponseSchema)\n\t\t.query(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.findById(input);\n\t\t\t\treturn response('Spend to get history fetched successfully', Schema.parse(result));\n\t\t\t})\n\t\t),\n\n\tget: publicProcedure\n\t\t.input(FilterSchema)\n\t\t.output(ResponseSchema)\n\t\t.query(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.find(input);\n\t\t\t\treturn response('Spend to get history fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\tupdate: publicProcedure\n\t\t.input(UpdateSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst { _id, ...rest } = input;\n\t\t\t\tawait service.update(String(_id), rest);\n\t\t\t\treturn response('Spend to get history updated successfully');\n\t\t\t})\n\t\t),\n\n\tdeleteById: publicProcedure\n\t\t.input(DeleteSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.deleteById(input);\n\t\t\t\treturn response('Spend to get history deleted successfully');\n\t\t\t})\n\t\t),\n\n\trecordRedemption: publicProcedure\n\t\t.input(RecordSpendToGetRedemptionSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.recordRedemption(input);\n\t\t\t\treturn response('Spend to get redemption recorded successfully');\n\t\t\t})\n\t\t),\n\n\treturnRedemption: publicProcedure\n\t\t.input(ReturnSpendToGetRedemptionSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.returnRedemption(input.order);\n\t\t\t\treturn response('Spend to get redemption returned successfully');\n\t\t\t})\n\t\t),\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/spend-to-get-history/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./spend-to-get-history.service"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/spend-to-get-history/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C","sourcesContent":["export * from './spend-to-get-history.service';\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DocumentType, mongoose } from '@typegoose/typegoose';
|
|
2
|
+
import { FilterDTO, PaginatedResponse, DeleteDTO } from '@lyxa.ai/core/dist/utilities/validation';
|
|
3
|
+
import { ModelType } from '@typegoose/typegoose/lib/types';
|
|
4
|
+
import { SpendToGetHistory as Model } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
5
|
+
import { CreateSpendToGetHistoryDTO as CreateDTO, UpdateSpendToGetHistoryDTO as UpdateDTO } from '../../spend-to-get-history/validations';
|
|
6
|
+
export declare class SpendToGetHistoryService {
|
|
7
|
+
private model;
|
|
8
|
+
constructor();
|
|
9
|
+
create(data: CreateDTO): Promise<DocumentType<Model>>;
|
|
10
|
+
findById(id: string | mongoose.Types.ObjectId): Promise<DocumentType<Model>>;
|
|
11
|
+
find(data?: Partial<FilterDTO>): Promise<PaginatedResponse<DocumentType<ModelType<Model>>>>;
|
|
12
|
+
update(id: string, data: UpdateDTO): Promise<DocumentType<Model>>;
|
|
13
|
+
deleteById(data: DeleteDTO): Promise<string>;
|
|
14
|
+
recordRedemption(params: {
|
|
15
|
+
user: mongoose.Types.ObjectId;
|
|
16
|
+
shop: mongoose.Types.ObjectId;
|
|
17
|
+
marketing: mongoose.Types.ObjectId;
|
|
18
|
+
order: mongoose.Types.ObjectId;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
returnRedemption(orderId: mongoose.Types.ObjectId): Promise<void>;
|
|
21
|
+
hasUserReachedLimit(userId: mongoose.Types.ObjectId, marketingId: mongoose.Types.ObjectId, perUserLimit: number): Promise<boolean>;
|
|
22
|
+
}
|
|
23
|
+
export declare const spendToGetHistoryService: SpendToGetHistoryService;
|
|
24
|
+
//# sourceMappingURL=spend-to-get-history.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spend-to-get-history.service.d.ts","sourceRoot":"/","sources":["modules/spend-to-get-history/services/spend-to-get-history.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAElG,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAA0B,iBAAiB,IAAI,KAAK,EAAE,MAAM,2CAA2C,CAAC;AAC/G,OAAO,EACN,0BAA0B,IAAI,SAAS,EACvC,0BAA0B,IAAI,SAAS,EACvC,MAAM,2CAA2C,CAAC;AAGnD,qBACa,wBAAwB;IACpC,OAAO,CAAC,KAAK,CAAyD;;IAU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