@lyxa.ai/marketing 1.0.57 → 1.0.59
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 +1 -0
- package/dist/lib/event/event-initializations.js.map +1 -1
- package/dist/lib/event/event-listeners/event-listeners.d.ts +1 -0
- package/dist/lib/event/event-listeners/event-listeners.d.ts.map +1 -1
- package/dist/lib/event/event-listeners/event-listeners.js +62 -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 +243 -12
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +3 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +2 -2
- 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/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 +6 -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 +45 -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/config/limited-time-offer-config.validation.d.ts +2 -2
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +241 -10
- 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 +10 -2
- 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 +4 -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 +187 -2
- 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 +395 -0
- 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 +31 -6
- 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/services/marketing.service.d.ts +1 -0
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +60 -46
- 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/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/types/event/event-initializations.d.ts.map +1 -1
- package/dist/types/event/event-listeners/event-listeners.d.ts +1 -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/index.d.ts +243 -12
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +2 -2
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +6 -6
- 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 +6 -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/config/limited-time-offer-config.validation.d.ts +2 -2
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +241 -10
- 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 +10 -2
- 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 +187 -2
- 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.validation.d.ts +395 -0
- 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/services/marketing.service.d.ts +1 -0
- 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/synchronize-product-marketing.service.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DocumentType, mongoose } from '@typegoose/typegoose';
|
|
2
|
-
import {
|
|
2
|
+
import { LimitedTimeOfferCampaign } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
3
|
+
import { AdminEnrollShopEntryDTO, JoinLtoCampaignDTO, ParticipantStatusDTO } from '../limited-time-offer-participant.validation';
|
|
3
4
|
import { GetLtoCampaignParticipantsDTO } from '../../campaign/limited-time-offer-campaign.validation';
|
|
4
5
|
export declare class LimitedTimeOfferParticipantService {
|
|
5
6
|
private repository;
|
|
@@ -7,7 +8,16 @@ export declare class LimitedTimeOfferParticipantService {
|
|
|
7
8
|
private marketingService;
|
|
8
9
|
constructor();
|
|
9
10
|
join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO): Promise<DocumentType<import("@lyxa.ai/core/dist/libraries/mongo/models").LimitedTimeOfferParticipant>>;
|
|
11
|
+
enrollShops(entries: AdminEnrollShopEntryDTO[]): Promise<(mongoose.Document<unknown, import("@typegoose/typegoose/lib/types").BeAnObject, import("@lyxa.ai/core/dist/libraries/mongo/models").LimitedTimeOfferParticipant, Record<string, any>, {}> & import("@lyxa.ai/core/dist/libraries/mongo/models").LimitedTimeOfferParticipant & {
|
|
12
|
+
_id: mongoose.Types.ObjectId;
|
|
13
|
+
} & {
|
|
14
|
+
__v: number;
|
|
15
|
+
} & import("@typegoose/typegoose/lib/types").IObjectWithTypegooseFunction)[]>;
|
|
16
|
+
private joinShop;
|
|
17
|
+
private pauseIfLive;
|
|
10
18
|
withdraw(shopId: mongoose.Types.ObjectId): Promise<void>;
|
|
19
|
+
cleanupCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void>;
|
|
20
|
+
isActiveParticipant(shopId: mongoose.Types.ObjectId): Promise<boolean>;
|
|
11
21
|
getStatus(shopId: mongoose.Types.ObjectId): Promise<ParticipantStatusDTO>;
|
|
12
22
|
update(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO): Promise<DocumentType<import("@lyxa.ai/core/dist/libraries/mongo/models").LimitedTimeOfferParticipant> | null>;
|
|
13
23
|
getParticipants(dto: GetLtoCampaignParticipantsDTO): Promise<{
|
|
@@ -15,9 +25,9 @@ export declare class LimitedTimeOfferParticipantService {
|
|
|
15
25
|
shopId: mongoose.Types.ObjectId;
|
|
16
26
|
joinedAt: Date;
|
|
17
27
|
shopName: string | null;
|
|
28
|
+
shopPhoto?: string | null | undefined;
|
|
18
29
|
discountPercentage?: number | undefined;
|
|
19
30
|
maxDiscountCap?: number | undefined;
|
|
20
|
-
shopPhoto?: string | null | undefined;
|
|
21
31
|
}[];
|
|
22
32
|
metadata: {
|
|
23
33
|
page: number;
|
|
@@ -31,7 +41,8 @@ export declare class LimitedTimeOfferParticipantService {
|
|
|
31
41
|
latitude: number;
|
|
32
42
|
longitude: number;
|
|
33
43
|
}): Promise<any[]>;
|
|
34
|
-
|
|
44
|
+
reactivateMarketings(campaign: DocumentType<LimitedTimeOfferCampaign>): Promise<void>;
|
|
45
|
+
private applyMarketingWithRollback;
|
|
35
46
|
private fetchCurrentCampaignOrThrow;
|
|
36
47
|
private assertNotAlreadyJoined;
|
|
37
48
|
private resolveCategorySelection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-participant.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"limited-time-offer-participant.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAC,wBAAwB,EAAU,MAAM,2CAA2C,CAAC;AAK5F,OAAO,EACN,uBAAuB,EACvB,kBAAkB,EAElB,oBAAoB,EAEpB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EAAC,6BAA6B,EAAC,MAAM,uDAAuD,CAAC;AAGpG,qBACa,kCAAkC;IAC9C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,gBAAgB,CAAiC;;IAQ5C,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,kBAAkB;IAK7D,WAAW,CAAC,OAAO,EAAE,uBAAuB,EAAE;;;;;YAK7C,QAAQ;YAqCR,WAAW;IAQZ,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAcxD,yBAAyB,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7E,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAMtE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmBzE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,kBAAkB;IA2B/D,eAAe,CAAC,GAAG,EAAE,6BAA6B;;;;;;;;;;;;;;;;IAQlD,6BAA6B,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ;IAIjE,SAAS,CACrB,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAOlC,oBAAoB,CAAC,QAAQ,EAAE,YAAY,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;YA+BpF,0BAA0B;YAe1B,2BAA2B;YAQ3B,sBAAsB;YActB,wBAAwB;YAqBxB,0BAA0B;IAexC,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,0BAA0B;CAkBlC;AAED,eAAO,MAAM,qBAAqB,oCAAoD,CAAC"}
|
|
@@ -63,15 +63,40 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
|
|
|
63
63
|
}
|
|
64
64
|
async join(shopId, dto) {
|
|
65
65
|
const campaign = await this.fetchCurrentCampaignOrThrow();
|
|
66
|
+
return this.joinShop(campaign, shopId, dto);
|
|
67
|
+
}
|
|
68
|
+
async enrollShops(entries) {
|
|
69
|
+
const campaign = await this.fetchCurrentCampaignOrThrow();
|
|
70
|
+
return Promise.all(entries.map(({ shopId, ...dto }) => this.joinShop(campaign, shopId, dto)));
|
|
71
|
+
}
|
|
72
|
+
async joinShop(campaign, shopId, dto) {
|
|
66
73
|
await this.assertNotAlreadyJoined(campaign._id, shopId);
|
|
67
|
-
this.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap);
|
|
74
|
+
this.validateDiscountSelections({ campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap });
|
|
68
75
|
await this.assertProductsBelongToShop(shopId, dto);
|
|
69
76
|
const resolvedDto = await this.resolveCategorySelection(shopId, dto);
|
|
70
|
-
const
|
|
71
|
-
const
|
|
77
|
+
const pausedMarketings = await this.pauseIfLive(campaign, shopId);
|
|
78
|
+
const { marketingId, pausedMarketingIds } = await this.applyMarketingWithRollback({
|
|
79
|
+
shopId,
|
|
80
|
+
campaign,
|
|
81
|
+
dto: resolvedDto,
|
|
82
|
+
pausedMarketings,
|
|
83
|
+
});
|
|
84
|
+
const allPausedMarketings = this.uniqueObjectIds([...pausedMarketings, ...pausedMarketingIds]);
|
|
85
|
+
const participant = await this.repository.create(limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildCreateInput({
|
|
86
|
+
campaignId: campaign._id,
|
|
87
|
+
shopId,
|
|
88
|
+
marketingId,
|
|
89
|
+
dto: resolvedDto,
|
|
90
|
+
pausedMarketings: allPausedMarketings,
|
|
91
|
+
}));
|
|
72
92
|
await this.repository.updateShopOrderCapacity(shopId, resolvedDto.isOrderCapacityEnabled, resolvedDto.maxOrderCapacity);
|
|
73
93
|
return participant;
|
|
74
94
|
}
|
|
95
|
+
async pauseIfLive(campaign, shopId) {
|
|
96
|
+
if (campaign.status !== enum_1.LimitedTimeOfferCampaignStatus.ACTIVE)
|
|
97
|
+
return [];
|
|
98
|
+
return this.marketingService.pauseActiveShopMarketings(shopId, enum_1.MarketingType.DISCOUNT);
|
|
99
|
+
}
|
|
75
100
|
async withdraw(shopId) {
|
|
76
101
|
const campaign = await this.fetchCurrentCampaignOrThrow();
|
|
77
102
|
const participant = await this.repository.withdraw(campaign._id, shopId);
|
|
@@ -80,6 +105,18 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
|
|
|
80
105
|
if (participant.marketing) {
|
|
81
106
|
await this.marketingService.removeMarketing(participant.marketing);
|
|
82
107
|
}
|
|
108
|
+
await this.marketingService.resumeMarketings((participant.pausedMarketings ?? []));
|
|
109
|
+
}
|
|
110
|
+
async cleanupCampaignMarketings(campaignId) {
|
|
111
|
+
await this.marketingService.removeAllCampaignMarketings(campaignId);
|
|
112
|
+
const pausedMarketingIds = await this.repository.findPausedMarketingIdsByCampaign(campaignId);
|
|
113
|
+
await this.marketingService.resumeMarketings(pausedMarketingIds);
|
|
114
|
+
}
|
|
115
|
+
async isActiveParticipant(shopId) {
|
|
116
|
+
const campaign = await this.campaignService.getCurrent();
|
|
117
|
+
if (!campaign)
|
|
118
|
+
return false;
|
|
119
|
+
return this.repository.existsActiveByCampaignAndShop(campaign._id, shopId);
|
|
83
120
|
}
|
|
84
121
|
async getStatus(shopId) {
|
|
85
122
|
const campaign = await this.campaignService.getCurrent();
|
|
@@ -100,12 +137,13 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
|
|
|
100
137
|
const participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);
|
|
101
138
|
if (!participant)
|
|
102
139
|
throw (0, error_common_1.notFoundError)('You have not joined this campaign.');
|
|
103
|
-
this.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap, participant);
|
|
140
|
+
this.validateDiscountSelections({ campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap, participant });
|
|
104
141
|
await this.assertProductsBelongToShop(shopId, dto);
|
|
105
142
|
const resolvedDto = await this.resolveCategorySelection(shopId, dto);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
143
|
+
if (participant.marketingId) {
|
|
144
|
+
await this.marketingService.removeMarketing(participant.marketingId);
|
|
145
|
+
}
|
|
146
|
+
const { marketingId: newMarketingId } = await this.marketingService.applyMarketing(shopId, campaign, resolvedDto);
|
|
109
147
|
return this.repository.updateParticipant(campaign._id, shopId, {
|
|
110
148
|
products: resolvedDto.products ?? [],
|
|
111
149
|
isEntireMenu: resolvedDto.isEntireMenu,
|
|
@@ -120,12 +158,7 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
|
|
|
120
158
|
const { documents, total } = await this.repository.findByCampaign(dto);
|
|
121
159
|
return {
|
|
122
160
|
documents,
|
|
123
|
-
metadata: {
|
|
124
|
-
page: dto.page,
|
|
125
|
-
size: dto.size,
|
|
126
|
-
totalElements: total,
|
|
127
|
-
totalPages: Math.ceil(total / dto.size),
|
|
128
|
-
},
|
|
161
|
+
metadata: { page: dto.page, size: dto.size, totalElements: total, totalPages: Math.ceil(total / dto.size) },
|
|
129
162
|
};
|
|
130
163
|
}
|
|
131
164
|
async getParticipantIdsByCampaignId(campaignId) {
|
|
@@ -136,8 +169,34 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
|
|
|
136
169
|
const nearByShopDistance = settings.nearByShopDistance || 10000;
|
|
137
170
|
return this.repository.findNearby(campaignId, input, nearByShopDistance);
|
|
138
171
|
}
|
|
139
|
-
async
|
|
140
|
-
await this.
|
|
172
|
+
async reactivateMarketings(campaign) {
|
|
173
|
+
const participants = await this.repository.findAllActiveByCampaign(campaign._id);
|
|
174
|
+
for (const participant of participants) {
|
|
175
|
+
const dto = {
|
|
176
|
+
isEntireMenu: participant.isEntireMenu,
|
|
177
|
+
products: (participant.products ?? []),
|
|
178
|
+
shopCategories: [],
|
|
179
|
+
discountPercentage: participant.discountPercentage ?? 0,
|
|
180
|
+
maxDiscountCap: participant.maxDiscountCap ?? 0,
|
|
181
|
+
isOrderCapacityEnabled: participant.isOrderCapacityEnabled,
|
|
182
|
+
maxOrderCapacity: participant.maxOrderCapacity,
|
|
183
|
+
};
|
|
184
|
+
if (participant.marketing) {
|
|
185
|
+
await this.marketingService.removeMarketing(participant.marketing);
|
|
186
|
+
}
|
|
187
|
+
const { marketingId } = await this.marketingService.applyMarketing(participant.shop, campaign, dto);
|
|
188
|
+
await this.repository.updateParticipant(campaign._id, participant.shop, { ...dto, marketing: marketingId });
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async applyMarketingWithRollback(input) {
|
|
192
|
+
const { shopId, campaign, dto, pausedMarketings } = input;
|
|
193
|
+
try {
|
|
194
|
+
return await this.marketingService.applyMarketing(shopId, campaign, dto);
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
await this.marketingService.resumeMarketings(pausedMarketings);
|
|
198
|
+
throw err;
|
|
199
|
+
}
|
|
141
200
|
}
|
|
142
201
|
async fetchCurrentCampaignOrThrow() {
|
|
143
202
|
const campaign = await this.campaignService.getCurrent();
|
|
@@ -175,7 +234,8 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
|
|
|
175
234
|
uniqueObjectIds(ids) {
|
|
176
235
|
return [...new Map(ids.map(id => [id.toString(), id])).values()];
|
|
177
236
|
}
|
|
178
|
-
validateDiscountSelections(
|
|
237
|
+
validateDiscountSelections(input) {
|
|
238
|
+
const { campaign, discountPercentage, maxDiscountCap, participant } = input;
|
|
179
239
|
if (!campaign.discountOptions.includes(discountPercentage)) {
|
|
180
240
|
if (!participant || discountPercentage != participant.discountPercentage) {
|
|
181
241
|
throw (0, error_common_1.badRequestError)('Selected discount is not an available option for this campaign.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-participant.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAG1C,4DAAiF;AACjF,4EAAwG;AACxG,2IAAqH;AACrH,yHAAkG;AAClG,4GAKsD;AACtD,sGAAqF;AACrF,4GAAsF;AAEtF,wCAA2C;AAGpC,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IACtC,UAAU,CAA2B;IACrC,eAAe,CAAqB;IACpC,gBAAgB,CAAiC;IAEzD;QACC,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,oEAAwB,CAAC,CAAC;QAC1D,IAAI,CAAC,eAAe,GAAG,gBAAS,CAAC,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E,CAAC;IAEO,0BAA0B,CACjC,QAAgD,EAChD,kBAA0B,EAC1B,cAAsB,EACtB,WAAmC;QAEnC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC5D,IAAI,CAAC,WAAW,IAAI,kBAAkB,IAAI,WAAW,CAAC,kBAAkB,EAAE,CAAC;gBAC1E,MAAM,IAAA,8BAAe,EAAC,iEAAiE,CAAC,CAAC;YAC1F,CAAC;QACF,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YACxD,IAAI,CAAC,WAAW,IAAI,cAAc,IAAI,WAAW,CAAC,cAAc,EAAE,CAAC;gBAClE,MAAM,IAAA,8BAAe,EAAC,yEAAyE,CAAC,CAAC;YAClG,CAAC;QACF,CAAC;IACF,CAAC;CACD,CAAA;AAtMY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,gBAAO,GAAE;;GACG,kCAAkC,CAsM9C;AAEY,QAAA,qBAAqB,GAAG,gBAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign, Setting} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {LimitedTimeOfferCampaignStatus} from '@lyxa.ai/core/dist/utilities/enum';\nimport {badRequestError, conflictError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {LtoCampaignService} from '@modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service';\nimport {LtoParticipantMarketingService} from './limited-time-offer-participant-marketing.service';\nimport {\n\tJoinLtoCampaignDTO,\n\tLtoCardState,\n\tParticipantStatusDTO,\n\tParticipantSummaryDTO,\n} from '../limited-time-offer-participant.validation';\nimport {LtoParticipantQueryBuilder} from '../limited-time-offer-participant.builder';\nimport {LtoParticipantRepository} from '../limited-time-offer-participant.repository';\nimport {GetLtoCampaignParticipantsDTO} from '../../campaign/limited-time-offer-campaign.validation';\nimport {getLibraries} from '@lyxa.ai/core';\n\n@Service()\nexport class LimitedTimeOfferParticipantService {\n\tprivate repository: LtoParticipantRepository;\n\tprivate campaignService: LtoCampaignService;\n\tprivate marketingService: LtoParticipantMarketingService;\n\n\tconstructor() {\n\t\tthis.repository = Container.get(LtoParticipantRepository);\n\t\tthis.campaignService = Container.get(LtoCampaignService);\n\t\tthis.marketingService = Container.get(LtoParticipantMarketingService);\n\t}\n\n\tpublic async join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tawait this.assertNotAlreadyJoined(campaign._id, shopId);\n\t\tthis.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap);\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\t\tconst marketingId = await this.marketingService.applyMarketing(shopId, campaign, resolvedDto);\n\n\t\tconst participant = await this.repository.create(\n\t\t\tLtoParticipantQueryBuilder.buildCreateInput(campaign._id, shopId, marketingId, resolvedDto)\n\t\t);\n\t\t// Update shop\n\t\tawait this.repository.updateShopOrderCapacity(\n\t\t\tshopId,\n\t\t\tresolvedDto.isOrderCapacityEnabled,\n\t\t\tresolvedDto.maxOrderCapacity\n\t\t);\n\t\treturn participant;\n\t}\n\n\tpublic async withdraw(shopId: mongoose.Types.ObjectId): Promise<void> {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.withdraw(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tif (participant.marketing) {\n\t\t\tawait this.marketingService.removeMarketing(participant.marketing as mongoose.Types.ObjectId);\n\t\t}\n\t}\n\n\tpublic async getStatus(shopId: mongoose.Types.ObjectId): Promise<ParticipantStatusDTO> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\n\t\tif (!campaign) return { campaignState: LtoCardState.NONE };\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\n\t\tconst campaignState =\n\t\t\tcampaign.status === LimitedTimeOfferCampaignStatus.SCHEDULED\n\t\t\t\t? LtoCardState.SCHEDULED\n\t\t\t\t: campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE\n\t\t\t\t\t? LtoCardState.LIVE\n\t\t\t\t\t: LtoCardState.NONE;\n\n\t\treturn participant\n\t\t\t? { campaignState, campaign: campaign as any, participant }\n\t\t\t: { campaignState, campaign: campaign as any };\n\t}\n\n\tpublic async update(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tthis.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap, participant);\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\n\t\tconst newMarketingId = participant.marketingId\n\t\t\t? await this.marketingService.replaceMarketing(participant.marketingId, shopId, campaign, resolvedDto)\n\t\t\t: await this.marketingService.applyMarketing(shopId, campaign, resolvedDto);\n\n\t\treturn this.repository.updateParticipant(campaign._id, shopId, {\n\t\t\tproducts: resolvedDto.products ?? [],\n\t\t\tisEntireMenu: resolvedDto.isEntireMenu,\n\t\t\tdiscountPercentage: resolvedDto.discountPercentage,\n\t\t\tmaxDiscountCap: resolvedDto.maxDiscountCap,\n\t\t\tisOrderCapacityEnabled: resolvedDto.isOrderCapacityEnabled,\n\t\t\tmaxOrderCapacity: resolvedDto.maxOrderCapacity,\n\t\t\tmarketing: newMarketingId,\n\t\t});\n\t}\n\n\tpublic async getParticipants(dto: GetLtoCampaignParticipantsDTO) {\n\t\tconst { documents, total } = await this.repository.findByCampaign(dto);\n\t\treturn {\n\t\t\tdocuments,\n\t\t\tmetadata: {\n\t\t\t\tpage: dto.page,\n\t\t\t\tsize: dto.size,\n\t\t\t\ttotalElements: total,\n\t\t\t\ttotalPages: Math.ceil(total / dto.size),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic async getParticipantIdsByCampaignId(campaignId: mongoose.Types.ObjectId) {\n\t\treturn await this.repository.findParticipantIdsByCampaignId(campaignId);\n\t}\n\n\tpublic async getNearby(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tinput: { latitude: number; longitude: number }\n\t) {\n\t\tconst settings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst nearByShopDistance = settings.nearByShopDistance || 10000;\n\t\treturn this.repository.findNearby(campaignId, input, nearByShopDistance);\n\t}\n\n\tpublic async removeCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void> {\n\t\tawait this.marketingService.removeAllCampaignMarketings(campaignId);\n\t}\n\n\tprivate async fetchCurrentCampaignOrThrow(): Promise<DocumentType<LimitedTimeOfferCampaign>> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\t\tif (!campaign) {\n\t\t\tthrow badRequestError('No campaign active or scheduled.');\n\t\t}\n\t\treturn campaign;\n\t}\n\n\tprivate async assertNotAlreadyJoined(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<void> {\n\t\tif (await this.repository.existsActiveByCampaignAndShop(campaignId, shopId)) {\n\t\t\tthrow conflictError('Your shop has already joined this campaign.');\n\t\t}\n\t}\n\n\t/**\n\t * Expands the selected shop categories into their product ids and merges them with any explicitly\n\t * selected products. The marketing layer only ever receives a flat product list, so category\n\t * selection is purely an LTO-side convenience that is resolved here before anything is persisted.\n\t */\n\tprivate async resolveCategorySelection(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<JoinLtoCampaignDTO> {\n\t\tif (dto.isEntireMenu || !dto.shopCategories?.length) return dto;\n\n\t\tconst categoryProductIds = await this.repository.findProductIdsByCategories(shopId, dto.shopCategories);\n\t\tconst products = this.uniqueObjectIds([...(dto.products ?? []), ...categoryProductIds]);\n\n\t\tif (products.length === 0) {\n\t\t\tthrow badRequestError('The selected categories do not contain any products.');\n\t\t}\n\n\t\treturn { ...dto, products };\n\t}\n\n\t/**\n\t * Validates that explicitly selected products belong to the shop. Categories are not checked here:\n\t * {@link resolveCategorySelection} fetches their products with a shop-scoped query, so any category\n\t * that does not belong to the shop simply contributes no products.\n\t */\n\tprivate async assertProductsBelongToShop(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<void> {\n\t\tif (dto.isEntireMenu) return;\n\n\t\tconst productIds = this.uniqueObjectIds(dto.products ?? []);\n\t\tif (!productIds.length) return;\n\n\t\tconst owned = await this.repository.countShopProducts(shopId, productIds);\n\t\tif (owned !== productIds.length) {\n\t\t\tthrow badRequestError('One or more selected products do not belong to your shop.');\n\t\t}\n\t}\n\n\tprivate uniqueObjectIds(ids: mongoose.Types.ObjectId[]): mongoose.Types.ObjectId[] {\n\t\treturn [...new Map(ids.map(id => [id.toString(), id])).values()];\n\t}\n\n\tprivate validateDiscountSelections(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tdiscountPercentage: number,\n\t\tmaxDiscountCap: number,\n\t\tparticipant?: ParticipantSummaryDTO\n\t): void {\n\t\tif (!campaign.discountOptions.includes(discountPercentage)) {\n\t\t\tif (!participant || discountPercentage != participant.discountPercentage) {\n\t\t\t\tthrow badRequestError('Selected discount is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t\tif (!campaign.maxDiscountCaps.includes(maxDiscountCap)) {\n\t\t\tif (!participant || maxDiscountCap != participant.maxDiscountCap) {\n\t\t\t\tthrow badRequestError('Selected max discount cap is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport const ltoParticipantService = Container.get(LimitedTimeOfferParticipantService);\n"]}
|
|
1
|
+
{"version":3,"file":"limited-time-offer-participant.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAG1C,4DAAgG;AAChG,4EAAwG;AACxG,2IAAqH;AACrH,yHAAkG;AAClG,4GAMsD;AACtD,sGAAqF;AACrF,4GAAsF;AAEtF,wCAA2C;AAGpC,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IACtC,UAAU,CAA2B;IACrC,eAAe,CAAqB;IACpC,gBAAgB,CAAiC;IAEzD;QACC,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,oEAAwB,CAAC,CAAC;QAC1D,IAAI,CAAC,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,wDAAkB,CAAC,CAAC;QACzD,IAAI,CAAC,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,iFAA8B,CAAC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAA+B,EAAE,GAAuB;QACzE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,2BAA2B,EAAE,CAAC;QAC1D,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,OAAkC;QAC1D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,2BAA2B,EAAE,CAAC;QAC1D,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAC,MAAM,EAAE,GAAG,GAAG,EAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7F,CAAC;IAEO,KAAK,CA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BAAkB,EAAE,cAAc,EAAE,WAAW,EAAC,GAAG,KAAK,CAAC;QAC1E,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC5D,IAAI,CAAC,WAAW,IAAI,kBAAkB,IAAI,WAAW,CAAC,kBAAkB,EAAE,CAAC;gBAC1E,MAAM,IAAA,8BAAe,EAAC,iEAAiE,CAAC,CAAC;YAC1F,CAAC;QACF,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YACxD,IAAI,CAAC,WAAW,IAAI,cAAc,IAAI,WAAW,CAAC,cAAc,EAAE,CAAC;gBAClE,MAAM,IAAA,8BAAe,EAAC,yEAAyE,CAAC,CAAC;YAClG,CAAC;QACF,CAAC;IACF,CAAC;CACD,CAAA;AA7RY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,gBAAO,GAAE;;GACG,kCAAkC,CA6R9C;AAEY,QAAA,qBAAqB,GAAG,gBAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign, Setting} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {LimitedTimeOfferCampaignStatus, MarketingType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {badRequestError, conflictError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {LtoCampaignService} from '@modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service';\nimport {LtoParticipantMarketingService} from './limited-time-offer-participant-marketing.service';\nimport {\n\tAdminEnrollShopEntryDTO,\n\tJoinLtoCampaignDTO,\n\tLtoCardState,\n\tParticipantStatusDTO,\n\tParticipantSummaryDTO,\n} from '../limited-time-offer-participant.validation';\nimport {LtoParticipantQueryBuilder} from '../limited-time-offer-participant.builder';\nimport {LtoParticipantRepository} from '../limited-time-offer-participant.repository';\nimport {GetLtoCampaignParticipantsDTO} from '../../campaign/limited-time-offer-campaign.validation';\nimport {getLibraries} from '@lyxa.ai/core';\n\n@Service()\nexport class LimitedTimeOfferParticipantService {\n\tprivate repository: LtoParticipantRepository;\n\tprivate campaignService: LtoCampaignService;\n\tprivate marketingService: LtoParticipantMarketingService;\n\n\tconstructor() {\n\t\tthis.repository = Container.get(LtoParticipantRepository);\n\t\tthis.campaignService = Container.get(LtoCampaignService);\n\t\tthis.marketingService = Container.get(LtoParticipantMarketingService);\n\t}\n\n\tpublic async join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\t\treturn this.joinShop(campaign, shopId, dto);\n\t}\n\n\tpublic async enrollShops(entries: AdminEnrollShopEntryDTO[]) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\t\treturn Promise.all(entries.map(({shopId, ...dto}) => this.joinShop(campaign, shopId, dto)));\n\t}\n\n\tprivate async joinShop(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t) {\n\t\tawait this.assertNotAlreadyJoined(campaign._id, shopId);\n\t\tthis.validateDiscountSelections({campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap});\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\t\tconst pausedMarketings = await this.pauseIfLive(campaign, shopId);\n\n\t\tconst {marketingId, pausedMarketingIds} = await this.applyMarketingWithRollback({\n\t\t\tshopId,\n\t\t\tcampaign,\n\t\t\tdto: resolvedDto,\n\t\t\tpausedMarketings,\n\t\t});\n\t\tconst allPausedMarketings = this.uniqueObjectIds([...pausedMarketings, ...pausedMarketingIds]);\n\n\t\tconst participant = await this.repository.create(\n\t\t\tLtoParticipantQueryBuilder.buildCreateInput({\n\t\t\t\tcampaignId: campaign._id,\n\t\t\t\tshopId,\n\t\t\t\tmarketingId,\n\t\t\t\tdto: resolvedDto,\n\t\t\t\tpausedMarketings: allPausedMarketings,\n\t\t\t})\n\t\t);\n\t\tawait this.repository.updateShopOrderCapacity(\n\t\t\tshopId,\n\t\t\tresolvedDto.isOrderCapacityEnabled,\n\t\t\tresolvedDto.maxOrderCapacity\n\t\t);\n\t\treturn participant;\n\t}\n\n\tprivate async pauseIfLive(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<mongoose.Types.ObjectId[]> {\n\t\tif (campaign.status !== LimitedTimeOfferCampaignStatus.ACTIVE) return [];\n\t\treturn this.marketingService.pauseActiveShopMarketings(shopId, MarketingType.DISCOUNT);\n\t}\n\n\tpublic async withdraw(shopId: mongoose.Types.ObjectId): Promise<void> {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.withdraw(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tif (participant.marketing) {\n\t\t\tawait this.marketingService.removeMarketing(participant.marketing as mongoose.Types.ObjectId);\n\t\t}\n\t\tawait this.marketingService.resumeMarketings(\n\t\t\t(participant.pausedMarketings ?? []) as mongoose.Types.ObjectId[]\n\t\t);\n\t}\n\n\tpublic async cleanupCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void> {\n\t\tawait this.marketingService.removeAllCampaignMarketings(campaignId);\n\t\tconst pausedMarketingIds = await this.repository.findPausedMarketingIdsByCampaign(campaignId);\n\t\tawait this.marketingService.resumeMarketings(pausedMarketingIds);\n\t}\n\n\tpublic async isActiveParticipant(shopId: mongoose.Types.ObjectId): Promise<boolean> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\t\tif (!campaign) return false;\n\t\treturn this.repository.existsActiveByCampaignAndShop(campaign._id, shopId);\n\t}\n\n\tpublic async getStatus(shopId: mongoose.Types.ObjectId): Promise<ParticipantStatusDTO> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\n\t\tif (!campaign) return { campaignState: LtoCardState.NONE };\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\n\t\tconst campaignState =\n\t\t\tcampaign.status === LimitedTimeOfferCampaignStatus.SCHEDULED\n\t\t\t\t? LtoCardState.SCHEDULED\n\t\t\t\t: campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE\n\t\t\t\t\t? LtoCardState.LIVE\n\t\t\t\t\t: LtoCardState.NONE;\n\n\t\treturn participant\n\t\t\t? { campaignState, campaign: campaign as any, participant }\n\t\t\t: { campaignState, campaign: campaign as any };\n\t}\n\n\tpublic async update(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tthis.validateDiscountSelections({campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap, participant});\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\n\t\tif (participant.marketingId) {\n\t\t\tawait this.marketingService.removeMarketing(participant.marketingId);\n\t\t}\n\t\tconst {marketingId: newMarketingId} = await this.marketingService.applyMarketing(shopId, campaign, resolvedDto);\n\n\t\treturn this.repository.updateParticipant(campaign._id, shopId, {\n\t\t\tproducts: resolvedDto.products ?? [],\n\t\t\tisEntireMenu: resolvedDto.isEntireMenu,\n\t\t\tdiscountPercentage: resolvedDto.discountPercentage,\n\t\t\tmaxDiscountCap: resolvedDto.maxDiscountCap,\n\t\t\tisOrderCapacityEnabled: resolvedDto.isOrderCapacityEnabled,\n\t\t\tmaxOrderCapacity: resolvedDto.maxOrderCapacity,\n\t\t\tmarketing: newMarketingId,\n\t\t});\n\t}\n\n\tpublic async getParticipants(dto: GetLtoCampaignParticipantsDTO) {\n\t\tconst {documents, total} = await this.repository.findByCampaign(dto);\n\t\treturn {\n\t\t\tdocuments,\n\t\t\tmetadata: {page: dto.page, size: dto.size, totalElements: total, totalPages: Math.ceil(total / dto.size)},\n\t\t};\n\t}\n\n\tpublic async getParticipantIdsByCampaignId(campaignId: mongoose.Types.ObjectId) {\n\t\treturn await this.repository.findParticipantIdsByCampaignId(campaignId);\n\t}\n\n\tpublic async getNearby(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tinput: { latitude: number; longitude: number }\n\t) {\n\t\tconst settings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst nearByShopDistance = settings.nearByShopDistance || 10000;\n\t\treturn this.repository.findNearby(campaignId, input, nearByShopDistance);\n\t}\n\n\tpublic async reactivateMarketings(campaign: DocumentType<LimitedTimeOfferCampaign>): Promise<void> {\n\t\tconst participants = await this.repository.findAllActiveByCampaign(campaign._id);\n\n\t\tfor (const participant of participants) {\n\t\t\tconst dto: JoinLtoCampaignDTO = {\n\t\t\t\tisEntireMenu: participant.isEntireMenu,\n\t\t\t\tproducts: (participant.products ?? []) as mongoose.Types.ObjectId[],\n\t\t\t\tshopCategories: [],\n\t\t\t\tdiscountPercentage: participant.discountPercentage ?? 0,\n\t\t\t\tmaxDiscountCap: participant.maxDiscountCap ?? 0,\n\t\t\t\tisOrderCapacityEnabled: participant.isOrderCapacityEnabled,\n\t\t\t\tmaxOrderCapacity: participant.maxOrderCapacity,\n\t\t\t};\n\t\t\t// Drop any prior marketing (e.g. created when the shop joined between recurrences) so we\n\t\t\t// don't orphan it — it carries no campaign ref and would leak past cleanup.\n\t\t\tif (participant.marketing) {\n\t\t\t\tawait this.marketingService.removeMarketing(participant.marketing as mongoose.Types.ObjectId);\n\t\t\t}\n\t\t\tconst {marketingId} = await this.marketingService.applyMarketing(\n\t\t\t\tparticipant.shop as mongoose.Types.ObjectId,\n\t\t\t\tcampaign,\n\t\t\t\tdto,\n\t\t\t);\n\t\t\tawait this.repository.updateParticipant(\n\t\t\t\tcampaign._id,\n\t\t\t\tparticipant.shop as mongoose.Types.ObjectId,\n\t\t\t\t{...dto, marketing: marketingId},\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate async applyMarketingWithRollback(input: {\n\t\tshopId: mongoose.Types.ObjectId;\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>;\n\t\tdto: JoinLtoCampaignDTO;\n\t\tpausedMarketings: mongoose.Types.ObjectId[];\n\t}): Promise<{marketingId: mongoose.Types.ObjectId; pausedMarketingIds: mongoose.Types.ObjectId[]}> {\n\t\tconst {shopId, campaign, dto, pausedMarketings} = input;\n\t\ttry {\n\t\t\treturn await this.marketingService.applyMarketing(shopId, campaign, dto);\n\t\t} catch (err) {\n\t\t\tawait this.marketingService.resumeMarketings(pausedMarketings);\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async fetchCurrentCampaignOrThrow(): Promise<DocumentType<LimitedTimeOfferCampaign>> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\t\tif (!campaign) {\n\t\t\tthrow badRequestError('No campaign active or scheduled.');\n\t\t}\n\t\treturn campaign;\n\t}\n\n\tprivate async assertNotAlreadyJoined(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<void> {\n\t\tif (await this.repository.existsActiveByCampaignAndShop(campaignId, shopId)) {\n\t\t\tthrow conflictError('Your shop has already joined this campaign.');\n\t\t}\n\t}\n\n\t/**\n\t * Expands the selected shop categories into their product ids and merges them with any explicitly\n\t * selected products. The marketing layer only ever receives a flat product list, so category\n\t * selection is purely an LTO-side convenience that is resolved here before anything is persisted.\n\t */\n\tprivate async resolveCategorySelection(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<JoinLtoCampaignDTO> {\n\t\tif (dto.isEntireMenu || !dto.shopCategories?.length) return dto;\n\n\t\tconst categoryProductIds = await this.repository.findProductIdsByCategories(shopId, dto.shopCategories);\n\t\tconst products = this.uniqueObjectIds([...(dto.products ?? []), ...categoryProductIds]);\n\n\t\tif (products.length === 0) {\n\t\t\tthrow badRequestError('The selected categories do not contain any products.');\n\t\t}\n\n\t\treturn { ...dto, products };\n\t}\n\n\t/**\n\t * Validates that explicitly selected products belong to the shop. Categories are not checked here:\n\t * {@link resolveCategorySelection} fetches their products with a shop-scoped query, so any category\n\t * that does not belong to the shop simply contributes no products.\n\t */\n\tprivate async assertProductsBelongToShop(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<void> {\n\t\tif (dto.isEntireMenu) return;\n\n\t\tconst productIds = this.uniqueObjectIds(dto.products ?? []);\n\t\tif (!productIds.length) return;\n\n\t\tconst owned = await this.repository.countShopProducts(shopId, productIds);\n\t\tif (owned !== productIds.length) {\n\t\t\tthrow badRequestError('One or more selected products do not belong to your shop.');\n\t\t}\n\t}\n\n\tprivate uniqueObjectIds(ids: mongoose.Types.ObjectId[]): mongoose.Types.ObjectId[] {\n\t\treturn [...new Map(ids.map(id => [id.toString(), id])).values()];\n\t}\n\n\tprivate validateDiscountSelections(input: {\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>;\n\t\tdiscountPercentage: number;\n\t\tmaxDiscountCap: number;\n\t\tparticipant?: ParticipantSummaryDTO;\n\t}): void {\n\t\tconst {campaign, discountPercentage, maxDiscountCap, participant} = input;\n\t\tif (!campaign.discountOptions.includes(discountPercentage)) {\n\t\t\tif (!participant || discountPercentage != participant.discountPercentage) {\n\t\t\t\tthrow badRequestError('Selected discount is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t\tif (!campaign.maxDiscountCaps.includes(maxDiscountCap)) {\n\t\t\tif (!participant || maxDiscountCap != participant.maxDiscountCap) {\n\t\t\t\tthrow badRequestError('Selected max discount cap is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport const ltoParticipantService = Container.get(LimitedTimeOfferParticipantService);\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
+
import { LimitedTimeOfferCampaignSession as Model } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
3
|
+
export declare class LtoCampaignSessionRepository {
|
|
4
|
+
private model;
|
|
5
|
+
constructor();
|
|
6
|
+
create(data: object): Promise<InstanceType<typeof Model>>;
|
|
7
|
+
findByCampaign(campaignId: mongoose.Types.ObjectId, page: number, size: number): Promise<{
|
|
8
|
+
documents: InstanceType<typeof Model>[];
|
|
9
|
+
total: number;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export declare const ltoCampaignSessionRepository: LtoCampaignSessionRepository;
|
|
13
|
+
//# sourceMappingURL=limited-time-offer-campaign-session.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limited-time-offer-campaign-session.repository.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACH,+BAA+B,IAAI,KAAK,EAE3C,MAAM,2CAA2C,CAAC;AAEnD,qBACa,4BAA4B;IACrC,OAAO,CAAC,KAAK,CAA8C;;IAMrD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,KAAK,CAAC,CAAC;IAIzD,cAAc,CAChB,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACb,OAAO,CAAC;QAAC,SAAS,EAAE,YAAY,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC;CAYvE;AAED,eAAO,MAAM,4BAA4B,8BAA8C,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.ltoCampaignSessionRepository = exports.LtoCampaignSessionRepository = void 0;
|
|
46
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
47
|
+
const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
|
|
48
|
+
let LtoCampaignSessionRepository = class LtoCampaignSessionRepository {
|
|
49
|
+
model;
|
|
50
|
+
constructor() {
|
|
51
|
+
this.model = models_1.LimitedTimeOfferCampaignSessionModel;
|
|
52
|
+
}
|
|
53
|
+
async create(data) {
|
|
54
|
+
return this.model.create(data);
|
|
55
|
+
}
|
|
56
|
+
async findByCampaign(campaignId, page, size) {
|
|
57
|
+
const [documents, total] = await Promise.all([
|
|
58
|
+
this.model
|
|
59
|
+
.find({ campaign: campaignId })
|
|
60
|
+
.sort({ archivedAt: -1 })
|
|
61
|
+
.skip((page - 1) * size)
|
|
62
|
+
.limit(size)
|
|
63
|
+
.lean(),
|
|
64
|
+
this.model.countDocuments({ campaign: campaignId }),
|
|
65
|
+
]);
|
|
66
|
+
return { documents, total };
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.LtoCampaignSessionRepository = LtoCampaignSessionRepository;
|
|
70
|
+
exports.LtoCampaignSessionRepository = LtoCampaignSessionRepository = __decorate([
|
|
71
|
+
(0, typedi_1.Service)(),
|
|
72
|
+
__metadata("design:paramtypes", [])
|
|
73
|
+
], LtoCampaignSessionRepository);
|
|
74
|
+
exports.ltoCampaignSessionRepository = typedi_1.default.get(LtoCampaignSessionRepository);
|
|
75
|
+
//# sourceMappingURL=limited-time-offer-campaign-session.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limited-time-offer-campaign-session.repository.js","sourceRoot":"/","sources":["modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,sEAGmD;AAG5C,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAC7B,KAAK,CAA8C;IAE3D;QACI,IAAI,CAAC,KAAK,GAAG,6CAAoC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAQ,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,cAAc,CAChB,UAAmC,EACnC,IAAY,EACZ,IAAY;QAEZ,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACzC,IAAI,CAAC,KAAK;iBACL,IAAI,CAAC,EAAC,QAAQ,EAAE,UAAU,EAAC,CAAC;iBAC5B,IAAI,CAAC,EAAC,UAAU,EAAE,CAAC,CAAC,EAAC,CAAC;iBACtB,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;iBACvB,KAAK,CAAC,IAAI,CAAC;iBACX,IAAI,EAAS;YAClB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,EAAC,QAAQ,EAAE,UAAU,EAAC,CAAC;SACpD,CAAC,CAAC;QACH,OAAO,EAAC,SAAS,EAAE,KAAK,EAAC,CAAC;IAC9B,CAAC;CACJ,CAAA;AA3BY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,gBAAO,GAAE;;GACG,4BAA4B,CA2BxC;AAEY,QAAA,4BAA4B,GAAG,gBAAS,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {\n LimitedTimeOfferCampaignSession as Model,\n LimitedTimeOfferCampaignSessionModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class LtoCampaignSessionRepository {\n private model: typeof LimitedTimeOfferCampaignSessionModel;\n\n constructor() {\n this.model = LimitedTimeOfferCampaignSessionModel;\n }\n\n async create(data: object): Promise<InstanceType<typeof Model>> {\n return this.model.create(data) as any;\n }\n\n async findByCampaign(\n campaignId: mongoose.Types.ObjectId,\n page: number,\n size: number,\n ): Promise<{documents: InstanceType<typeof Model>[]; total: number}> {\n const [documents, total] = await Promise.all([\n this.model\n .find({campaign: campaignId})\n .sort({archivedAt: -1})\n .skip((page - 1) * size)\n .limit(size)\n .lean() as any,\n this.model.countDocuments({campaign: campaignId}),\n ]);\n return {documents, total};\n }\n}\n\nexport const ltoCampaignSessionRepository = Container.get(LtoCampaignSessionRepository);\n"]}
|
package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DocumentType, mongoose } from '@typegoose/typegoose';
|
|
2
|
+
import { LimitedTimeOfferCampaign } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
3
|
+
export interface LtoCampaignSessionItemDTO {
|
|
4
|
+
_id: mongoose.Types.ObjectId;
|
|
5
|
+
campaign: mongoose.Types.ObjectId;
|
|
6
|
+
startDate: Date;
|
|
7
|
+
endDate: Date;
|
|
8
|
+
shopCount: number;
|
|
9
|
+
archivedAt: Date;
|
|
10
|
+
}
|
|
11
|
+
export declare class LtoCampaignSessionService {
|
|
12
|
+
private repository;
|
|
13
|
+
constructor();
|
|
14
|
+
logSession(campaign: DocumentType<LimitedTimeOfferCampaign>, shopCount: number): Promise<void>;
|
|
15
|
+
getSessionsByCampaign(campaignId: mongoose.Types.ObjectId, page: number, size: number): Promise<{
|
|
16
|
+
documents: LtoCampaignSessionItemDTO[];
|
|
17
|
+
total: number;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export declare const ltoCampaignSessionService: LtoCampaignSessionService;
|
|
21
|
+
//# sourceMappingURL=limited-time-offer-campaign-session.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limited-time-offer-campaign-session.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/session/limited-time-offer-campaign-session.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAC,wBAAwB,EAAC,MAAM,2CAA2C,CAAC;AAGnF,MAAM,WAAW,yBAAyB;IACtC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAClC,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,IAAI,CAAC;CACpB;AAED,qBACa,yBAAyB;IAClC,OAAO,CAAC,UAAU,CAA+B;;IAMpC,UAAU,CACnB,QAAQ,EAAE,YAAY,CAAC,wBAAwB,CAAC,EAChD,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC;IAUH,qBAAqB,CAC9B,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACb,OAAO,CAAC;QAAC,SAAS,EAAE,yBAAyB,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC;CActE;AAED,eAAO,MAAM,yBAAyB,2BAA2C,CAAC"}
|
package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.ltoCampaignSessionService = exports.LtoCampaignSessionService = void 0;
|
|
46
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
47
|
+
const limited_time_offer_campaign_session_repository_1 = require("./limited-time-offer-campaign-session.repository");
|
|
48
|
+
let LtoCampaignSessionService = class LtoCampaignSessionService {
|
|
49
|
+
repository;
|
|
50
|
+
constructor() {
|
|
51
|
+
this.repository = typedi_1.default.get(limited_time_offer_campaign_session_repository_1.LtoCampaignSessionRepository);
|
|
52
|
+
}
|
|
53
|
+
async logSession(campaign, shopCount) {
|
|
54
|
+
await this.repository.create({
|
|
55
|
+
campaign: campaign._id,
|
|
56
|
+
startDate: campaign.startDate,
|
|
57
|
+
endDate: campaign.endDate,
|
|
58
|
+
shopCount,
|
|
59
|
+
archivedAt: new Date(),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async getSessionsByCampaign(campaignId, page, size) {
|
|
63
|
+
const { documents, total } = await this.repository.findByCampaign(campaignId, page, size);
|
|
64
|
+
return {
|
|
65
|
+
documents: documents.map((d) => ({
|
|
66
|
+
_id: d._id,
|
|
67
|
+
campaign: d.campaign,
|
|
68
|
+
startDate: d.startDate,
|
|
69
|
+
endDate: d.endDate,
|
|
70
|
+
shopCount: d.shopCount ?? 0,
|
|
71
|
+
archivedAt: d.archivedAt,
|
|
72
|
+
})),
|
|
73
|
+
total,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
exports.LtoCampaignSessionService = LtoCampaignSessionService;
|
|
78
|
+
exports.LtoCampaignSessionService = LtoCampaignSessionService = __decorate([
|
|
79
|
+
(0, typedi_1.Service)(),
|
|
80
|
+
__metadata("design:paramtypes", [])
|
|
81
|
+
], LtoCampaignSessionService);
|
|
82
|
+
exports.ltoCampaignSessionService = typedi_1.default.get(LtoCampaignSessionService);
|
|
83
|
+
//# sourceMappingURL=limited-time-offer-campaign-session.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limited-time-offer-campaign-session.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/session/limited-time-offer-campaign-session.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAG1C,qHAA8F;AAYvF,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAC1B,UAAU,CAA+B;IAEjD;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,6EAA4B,CAAC,CAAC;IAClE,CAAC;IAEM,KAAK,CAAC,UAAU,CACnB,QAAgD,EAChD,SAAiB;QAEjB,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YACzB,QAAQ,EAAE,QAAQ,CAAC,GAAG;YACtB,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,SAAS;YACT,UAAU,EAAE,IAAI,IAAI,EAAE;SACzB,CAAC,CAAC;IACP,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAC9B,UAAmC,EACnC,IAAY,EACZ,IAAY;QAEZ,MAAM,EAAC,SAAS,EAAE,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACxF,OAAO;YACH,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;gBAClC,GAAG,EAAE,CAAC,CAAC,GAAG;gBACV,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,SAAS,EAAE,CAAC,CAAC,SAAS;gBACtB,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC;gBAC3B,UAAU,EAAE,CAAC,CAAC,UAAU;aAC3B,CAAC,CAAC;YACH,KAAK;SACR,CAAC;IACN,CAAC;CACJ,CAAA;AAtCY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,gBAAO,GAAE;;GACG,yBAAyB,CAsCrC;AAEY,QAAA,yBAAyB,GAAG,gBAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {LtoCampaignSessionRepository} from './limited-time-offer-campaign-session.repository';\n\nexport interface LtoCampaignSessionItemDTO {\n _id: mongoose.Types.ObjectId;\n campaign: mongoose.Types.ObjectId;\n startDate: Date;\n endDate: Date;\n shopCount: number;\n archivedAt: Date;\n}\n\n@Service()\nexport class LtoCampaignSessionService {\n private repository: LtoCampaignSessionRepository;\n\n constructor() {\n this.repository = Container.get(LtoCampaignSessionRepository);\n }\n\n public async logSession(\n campaign: DocumentType<LimitedTimeOfferCampaign>,\n shopCount: number,\n ): Promise<void> {\n await this.repository.create({\n campaign: campaign._id,\n startDate: campaign.startDate,\n endDate: campaign.endDate,\n shopCount,\n archivedAt: new Date(),\n });\n }\n\n public async getSessionsByCampaign(\n campaignId: mongoose.Types.ObjectId,\n page: number,\n size: number,\n ): Promise<{documents: LtoCampaignSessionItemDTO[]; total: number}> {\n const {documents, total} = await this.repository.findByCampaign(campaignId, page, size);\n return {\n documents: documents.map((d: any) => ({\n _id: d._id,\n campaign: d.campaign,\n startDate: d.startDate,\n endDate: d.endDate,\n shopCount: d.shopCount ?? 0,\n archivedAt: d.archivedAt,\n })),\n total,\n };\n }\n}\n\nexport const ltoCampaignSessionService = Container.get(LtoCampaignSessionService);\n"]}
|
|
@@ -24,6 +24,7 @@ export declare class MarketingService {
|
|
|
24
24
|
private expireMarketingsExceedingSpendLimits;
|
|
25
25
|
private unExpireMarketingsBelowSpendLimits;
|
|
26
26
|
recomputeAndSyncAllMarketingSpent(): Promise<void>;
|
|
27
|
+
private publishEntireMenuSeedEvents;
|
|
27
28
|
reseedEntireMenuMarketing(marketingId: mongoose.Types.ObjectId): Promise<void>;
|
|
28
29
|
assignMarketingToProducts(marketing: DocumentType<Buy1Get1Marketing | DiscountMarketing>): Promise<void>;
|
|
29
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketing.service.d.ts","sourceRoot":"/","sources":["modules/marketing/services/marketing.service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EAMjB,SAAS,IAAI,KAAK,
|
|
1
|
+
{"version":3,"file":"marketing.service.d.ts","sourceRoot":"/","sources":["modules/marketing/services/marketing.service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EAMjB,SAAS,IAAI,KAAK,EAOlB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAEN,0BAA0B,EAE1B,oCAAoC,EACpC,kBAAkB,IAAI,SAAS,EAC/B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,SAAS,EACT,iBAAiB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