@lyxa.ai/marketing 1.0.34 → 1.0.37
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/index.d.ts +45 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +27 -0
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +21 -3
- package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +8 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +64 -9
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +16 -0
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js +3 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts +18 -0
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.js +8 -0
- package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.d.ts +7 -0
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +200 -0
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -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 +5 -0
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js.map +1 -1
- package/dist/types/index.d.ts +45 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +27 -0
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +8 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +16 -0
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/marketing/routers/marketing.router.d.ts +18 -0
- package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/marketing.service.d.ts +7 -0
- package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/lib/index.d.ts
CHANGED
|
@@ -689,6 +689,24 @@ declare const marketingMicroServiceRouter: import("@trpc/server").TRPCBuiltRoute
|
|
|
689
689
|
};
|
|
690
690
|
meta: object;
|
|
691
691
|
}>;
|
|
692
|
+
calculateMarketingSpent: import("@trpc/server").TRPCMutationProcedure<{
|
|
693
|
+
input: string | import("mongoose").Types.ObjectId;
|
|
694
|
+
output: {
|
|
695
|
+
success: boolean;
|
|
696
|
+
message: string;
|
|
697
|
+
data: any;
|
|
698
|
+
};
|
|
699
|
+
meta: object;
|
|
700
|
+
}>;
|
|
701
|
+
incrementMarketingSpentFromOrder: import("@trpc/server").TRPCMutationProcedure<{
|
|
702
|
+
input: string | import("mongoose").Types.ObjectId;
|
|
703
|
+
output: {
|
|
704
|
+
success: boolean;
|
|
705
|
+
message: string;
|
|
706
|
+
data: any;
|
|
707
|
+
};
|
|
708
|
+
meta: object;
|
|
709
|
+
}>;
|
|
692
710
|
}>>;
|
|
693
711
|
couponRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
694
712
|
ctx: import("@lyxa.ai/core/dist/libraries/trpc/context").LyxaHTTPContext;
|
|
@@ -6043,6 +6061,11 @@ declare const marketingMicroServiceRouter: import("@trpc/server").TRPCBuiltRoute
|
|
|
6043
6061
|
output: void;
|
|
6044
6062
|
meta: object;
|
|
6045
6063
|
}>;
|
|
6064
|
+
syncCouponExpiry: import("@trpc/server").TRPCMutationProcedure<{
|
|
6065
|
+
input: void;
|
|
6066
|
+
output: void;
|
|
6067
|
+
meta: object;
|
|
6068
|
+
}>;
|
|
6046
6069
|
addExistingCouponsToNewUser: import("@trpc/server").TRPCMutationProcedure<{
|
|
6047
6070
|
input: {
|
|
6048
6071
|
userId: string;
|
|
@@ -6057,6 +6080,28 @@ declare const marketingMicroServiceRouter: import("@trpc/server").TRPCBuiltRoute
|
|
|
6057
6080
|
output: void;
|
|
6058
6081
|
meta: object;
|
|
6059
6082
|
}>;
|
|
6083
|
+
getCouponGiftBox: import("@trpc/server").TRPCQueryProcedure<{
|
|
6084
|
+
input: {
|
|
6085
|
+
deviceId: string;
|
|
6086
|
+
};
|
|
6087
|
+
output: {
|
|
6088
|
+
success: boolean;
|
|
6089
|
+
message: string;
|
|
6090
|
+
data: import("@typegoose/typegoose").DocumentType<import("@lyxa.ai/core/dist/libraries/mongo/models").GlobalCoupon>[] | undefined;
|
|
6091
|
+
};
|
|
6092
|
+
meta: object;
|
|
6093
|
+
}>;
|
|
6094
|
+
updateCouponGiftBoxShown: import("@trpc/server").TRPCMutationProcedure<{
|
|
6095
|
+
input: {
|
|
6096
|
+
isNewUserGiftBoxShown: boolean;
|
|
6097
|
+
};
|
|
6098
|
+
output: {
|
|
6099
|
+
success: boolean;
|
|
6100
|
+
message: string;
|
|
6101
|
+
data: number | undefined;
|
|
6102
|
+
};
|
|
6103
|
+
meta: object;
|
|
6104
|
+
}>;
|
|
6060
6105
|
}>>;
|
|
6061
6106
|
punchMarketingHistoryRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
6062
6107
|
ctx: import("@lyxa.ai/core/dist/libraries/trpc/context").LyxaHTTPContext;
|
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAR/B,CAAC;AAoCH,MAAM,MAAM,2BAA2B,GAAG,OAAO,2BAA2B,CAAC"}
|
|
@@ -5353,6 +5353,11 @@ export declare const couponRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
5353
5353
|
output: void;
|
|
5354
5354
|
meta: object;
|
|
5355
5355
|
}>;
|
|
5356
|
+
syncCouponExpiry: import("@trpc/server").TRPCMutationProcedure<{
|
|
5357
|
+
input: void;
|
|
5358
|
+
output: void;
|
|
5359
|
+
meta: object;
|
|
5360
|
+
}>;
|
|
5356
5361
|
addExistingCouponsToNewUser: import("@trpc/server").TRPCMutationProcedure<{
|
|
5357
5362
|
input: {
|
|
5358
5363
|
userId: string;
|
|
@@ -5367,5 +5372,27 @@ export declare const couponRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
5367
5372
|
output: void;
|
|
5368
5373
|
meta: object;
|
|
5369
5374
|
}>;
|
|
5375
|
+
getCouponGiftBox: import("@trpc/server").TRPCQueryProcedure<{
|
|
5376
|
+
input: {
|
|
5377
|
+
deviceId: string;
|
|
5378
|
+
};
|
|
5379
|
+
output: {
|
|
5380
|
+
success: boolean;
|
|
5381
|
+
message: string;
|
|
5382
|
+
data: import("@typegoose/typegoose").DocumentType<import("@lyxa.ai/core/dist/libraries/mongo/models").GlobalCoupon>[] | undefined;
|
|
5383
|
+
};
|
|
5384
|
+
meta: object;
|
|
5385
|
+
}>;
|
|
5386
|
+
updateCouponGiftBoxShown: import("@trpc/server").TRPCMutationProcedure<{
|
|
5387
|
+
input: {
|
|
5388
|
+
isNewUserGiftBoxShown: boolean;
|
|
5389
|
+
};
|
|
5390
|
+
output: {
|
|
5391
|
+
success: boolean;
|
|
5392
|
+
message: string;
|
|
5393
|
+
data: number | undefined;
|
|
5394
|
+
};
|
|
5395
|
+
meta: object;
|
|
5396
|
+
}>;
|
|
5370
5397
|
}>>;
|
|
5371
5398
|
//# sourceMappingURL=coupon.router.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coupon.router.d.ts","sourceRoot":"/","sources":["modules/coupon/routers/coupon.router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"coupon.router.d.ts","sourceRoot":"/","sources":["modules/coupon/routers/coupon.router.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkOo2wB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GADv4wB,CAAC"}
|
|
@@ -12,6 +12,7 @@ const auth_1 = require("@lyxa.ai/core/dist/libraries/trpc/middlewares/auth");
|
|
|
12
12
|
const auth_2 = require("@lyxa.ai/core/dist/libraries/auth");
|
|
13
13
|
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
14
|
const zod_1 = require("zod");
|
|
15
|
+
const publicUserDecoder_1 = require("@lyxa.ai/core/dist/libraries/trpc/middlewares/publicUserDecoder");
|
|
15
16
|
exports.couponRouter = (0, trpc_1.createTRPCRouter)({
|
|
16
17
|
create: (0, auth_1.createAuthenticatedProcedure)({ entityTypes: [auth_2.AuthEntityType.CRM] })
|
|
17
18
|
.input(validations_1.AllCouponsValidationSchema)
|
|
@@ -126,12 +127,14 @@ exports.couponRouter = (0, trpc_1.createTRPCRouter)({
|
|
|
126
127
|
const result = await services_1.couponService.getShareableLink(input);
|
|
127
128
|
return (0, response_1.response)('Invite friend shareable link fetched successfully', result);
|
|
128
129
|
})),
|
|
129
|
-
handleCouponExpiry: trpc_1.publicProcedure
|
|
130
|
-
.input(zod_1.z.object({ couponId: zod_1.z.string() }))
|
|
131
|
-
.mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
130
|
+
handleCouponExpiry: trpc_1.publicProcedure.input(zod_1.z.object({ couponId: zod_1.z.string() })).mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
132
131
|
const result = await services_1.couponService.handleCouponExpiry(new typegoose_1.mongoose.Types.ObjectId(input.couponId));
|
|
133
132
|
return result;
|
|
134
133
|
})),
|
|
134
|
+
syncCouponExpiry: trpc_1.publicProcedure.mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
135
|
+
const result = await services_1.couponService.syncCouponExpiry();
|
|
136
|
+
return result;
|
|
137
|
+
})),
|
|
135
138
|
addExistingCouponsToNewUser: trpc_1.publicProcedure
|
|
136
139
|
.input(zod_1.z.object({ userId: zod_1.z.string() }))
|
|
137
140
|
.mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
@@ -144,5 +147,20 @@ exports.couponRouter = (0, trpc_1.createTRPCRouter)({
|
|
|
144
147
|
const result = await services_1.referralRewardCouponService.giveReferralRewardToReferrer(new typegoose_1.mongoose.Types.ObjectId(input.orderId));
|
|
145
148
|
return result;
|
|
146
149
|
})),
|
|
150
|
+
getCouponGiftBox: (0, publicUserDecoder_1.publicUserDecoder)({ entityTypes: [auth_2.AuthEntityType.USER] })
|
|
151
|
+
.input(validations_1.DeviceIdSchema)
|
|
152
|
+
.query(async ({ ctx, input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
153
|
+
const userId = ctx.entity ? new typegoose_1.mongoose.Types.ObjectId(ctx.entity?.id) : null;
|
|
154
|
+
const result = await services_1.couponService.handleCouponGiftBox(input.deviceId, userId);
|
|
155
|
+
return (0, response_1.response)('Coupon gift box fetched successfully', result);
|
|
156
|
+
})),
|
|
157
|
+
updateCouponGiftBoxShown: (0, auth_1.createAuthenticatedProcedure)({
|
|
158
|
+
entityTypes: [auth_2.AuthEntityType.USER],
|
|
159
|
+
})
|
|
160
|
+
.input(validations_1.IsNewUserGiftBoxShownSchema)
|
|
161
|
+
.mutation(async ({ ctx, input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
162
|
+
const result = await services_1.couponService.updateCouponGiftBoxShown(new typegoose_1.mongoose.Types.ObjectId(ctx.entity?.id), input);
|
|
163
|
+
return (0, response_1.response)('Gift box shown status updated successfully', result);
|
|
164
|
+
})),
|
|
147
165
|
});
|
|
148
166
|
//# sourceMappingURL=coupon.router.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3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couponService as service,\n} from '@modules/coupon/services';\nimport {\n\tCouponSchema as Schema,\n\tCouponIdValidationSchema as IdSchema,\n\tAllCouponsUpdateSchema as UpdateSchema,\n\tAllCouponsValidationSchema,\n\tCouponResponseSchema as ResponseSchema,\n\tGetUserCouponSchema,\n\tValidateCouponSchema,\n\tCouponValidationResponseSchema,\n\tCouponCodeSchema,\n\tUpdateCouponStatusSchema,\n\tCheckExistingNewUserCouponOutputSchema,\n} from '@modules/coupon/validations';\nimport { allCouponTransformer as transformer } from '@modules/coupon/transformers';\nimport {\n\tDeleteSchema,\n\tFilterSchema,\n\tShareableLinkResponseSchema,\n\tStringSchema,\n} 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';\nimport { createAuthenticatedProcedure } from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport { AuthEntityType } from '@lyxa.ai/core/dist/libraries/auth';\nimport { mongoose } from '@typegoose/typegoose';\nimport { z } from 'zod';\n\nexport const couponRouter = createTRPCRouter({\n\tcreate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(AllCouponsValidationSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.create({ ...input, createdBy: new mongoose.Types.ObjectId(ctx.entity?.id) });\n\t\t\t\treturn response('Coupon 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\tconst transformedResult = transformer.transformToBasicView(result);\n\t\t\t\treturn response('Coupon fetched successfully', transformedResult);\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('Coupons fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\tcheckExistingNewUserCoupon: publicProcedure.output(ResponseSchema).query(async () =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.checkExistingNewUserCoupon();\n\t\t\treturn response('Coupon checked successfully', result);\n\t\t})\n\t),\n\n\tupdate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(UpdateSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst { _id, data } = input;\n\t\t\t\tawait service.update(String(_id), {\n\t\t\t\t\t...data,\n\t\t\t\t\tcreatedBy: new mongoose.Types.ObjectId(ctx.entity?.id),\n\t\t\t\t});\n\t\t\t\treturn response('Coupon updated successfully');\n\t\t\t})\n\t\t),\n\n\tupdateStatus: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(UpdateCouponStatusSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst { _id, status } = input;\n\t\t\t\tawait service.updateStatus(String(_id), status);\n\t\t\t\treturn response('Coupon 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('Coupon deleted successfully');\n\t\t\t})\n\t\t),\n\n\tgetUserCoupons: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.USER] })\n\t\t.input(GetUserCouponSchema)\n\t\t// .output(ResponseSchema)\n\t\t.query(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\t\t\t\tconst id = new mongoose.Types.ObjectId(ctx.entity?.id);\n\t\t\t\tconst result = await service.getUserCoupons(\n\t\t\t\t\tisAdmin ? input.user : id,\n\t\t\t\t\tinput.shop,\n\t\t\t\t\tinput.page,\n\t\t\t\t\tinput.size\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t\t// return response('Coupons fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\tgetUserCouponList: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(FilterSchema)\n\t\t// .output(ResponseSchema)\n\t\t.query(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.getUserCouponList(input);\n\t\t\t\treturn result;\n\t\t\t\t// return response('Coupons fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\tvalidateCoupon: publicProcedure\n\t\t.input(ValidateCouponSchema)\n\t\t.output(CouponValidationResponseSchema)\n\t\t.query(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.validateCoupon(input);\n\t\t\t\treturn response('Coupon validated successfully', result);\n\t\t\t})\n\t\t),\n\n\tvalidateCouponMutation: publicProcedure\n\t\t.input(ValidateCouponSchema)\n\t\t.output(CouponValidationResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.validateCoupon(input);\n\t\t\t\tconst message = result.isValid ? 'Coupon validated successfully' : 'Coupon validation failed';\n\t\t\t\treturn response(message, result);\n\t\t\t})\n\t\t),\n\n\tcreateReferralCodeForUser: createAuthenticatedProcedure({\n\t\tentityTypes: [AuthEntityType.CRM, AuthEntityType.USER],\n\t})\n\t\t.input(GetUserCouponSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\t\t\t\tconst id = new mongoose.Types.ObjectId(ctx.entity?.id);\n\t\t\t\tconst result = await referralCodeCouponService.createReferralCodeForUser(isAdmin ? input.user : id);\n\t\t\t\treturn result;\n\t\t\t})\n\t\t),\n\n\tgetReferralCodeCoupon: createAuthenticatedProcedure({\n\t\tentityTypes: [AuthEntityType.USER],\n\t}).query(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst id = new mongoose.Types.ObjectId(ctx.entity?.id);\n\t\t\tconst result = await referralCodeCouponService.getReferralCodeCoupon(id);\n\t\t\treturn result;\n\t\t})\n\t),\n\n\taddCouponToUser: createAuthenticatedProcedure({\n\t\tentityTypes: [AuthEntityType.USER],\n\t})\n\t\t.input(CouponCodeSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.addCouponToUser(ctx.entity?.id as string, input.couponCode);\n\t\t\t\treturn result;\n\t\t\t})\n\t\t),\n\n\tgetShareableLink: publicProcedure\n\t\t.input(StringSchema)\n\t\t.output(ShareableLinkResponseSchema)\n\t\t.query(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.getShareableLink(input);\n\t\t\t\treturn response('Invite friend shareable link fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\thandleCouponExpiry: publicProcedure\n\t\t.input(z.object({ couponId: z.string() }))\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.handleCouponExpiry(new mongoose.Types.ObjectId(input.couponId));\n\t\t\t\treturn result;\n\t\t\t})\n\t\t),\n\n\taddExistingCouponsToNewUser: publicProcedure\n\t\t.input(z.object({ userId: z.string() }))\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.addExistingCouponsToNewUser(new mongoose.Types.ObjectId(input.userId));\n\t\t\t\treturn result;\n\t\t\t})\n\t\t),\n\n\tgiveReferralRewardToReferrer: publicProcedure\n\t\t.input(z.object({ orderId: z.string() }))\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await referralRewardCouponService.giveReferralRewardToReferrer(\n\t\t\t\t\tnew mongoose.Types.ObjectId(input.orderId)\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t})\n\t\t),\n});\n"]}
|
|
1
|
+
{"version":3,"file":"coupon.router.js","sourceRoot":"/","sources":["modules/coupon/routers/coupon.router.ts"],"names":[],"mappings":";;;AAAA,4DAAsF;AACtF,uDAIkC;AAClC,6DAeqC;AACrC,+DAAmF;AACnF,wEAKiD;AACjD,8EAA0E;AAC1E,oEAAiE;AACjE,6EAAkG;AAClG,4DAAmE;AACnE,oDAAgD;AAChD,6BAAwB;AACxB,uGAAoG;AAEvF,QAAA,YAAY,GAAG,IAAA,uBAAgB,EAAC;IAC5C,MAAM,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAE,CAAC;SACzE,KAAK,CAAC,wCAA0B,CAAC;SACjC,MAAM,CAAC,kCAAc,CAAC;SACtB,QAAQ,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAClC,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,wBAAO,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QAC3F,OAAO,IAAA,mBAAQ,EAAC,6BAA6B,CAAC,CAAC;IAChD,CAAC,CAAC,CACF;IAEF,OAAO,EAAE,sBAAe;SACtB,KAAK,CAAC,sC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C,yCAA2B,CAAC;SAClC,QAAQ,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAClC,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,MAAM,GAAG,MAAM,wBAAO,CAAC,wBAAwB,CACpD,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAC3C,KAAK,CACL,CAAC;QACF,OAAO,IAAA,mBAAQ,EAAC,4CAA4C,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC,CAAC,CACF;CACF,CAAC,CAAC","sourcesContent":["import { createTRPCRouter, publicProcedure } from '@lyxa.ai/core/dist/libraries/trpc';\nimport {\n\treferralCodeCouponService,\n\treferralRewardCouponService,\n\tcouponService as service,\n} from '@modules/coupon/services';\nimport {\n\tCouponSchema as Schema,\n\tCouponIdValidationSchema as IdSchema,\n\tAllCouponsUpdateSchema as UpdateSchema,\n\tAllCouponsValidationSchema,\n\tCouponResponseSchema as ResponseSchema,\n\tGetUserCouponSchema,\n\tValidateCouponSchema,\n\tCouponValidationResponseSchema,\n\tCouponCodeSchema,\n\tUpdateCouponStatusSchema,\n\tCheckExistingNewUserCouponOutputSchema,\n\tCouponSchema,\n\tDeviceIdSchema,\n\tIsNewUserGiftBoxShownSchema,\n} from '@modules/coupon/validations';\nimport { allCouponTransformer as transformer } from '@modules/coupon/transformers';\nimport {\n\tDeleteSchema,\n\tFilterSchema,\n\tShareableLinkResponseSchema,\n\tStringSchema,\n} 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';\nimport { createAuthenticatedProcedure } from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport { AuthEntityType } from '@lyxa.ai/core/dist/libraries/auth';\nimport { mongoose } from '@typegoose/typegoose';\nimport { z } from 'zod';\nimport { publicUserDecoder } from '@lyxa.ai/core/dist/libraries/trpc/middlewares/publicUserDecoder';\n\nexport const couponRouter = createTRPCRouter({\n\tcreate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(AllCouponsValidationSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.create({ ...input, createdBy: new mongoose.Types.ObjectId(ctx.entity?.id) });\n\t\t\t\treturn response('Coupon 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\tconst transformedResult = transformer.transformToBasicView(result);\n\t\t\t\treturn response('Coupon fetched successfully', transformedResult);\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('Coupons fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\tcheckExistingNewUserCoupon: publicProcedure.output(ResponseSchema).query(async () =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.checkExistingNewUserCoupon();\n\t\t\treturn response('Coupon checked successfully', result);\n\t\t})\n\t),\n\n\tupdate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(UpdateSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst { _id, data } = input;\n\t\t\t\tawait service.update(String(_id), {\n\t\t\t\t\t...data,\n\t\t\t\t\tcreatedBy: new mongoose.Types.ObjectId(ctx.entity?.id),\n\t\t\t\t});\n\t\t\t\treturn response('Coupon updated successfully');\n\t\t\t})\n\t\t),\n\n\tupdateStatus: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(UpdateCouponStatusSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst { _id, status } = input;\n\t\t\t\tawait service.updateStatus(String(_id), status);\n\t\t\t\treturn response('Coupon 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('Coupon deleted successfully');\n\t\t\t})\n\t\t),\n\n\tgetUserCoupons: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.USER] })\n\t\t.input(GetUserCouponSchema)\n\t\t// .output(ResponseSchema)\n\t\t.query(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\t\t\t\tconst id = new mongoose.Types.ObjectId(ctx.entity?.id);\n\t\t\t\tconst result = await service.getUserCoupons(\n\t\t\t\t\tisAdmin ? input.user : id,\n\t\t\t\t\tinput.shop,\n\t\t\t\t\tinput.page,\n\t\t\t\t\tinput.size\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t\t// return response('Coupons fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\tgetUserCouponList: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(FilterSchema)\n\t\t// .output(ResponseSchema)\n\t\t.query(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.getUserCouponList(input);\n\t\t\t\treturn result;\n\t\t\t\t// return response('Coupons fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\tvalidateCoupon: publicProcedure\n\t\t.input(ValidateCouponSchema)\n\t\t.output(CouponValidationResponseSchema)\n\t\t.query(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.validateCoupon(input);\n\t\t\t\treturn response('Coupon validated successfully', result);\n\t\t\t})\n\t\t),\n\n\tvalidateCouponMutation: publicProcedure\n\t\t.input(ValidateCouponSchema)\n\t\t.output(CouponValidationResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.validateCoupon(input);\n\t\t\t\tconst message = result.isValid ? 'Coupon validated successfully' : 'Coupon validation failed';\n\t\t\t\treturn response(message, result);\n\t\t\t})\n\t\t),\n\n\tcreateReferralCodeForUser: createAuthenticatedProcedure({\n\t\tentityTypes: [AuthEntityType.CRM, AuthEntityType.USER],\n\t})\n\t\t.input(GetUserCouponSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\t\t\t\tconst id = new mongoose.Types.ObjectId(ctx.entity?.id);\n\t\t\t\tconst result = await referralCodeCouponService.createReferralCodeForUser(isAdmin ? input.user : id);\n\t\t\t\treturn result;\n\t\t\t})\n\t\t),\n\n\tgetReferralCodeCoupon: createAuthenticatedProcedure({\n\t\tentityTypes: [AuthEntityType.USER],\n\t}).query(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst id = new mongoose.Types.ObjectId(ctx.entity?.id);\n\t\t\tconst result = await referralCodeCouponService.getReferralCodeCoupon(id);\n\t\t\treturn result;\n\t\t})\n\t),\n\n\taddCouponToUser: createAuthenticatedProcedure({\n\t\tentityTypes: [AuthEntityType.USER],\n\t})\n\t\t.input(CouponCodeSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.addCouponToUser(ctx.entity?.id as string, input.couponCode);\n\t\t\t\treturn result;\n\t\t\t})\n\t\t),\n\n\tgetShareableLink: publicProcedure\n\t\t.input(StringSchema)\n\t\t.output(ShareableLinkResponseSchema)\n\t\t.query(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.getShareableLink(input);\n\t\t\t\treturn response('Invite friend shareable link fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\thandleCouponExpiry: publicProcedure.input(z.object({ couponId: z.string() })).mutation(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.handleCouponExpiry(new mongoose.Types.ObjectId(input.couponId));\n\t\t\treturn result;\n\t\t})\n\t),\n\n\tsyncCouponExpiry: publicProcedure.mutation(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.syncCouponExpiry();\n\t\t\treturn result;\n\t\t})\n\t),\n\n\taddExistingCouponsToNewUser: publicProcedure\n\t\t.input(z.object({ userId: z.string() }))\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.addExistingCouponsToNewUser(new mongoose.Types.ObjectId(input.userId));\n\t\t\t\treturn result;\n\t\t\t})\n\t\t),\n\n\tgiveReferralRewardToReferrer: publicProcedure\n\t\t.input(z.object({ orderId: z.string() }))\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await referralRewardCouponService.giveReferralRewardToReferrer(\n\t\t\t\t\tnew mongoose.Types.ObjectId(input.orderId)\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t})\n\t\t),\n\n\t// Coupon gift box details - before login\n\tgetCouponGiftBox: publicUserDecoder({ entityTypes: [AuthEntityType.USER] })\n\t\t.input(DeviceIdSchema)\n\t\t.query(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst userId = ctx.entity ? new mongoose.Types.ObjectId(ctx.entity?.id) : null;\n\t\t\t\tconst result = await service.handleCouponGiftBox(input.deviceId, userId);\n\t\t\t\treturn response('Coupon gift box fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\t// Update new user coupon flag\n\tupdateCouponGiftBoxShown: createAuthenticatedProcedure({\n\t\tentityTypes: [AuthEntityType.USER],\n\t})\n\t\t.input(IsNewUserGiftBoxShownSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.updateCouponGiftBoxShown(\n\t\t\t\t\tnew mongoose.Types.ObjectId(ctx.entity?.id),\n\t\t\t\t\tinput\n\t\t\t\t);\n\t\t\t\treturn response('Gift box shown status updated successfully', result);\n\t\t\t})\n\t\t),\n});\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { DocumentType, mongoose } from '@typegoose/typegoose';
|
|
2
|
-
import { Coupon as Model } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
2
|
+
import { GlobalCoupon, Coupon as Model } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
3
3
|
import { AllCouponsValidationDTO, CouponValidationOutputDTO, ValidateCouponDTO, AllCouponsDTO, CheckExistingNewUserCouponOutputDTO } from '../../coupon/validations';
|
|
4
4
|
import { FilterDTO, PaginatedResponse, DeleteDTO, ShareableLinkDTO } from '@lyxa.ai/core/dist/utilities/validation';
|
|
5
5
|
import { ModelType } from '@typegoose/typegoose/lib/types';
|
|
6
6
|
import { Status } from '@lyxa.ai/core/dist/utilities/enum';
|
|
7
|
+
import { BaseCoupon } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
7
8
|
export declare class CouponService {
|
|
8
9
|
private model;
|
|
9
10
|
private baseCouponModel;
|
|
@@ -33,6 +34,8 @@ export declare class CouponService {
|
|
|
33
34
|
private verifyNewUserConditions;
|
|
34
35
|
private getCouponOrdersForUser;
|
|
35
36
|
handleCouponExpiry(couponId: mongoose.Types.ObjectId): Promise<void>;
|
|
37
|
+
private processCouponForExpiry;
|
|
38
|
+
syncCouponExpiry(): Promise<void>;
|
|
36
39
|
private findCouponByCode;
|
|
37
40
|
private getCouponDiscountTotals;
|
|
38
41
|
private assignCouponToUser;
|
|
@@ -47,7 +50,11 @@ export declare class CouponService {
|
|
|
47
50
|
getShareableLink: (code: string) => Promise<ShareableLinkDTO>;
|
|
48
51
|
getUserCouponList(data?: Partial<FilterDTO>): Promise<PaginatedResponse<AllCouponsDTO>>;
|
|
49
52
|
addExistingCouponsToNewUser(userId: mongoose.Types.ObjectId): Promise<void>;
|
|
53
|
+
getActiveNewUserCoupon(): Promise<DocumentType<BaseCoupon> | null>;
|
|
50
54
|
checkExistingNewUserCoupon(): Promise<CheckExistingNewUserCouponOutputDTO>;
|
|
55
|
+
private getAllOrders;
|
|
56
|
+
handleCouponGiftBox(deviceId: string, userId: mongoose.Types.ObjectId | null): Promise<DocumentType<GlobalCoupon>[]>;
|
|
57
|
+
updateCouponGiftBoxShown(userId: mongoose.Types.ObjectId, data: any): Promise<number>;
|
|
51
58
|
}
|
|
52
59
|
export declare const couponService: CouponService;
|
|
53
60
|
//# sourceMappingURL=coupon.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coupon.service.d.ts","sourceRoot":"/","sources":["modules/coupon/services/coupon.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAgC,MAAM,sBAAsB,CAAC;AAC5F,OAAO,
|
|
1
|
+
{"version":3,"file":"coupon.service.d.ts","sourceRoot":"/","sources":["modules/coupon/services/coupon.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAgC,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAKN,YAAY,EAGZ,MAAM,IAAI,KAAK,EAWf,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACN,uBAAuB,EACvB,yBAAyB,EACzB,i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,CAAC,KAAK,CAAC,QAAQ;IAsC3D,sBAAsB,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAqBlE,0BAA0B,IAAI,OAAO,CAAC,mCAAmC,CAAC;YAUzE,YAAY;IAQb,mBAAmB,CAC/B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,GACpC,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC;IAoC3B,wBAAwB,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;CAYlG;AAED,eAAO,MAAM,aAAa,eAA+B,CAAC"}
|
|
@@ -567,8 +567,11 @@ let CouponService = class CouponService {
|
|
|
567
567
|
return;
|
|
568
568
|
}
|
|
569
569
|
const typedCoupon = coupon;
|
|
570
|
+
await this.processCouponForExpiry(typedCoupon);
|
|
571
|
+
}
|
|
572
|
+
async processCouponForExpiry(coupon) {
|
|
570
573
|
let expirationReason = null;
|
|
571
|
-
if (
|
|
574
|
+
if (coupon.isTotalOrderLimitEnabled && coupon.totalOrderLimit) {
|
|
572
575
|
const pipeline = [
|
|
573
576
|
{
|
|
574
577
|
$match: {
|
|
@@ -589,7 +592,7 @@ let CouponService = class CouponService {
|
|
|
589
592
|
},
|
|
590
593
|
{
|
|
591
594
|
$match: {
|
|
592
|
-
'cart.couponCode':
|
|
595
|
+
'cart.couponCode': coupon.code,
|
|
593
596
|
},
|
|
594
597
|
},
|
|
595
598
|
{
|
|
@@ -598,17 +601,17 @@ let CouponService = class CouponService {
|
|
|
598
601
|
];
|
|
599
602
|
const result = await this.orderModel.aggregate(pipeline);
|
|
600
603
|
const orderCount = result[0]?.orderCount ?? 0;
|
|
601
|
-
if (orderCount >=
|
|
604
|
+
if (orderCount >= coupon.totalOrderLimit) {
|
|
602
605
|
expirationReason = enum_1.CouponExpirationReason.TOTAL_ORDER_LIMIT;
|
|
603
606
|
}
|
|
604
607
|
}
|
|
605
|
-
if (
|
|
606
|
-
const { totalCouponDiscount, totalSecondaryCouponDiscount } = await this.getCouponDiscountTotals(
|
|
607
|
-
if (totalCouponDiscount >=
|
|
608
|
+
if (coupon.isSpendLimitEnabled && coupon.spendLimit) {
|
|
609
|
+
const { totalCouponDiscount, totalSecondaryCouponDiscount } = await this.getCouponDiscountTotals(coupon.code);
|
|
610
|
+
if (totalCouponDiscount >= coupon.spendLimit) {
|
|
608
611
|
expirationReason = enum_1.CouponExpirationReason.SPEND_LIMIT;
|
|
609
612
|
}
|
|
610
613
|
}
|
|
611
|
-
await this.baseCouponModel.findByIdAndUpdate(
|
|
614
|
+
await this.baseCouponModel.findByIdAndUpdate(coupon._id, {
|
|
612
615
|
$set: {
|
|
613
616
|
expirationReason,
|
|
614
617
|
},
|
|
@@ -617,6 +620,20 @@ let CouponService = class CouponService {
|
|
|
617
620
|
runValidators: true,
|
|
618
621
|
});
|
|
619
622
|
}
|
|
623
|
+
async syncCouponExpiry() {
|
|
624
|
+
const coupons = await this.baseCouponModel.find({
|
|
625
|
+
couponType: { $ne: enum_1.CouponType.REFERRAL_CODE },
|
|
626
|
+
expirationReason: null,
|
|
627
|
+
});
|
|
628
|
+
console.log(`Syncing expiry for ${coupons.length} coupons`);
|
|
629
|
+
console.time('syncCouponExpiry');
|
|
630
|
+
for (const coupon of coupons) {
|
|
631
|
+
console.time(`Processing coupon ${coupon.code}`);
|
|
632
|
+
await this.processCouponForExpiry(coupon);
|
|
633
|
+
console.timeEnd(`Processing coupon ${coupon.code}`);
|
|
634
|
+
}
|
|
635
|
+
console.timeEnd('syncCouponExpiry');
|
|
636
|
+
}
|
|
620
637
|
async findCouponByCode(code) {
|
|
621
638
|
const coupon = await this.model.findOne({ code: code, updatedVersion: { $exists: false } });
|
|
622
639
|
if (!coupon) {
|
|
@@ -921,9 +938,9 @@ let CouponService = class CouponService {
|
|
|
921
938
|
runValidators: true,
|
|
922
939
|
});
|
|
923
940
|
}
|
|
924
|
-
async
|
|
941
|
+
async getActiveNewUserCoupon() {
|
|
925
942
|
const currentDate = (0, dayjs_1.dayjs)().toDate();
|
|
926
|
-
const
|
|
943
|
+
const activeForNewUserCoupon = await this.baseCouponModel.findOne({
|
|
927
944
|
couponType: enum_1.CouponType.GLOBAL,
|
|
928
945
|
forNewUserOnly: true,
|
|
929
946
|
deletedAt: null,
|
|
@@ -938,11 +955,49 @@ let CouponService = class CouponService {
|
|
|
938
955
|
'duration.end': { $gte: currentDate },
|
|
939
956
|
updatedVersion: { $exists: false },
|
|
940
957
|
});
|
|
958
|
+
return activeForNewUserCoupon;
|
|
959
|
+
}
|
|
960
|
+
async checkExistingNewUserCoupon() {
|
|
961
|
+
const alreadyActiveForNewUserCoupon = await this.getActiveNewUserCoupon();
|
|
941
962
|
if (alreadyActiveForNewUserCoupon) {
|
|
942
963
|
return { exists: true };
|
|
943
964
|
}
|
|
944
965
|
return { exists: false };
|
|
945
966
|
}
|
|
967
|
+
async getAllOrders(userIds) {
|
|
968
|
+
return await this.orderModel.countDocuments({
|
|
969
|
+
user: { $in: userIds },
|
|
970
|
+
status: { $ne: enum_1.RegularOrderStatus.CANCELLED },
|
|
971
|
+
orderType: enum_1.OrderType.REGULAR,
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
async handleCouponGiftBox(deviceId, userId) {
|
|
975
|
+
const couponRepository = new CouponRepository_1.CouponRepository();
|
|
976
|
+
const allUsers = await this.userModel.find({ deviceId }).select('_id');
|
|
977
|
+
const userIds = allUsers.map(user => user._id);
|
|
978
|
+
if (userId) {
|
|
979
|
+
userIds.push(new typegoose_1.mongoose.Types.ObjectId(userId));
|
|
980
|
+
}
|
|
981
|
+
const totalOrders = await this.getAllOrders(userIds);
|
|
982
|
+
const activeNewUserCoupon = await this.getActiveNewUserCoupon();
|
|
983
|
+
if (!activeNewUserCoupon) {
|
|
984
|
+
(0, error_common_1.notFoundError)('No active new user coupon found');
|
|
985
|
+
}
|
|
986
|
+
if (activeNewUserCoupon.isOrderLimitPerUserEnabled &&
|
|
987
|
+
totalOrders < (activeNewUserCoupon.orderLimitPerUser || 0)) {
|
|
988
|
+
return couponRepository.addLabelsToCoupons([activeNewUserCoupon.toJSON()]);
|
|
989
|
+
}
|
|
990
|
+
(0, error_common_1.notFoundError)('No gift box coupon available');
|
|
991
|
+
return [];
|
|
992
|
+
}
|
|
993
|
+
async updateCouponGiftBoxShown(userId, data) {
|
|
994
|
+
const result = await this.userModel.updateOne({ _id: userId }, {
|
|
995
|
+
$set: {
|
|
996
|
+
isNewUserCouponShowed: data.isNewUserGiftBoxShown,
|
|
997
|
+
},
|
|
998
|
+
});
|
|
999
|
+
return result.modifiedCount;
|
|
1000
|
+
}
|
|
946
1001
|
};
|
|
947
1002
|
exports.CouponService = CouponService;
|
|
948
1003
|
exports.CouponService = CouponService = __decorate([
|