@lyxa.ai/marketing 1.0.28 → 1.0.30
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 +642 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +642 -0
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +10 -0
- package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +4 -3
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +77 -50
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/custom-coupon.service.js +6 -0
- package/dist/lib/modules/coupon/services/custom-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/global-coupon.service.js +8 -1
- package/dist/lib/modules/coupon/services/global-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/helper.service.d.ts +12 -0
- package/dist/lib/modules/coupon/services/helper.service.d.ts.map +1 -0
- package/dist/lib/modules/coupon/services/helper.service.js +147 -0
- package/dist/lib/modules/coupon/services/helper.service.js.map +1 -0
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.js +9 -0
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.js +8 -1
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts +6 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js +102 -6
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js.map +1 -1
- package/dist/lib/modules/coupon/services/referral-code-coupon.service.d.ts +0 -1
- package/dist/lib/modules/coupon/services/referral-code-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/referral-code-coupon.service.js +16 -14
- package/dist/lib/modules/coupon/services/referral-code-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.d.ts +2 -1
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js +23 -20
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.js +11 -1
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +21 -0
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js +11 -8
- package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
- package/dist/lib/modules/deal-setting/routers/deal-setting.router.d.ts.map +1 -1
- package/dist/lib/modules/deal-setting/services/deal-setting.service.d.ts +2 -0
- 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 +32 -8
- package/dist/lib/modules/deal-setting/services/deal-setting.service.js.map +1 -1
- package/dist/lib/modules/featured-setting/routers/featured-setting.router.d.ts.map +1 -1
- package/dist/lib/modules/featured-setting/services/featured-setting.service.d.ts +2 -0
- 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 +54 -8
- package/dist/lib/modules/featured-setting/services/featured-setting.service.js.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.js +5 -8
- package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
- package/dist/lib/modules/marketing/services/buy1-get1-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/buy1-get1-marketing.service.js +22 -6
- package/dist/lib/modules/marketing/services/buy1-get1-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/discount-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/discount-marketing.service.js +22 -6
- package/dist/lib/modules/marketing/services/discount-marketing.service.js.map +1 -1
- 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 +31 -4
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/validations/featured-marketing.validation.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/featured-marketing.validation.js +12 -13
- package/dist/lib/modules/marketing/validations/featured-marketing.validation.js.map +1 -1
- package/dist/lib/modules/marketing/validations/free-delivery-marketing.validation.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/free-delivery-marketing.validation.js +8 -6
- package/dist/lib/modules/marketing/validations/free-delivery-marketing.validation.js.map +1 -1
- package/dist/lib/modules/marketing/validations/punch-marketing.validation.js +3 -6
- package/dist/lib/modules/marketing/validations/punch-marketing.validation.js.map +1 -1
- package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts.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 +12 -9
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js.map +1 -1
- package/dist/types/index.d.ts +642 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +642 -0
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +4 -3
- package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/helper.service.d.ts +12 -0
- package/dist/types/modules/coupon/services/helper.service.d.ts.map +1 -0
- package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/patterns/repository/CouponRepository.d.ts +6 -1
- package/dist/types/modules/coupon/services/patterns/repository/CouponRepository.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/referral-code-coupon.service.d.ts +0 -1
- package/dist/types/modules/coupon/services/referral-code-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/referral-reward-coupon.service.d.ts +2 -1
- package/dist/types/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +21 -0
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/deal-setting/routers/deal-setting.router.d.ts.map +1 -1
- package/dist/types/modules/deal-setting/services/deal-setting.service.d.ts +2 -0
- package/dist/types/modules/deal-setting/services/deal-setting.service.d.ts.map +1 -1
- package/dist/types/modules/featured-setting/routers/featured-setting.router.d.ts.map +1 -1
- package/dist/types/modules/featured-setting/services/featured-setting.service.d.ts +2 -0
- package/dist/types/modules/featured-setting/services/featured-setting.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/buy1-get1-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/discount-marketing.service.d.ts.map +1 -1
- 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/validations/featured-marketing.validation.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/free-delivery-marketing.validation.d.ts.map +1 -1
- package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.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
|
@@ -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":"AA8BA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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 @@ exports.couponRouter = (0, trpc_1.createTRPCRouter)({
|
|
|
35
35
|
const result = await services_1.couponService.find(input);
|
|
36
36
|
return (0, response_1.response)('Coupons fetched successfully', result);
|
|
37
37
|
})),
|
|
38
|
+
checkExistingNewUserCoupon: trpc_1.publicProcedure.output(validations_1.CouponResponseSchema).query(async () => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
39
|
+
const result = await services_1.couponService.checkExistingNewUserCoupon();
|
|
40
|
+
return (0, response_1.response)('Coupon checked successfully', result);
|
|
41
|
+
})),
|
|
38
42
|
update: trpc_1.publicProcedure
|
|
39
43
|
.input(validations_1.AllCouponsUpdateSchema)
|
|
40
44
|
.output(validations_1.CouponResponseSchema)
|
|
@@ -130,5 +134,11 @@ exports.couponRouter = (0, trpc_1.createTRPCRouter)({
|
|
|
130
134
|
const result = await services_1.couponService.addExistingCouponsToNewUser(new typegoose_1.mongoose.Types.ObjectId(input.userId));
|
|
131
135
|
return result;
|
|
132
136
|
})),
|
|
137
|
+
giveReferralRewardToReferrer: trpc_1.publicProcedure
|
|
138
|
+
.input(zod_1.z.object({ orderId: zod_1.z.string() }))
|
|
139
|
+
.mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
140
|
+
const result = await services_1.referralRewardCouponService.giveReferralRewardToReferrer(new typegoose_1.mongoose.Types.ObjectId(input.orderId));
|
|
141
|
+
return result;
|
|
142
|
+
})),
|
|
133
143
|
});
|
|
134
144
|
//# sourceMappingURL=coupon.router.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coupon.router.js","sourceRoot":"/","sources":["modules/coupon/routers/coupon.router.ts"],"names":[],"mappings":";;;AAAA,4DAAsF;AACtF,uDAA+F;AAC/F,6DAWqC;AACrC,+DAAmF;AACnF,wEAKiD;AACjD,8EAA0E;AAC1E,oEAAiE;AACjE,6EAAkG;AAClG,4DAAmE;AACnE,oDAAgD;AAChD,6BAAwB;AAEX,QAAA,YAAY,GAAG,I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AC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACrD,OAAO,IAAA,mBAAQ,EAAC,mDAAmD,EAAE,MAAM,CAAC,CAAC;IAC9E,CAAC,CAAC,CACF;IAEF,kBAAkB,EAAE,sBAAe;SACjC,KAAK,CAAC,OAAC,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SAC3C,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC7B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,MAAM,GAAG,MAAM,wBAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAClE,OAAO,MAAM,CAAC;IACf,CAAC,CAAC,CACF;IAEF,2BAA2B,EAAE,sBAAe;SAC1C,KAAK,CAAC,OAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SACvC,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC7B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,MAAM,GAAG,MAAM,wBAAO,CAAC,2BAA2B,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QACpG,OAAO,MAAM,CAAC;IACf,CAAC,CAAC,CACF;CACF,CAAC,CAAC","sourcesContent":["import { createTRPCRouter, publicProcedure } from '@lyxa.ai/core/dist/libraries/trpc';\nimport { referralCodeCouponService, couponService as service } 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} 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\tupdate: publicProcedure\n\t\t.input(UpdateSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst { _id, data } = input;\n\t\t\t\tawait service.update(String(_id), data);\n\t\t\t\treturn response('Coupon updated successfully');\n\t\t\t})\n\t\t),\n\n\tupdateStatus: publicProcedure\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\treturn response('Coupon validated successfully', 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({ couponCode: z.string() }))\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.handleCouponExpiry(input.couponCode);\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"]}
|
|
1
|
+
{"version":3,"file":"coupon.router.js","sourceRoot":"/","sources":["modules/coupon/routers/coupon.router.ts"],"names":[],"mappings":";;;AAAA,4DAAsF;AACtF,uDAIkC;AAClC,6DAYqC;AACrC,+DAAmF;AACnF,wEAKiD;AACjD,8EAA0E;AAC1E,oEAAiE;AACjE,6EAAkG;AAClG,4DAAmE;AACnE,oDAAgD;AAChD,6BAAwB;AAEX,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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AAG,MAAM,sCAA2B,CAAC,4BAA4B,CAC5E,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAC1C,CAAC;QACF,OAAO,MAAM,CAAC;IACf,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} 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: publicProcedure\n\t\t.input(UpdateSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst { _id, data } = input;\n\t\t\t\tawait service.update(String(_id), data);\n\t\t\t\treturn response('Coupon updated successfully');\n\t\t\t})\n\t\t),\n\n\tupdateStatus: publicProcedure\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\treturn response('Coupon validated successfully', 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({ couponCode: z.string() }))\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.handleCouponExpiry(input.couponCode);\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,6 +1,6 @@
|
|
|
1
1
|
import { DocumentType, mongoose } from '@typegoose/typegoose';
|
|
2
2
|
import { Coupon as Model } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
3
|
-
import { AllCouponsValidationDTO, CouponValidationOutputDTO, ValidateCouponDTO, AllCouponsDTO } from '../../coupon/validations';
|
|
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';
|
|
@@ -9,6 +9,7 @@ export declare class CouponService {
|
|
|
9
9
|
private baseCouponModel;
|
|
10
10
|
private userModel;
|
|
11
11
|
private orderModel;
|
|
12
|
+
private shopModel;
|
|
12
13
|
private referralRewardModel;
|
|
13
14
|
private punchHistoryService;
|
|
14
15
|
private _coreUserModel;
|
|
@@ -28,16 +29,15 @@ export declare class CouponService {
|
|
|
28
29
|
validateCoupon(data: ValidateCouponDTO): Promise<CouponValidationOutputDTO>;
|
|
29
30
|
private isCouponExpired;
|
|
30
31
|
private validateBaseCoupon;
|
|
31
|
-
private checkIfNewUser;
|
|
32
32
|
private getCouponOrdersForUser;
|
|
33
33
|
handleCouponExpiry(couponCode: string): Promise<void>;
|
|
34
34
|
private findCouponByCode;
|
|
35
35
|
private getCouponDiscountTotals;
|
|
36
36
|
private assignCouponToUser;
|
|
37
37
|
private assignCouponToMultipleUser;
|
|
38
|
+
private assignCouponToNewUsers;
|
|
38
39
|
private removeCouponFromUser;
|
|
39
40
|
private removeCouponFromMultipleUser;
|
|
40
|
-
private newUserCheck;
|
|
41
41
|
private throwBadRequest;
|
|
42
42
|
addCouponToUser(user: any, couponCode: string): Promise<DocumentType<Model>>;
|
|
43
43
|
private hasUserAlreadyAppliedCoupon;
|
|
@@ -45,6 +45,7 @@ export declare class CouponService {
|
|
|
45
45
|
getShareableLink: (code: string) => Promise<ShareableLinkDTO>;
|
|
46
46
|
getUserCouponList(data?: Partial<FilterDTO>): Promise<PaginatedResponse<AllCouponsDTO>>;
|
|
47
47
|
addExistingCouponsToNewUser(userId: mongoose.Types.ObjectId): Promise<void>;
|
|
48
|
+
checkExistingNewUserCoupon(): Promise<CheckExistingNewUserCouponOutputDTO>;
|
|
48
49
|
}
|
|
49
50
|
export declare const couponService: CouponService;
|
|
50
51
|
//# 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,EAQN,MAAM,IAAI,KAAK,
|
|
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,EAQN,MAAM,IAAI,KAAK,EAUf,MAAM,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AM,aAAa,eAA+B,CAAC"}
|
|
@@ -45,6 +45,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
45
45
|
exports.couponService = exports.CouponService = void 0;
|
|
46
46
|
const typedi_1 = __importStar(require("typedi"));
|
|
47
47
|
const server_1 = require("@trpc/server");
|
|
48
|
+
const typegoose_1 = require("@typegoose/typegoose");
|
|
48
49
|
const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
|
|
49
50
|
const pagination_1 = require("@lyxa.ai/core/dist/utilities/pagination");
|
|
50
51
|
const _1 = require(".");
|
|
@@ -55,11 +56,14 @@ const core_1 = require("@lyxa.ai/core");
|
|
|
55
56
|
const CouponRepository_1 = require("./patterns/repository/CouponRepository");
|
|
56
57
|
const error_common_1 = require("@lyxa.ai/core/dist/utilities/error-common");
|
|
57
58
|
const shops_categories_coupon_service_1 = require("./shops-categories-coupon.service");
|
|
59
|
+
const helper_service_1 = require("./helper.service");
|
|
60
|
+
const dayjs_1 = require("@lyxa.ai/core/dist/utilities/dayjs");
|
|
58
61
|
let CouponService = class CouponService {
|
|
59
62
|
model;
|
|
60
63
|
baseCouponModel;
|
|
61
64
|
userModel;
|
|
62
65
|
orderModel;
|
|
66
|
+
shopModel;
|
|
63
67
|
referralRewardModel;
|
|
64
68
|
punchHistoryService;
|
|
65
69
|
_coreUserModel = null;
|
|
@@ -68,6 +72,7 @@ let CouponService = class CouponService {
|
|
|
68
72
|
this.baseCouponModel = models_2.BaseCouponModel;
|
|
69
73
|
this.userModel = models_1.UserModel;
|
|
70
74
|
this.orderModel = models_1.RegularOrderModel;
|
|
75
|
+
this.shopModel = models_1.ShopModel;
|
|
71
76
|
this.referralRewardModel = models_1.ReferralRewardCouponModel;
|
|
72
77
|
this.punchHistoryService = services_1.punchMarketingHistoryService;
|
|
73
78
|
}
|
|
@@ -83,12 +88,8 @@ let CouponService = class CouponService {
|
|
|
83
88
|
code: data.code,
|
|
84
89
|
deletedAt: null,
|
|
85
90
|
});
|
|
86
|
-
if (checkCoupon)
|
|
87
|
-
|
|
88
|
-
code: 'CONFLICT',
|
|
89
|
-
message: 'Coupon code already exists',
|
|
90
|
-
});
|
|
91
|
-
}
|
|
91
|
+
if (checkCoupon)
|
|
92
|
+
(0, error_common_1.conflictError)('Coupon code already exists');
|
|
92
93
|
switch (data.couponType) {
|
|
93
94
|
case enum_1.CouponType.GLOBAL: {
|
|
94
95
|
coupon = await _1.globalCouponService.create(data);
|
|
@@ -97,6 +98,9 @@ let CouponService = class CouponService {
|
|
|
97
98
|
if (!globalCoupon.forNewUserOnly) {
|
|
98
99
|
await this.assignCouponToMultipleUser({}, coupon._id);
|
|
99
100
|
}
|
|
101
|
+
else {
|
|
102
|
+
await this.assignCouponToNewUsers(coupon._id);
|
|
103
|
+
}
|
|
100
104
|
}
|
|
101
105
|
break;
|
|
102
106
|
}
|
|
@@ -115,6 +119,9 @@ let CouponService = class CouponService {
|
|
|
115
119
|
if (!shopsCategoriesCoupon.forNewUserOnly) {
|
|
116
120
|
await this.assignCouponToMultipleUser({}, coupon._id);
|
|
117
121
|
}
|
|
122
|
+
else {
|
|
123
|
+
await this.assignCouponToNewUsers(coupon._id);
|
|
124
|
+
}
|
|
118
125
|
}
|
|
119
126
|
break;
|
|
120
127
|
}
|
|
@@ -125,6 +132,9 @@ let CouponService = class CouponService {
|
|
|
125
132
|
if (!individualStoreCoupon.forNewUserOnly) {
|
|
126
133
|
await this.assignCouponToMultipleUser({}, coupon._id);
|
|
127
134
|
}
|
|
135
|
+
else {
|
|
136
|
+
await this.assignCouponToNewUsers(coupon._id);
|
|
137
|
+
}
|
|
128
138
|
}
|
|
129
139
|
break;
|
|
130
140
|
}
|
|
@@ -142,18 +152,11 @@ let CouponService = class CouponService {
|
|
|
142
152
|
break;
|
|
143
153
|
}
|
|
144
154
|
default: {
|
|
145
|
-
|
|
146
|
-
code: 'BAD_REQUEST',
|
|
147
|
-
message: 'Coupon type is not valid',
|
|
148
|
-
});
|
|
155
|
+
(0, error_common_1.badRequestError)('Coupon type is not valid');
|
|
149
156
|
}
|
|
150
157
|
}
|
|
151
|
-
if (!coupon)
|
|
152
|
-
|
|
153
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
154
|
-
message: 'Could not create coupon',
|
|
155
|
-
});
|
|
156
|
-
}
|
|
158
|
+
if (!coupon)
|
|
159
|
+
(0, error_common_1.internalServerError)('Could not create coupon');
|
|
157
160
|
const dispatcher = (0, core_1.getLibraries)().getMicroServiceDispatcher();
|
|
158
161
|
const notificationRouter = await dispatcher.getMicroService('notification');
|
|
159
162
|
await notificationRouter.notificationRouter.sendPushNotificationForCoupon.mutate(coupon._id);
|
|
@@ -408,14 +411,19 @@ let CouponService = class CouponService {
|
|
|
408
411
|
}
|
|
409
412
|
async getUserCoupons(user, shop, page = 0, size = 0) {
|
|
410
413
|
const couponRepository = new CouponRepository_1.CouponRepository();
|
|
411
|
-
|
|
414
|
+
let itemType = undefined;
|
|
415
|
+
if (shop) {
|
|
416
|
+
const shopDocument = await this.shopModel.findOne({ _id: shop }).select('itemType');
|
|
417
|
+
itemType = shopDocument?.itemType;
|
|
418
|
+
}
|
|
419
|
+
const coupons = await couponRepository.getUserCoupons(user, shop, itemType);
|
|
412
420
|
if (shop && user) {
|
|
413
421
|
const punch = await this.punchHistoryService.getPunchCoupon(user, shop);
|
|
414
422
|
if (punch) {
|
|
415
423
|
coupons.available.unshift(punch);
|
|
416
424
|
}
|
|
417
425
|
}
|
|
418
|
-
return coupons;
|
|
426
|
+
return couponRepository.addLabelsToAllCoupons(coupons);
|
|
419
427
|
}
|
|
420
428
|
async validateCoupon(data) {
|
|
421
429
|
if (data.coupon === 'punch') {
|
|
@@ -425,26 +433,19 @@ let CouponService = class CouponService {
|
|
|
425
433
|
this.userModel.findById(data.user),
|
|
426
434
|
this.model.findOne({ code: data.coupon, updatedVersion: { $exists: false } }),
|
|
427
435
|
]);
|
|
428
|
-
if (!user)
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
if (!coupon) {
|
|
435
|
-
throw new server_1.TRPCError({
|
|
436
|
-
code: 'NOT_FOUND',
|
|
437
|
-
message: 'Coupon not found',
|
|
438
|
-
});
|
|
439
|
-
}
|
|
436
|
+
if (!user)
|
|
437
|
+
(0, error_common_1.notFoundError)('User not found');
|
|
438
|
+
if (!coupon)
|
|
439
|
+
(0, error_common_1.notFoundError)('Coupon not found');
|
|
440
440
|
if (coupon.couponType == enum_1.CouponType.REFERRAL_CODE) {
|
|
441
441
|
return await _1.referralCodeCouponService.validateCoupon(data);
|
|
442
442
|
}
|
|
443
443
|
const baseCoupon = coupon;
|
|
444
|
-
const isValid = await this.validateBaseCoupon(baseCoupon, user._id, data.amountBeforeCoupon);
|
|
444
|
+
const { isValid, invalidMessage } = await this.validateBaseCoupon(baseCoupon, user._id, data.amountBeforeCoupon);
|
|
445
445
|
if (!isValid) {
|
|
446
446
|
return {
|
|
447
447
|
isValid,
|
|
448
|
+
message: invalidMessage,
|
|
448
449
|
};
|
|
449
450
|
}
|
|
450
451
|
switch (coupon.couponType) {
|
|
@@ -461,10 +462,7 @@ let CouponService = class CouponService {
|
|
|
461
462
|
case enum_1.CouponType.CUSTOM_COUPON:
|
|
462
463
|
return await _1.customCouponService.validateCoupon(data, coupon);
|
|
463
464
|
default:
|
|
464
|
-
|
|
465
|
-
code: 'NOT_IMPLEMENTED',
|
|
466
|
-
message: `Validation not implemented for ${coupon.couponType} coupons`,
|
|
467
|
-
});
|
|
465
|
+
(0, error_common_1.notImplementedError)(`Validation not implemented for ${coupon.couponType} coupons`);
|
|
468
466
|
}
|
|
469
467
|
}
|
|
470
468
|
isCouponExpired(coupon) {
|
|
@@ -478,19 +476,21 @@ let CouponService = class CouponService {
|
|
|
478
476
|
this.isCouponExpired(coupon),
|
|
479
477
|
coupon.duration.start > new Date(),
|
|
480
478
|
coupon.isMinOrderValueEnabled && coupon.minOrderValue && orderAmount < coupon.minOrderValue,
|
|
481
|
-
coupon.forNewUserOnly && !(await
|
|
479
|
+
coupon.forNewUserOnly && !(await helper_service_1.couponHelperService.isNewUser(user)),
|
|
482
480
|
coupon.isOrderLimitPerUserEnabled &&
|
|
483
481
|
coupon.orderLimitPerUser &&
|
|
484
482
|
(await this.getCouponOrdersForUser(user, coupon.code)) >= coupon.orderLimitPerUser,
|
|
485
483
|
];
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
484
|
+
const invalidMessages = [
|
|
485
|
+
'This coupon is expired',
|
|
486
|
+
'This coupon is not available yet',
|
|
487
|
+
'The minimum order amount for this coupon is not met',
|
|
488
|
+
'This coupon is for new users only',
|
|
489
|
+
'You have reached the order limit for this coupon',
|
|
490
|
+
];
|
|
491
|
+
const isValid = invalidConditions.every(value => Boolean(value) == false);
|
|
492
|
+
const invalidMessage = invalidMessages.filter((_, index) => invalidConditions[index])?.[0];
|
|
493
|
+
return { isValid, invalidMessage };
|
|
494
494
|
}
|
|
495
495
|
async getCouponOrdersForUser(user, couponCode) {
|
|
496
496
|
const orders = (await this.orderModel
|
|
@@ -632,12 +632,22 @@ let CouponService = class CouponService {
|
|
|
632
632
|
});
|
|
633
633
|
}
|
|
634
634
|
async assignCouponToMultipleUser(query, coupon) {
|
|
635
|
+
console.log('Assigning coupon to multiple users with coupon:', coupon);
|
|
635
636
|
const updatedUsers = await this.userModel.updateMany(query, {
|
|
636
637
|
$push: {
|
|
637
638
|
coupons: coupon,
|
|
638
639
|
},
|
|
639
640
|
});
|
|
640
641
|
}
|
|
642
|
+
async assignCouponToNewUsers(coupon) {
|
|
643
|
+
console.log('Assigning coupon to new users', coupon);
|
|
644
|
+
const newUsers = await helper_service_1.couponHelperService.getNewUsers();
|
|
645
|
+
const updatedUsers = await this.userModel.updateMany({ _id: { $in: newUsers.map(user => user._id) } }, {
|
|
646
|
+
$push: {
|
|
647
|
+
coupons: coupon,
|
|
648
|
+
},
|
|
649
|
+
});
|
|
650
|
+
}
|
|
641
651
|
async removeCouponFromUser(user, coupon) {
|
|
642
652
|
const updatedUser = await this.userModel.findByIdAndUpdate(user, {
|
|
643
653
|
$pull: {
|
|
@@ -655,10 +665,6 @@ let CouponService = class CouponService {
|
|
|
655
665
|
},
|
|
656
666
|
});
|
|
657
667
|
}
|
|
658
|
-
async newUserCheck(userId) {
|
|
659
|
-
const user = await this.userModel.findById(userId).select('orderCompleted');
|
|
660
|
-
return (user?.orderCompleted ?? 0) < 1;
|
|
661
|
-
}
|
|
662
668
|
throwBadRequest(message) {
|
|
663
669
|
throw new server_1.TRPCError({
|
|
664
670
|
code: 'BAD_REQUEST',
|
|
@@ -670,7 +676,7 @@ let CouponService = class CouponService {
|
|
|
670
676
|
if (!coupon) {
|
|
671
677
|
this.throwBadRequest('Coupon not found');
|
|
672
678
|
}
|
|
673
|
-
const isNewUser = await
|
|
679
|
+
const isNewUser = await helper_service_1.couponHelperService.isNewUser(new typegoose_1.mongoose.Types.ObjectId(user));
|
|
674
680
|
if (coupon.couponType == enum_1.CouponType.REFERRAL_CODE && !isNewUser) {
|
|
675
681
|
this.throwBadRequest('This coupon is valid for new users only');
|
|
676
682
|
}
|
|
@@ -825,7 +831,7 @@ let CouponService = class CouponService {
|
|
|
825
831
|
}
|
|
826
832
|
async addExistingCouponsToNewUser(userId) {
|
|
827
833
|
const coupons = await this.baseCouponModel.find({
|
|
828
|
-
couponType: enum_1.CouponType.GLOBAL,
|
|
834
|
+
couponType: { $in: [enum_1.CouponType.GLOBAL, enum_1.CouponType.INDIVIDUAL_STORE, enum_1.CouponType.SHOPS_CATEGORIES] },
|
|
829
835
|
deletedAt: null,
|
|
830
836
|
expirationReason: null,
|
|
831
837
|
$or: [
|
|
@@ -845,6 +851,27 @@ let CouponService = class CouponService {
|
|
|
845
851
|
runValidators: true,
|
|
846
852
|
});
|
|
847
853
|
}
|
|
854
|
+
async checkExistingNewUserCoupon() {
|
|
855
|
+
const currentDate = (0, dayjs_1.dayjs)().toDate();
|
|
856
|
+
const alreadyActiveForNewUserCoupon = await this.baseCouponModel.findOne({
|
|
857
|
+
couponType: enum_1.CouponType.GLOBAL,
|
|
858
|
+
forNewUserOnly: true,
|
|
859
|
+
deletedAt: null,
|
|
860
|
+
$or: [
|
|
861
|
+
{
|
|
862
|
+
expirationReason: { $exists: false },
|
|
863
|
+
},
|
|
864
|
+
{
|
|
865
|
+
expirationReason: null,
|
|
866
|
+
},
|
|
867
|
+
],
|
|
868
|
+
'duration.end': { $gte: currentDate },
|
|
869
|
+
});
|
|
870
|
+
if (alreadyActiveForNewUserCoupon) {
|
|
871
|
+
return { exists: true };
|
|
872
|
+
}
|
|
873
|
+
return { exists: false };
|
|
874
|
+
}
|
|
848
875
|
};
|
|
849
876
|
exports.CouponService = CouponService;
|
|
850
877
|
exports.CouponService = CouponService = __decorate([
|