@lyxa.ai/marketing 1.0.38 → 1.0.41
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 +89 -9
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +4 -0
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +3 -0
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +111 -6
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts +28 -2
- package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/custom-coupon.service.js +13 -33
- package/dist/lib/modules/coupon/services/custom-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/helper.service.d.ts +30 -2
- package/dist/lib/modules/coupon/services/helper.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/helper.service.js +112 -4
- package/dist/lib/modules/coupon/services/helper.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts +29 -3
- 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 +10 -62
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.js.map +1 -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 +16 -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 +9 -0
- 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 +96 -29
- package/dist/lib/modules/coupon/services/referral-code-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts +29 -3
- 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 +10 -63
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +13 -0
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js +6 -14
- 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 -4
- package/dist/lib/modules/deal-setting/services/deal-setting.service.js.map +1 -1
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts +39 -0
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -0
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js +539 -0
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js.map +1 -0
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts +85 -9
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.js +26 -8
- package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.d.ts +2 -8
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +35 -354
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts +1 -0
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.js +4 -0
- 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 +28 -7
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +12 -12
- package/dist/lib/modules/marketing/validations/discount-marketing.validation.d.ts +12 -12
- package/dist/lib/modules/marketing/validations/marketing.validation.d.ts +106 -1
- package/dist/lib/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/marketing.validation.js +31 -1
- package/dist/lib/modules/marketing/validations/marketing.validation.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 +19 -1
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js.map +1 -1
- package/dist/lib/utility/utils.d.ts +3 -0
- package/dist/lib/utility/utils.d.ts.map +1 -0
- package/dist/lib/utility/utils.js +31 -0
- package/dist/lib/utility/utils.js.map +1 -0
- package/dist/types/index.d.ts +89 -9
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +4 -0
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +3 -0
- package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/custom-coupon.service.d.ts +28 -2
- package/dist/types/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/helper.service.d.ts +30 -2
- package/dist/types/modules/coupon/services/helper.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts +29 -3
- package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -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 +57 -0
- package/dist/types/modules/coupon/services/referral-code-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts +29 -3
- package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +13 -0
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/deal-setting/services/deal-setting.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts +39 -0
- package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -0
- package/dist/types/modules/marketing/routers/marketing.router.d.ts +85 -9
- package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/marketing.service.d.ts +2 -8
- package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/product-marketing.service.d.ts +1 -0
- 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/dist/types/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +12 -12
- package/dist/types/modules/marketing/validations/discount-marketing.validation.d.ts +12 -12
- package/dist/types/modules/marketing/validations/marketing.validation.d.ts +106 -1
- package/dist/types/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
- package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
- package/dist/types/utility/utils.d.ts +15 -0
- package/dist/types/utility/utils.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketing.validation.js","sourceRoot":"/","sources":["modules/marketing/validations/marketing.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,iGAImE;AACnE,
|
|
1
|
+
{"version":3,"file":"marketing.validation.js","source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A,aAAK,EAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1F,IAAI,EAAE,iCAAa,CAAC,QAAQ,CAAC,gBAAS,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,gBAAS,CAAC,KAAK,CAAC;CACxE,CAAC,CAAC;AAEU,QAAA,gCAAgC,GAAG,OAAC,CAAC,KAAK,CACtD,OAAC,CAAC,MAAM,CAAC;IACR,IAAI,EAAE,iCAAa,CAAC,MAAM,CAAC,MAAM,CAAC;IAClC,MAAM,EAAE,iCAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;CACjD,CAAC,CACF,CAAC;AAEW,QAAA,mCAAmC,GAAG,OAAC,CAAC,KAAK,CACzD,OAAC,CAAC,MAAM,CAAC;IACR,IAAI,EAAE,iCAAa,CAAC,MAAM,CAAC,MAAM,CAAC;IAClC,SAAS,EAAE,iCAAa,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;CACvD,CAAC,CACF,CAAC;AAEW,QAAA,qCAAqC,GAAG,OAAC,CAAC,KAAK,CAC3D,OAAC,CAAC,MAAM,CAAC;IACR,IAAI,EAAE,iCAAa,CAAC,MAAM,CAAC,MAAM,CAAC;IAClC,MAAM,EAAE,iCAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;CACjD,CAAC,CACF,CAAC","sourcesContent":["import { z } from 'zod';\nimport {\n\tZodValidation,\n\tcreateSchemaBuilder,\n\tDTO,\n} from '@lyxa.ai/core/dist/utilities/validation/global-validation';\nimport { GraphType, MarketingStatus, MarketingType } from '@lyxa.ai/core/dist/utilities/enum';\nimport { DurationSchema } from '@lyxa.ai/core/dist/utilities/validation/common-validation';\nimport { dayjs } from '@lyxa.ai/core/dist/utilities/dayjs';\n\n/**\n * Define the base parent schema fields\n */\nexport const baseMarketingFields = {\n\tshop: ZodValidation.objectId('Shop'),\n\tmarketingType: ZodValidation.enumType(MarketingType, 'Marketing type'),\n\tisAppliedByCompany: ZodValidation.boolean('isAppliedByCompany'),\n\tduration: DurationSchema,\n\tstatus: ZodValidation.enumType(MarketingStatus, 'Marketing status').default(MarketingStatus.ACTIVE),\n\tpausedAt: ZodValidation.date('Paused at').optional().nullable().default(null),\n\tadmin: ZodValidation.objectId('Admin').optional().nullable(),\n};\n\n/**\n * Create schema builder for Parent entity\n * - Includes timestamps\n * - Excludes 'createdAt' from update operations\n */\nconst schemaBuilder = createSchemaBuilder(baseMarketingFields);\n\n/**\n * Get all schemas for the Parent entity\n */\nconst {\n\tBaseSchema: MarketingValidationSchema,\n\tEntitySchema: MarketingSchema,\n\tIdSchema: MarketingIdSchema,\n\tUpdateSchema: UpdateMarketingSchema,\n} = schemaBuilder.getAllSchemas({ createdAt: true });\n\n/**\n * Export schemas\n */\nexport {\n\tMarketingValidationSchema,\n\tMarketingSchema,\n\tMarketingIdSchema as MarketingIdValidationSchema,\n\tUpdateMarketingSchema,\n};\n\nexport const ProductEntireMenuMarketingHandlerSchema = z.object({\n\tproduct: ZodValidation.objectId('Product'),\n\tshop: ZodValidation.objectId('Shop'),\n});\n\nexport const MarketingSpendLimitsEvaluationSchema = z.object({\n\tmarketings: ZodValidation.array(ZodValidation.objectId('marketing'), 'marketings'),\n});\n\nexport const SyncProductMarketingForMultipleProductsSchema = z.object({\n\tproductIds: ZodValidation.array(ZodValidation.objectId('product id'), 'product ids'),\n});\n\nexport const IncreaseDuringDiscountSchema = z.object({\n\tcount: ZodValidation.number('Count of orders or customers during discount').optional().default(0),\n\tpercentageIncrease: ZodValidation.number('Percentage increase compared to previous duration')\n\t\t.optional()\n\t\t.default(0),\n});\n\nexport const MarketingMetricsSchema = z.object({\n\tnumberOfItems: ZodValidation.number('Number of items in the marketing').optional(),\n\torderIncreaseWithDiscount: IncreaseDuringDiscountSchema.optional(),\n\tcustomerIncreaseWithDiscount: IncreaseDuringDiscountSchema.optional(),\n});\n\nexport const MarketingGraphInputSchema = z.object({\n\tmarketingId: ZodValidation.objectIdOrStringSchema,\n\tstartDate: ZodValidation.date('Start Date').transform(val => dayjs(val).startOf('day').toDate()),\n\tendDate: ZodValidation.date('End Date').transform(val => dayjs(val).endOf('day').toDate()),\n\ttype: ZodValidation.enumType(GraphType, 'Type').default(GraphType.DAILY),\n});\n\nexport const MarketingOrdersGraphOutputSchema = z.array(\n\tz.object({\n\t\tdate: ZodValidation.string('Date'),\n\t\torders: ZodValidation.number('Orders').default(0),\n\t})\n);\n\nexport const MarketingCustomersGraphOutputSchema = z.array(\n\tz.object({\n\t\tdate: ZodValidation.string('Date'),\n\t\tcustomers: ZodValidation.number('Customers').default(0),\n\t})\n);\n\nexport const MarketingAmountSpentGraphOutputSchema = z.array(\n\tz.object({\n\t\tdate: ZodValidation.string('Date'),\n\t\tamount: ZodValidation.number('Amount').default(0),\n\t})\n);\n\n/**\n * Export DTO types\n */\nexport type CreateMarketingDTO = DTO<typeof MarketingValidationSchema>;\nexport type MarketingDTO = DTO<typeof MarketingSchema>;\nexport type UpdateMarketingDTO = DTO<typeof UpdateMarketingSchema>;\nexport type ProductEntireMenuMarketingHandlerDTO = DTO<typeof ProductEntireMenuMarketingHandlerSchema>;\nexport type IncreaseDuringDiscountDTO = DTO<typeof IncreaseDuringDiscountSchema>;\nexport type MarketingMetricsDTO = DTO<typeof MarketingMetricsSchema>;\nexport type MarketingGraphInputDTO = DTO<typeof MarketingGraphInputSchema>;\nexport type MarketingOrdersGraphOutputDTO = DTO<typeof MarketingOrdersGraphOutputSchema>;\nexport type MarketingCustomersGraphOutputDTO = DTO<typeof MarketingCustomersGraphOutputSchema>;\nexport type MarketingAmountSpentGraphOutputDTO = DTO<typeof MarketingAmountSpentGraphOutputSchema>;"]}
|
package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"punch-marketing-history.service.d.ts","sourceRoot":"/","sources":["modules/punch-marketing-history/services/punch-marketing-history.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAElG,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAEN,qBAAqB,IAAI,KAAK,EAK9B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACN,8BAA8B,IAAI,SAAS,EAC3C,mBAAmB,EACnB,8BAA8B,IAAI,SAAS,EAC3C,MAAM,8CAA8C,CAAC;AAWtD,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"punch-marketing-history.service.d.ts","sourceRoot":"/","sources":["modules/punch-marketing-history/services/punch-marketing-history.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAElG,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAEN,qBAAqB,IAAI,KAAK,EAK9B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACN,8BAA8B,IAAI,SAAS,EAC3C,mBAAmB,EACnB,8BAA8B,IAAI,SAAS,EAC3C,MAAM,8CAA8C,CAAC;AAWtD,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAO3F,qBACa,4BAA4B;IACxC,OAAO,CAAC,KAAK,CAA6D;IAC1E,OAAO,CAAC,cAAc,CAA+D;IACrF,OAAO,CAAC,UAAU,CAA2D;;IAYhE,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,Y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
|
53
53
|
const currency_1 = require("@lyxa.ai/core/dist/utilities/currency");
|
|
54
54
|
const shared_1 = require("@lyxa.ai/core/dist/utilities/shared");
|
|
55
55
|
const core_1 = require("@lyxa.ai/core");
|
|
56
|
+
const events_common_methods_1 = require("@lyxa.ai/core/dist/utilities/events-common-methods");
|
|
57
|
+
const mongo_stream_changes_batch_process_shops_event_1 = require("@lyxa.ai/core/dist/libraries/event/events/mongo-stream-changes-batch-process-shops-event");
|
|
56
58
|
let PunchMarketingHistoryService = class PunchMarketingHistoryService {
|
|
57
59
|
model;
|
|
58
60
|
marketingModel;
|
|
@@ -158,7 +160,6 @@ let PunchMarketingHistoryService = class PunchMarketingHistoryService {
|
|
|
158
160
|
return 'Record deleted successfully';
|
|
159
161
|
}
|
|
160
162
|
async incrementUserHistory(userId, orderId) {
|
|
161
|
-
console.log('here we go');
|
|
162
163
|
const order = await this.orderModel.findById(orderId);
|
|
163
164
|
if (!order || order.user.toString != userId.toString) {
|
|
164
165
|
(0, error_common_1.notFoundError)('Order not found');
|
|
@@ -193,6 +194,11 @@ let PunchMarketingHistoryService = class PunchMarketingHistoryService {
|
|
|
193
194
|
else {
|
|
194
195
|
await this.createNewHistory(userId, order);
|
|
195
196
|
}
|
|
197
|
+
await (0, events_common_methods_1.publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent)({
|
|
198
|
+
userId,
|
|
199
|
+
shopId: order.shop._id,
|
|
200
|
+
operation: mongo_stream_changes_batch_process_shops_event_1.ChangeStreamOperationTypes.UPDATE,
|
|
201
|
+
});
|
|
196
202
|
return 'Record updated successfully';
|
|
197
203
|
}
|
|
198
204
|
async createNewHistory(userId, order) {
|
|
@@ -263,6 +269,11 @@ let PunchMarketingHistoryService = class PunchMarketingHistoryService {
|
|
|
263
269
|
marketings: punchHistory.marketing,
|
|
264
270
|
},
|
|
265
271
|
});
|
|
272
|
+
await (0, events_common_methods_1.publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent)({
|
|
273
|
+
userId,
|
|
274
|
+
shopId: order.shop._id,
|
|
275
|
+
operation: mongo_stream_changes_batch_process_shops_event_1.ChangeStreamOperationTypes.DELETE,
|
|
276
|
+
});
|
|
266
277
|
}
|
|
267
278
|
async getPunchDiscount(data) {
|
|
268
279
|
const punchHistory = await this.model.findOne({
|
|
@@ -276,6 +287,13 @@ let PunchMarketingHistoryService = class PunchMarketingHistoryService {
|
|
|
276
287
|
isValid: false,
|
|
277
288
|
};
|
|
278
289
|
}
|
|
290
|
+
if (data.scheduledAt &&
|
|
291
|
+
Boolean(punchHistory.couponExpiryDate) &&
|
|
292
|
+
(0, dayjs_1.dayjs)(punchHistory.couponExpiryDate).isBefore(data.scheduledAt)) {
|
|
293
|
+
return {
|
|
294
|
+
isValid: false,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
279
297
|
let discountAmount = punchHistory.couponValueType == enum_1.ValueType.FIXED
|
|
280
298
|
? punchHistory.couponValue
|
|
281
299
|
: (0, shared_1.roundBaseCurrency)((punchHistory.couponValue / 100) * data.amountBeforeCoupon);
|
package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"punch-marketing-history.service.js","sourceRoot":"/","sources":["modules/punch-marketing-history/services/punch-marketing-history.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAA0E;AAC1E,iDAA4C;AAC5C,yCAAyC;AAGzC,wEAA6G;AAE7G,sEAOmD;AAOnD,4DAM2C;AAC3C,8DAA2D;AAG3D,oEAA2E;AAC3E,gEAAgG;AAChG,wCAA6C;AAGtC,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAChC,KAAK,CAA6D;IAClE,cAAc,CAA+D;IAC7E,UAAU,CAA2D;IAE7E;QACC,IAAI,CAAC,KAAK,GAAG,mCAAwF,CAAC;QACtG,IAAI,CAAC,cAAc,GAAG,4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gBAAgB;aAClC;YACD,KAAK,EAAE,CAAC,IAAI,CAAC;YACb,UAAU,EAAE,IAAI;YAChB,eAAe,EAAE,CAAC;YAClB,aAAa,EAAE,IAAI;YACnB,cAAc,EAAE,KAAK;YACrB,MAAM,EAAE,aAAM,CAAC,MAAM;YACrB,gBAAgB,EAAE,IAAI;YACtB,SAAS,EAAE,YAAY,CAAC,WAAW;YACnC,SAAS,EAAE,YAAY,CAAC,WAAW;YACnC,sBAAsB,EACrB,YAAY,CAAC,eAAe,KAAK,gBAAS,CAAC,KAAK;gBAC/C,CAAC,CAAC,IAAA,+BAAsB,EAAC,YAAY,CAAC,WAAW,GAAG,YAAY,CAAC;gBACjE,CAAC,CAAC,IAAI;YACR,iCAAiC,EAAE,IAAI;YACvC,8BAA8B,EAAE,IAAI;SACpC,CAAC;QACF,OAAO,WAAW,CAAC;IACpB,CAAC;CACD,CAAA;AA/XY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,gBAAO,GAAE;;GACG,4BAA4B,CA+XxC;AAEY,QAAA,4BAA4B,GAAG,gBAAS,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC","sourcesContent":["import { notFoundError } from '@lyxa.ai/core/dist/utilities/error-common';\nimport Container, { Service } from 'typedi';\nimport { TRPCError } from '@trpc/server';\nimport { DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';\nimport { FilterDTO, PaginatedResponse, DeleteDTO } from '@lyxa.ai/core/dist/utilities/validation';\nimport { createRawDocumentPaginatorObject, PaginatorOptions } from '@lyxa.ai/core/dist/utilities/pagination';\nimport { ModelType } from '@typegoose/typegoose/lib/types';\nimport {\n\tPunchMarketingHistoryModel,\n\tPunchMarketingHistory as Model,\n\tPunchMarketingModel,\n\tPunchMarketing,\n\tRegularOrder,\n\tRegularOrderModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {\n\tCreatePunchMarketingHistoryDTO as CreateDTO,\n\tGetByUserAndShopDTO,\n\tUpdatePunchMarketingHistoryDTO as UpdateDTO,\n} from '@modules/punch-marketing-history/validations';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {\n\tCouponType,\n\tMarketingType,\n\tPunchMarketingStatus,\n\tStatus,\n\tValueType,\n} from '@lyxa.ai/core/dist/utilities/enum';\nimport { dayjs } from '@lyxa.ai/core/dist/utilities/dayjs';\nimport { PunchMarketingSchema, PunchMarketingValidationSchema } from '@modules/marketing/validations';\nimport { CouponValidationOutputDTO, ValidateCouponDTO } from '@modules/coupon/validations';\nimport { convertToSecondary } from '@lyxa.ai/core/dist/utilities/currency';\nimport { roundBaseCurrency, roundSecondaryCurrency } from '@lyxa.ai/core/dist/utilities/shared';\nimport { getLibraries } from '@lyxa.ai/core';\n\n@Service()\nexport class PunchMarketingHistoryService {\n\tprivate model: typeof PunchMarketingHistoryModel & SoftDeleteModel<Model>;\n\tprivate marketingModel: typeof PunchMarketingModel & SoftDeleteModel<PunchMarketing>;\n\tprivate orderModel: typeof RegularOrderModel & SoftDeleteModel<RegularOrder>;\n\n\tconstructor() {\n\t\tthis.model = PunchMarketingHistoryModel as typeof PunchMarketingHistoryModel & SoftDeleteModel<Model>;\n\t\tthis.marketingModel = PunchMarketingModel as typeof PunchMarketingModel & SoftDeleteModel<PunchMarketing>;\n\t\tthis.orderModel = RegularOrderModel as typeof RegularOrderModel & SoftDeleteModel<RegularOrder>;\n\t}\n\n\t/**\n\t * Create a new record\n\t * @param data Data for the new record\n\t */\n\tpublic async create(data: CreateDTO): Promise<DocumentType<Model>> {\n\t\treturn await this.model.create(data);\n\t}\n\n\t/**\n\t * Get record by ID\n\t * @param id ID of the record\n\t */\n\tpublic async findById(id: string | mongoose.Types.ObjectId): Promise<DocumentType<Model>> {\n\t\tconst result = await this.model.findOne({\n\t\t\t_id: id,\n\t\t\tdeletedAt: null,\n\t\t});\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get records\n\t * @param query Query to find records\n\t */\n\tpublic async find(data?: Partial<FilterDTO>): Promise<PaginatedResponse<DocumentType<ModelType<Model>>>> {\n\t\ttry {\n\t\t\tconst paginate = createRawDocumentPaginatorObject(this.model as ReturnModelType<typeof this.model>);\n\t\t\tconst options: PaginatorOptions<typeof Model> = {\n\t\t\t\tpage: data?.page,\n\t\t\t\tsize: data?.size,\n\t\t\t\tsort: data?.sort,\n\t\t\t\tquery: data?.query,\n\t\t\t\tselect: data?.select,\n\t\t\t\tpopulate: data?.populate,\n\t\t\t};\n\t\t\tconst paginatedResult = await paginate(options);\n\t\t\treturn paginatedResult;\n\t\t} catch (err) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: `err: ${err}`,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get Record\n\t * @param UserId ShopId to find records\n\t */\n\tpublic async getByUserAndShop(data: GetByUserAndShopDTO): Promise<any> {\n\t\tlet result = await this.model.findOne({\n\t\t\tuser: data.userId,\n\t\t\tshop: data.shopId,\n\t\t\texpiryDate: { $gt: new Date() },\n\t\t\tcompletedAt: null,\n\t\t\tstatus: PunchMarketingStatus.ACTIVE,\n\t\t});\n\n\t\tif (result) return result;\n\n\t\tconst marketing = await this.marketingModel.findOne({\n\t\t\tmarketingType: MarketingType.PUNCH_MARKETING,\n\t\t\tshop: data.shopId,\n\t\t\tstatus: Status.ACTIVE,\n\t\t\t'duration.start': { $lt: new Date() },\n\t\t\t'duration.end': { $gt: new Date() },\n\t\t});\n\n\t\tif (!marketing) notFoundError('No Punch Marketing is Active For This Shop...');\n\n\t\treturn {\n\t\t\tuser: data.userId,\n\t\t\tshop: data.shopId,\n\t\t\tmarketing: marketing!._id,\n\t\t\ttargetOrder: marketing.targetOrders,\n\t\t\tminimumOrderValue: marketing.minimumOrderValue,\n\t\t\tcompletedOrder: 0,\n\t\t\tcouponValueType: marketing.couponValueType,\n\t\t\tcouponValue: marketing.couponValue,\n\t\t\tcouponDurationInDays: marketing.couponDurationInDays,\n\t\t};\n\t}\n\n\t/**\n\t * Update record\n\t * @param id ID of the record\n\t * @param data Data to update\n\t */\n\tpublic async update(id: string, data: UpdateDTO): Promise<DocumentType<Model>> {\n\t\tconst record = await this.model.findOneAndUpdate(\n\t\t\t{\n\t\t\t\t_id: id,\n\t\t\t\tdeletedAt: null,\n\t\t\t},\n\t\t\tdata,\n\t\t\t{\n\t\t\t\tnew: true,\n\t\t\t\trunValidators: true,\n\t\t\t}\n\t\t);\n\n\t\tif (!record) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: `Record not found`,\n\t\t\t});\n\t\t}\n\n\t\treturn record;\n\t}\n\n\t/**\n\t * Delete record\n\t * @param data Data for delete\n\t */\n\tpublic async deleteById(data: DeleteDTO): Promise<string> {\n\t\tconst { _id, softDelete } = data;\n\n\t\tconst result = await this.model.deleteRecord({ _id, deletedAt: null }, softDelete);\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\n\t\treturn 'Record deleted successfully';\n\t}\n\n\t/**\n\t * Increment punch history for user\n\t * @param userId User ID\n\t * @param orderId Order ID\n\t */\n\tpublic async incrementUserHistory(\n\t\tuserId: mongoose.Types.ObjectId,\n\t\torderId: mongoose.Types.ObjectId\n\t): Promise<string> {\n\t\tconsole.log('here we go');\n\t\tconst order = await this.orderModel.findById(orderId);\n\n\t\tif (!order || order.user.toString != userId.toString) {\n\t\t\tnotFoundError('Order not found');\n\t\t}\n\n\t\tconst existingHistory = await this.model.findOne({\n\t\t\tuser: userId,\n\t\t\tshop: order.shop,\n\t\t\texpiryDate: { $gt: new Date() },\n\t\t\tcompletedAt: null,\n\t\t\tstatus: PunchMarketingStatus.ACTIVE,\n\t\t});\n\n\t\tif (existingHistory) {\n\t\t\tif (order.finance.pricing.subtotal ?? 0 >= existingHistory.minimumOrderValue) {\n\t\t\t\tconst completedAt =\n\t\t\t\t\texistingHistory.targetOrder == existingHistory.completedOrder + 1 ? new Date() : null;\n\t\t\t\tconst couponExpiryDate = completedAt\n\t\t\t\t\t? dayjs(completedAt).add(existingHistory.couponDurationInDays, 'day').toDate()\n\t\t\t\t\t: null;\n\t\t\t\tconst status = completedAt ? PunchMarketingStatus.COMPLETED : PunchMarketingStatus.ACTIVE;\n\n\t\t\t\tawait this.model.findByIdAndUpdate(\n\t\t\t\t\texistingHistory._id,\n\t\t\t\t\t{\n\t\t\t\t\t\t$inc: {\n\t\t\t\t\t\t\tcompletedOrder: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcompletedAt,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t\tcouponExpiryDate,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tnew: true,\n\t\t\t\t\t\trunValidators: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tawait this.createNewHistory(userId, order);\n\t\t}\n\n\t\treturn 'Record updated successfully';\n\t}\n\n\t/**\n\t * Create new history with current punch marketing of the shop\n\t * @param userId User ID\n\t * @param order Order document\n\t */\n\tprivate async createNewHistory(userId: mongoose.Types.ObjectId, order: DocumentType<RegularOrder>) {\n\t\tconst marketing = await this.marketingModel.findOne({\n\t\t\tmarketingType: MarketingType.PUNCH_MARKETING,\n\t\t\tshop: order.shop,\n\t\t\tstatus: Status.ACTIVE,\n\t\t\t'duration.start': { $lt: new Date() },\n\t\t\t'duration.end': { $gt: new Date() },\n\t\t});\n\n\t\tif (!marketing) notFoundError('Marketing Not Found');\n\n\t\tconst expiryDate = dayjs().add(marketing.dayLimit, 'day').toDate();\n\t\tconst couponDurationInDays = marketing!.couponDurationInDays;\n\t\tconst couponValue = marketing!.couponValue;\n\t\tconst couponValueType = marketing!.couponValueType;\n\t\tconst targetOrder = marketing!.targetOrders;\n\t\tconst minimumOrderValue = marketing!.minimumOrderValue;\n\t\tconst completedOrder = 1;\n\t\tconst status =\n\t\t\tmarketing!.targetOrders == completedOrder\n\t\t\t\t? PunchMarketingStatus.COMPLETED\n\t\t\t\t: PunchMarketingStatus.ACTIVE;\n\t\tconst completedAt = marketing!.targetOrders == completedOrder ? new Date() : null;\n\t\tconst couponExpiryDate = completedAt\n\t\t\t? dayjs(completedAt).add(marketing!.couponDurationInDays, 'day').toDate()\n\t\t\t: null;\n\n\t\tif (order.finance.pricing.subtotal ?? 0 >= marketing.minimumOrderValue) {\n\t\t\tconst data: CreateDTO = {\n\t\t\t\tuser: userId as mongoose.Types.ObjectId,\n\t\t\t\tshop: order!.shop as mongoose.Types.ObjectId,\n\t\t\t\tmarketing: marketing!._id as mongoose.Types.ObjectId,\n\t\t\t\ttargetOrder,\n\t\t\t\tminimumOrderValue,\n\t\t\t\tcompletedOrder,\n\t\t\t\tstatus,\n\t\t\t\tcouponValueType,\n\t\t\t\tcouponValue,\n\t\t\t\tcouponDurationInDays,\n\t\t\t\texpiryDate,\n\t\t\t\t...(completedAt && { completedAt }),\n\t\t\t\t...(couponExpiryDate && { couponExpiryDate }),\n\t\t\t};\n\t\t\tawait this.create(data);\n\t\t}\n\t}\n\n\tpublic async applyPunchDiscountToOrder(userId: mongoose.Types.ObjectId, orderId: mongoose.Types.ObjectId) {\n\t\tconst order = await this.orderModel.findById(orderId);\n\t\tif (!order) notFoundError('Order not found');\n\n\t\tconst punchHistory = await this.model.findOneAndUpdate(\n\t\t\t{\n\t\t\t\tuser: userId,\n\t\t\t\tshop: order.shop,\n\t\t\t\tcouponExpiryDate: { $gte: new Date() },\n\t\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t\t},\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\torder: orderId,\n\t\t\t\t\tstatus: PunchMarketingStatus.COUPON_USED,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tnew: true,\n\t\t\t\trunValidators: true,\n\t\t\t}\n\t\t);\n\n\t\tif (!punchHistory) notFoundError('No valid punch coupon available');\n\n\t\tawait this.orderModel.findByIdAndUpdate(orderId, {\n\t\t\t$push: {\n\t\t\t\tmarketings: punchHistory.marketing,\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Get punch discount\n\t * @param data Data to use for validating discount\n\t */\n\tpublic async getPunchDiscount(data: ValidateCouponDTO): Promise<CouponValidationOutputDTO> {\n\t\tconst punchHistory = await this.model.findOne({\n\t\t\tuser: data.user,\n\t\t\tshop: data.shop,\n\t\t\tcouponExpiryDate: { $gte: new Date() },\n\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t});\n\n\t\tif (!punchHistory) {\n\t\t\treturn {\n\t\t\t\tisValid: false,\n\t\t\t};\n\t\t}\n\n\t\tlet discountAmount =\n\t\t\tpunchHistory.couponValueType == ValueType.FIXED\n\t\t\t\t? punchHistory.couponValue\n\t\t\t\t: roundBaseCurrency((punchHistory.couponValue / 100) * data.amountBeforeCoupon);\n\n\t\tlet secondaryDiscountAmount =\n\t\t\tpunchHistory.couponValueType == ValueType.FIXED\n\t\t\t\t? await convertToSecondary(punchHistory.couponValue)\n\t\t\t\t: roundSecondaryCurrency((punchHistory.couponValue / 100) * data.secondaryAmountBeforeCoupon);\n\n\t\tif (discountAmount > data.amountBeforeCoupon) {\n\t\t\tdiscountAmount = data.amountBeforeCoupon;\n\t\t}\n\t\tif (secondaryDiscountAmount > data.secondaryAmountBeforeCoupon) {\n\t\t\tsecondaryDiscountAmount = data.secondaryAmountBeforeCoupon;\n\t\t}\n\n\t\treturn {\n\t\t\tisValid: true,\n\t\t\tdiscountAmount,\n\t\t\tsecondaryDiscountAmount,\n\t\t\tamountAfterCoupon: Math.max(0, roundBaseCurrency(data.amountBeforeCoupon - discountAmount)),\n\t\t\tsecondaryAmountAfterCoupon: Math.max(\n\t\t\t\t0,\n\t\t\t\troundSecondaryCurrency(data.secondaryAmountBeforeCoupon - secondaryDiscountAmount)\n\t\t\t),\n\t\t\tdiscountCut: {\n\t\t\t\tcompanyCut: 0,\n\t\t\t\tsecondaryCompanyCut: 0,\n\t\t\t\tshopCut: discountAmount,\n\t\t\t\tsecondaryShopCut: secondaryDiscountAmount,\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic async getPunchCoupon(user: mongoose.Types.ObjectId, shop: mongoose.Types.ObjectId): Promise<any> {\n\t\tconst punchHistory = await this.model.findOne({\n\t\t\tuser: user,\n\t\t\tshop: shop,\n\t\t\tcouponExpiryDate: { $gte: new Date() },\n\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t});\n\t\tif (!punchHistory) return null;\n\n\t\tconst settings = await getLibraries().getCachedSettingsService().getSettings();\n\t\tconst exchangeRate = settings?.currencySetting?.exchangeRate ?? 0;\n\n\t\tconst punchCoupon = {\n\t\t\t_id: null,\n\t\t\tcode: 'punch',\n\t\t\tcouponType: CouponType.INDIVIDUAL_USER,\n\t\t\torderLimitPerUser: 1,\n\t\t\tcreatedBy: null,\n\t\t\tdeletedAt: null,\n\t\t\tvalueType: punchHistory.couponValueType,\n\t\t\tvalue: punchHistory.couponValue,\n\t\t\tmaxDiscountLimit: null,\n\t\t\tduration: {\n\t\t\t\tstart: punchHistory.completedAt,\n\t\t\t\tend: punchHistory.couponExpiryDate,\n\t\t\t},\n\t\t\tshops: [shop],\n\t\t\tspendLimit: null,\n\t\t\ttotalOrderLimit: 1,\n\t\t\tminOrderValue: null,\n\t\t\tforNewUserOnly: false,\n\t\t\tstatus: Status.ACTIVE,\n\t\t\texpirationReason: null,\n\t\t\tcreatedAt: punchHistory.completedAt,\n\t\t\tupdatedAt: punchHistory.completedAt,\n\t\t\tsecondaryCurrencyValue:\n\t\t\t\tpunchHistory.couponValueType === ValueType.FIXED\n\t\t\t\t\t? roundSecondaryCurrency(punchHistory.couponValue * exchangeRate)\n\t\t\t\t\t: null,\n\t\t\tsecondaryCurrencyMaxDiscountLimit: null,\n\t\t\tsecondaryCurrencyMinOrderValue: null,\n\t\t};\n\t\treturn punchCoupon;\n\t}\n}\n\nexport const punchMarketingHistoryService = Container.get(PunchMarketingHistoryService);\n"]}
|
|
1
|
+
{"version":3,"file":"punch-marketing-history.service.js","sourceRoot":"/","sources":["modules/punch-marketing-history/services/punch-marketing-history.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAA0E;AAC1E,iDAA4C;AAC5C,yCAAyC;AAGzC,wEAA6G;AAE7G,sEAOmD;AAOnD,4DAM2C;AAC3C,8DAA2D;AAG3D,oEAA2E;AAC3E,gEAAgG;AAChG,wCAA6C;AAC7C,8FAA+I;AAC/I,6JAAsI;AAG/H,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAChC,KAAK,CAA6D;IAClE,cAAc,CAA+D;IAC7E,UAAU,CAA2D;IAE7E;QACC,IAAI,CAAC,KAAK,GAAG,mCAAwF,CAAC;QACtG,IAAI,CAAC,cAAc,GAAG,4BAAmF,CAAC;QAC1G,IAAI,CAAC,UAAU,GAAG,0BAA6E,CAAC;IACjG,CAAC;IAMM,KAAK,CAAC,MAAM,CAAC,IAAe;QAClC,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAMM,KAAK,CAAC,QAAQ,CAAC,EAAoC;QACzD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;YACvC,GAAG,EAAE,EAAE;YACP,SAAS,EAAE,IAAI;SACf,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,MAAM,IAAI,kBAAS,CAAC;gBACnB,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,kBAAkB;aAC3B,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,C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I,CAAC;YACb,UAAU,EAAE,IAAI;YAChB,eAAe,EAAE,CAAC;YAClB,aAAa,EAAE,IAAI;YACnB,cAAc,EAAE,KAAK;YACrB,MAAM,EAAE,aAAM,CAAC,MAAM;YACrB,gBAAgB,EAAE,IAAI;YACtB,SAAS,EAAE,YAAY,CAAC,WAAW;YACnC,SAAS,EAAE,YAAY,CAAC,WAAW;YACnC,sBAAsB,EACrB,YAAY,CAAC,eAAe,KAAK,gBAAS,CAAC,KAAK;gBAC/C,CAAC,CAAC,IAAA,+BAAsB,EAAC,YAAY,CAAC,WAAW,GAAG,YAAY,CAAC;gBACjE,CAAC,CAAC,IAAI;YACR,iCAAiC,EAAE,IAAI;YACvC,8BAA8B,EAAE,IAAI;SACpC,CAAC;QACF,OAAO,WAAW,CAAC;IACpB,CAAC;CACD,CAAA;AApZY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,gBAAO,GAAE;;GACG,4BAA4B,CAoZxC;AAEY,QAAA,4BAA4B,GAAG,gBAAS,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC","sourcesContent":["import { notFoundError } from '@lyxa.ai/core/dist/utilities/error-common';\nimport Container, { Service } from 'typedi';\nimport { TRPCError } from '@trpc/server';\nimport { DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';\nimport { FilterDTO, PaginatedResponse, DeleteDTO } from '@lyxa.ai/core/dist/utilities/validation';\nimport { createRawDocumentPaginatorObject, PaginatorOptions } from '@lyxa.ai/core/dist/utilities/pagination';\nimport { ModelType } from '@typegoose/typegoose/lib/types';\nimport {\n\tPunchMarketingHistoryModel,\n\tPunchMarketingHistory as Model,\n\tPunchMarketingModel,\n\tPunchMarketing,\n\tRegularOrder,\n\tRegularOrderModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {\n\tCreatePunchMarketingHistoryDTO as CreateDTO,\n\tGetByUserAndShopDTO,\n\tUpdatePunchMarketingHistoryDTO as UpdateDTO,\n} from '@modules/punch-marketing-history/validations';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {\n\tCouponType,\n\tMarketingType,\n\tPunchMarketingStatus,\n\tStatus,\n\tValueType,\n} from '@lyxa.ai/core/dist/utilities/enum';\nimport { dayjs } from '@lyxa.ai/core/dist/utilities/dayjs';\nimport { PunchMarketingSchema, PunchMarketingValidationSchema } from '@modules/marketing/validations';\nimport { CouponValidationOutputDTO, ValidateCouponDTO } from '@modules/coupon/validations';\nimport { convertToSecondary } from '@lyxa.ai/core/dist/utilities/currency';\nimport { roundBaseCurrency, roundSecondaryCurrency } from '@lyxa.ai/core/dist/utilities/shared';\nimport { getLibraries } from '@lyxa.ai/core';\nimport { publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent } from '@lyxa.ai/core/dist/utilities/events-common-methods';\nimport { ChangeStreamOperationTypes } from '@lyxa.ai/core/dist/libraries/event/events/mongo-stream-changes-batch-process-shops-event';\n\n@Service()\nexport class PunchMarketingHistoryService {\n\tprivate model: typeof PunchMarketingHistoryModel & SoftDeleteModel<Model>;\n\tprivate marketingModel: typeof PunchMarketingModel & SoftDeleteModel<PunchMarketing>;\n\tprivate orderModel: typeof RegularOrderModel & SoftDeleteModel<RegularOrder>;\n\n\tconstructor() {\n\t\tthis.model = PunchMarketingHistoryModel as typeof PunchMarketingHistoryModel & SoftDeleteModel<Model>;\n\t\tthis.marketingModel = PunchMarketingModel as typeof PunchMarketingModel & SoftDeleteModel<PunchMarketing>;\n\t\tthis.orderModel = RegularOrderModel as typeof RegularOrderModel & SoftDeleteModel<RegularOrder>;\n\t}\n\n\t/**\n\t * Create a new record\n\t * @param data Data for the new record\n\t */\n\tpublic async create(data: CreateDTO): Promise<DocumentType<Model>> {\n\t\treturn await this.model.create(data);\n\t}\n\n\t/**\n\t * Get record by ID\n\t * @param id ID of the record\n\t */\n\tpublic async findById(id: string | mongoose.Types.ObjectId): Promise<DocumentType<Model>> {\n\t\tconst result = await this.model.findOne({\n\t\t\t_id: id,\n\t\t\tdeletedAt: null,\n\t\t});\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get records\n\t * @param query Query to find records\n\t */\n\tpublic async find(data?: Partial<FilterDTO>): Promise<PaginatedResponse<DocumentType<ModelType<Model>>>> {\n\t\ttry {\n\t\t\tconst paginate = createRawDocumentPaginatorObject(this.model as ReturnModelType<typeof this.model>);\n\t\t\tconst options: PaginatorOptions<typeof Model> = {\n\t\t\t\tpage: data?.page,\n\t\t\t\tsize: data?.size,\n\t\t\t\tsort: data?.sort,\n\t\t\t\tquery: data?.query,\n\t\t\t\tselect: data?.select,\n\t\t\t\tpopulate: data?.populate,\n\t\t\t};\n\t\t\tconst paginatedResult = await paginate(options);\n\t\t\treturn paginatedResult;\n\t\t} catch (err) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: `err: ${err}`,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get Record\n\t * @param UserId ShopId to find records\n\t */\n\tpublic async getByUserAndShop(data: GetByUserAndShopDTO): Promise<any> {\n\t\tlet result = await this.model.findOne({\n\t\t\tuser: data.userId,\n\t\t\tshop: data.shopId,\n\t\t\texpiryDate: { $gt: new Date() },\n\t\t\tcompletedAt: null,\n\t\t\tstatus: PunchMarketingStatus.ACTIVE,\n\t\t});\n\n\t\tif (result) return result;\n\n\t\tconst marketing = await this.marketingModel.findOne({\n\t\t\tmarketingType: MarketingType.PUNCH_MARKETING,\n\t\t\tshop: data.shopId,\n\t\t\tstatus: Status.ACTIVE,\n\t\t\t'duration.start': { $lt: new Date() },\n\t\t\t'duration.end': { $gt: new Date() },\n\t\t});\n\n\t\tif (!marketing) notFoundError('No Punch Marketing is Active For This Shop...');\n\n\t\treturn {\n\t\t\tuser: data.userId,\n\t\t\tshop: data.shopId,\n\t\t\tmarketing: marketing!._id,\n\t\t\ttargetOrder: marketing.targetOrders,\n\t\t\tminimumOrderValue: marketing.minimumOrderValue,\n\t\t\tcompletedOrder: 0,\n\t\t\tcouponValueType: marketing.couponValueType,\n\t\t\tcouponValue: marketing.couponValue,\n\t\t\tcouponDurationInDays: marketing.couponDurationInDays,\n\t\t};\n\t}\n\n\t/**\n\t * Update record\n\t * @param id ID of the record\n\t * @param data Data to update\n\t */\n\tpublic async update(id: string, data: UpdateDTO): Promise<DocumentType<Model>> {\n\t\tconst record = await this.model.findOneAndUpdate(\n\t\t\t{\n\t\t\t\t_id: id,\n\t\t\t\tdeletedAt: null,\n\t\t\t},\n\t\t\tdata,\n\t\t\t{\n\t\t\t\tnew: true,\n\t\t\t\trunValidators: true,\n\t\t\t}\n\t\t);\n\n\t\tif (!record) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: `Record not found`,\n\t\t\t});\n\t\t}\n\n\t\treturn record;\n\t}\n\n\t/**\n\t * Delete record\n\t * @param data Data for delete\n\t */\n\tpublic async deleteById(data: DeleteDTO): Promise<string> {\n\t\tconst { _id, softDelete } = data;\n\n\t\tconst result = await this.model.deleteRecord({ _id, deletedAt: null }, softDelete);\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\n\t\treturn 'Record deleted successfully';\n\t}\n\n\t/**\n\t * Increment punch history for user\n\t * @param userId User ID\n\t * @param orderId Order ID\n\t */\n\tpublic async incrementUserHistory(\n\t\tuserId: mongoose.Types.ObjectId,\n\t\torderId: mongoose.Types.ObjectId\n\t): Promise<string> {\n\t\tconst order = await this.orderModel.findById(orderId);\n\n\t\tif (!order || order.user.toString != userId.toString) {\n\t\t\tnotFoundError('Order not found');\n\t\t}\n\n\t\tconst existingHistory = await this.model.findOne({\n\t\t\tuser: userId,\n\t\t\tshop: order.shop,\n\t\t\texpiryDate: { $gt: new Date() },\n\t\t\tcompletedAt: null,\n\t\t\tstatus: PunchMarketingStatus.ACTIVE,\n\t\t});\n\n\t\tif (existingHistory) {\n\t\t\tif (order.finance.pricing.subtotal ?? 0 >= existingHistory.minimumOrderValue) {\n\t\t\t\tconst completedAt =\n\t\t\t\t\texistingHistory.targetOrder == existingHistory.completedOrder + 1 ? new Date() : null;\n\t\t\t\tconst couponExpiryDate = completedAt\n\t\t\t\t\t? dayjs(completedAt).add(existingHistory.couponDurationInDays, 'day').toDate()\n\t\t\t\t\t: null;\n\t\t\t\tconst status = completedAt ? PunchMarketingStatus.COMPLETED : PunchMarketingStatus.ACTIVE;\n\n\t\t\t\tawait this.model.findByIdAndUpdate(\n\t\t\t\t\texistingHistory._id,\n\t\t\t\t\t{\n\t\t\t\t\t\t$inc: {\n\t\t\t\t\t\t\tcompletedOrder: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcompletedAt,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t\tcouponExpiryDate,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tnew: true,\n\t\t\t\t\t\trunValidators: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tawait this.createNewHistory(userId, order);\n\t\t}\n\n\t\tawait publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent({\n\t\t\tuserId,\n\t\t\tshopId: order.shop._id,\n\t\t\toperation: ChangeStreamOperationTypes.UPDATE,\n\t\t})\n\n\t\treturn 'Record updated successfully';\n\t}\n\n\t/**\n\t * Create new history with current punch marketing of the shop\n\t * @param userId User ID\n\t * @param order Order document\n\t */\n\tprivate async createNewHistory(userId: mongoose.Types.ObjectId, order: DocumentType<RegularOrder>) {\n\t\tconst marketing = await this.marketingModel.findOne({\n\t\t\tmarketingType: MarketingType.PUNCH_MARKETING,\n\t\t\tshop: order.shop,\n\t\t\tstatus: Status.ACTIVE,\n\t\t\t'duration.start': { $lt: new Date() },\n\t\t\t'duration.end': { $gt: new Date() },\n\t\t});\n\n\t\tif (!marketing) notFoundError('Marketing Not Found');\n\n\t\tconst expiryDate = dayjs().add(marketing.dayLimit, 'day').toDate();\n\t\tconst couponDurationInDays = marketing!.couponDurationInDays;\n\t\tconst couponValue = marketing!.couponValue;\n\t\tconst couponValueType = marketing!.couponValueType;\n\t\tconst targetOrder = marketing!.targetOrders;\n\t\tconst minimumOrderValue = marketing!.minimumOrderValue;\n\t\tconst completedOrder = 1;\n\t\tconst status =\n\t\t\tmarketing!.targetOrders == completedOrder\n\t\t\t\t? PunchMarketingStatus.COMPLETED\n\t\t\t\t: PunchMarketingStatus.ACTIVE;\n\t\tconst completedAt = marketing!.targetOrders == completedOrder ? new Date() : null;\n\t\tconst couponExpiryDate = completedAt\n\t\t\t? dayjs(completedAt).add(marketing!.couponDurationInDays, 'day').toDate()\n\t\t\t: null;\n\n\t\tif (order.finance.pricing.subtotal ?? 0 >= marketing.minimumOrderValue) {\n\t\t\tconst data: CreateDTO = {\n\t\t\t\tuser: userId as mongoose.Types.ObjectId,\n\t\t\t\tshop: order!.shop as mongoose.Types.ObjectId,\n\t\t\t\tmarketing: marketing!._id as mongoose.Types.ObjectId,\n\t\t\t\ttargetOrder,\n\t\t\t\tminimumOrderValue,\n\t\t\t\tcompletedOrder,\n\t\t\t\tstatus,\n\t\t\t\tcouponValueType,\n\t\t\t\tcouponValue,\n\t\t\t\tcouponDurationInDays,\n\t\t\t\texpiryDate,\n\t\t\t\t...(completedAt && { completedAt }),\n\t\t\t\t...(couponExpiryDate && { couponExpiryDate }),\n\t\t\t};\n\t\t\tawait this.create(data);\n\t\t}\n\t}\n\n\tpublic async applyPunchDiscountToOrder(userId: mongoose.Types.ObjectId, orderId: mongoose.Types.ObjectId) {\n\t\tconst order = await this.orderModel.findById(orderId);\n\t\tif (!order) notFoundError('Order not found');\n\n\t\tconst punchHistory = await this.model.findOneAndUpdate(\n\t\t\t{\n\t\t\t\tuser: userId,\n\t\t\t\tshop: order.shop,\n\t\t\t\tcouponExpiryDate: { $gte: new Date() },\n\t\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t\t},\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\torder: orderId,\n\t\t\t\t\tstatus: PunchMarketingStatus.COUPON_USED,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tnew: true,\n\t\t\t\trunValidators: true,\n\t\t\t}\n\t\t);\n\n\t\tif (!punchHistory) notFoundError('No valid punch coupon available');\n\n\t\tawait this.orderModel.findByIdAndUpdate(orderId, {\n\t\t\t$push: {\n\t\t\t\tmarketings: punchHistory.marketing,\n\t\t\t},\n\t\t});\n\t\t\n\t\tawait publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent({\n\t\t\tuserId,\n\t\t\tshopId: order.shop._id,\n\t\t\toperation: ChangeStreamOperationTypes.DELETE,\n\t\t})\n\t}\n\n\t/**\n\t * Get punch discount\n\t * @param data Data to use for validating discount\n\t */\n\tpublic async getPunchDiscount(data: ValidateCouponDTO): Promise<CouponValidationOutputDTO> {\n\t\tconst punchHistory = await this.model.findOne({\n\t\t\tuser: data.user,\n\t\t\tshop: data.shop,\n\t\t\tcouponExpiryDate: { $gte: new Date() },\n\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t});\n\n\t\tif (!punchHistory) {\n\t\t\treturn {\n\t\t\t\tisValid: false,\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tdata.scheduledAt &&\n\t\t\tBoolean(punchHistory.couponExpiryDate) &&\n\t\t\tdayjs(punchHistory.couponExpiryDate).isBefore(data.scheduledAt)\n\t\t) {\n\t\t\treturn {\n\t\t\t\tisValid: false,\n\t\t\t};\n\t\t}\n\n\t\tlet discountAmount =\n\t\t\tpunchHistory.couponValueType == ValueType.FIXED\n\t\t\t\t? punchHistory.couponValue\n\t\t\t\t: roundBaseCurrency((punchHistory.couponValue / 100) * data.amountBeforeCoupon);\n\n\t\tlet secondaryDiscountAmount =\n\t\t\tpunchHistory.couponValueType == ValueType.FIXED\n\t\t\t\t? await convertToSecondary(punchHistory.couponValue)\n\t\t\t\t: roundSecondaryCurrency((punchHistory.couponValue / 100) * data.secondaryAmountBeforeCoupon);\n\n\t\tif (discountAmount > data.amountBeforeCoupon) {\n\t\t\tdiscountAmount = data.amountBeforeCoupon;\n\t\t}\n\t\tif (secondaryDiscountAmount > data.secondaryAmountBeforeCoupon) {\n\t\t\tsecondaryDiscountAmount = data.secondaryAmountBeforeCoupon;\n\t\t}\n\n\t\treturn {\n\t\t\tisValid: true,\n\t\t\tdiscountAmount,\n\t\t\tsecondaryDiscountAmount,\n\t\t\tamountAfterCoupon: Math.max(0, roundBaseCurrency(data.amountBeforeCoupon - discountAmount)),\n\t\t\tsecondaryAmountAfterCoupon: Math.max(\n\t\t\t\t0,\n\t\t\t\troundSecondaryCurrency(data.secondaryAmountBeforeCoupon - secondaryDiscountAmount)\n\t\t\t),\n\t\t\tdiscountCut: {\n\t\t\t\tcompanyCut: 0,\n\t\t\t\tsecondaryCompanyCut: 0,\n\t\t\t\tshopCut: discountAmount,\n\t\t\t\tsecondaryShopCut: secondaryDiscountAmount,\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic async getPunchCoupon(user: mongoose.Types.ObjectId, shop: mongoose.Types.ObjectId): Promise<any> {\n\t\tconst punchHistory = await this.model.findOne({\n\t\t\tuser: user,\n\t\t\tshop: shop,\n\t\t\tcouponExpiryDate: { $gte: new Date() },\n\t\t\tstatus: PunchMarketingStatus.COMPLETED,\n\t\t});\n\t\tif (!punchHistory) return null;\n\n\t\tconst settings = await getLibraries().getCachedSettingsService().getSettings();\n\t\tconst exchangeRate = settings?.currencySetting?.exchangeRate ?? 0;\n\n\t\tconst punchCoupon = {\n\t\t\t_id: null,\n\t\t\tcode: 'punch',\n\t\t\tcouponType: CouponType.INDIVIDUAL_USER,\n\t\t\torderLimitPerUser: 1,\n\t\t\tcreatedBy: null,\n\t\t\tdeletedAt: null,\n\t\t\tvalueType: punchHistory.couponValueType,\n\t\t\tvalue: punchHistory.couponValue,\n\t\t\tmaxDiscountLimit: null,\n\t\t\tduration: {\n\t\t\t\tstart: punchHistory.completedAt,\n\t\t\t\tend: punchHistory.couponExpiryDate,\n\t\t\t},\n\t\t\tshops: [shop],\n\t\t\tspendLimit: null,\n\t\t\ttotalOrderLimit: 1,\n\t\t\tminOrderValue: null,\n\t\t\tforNewUserOnly: false,\n\t\t\tstatus: Status.ACTIVE,\n\t\t\texpirationReason: null,\n\t\t\tcreatedAt: punchHistory.completedAt,\n\t\t\tupdatedAt: punchHistory.completedAt,\n\t\t\tsecondaryCurrencyValue:\n\t\t\t\tpunchHistory.couponValueType === ValueType.FIXED\n\t\t\t\t\t? roundSecondaryCurrency(punchHistory.couponValue * exchangeRate)\n\t\t\t\t\t: null,\n\t\t\tsecondaryCurrencyMaxDiscountLimit: null,\n\t\t\tsecondaryCurrencyMinOrderValue: null,\n\t\t};\n\t\treturn punchCoupon;\n\t}\n}\n\nexport const punchMarketingHistoryService = Container.get(PunchMarketingHistoryService);\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { GraphType } from '@lyxa.ai/core/dist/utilities/enum';
|
|
2
|
+
export declare function fillMissingPeriods<T extends Record<string, any>>(results: T[], startDate: Date, endDate: Date, type: GraphType, defaultFields: Omit<T, 'date'>): T[];
|
|
3
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"/","sources":["utility/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAc9D,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5D,OAAO,EAAE,CAAC,EAAE,EACZ,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,IAAI,EACb,IAAI,EAAE,SAAS,EACf,aAAa,EAAE,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,GAC/B,CAAC,EAAE,CAqCL"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fillMissingPeriods = fillMissingPeriods;
|
|
4
|
+
const dayjs_1 = require("@lyxa.ai/core/dist/utilities/dayjs");
|
|
5
|
+
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
6
|
+
function fillMissingPeriods(results, startDate, endDate, type, defaultFields) {
|
|
7
|
+
const filledData = [];
|
|
8
|
+
const resultMap = new Map();
|
|
9
|
+
for (const item of results) {
|
|
10
|
+
resultMap.set(item.date, item);
|
|
11
|
+
}
|
|
12
|
+
const fieldKeys = Object.keys(defaultFields);
|
|
13
|
+
const unit = type === enum_1.GraphType.MONTHLY ? 'month' : 'day';
|
|
14
|
+
const dateFormat = type === enum_1.GraphType.MONTHLY ? 'YYYY-MM' : 'YYYY-MM-DD';
|
|
15
|
+
let current = (0, dayjs_1.dayjs)(startDate).startOf(unit);
|
|
16
|
+
const end = (0, dayjs_1.dayjs)(endDate).startOf(unit);
|
|
17
|
+
while (current.isBefore(end) || current.isSame(end)) {
|
|
18
|
+
const dateKey = current.format(dateFormat);
|
|
19
|
+
const existing = resultMap.get(dateKey);
|
|
20
|
+
const entry = {
|
|
21
|
+
date: dateKey,
|
|
22
|
+
...(existing
|
|
23
|
+
? Object.fromEntries(fieldKeys.map(key => [key, existing[key] ?? defaultFields[key]]))
|
|
24
|
+
: { ...defaultFields }),
|
|
25
|
+
};
|
|
26
|
+
filledData.push(entry);
|
|
27
|
+
current = current.add(1, unit);
|
|
28
|
+
}
|
|
29
|
+
return filledData;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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C,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBACtF,CAAC,CAAC,EAAE,GAAG,aAAa,EAAE,CAAC;SACd,CAAC;QAElB,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import { dayjs } from '@lyxa.ai/core/dist/utilities/dayjs';\nimport { GraphType } from '@lyxa.ai/core/dist/utilities/enum';\n\n/**\n * Fills in missing periods (daily or monthly) between two dates in a time-series dataset,\n * assigning default values for fields when data is missing.\n *\n * @template T - The shape of the result item, must include a `date` field.\n * @param results - Original array of time-series data with `date` keys.\n * @param startDate - The start date of the period to cover.\n * @param endDate - The end date of the period to cover.\n * @param type - Graph type (e.g., daily or monthly).\n * @param defaultFields - Default values to assign when a date is missing.\n * @returns A new array with missing dates filled in and populated with default values.\n */\nexport function fillMissingPeriods<T extends Record<string, any>>(\n results: T[],\n startDate: Date,\n endDate: Date,\n type: GraphType,\n defaultFields: Omit<T, 'date'>\n): T[] {\n const filledData: T[] = [];\n const resultMap = new Map<string, T>();\n\n // Index results by date string for quick lookup\n for (const item of results) {\n resultMap.set(item.date, item);\n }\n\n // Extract the field keys from defaultFields for dynamic value assignment\n const fieldKeys = Object.keys(defaultFields) as (keyof typeof defaultFields)[];\n\n // Determine the unit and format based on the graph type\n const unit = type === GraphType.MONTHLY ? 'month' : 'day';\n const dateFormat = type === GraphType.MONTHLY ? 'YYYY-MM' : 'YYYY-MM-DD';\n\n let current = dayjs(startDate).startOf(unit);\n const end = dayjs(endDate).startOf(unit);\n\n // Iterate through each period (day or month) and build the result\n while (current.isBefore(end) || current.isSame(end)) {\n const dateKey = current.format(dateFormat);\n const existing = resultMap.get(dateKey);\n\n // Construct the data entry using existing values or defaults\n const entry = {\n date: dateKey,\n ...(existing\n ? Object.fromEntries(fieldKeys.map(key => [key, existing[key] ?? defaultFields[key]]))\n : { ...defaultFields }),\n } as unknown as T;\n\n filledData.push(entry);\n current = current.add(1, unit);\n }\n\n return filledData;\n}"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -666,6 +666,11 @@ declare const marketingMicroServiceRouter: import("@trpc/server").TRPCBuiltRoute
|
|
|
666
666
|
output: string;
|
|
667
667
|
meta: object;
|
|
668
668
|
}>;
|
|
669
|
+
syncAllProductsMarketingInfoLocal: import("@trpc/server").TRPCMutationProcedure<{
|
|
670
|
+
input: void;
|
|
671
|
+
output: any;
|
|
672
|
+
meta: object;
|
|
673
|
+
}>;
|
|
669
674
|
syncProductMarketingInfoByProductId: import("@trpc/server").TRPCQueryProcedure<{
|
|
670
675
|
input: void;
|
|
671
676
|
output: string;
|
|
@@ -678,18 +683,19 @@ declare const marketingMicroServiceRouter: import("@trpc/server").TRPCBuiltRoute
|
|
|
678
683
|
output: string;
|
|
679
684
|
meta: object;
|
|
680
685
|
}>;
|
|
681
|
-
|
|
682
|
-
input:
|
|
683
|
-
marketings: (string | import("mongoose").Types.ObjectId)[];
|
|
684
|
-
};
|
|
686
|
+
calculateMarketingSpent: import("@trpc/server").TRPCMutationProcedure<{
|
|
687
|
+
input: string | import("mongoose").Types.ObjectId;
|
|
685
688
|
output: {
|
|
686
689
|
success: boolean;
|
|
687
690
|
message: string;
|
|
688
|
-
data:
|
|
691
|
+
data: {
|
|
692
|
+
amount: number;
|
|
693
|
+
marketingType: import("@lyxa.ai/core/dist/utilities/enum").MarketingType;
|
|
694
|
+
} | undefined;
|
|
689
695
|
};
|
|
690
696
|
meta: object;
|
|
691
697
|
}>;
|
|
692
|
-
|
|
698
|
+
incrementMarketingSpentFromOrder: import("@trpc/server").TRPCMutationProcedure<{
|
|
693
699
|
input: string | import("mongoose").Types.ObjectId;
|
|
694
700
|
output: {
|
|
695
701
|
success: boolean;
|
|
@@ -698,7 +704,7 @@ declare const marketingMicroServiceRouter: import("@trpc/server").TRPCBuiltRoute
|
|
|
698
704
|
};
|
|
699
705
|
meta: object;
|
|
700
706
|
}>;
|
|
701
|
-
|
|
707
|
+
decrementMarketingSpentFromOrder: import("@trpc/server").TRPCMutationProcedure<{
|
|
702
708
|
input: string | import("mongoose").Types.ObjectId;
|
|
703
709
|
output: {
|
|
704
710
|
success: boolean;
|
|
@@ -707,12 +713,82 @@ declare const marketingMicroServiceRouter: import("@trpc/server").TRPCBuiltRoute
|
|
|
707
713
|
};
|
|
708
714
|
meta: object;
|
|
709
715
|
}>;
|
|
710
|
-
|
|
716
|
+
recomputeAndSyncAllMarketingSpent: import("@trpc/server").TRPCMutationProcedure<{
|
|
717
|
+
input: void;
|
|
718
|
+
output: {
|
|
719
|
+
success: boolean;
|
|
720
|
+
message: string;
|
|
721
|
+
data: void | undefined;
|
|
722
|
+
};
|
|
723
|
+
meta: object;
|
|
724
|
+
}>;
|
|
725
|
+
getMetrics: import("@trpc/server").TRPCQueryProcedure<{
|
|
711
726
|
input: string | import("mongoose").Types.ObjectId;
|
|
712
727
|
output: {
|
|
713
728
|
success: boolean;
|
|
714
729
|
message: string;
|
|
715
|
-
data:
|
|
730
|
+
data: {
|
|
731
|
+
numberOfItems?: number | undefined;
|
|
732
|
+
orderIncreaseWithDiscount?: {
|
|
733
|
+
count: number;
|
|
734
|
+
percentageIncrease: number;
|
|
735
|
+
} | undefined;
|
|
736
|
+
customerIncreaseWithDiscount?: {
|
|
737
|
+
count: number;
|
|
738
|
+
percentageIncrease: number;
|
|
739
|
+
} | undefined;
|
|
740
|
+
} | undefined;
|
|
741
|
+
};
|
|
742
|
+
meta: object;
|
|
743
|
+
}>;
|
|
744
|
+
getOrdersGraph: import("@trpc/server").TRPCQueryProcedure<{
|
|
745
|
+
input: {
|
|
746
|
+
startDate: string | Date;
|
|
747
|
+
marketingId: string | import("mongoose").Types.ObjectId;
|
|
748
|
+
endDate: string | Date;
|
|
749
|
+
type?: import("@lyxa.ai/core/dist/utilities/enum").GraphType | undefined;
|
|
750
|
+
};
|
|
751
|
+
output: {
|
|
752
|
+
success: boolean;
|
|
753
|
+
message: string;
|
|
754
|
+
data: {
|
|
755
|
+
date: string;
|
|
756
|
+
orders: number;
|
|
757
|
+
}[] | undefined;
|
|
758
|
+
};
|
|
759
|
+
meta: object;
|
|
760
|
+
}>;
|
|
761
|
+
getCustomersGraph: import("@trpc/server").TRPCQueryProcedure<{
|
|
762
|
+
input: {
|
|
763
|
+
startDate: string | Date;
|
|
764
|
+
marketingId: string | import("mongoose").Types.ObjectId;
|
|
765
|
+
endDate: string | Date;
|
|
766
|
+
type?: import("@lyxa.ai/core/dist/utilities/enum").GraphType | undefined;
|
|
767
|
+
};
|
|
768
|
+
output: {
|
|
769
|
+
success: boolean;
|
|
770
|
+
message: string;
|
|
771
|
+
data: {
|
|
772
|
+
date: string;
|
|
773
|
+
users: number;
|
|
774
|
+
}[] | undefined;
|
|
775
|
+
};
|
|
776
|
+
meta: object;
|
|
777
|
+
}>;
|
|
778
|
+
getAmountSpentGraph: import("@trpc/server").TRPCQueryProcedure<{
|
|
779
|
+
input: {
|
|
780
|
+
startDate: string | Date;
|
|
781
|
+
marketingId: string | import("mongoose").Types.ObjectId;
|
|
782
|
+
endDate: string | Date;
|
|
783
|
+
type?: import("@lyxa.ai/core/dist/utilities/enum").GraphType | undefined;
|
|
784
|
+
};
|
|
785
|
+
output: {
|
|
786
|
+
success: boolean;
|
|
787
|
+
message: string;
|
|
788
|
+
data: {
|
|
789
|
+
date: string;
|
|
790
|
+
amount: number;
|
|
791
|
+
}[] | undefined;
|
|
716
792
|
};
|
|
717
793
|
meta: object;
|
|
718
794
|
}>;
|
|
@@ -5940,6 +6016,7 @@ declare const marketingMicroServiceRouter: import("@trpc/server").TRPCBuiltRoute
|
|
|
5940
6016
|
shopCut?: number | undefined;
|
|
5941
6017
|
secondaryShopCut?: number | undefined;
|
|
5942
6018
|
} | undefined;
|
|
6019
|
+
couponDetails?: Record<string, unknown> | undefined;
|
|
5943
6020
|
} | {
|
|
5944
6021
|
documents: {
|
|
5945
6022
|
message?: string | undefined;
|
|
@@ -5954,6 +6031,7 @@ declare const marketingMicroServiceRouter: import("@trpc/server").TRPCBuiltRoute
|
|
|
5954
6031
|
shopCut?: number | undefined;
|
|
5955
6032
|
secondaryShopCut?: number | undefined;
|
|
5956
6033
|
} | undefined;
|
|
6034
|
+
couponDetails?: Record<string, unknown> | undefined;
|
|
5957
6035
|
}[];
|
|
5958
6036
|
metadata?: {
|
|
5959
6037
|
page: number;
|
|
@@ -5990,6 +6068,7 @@ declare const marketingMicroServiceRouter: import("@trpc/server").TRPCBuiltRoute
|
|
|
5990
6068
|
shopCut?: number | undefined;
|
|
5991
6069
|
secondaryShopCut?: number | undefined;
|
|
5992
6070
|
} | undefined;
|
|
6071
|
+
couponDetails?: Record<string, unknown> | undefined;
|
|
5993
6072
|
} | {
|
|
5994
6073
|
documents: {
|
|
5995
6074
|
message?: string | undefined;
|
|
@@ -6004,6 +6083,7 @@ declare const marketingMicroServiceRouter: import("@trpc/server").TRPCBuiltRoute
|
|
|
6004
6083
|
shopCut?: number | undefined;
|
|
6005
6084
|
secondaryShopCut?: number | undefined;
|
|
6006
6085
|
} | undefined;
|
|
6086
|
+
couponDetails?: Record<string, unknown> | undefined;
|
|
6007
6087
|
}[];
|
|
6008
6088
|
metadata?: {
|
|
6009
6089
|
page: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAeD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAR/B,CAAC;AAoCH,MAAM,MAAM,2BAA2B,GAAG,OAAO,2BAA2B,CAAC"}
|
|
@@ -5223,6 +5223,7 @@ export declare const couponRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
5223
5223
|
shopCut?: number | undefined;
|
|
5224
5224
|
secondaryShopCut?: number | undefined;
|
|
5225
5225
|
} | undefined;
|
|
5226
|
+
couponDetails?: Record<string, unknown> | undefined;
|
|
5226
5227
|
} | {
|
|
5227
5228
|
documents: {
|
|
5228
5229
|
message?: string | undefined;
|
|
@@ -5237,6 +5238,7 @@ export declare const couponRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
5237
5238
|
shopCut?: number | undefined;
|
|
5238
5239
|
secondaryShopCut?: number | undefined;
|
|
5239
5240
|
} | undefined;
|
|
5241
|
+
couponDetails?: Record<string, unknown> | undefined;
|
|
5240
5242
|
}[];
|
|
5241
5243
|
metadata?: {
|
|
5242
5244
|
page: number;
|
|
@@ -5273,6 +5275,7 @@ export declare const couponRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
5273
5275
|
shopCut?: number | undefined;
|
|
5274
5276
|
secondaryShopCut?: number | undefined;
|
|
5275
5277
|
} | undefined;
|
|
5278
|
+
couponDetails?: Record<string, unknown> | undefined;
|
|
5276
5279
|
} | {
|
|
5277
5280
|
documents: {
|
|
5278
5281
|
message?: string | undefined;
|
|
@@ -5287,6 +5290,7 @@ export declare const couponRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
5287
5290
|
shopCut?: number | undefined;
|
|
5288
5291
|
secondaryShopCut?: number | undefined;
|
|
5289
5292
|
} | undefined;
|
|
5293
|
+
couponDetails?: Record<string, unknown> | undefined;
|
|
5290
5294
|
}[];
|
|
5291
5295
|
metadata?: {
|
|
5292
5296
|
page: number;
|
|
@@ -1 +1 @@
|
|
|
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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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAAD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkOokxB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GADvmxB,CAAC"}
|
|
@@ -15,6 +15,7 @@ export declare class CouponService {
|
|
|
15
15
|
private punchHistoryService;
|
|
16
16
|
private _coreUserModel;
|
|
17
17
|
private couponHelper;
|
|
18
|
+
private readonly referralSettingsModel;
|
|
18
19
|
constructor();
|
|
19
20
|
private get coreUserModel();
|
|
20
21
|
/**
|
|
@@ -83,9 +84,11 @@ export declare class CouponService {
|
|
|
83
84
|
getUserCouponList(data?: Partial<FilterDTO>): Promise<PaginatedResponse<AllCouponsDTO>>;
|
|
84
85
|
addExistingCouponsToNewUser(userId: mongoose.Types.ObjectId): Promise<void>;
|
|
85
86
|
getActiveNewUserCoupon(): Promise<DocumentType<BaseCoupon> | null>;
|
|
87
|
+
getActiveNewUserCouponWithSecondaryCurrency(): Promise<DocumentType<BaseCoupon> | null>;
|
|
86
88
|
checkExistingNewUserCoupon(): Promise<CheckExistingNewUserCouponOutputDTO>;
|
|
87
89
|
private getAllOrders;
|
|
88
90
|
handleCouponGiftBox(deviceId: string, userId: mongoose.Types.ObjectId | null): Promise<DocumentType<GlobalCoupon>[]>;
|
|
91
|
+
private updateNewUserCouponField;
|
|
89
92
|
updateCouponGiftBoxShown(userId: mongoose.Types.ObjectId, data: any): Promise<number>;
|
|
90
93
|
}
|
|
91
94
|
export declare const couponService: CouponService;
|
|
@@ -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,EAKN,YAAY,EAGZ,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,EAKN,YAAY,EAGZ,MAAM,IAAI,KAAK,EAaf,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACN,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,mCAAmC,EACnC,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACN,SAAS,EACT,iBAAiB,EACjB,SAAS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;IAgIvF,2BAA2B,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ;IAsC3D,sBAAsB,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAqBlE,2CAA2C,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAgGvF,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;YAkD1B,wBAAwB;IAczB,wBAAwB,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;CAsBlG;AAED,eAAO,MAAM,aAAa,eAA+B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DocumentType } from '@typegoose/typegoose';
|
|
2
2
|
import { CustomCoupon as Model } from '@lyxa.ai/core/dist/libraries/mongo/models/';
|
|
3
|
-
import {
|
|
3
|
+
import { CreateCustomCouponDTO as CreateDTO, UpdateCustomCouponDTO as UpdateDTO, ValidateCouponDTO } from '@modules/coupon/validations';
|
|
4
4
|
export declare class CustomCouponService {
|
|
5
5
|
private model;
|
|
6
6
|
constructor();
|
|
@@ -15,7 +15,33 @@ export declare class CustomCouponService {
|
|
|
15
15
|
* @param data Data to update
|
|
16
16
|
*/
|
|
17
17
|
update(id: string, data: UpdateDTO): Promise<DocumentType<Model>>;
|
|
18
|
-
validateCoupon(data: ValidateCouponDTO,
|
|
18
|
+
validateCoupon(data: ValidateCouponDTO, coupon: DocumentType<Model>): Promise<{
|
|
19
|
+
isValid: boolean;
|
|
20
|
+
message?: string | undefined;
|
|
21
|
+
amountAfterCoupon?: number | undefined;
|
|
22
|
+
secondaryAmountAfterCoupon?: number | undefined;
|
|
23
|
+
discountAmount?: number | undefined;
|
|
24
|
+
secondaryDiscountAmount?: number | undefined;
|
|
25
|
+
discountCut?: {
|
|
26
|
+
companyCut?: number | undefined;
|
|
27
|
+
secondaryCompanyCut?: number | undefined;
|
|
28
|
+
shopCut?: number | undefined;
|
|
29
|
+
secondaryShopCut?: number | undefined;
|
|
30
|
+
} | undefined;
|
|
31
|
+
couponDetails?: Record<string, unknown> | undefined;
|
|
32
|
+
} | {
|
|
33
|
+
isValid: boolean;
|
|
34
|
+
message: string;
|
|
35
|
+
shop?: undefined;
|
|
36
|
+
} | {
|
|
37
|
+
isValid: boolean;
|
|
38
|
+
shop: import("mongoose").Document<unknown, import("@typegoose/typegoose/lib/types").BeAnObject, import("@lyxa.ai/core/dist/libraries/mongo/models/shop.model").Shop, import("@typegoose/typegoose/lib/types").BeAnyObject, {}> & Omit<import("@lyxa.ai/core/dist/libraries/mongo/models/shop.model").Shop & {
|
|
39
|
+
_id: import("mongoose").Types.ObjectId;
|
|
40
|
+
} & {
|
|
41
|
+
__v: number;
|
|
42
|
+
}, "typegooseName"> & import("@typegoose/typegoose/lib/types").IObjectWithTypegooseFunction;
|
|
43
|
+
message?: undefined;
|
|
44
|
+
}>;
|
|
19
45
|
}
|
|
20
46
|
export declare const customCouponService: CustomCouponService;
|
|
21
47
|
//# sourceMappingURL=custom-coupon.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-coupon.service.d.ts","sourceRoot":"/","sources":["modules/coupon/services/custom-coupon.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAqB,YAAY,IAAI,KAAK,EAAE,MAAM,4CAA4C,CAAC;AACtG,OAAO,EACN,
|
|
1
|
+
{"version":3,"file":"custom-coupon.service.d.ts","sourceRoot":"/","sources":["modules/coupon/services/custom-coupon.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAqB,YAAY,IAAI,KAAK,EAAE,MAAM,4CAA4C,CAAC;AACtG,OAAO,EACN,qBAAqB,IAAI,SAAS,EAClC,qBAAqB,IAAI,SAAS,EAClC,iBAAiB,EACjB,MAAM,6BAA6B,CAAC;AAGrC,qBACa,mBAAmB;IAC/B,OAAO,CAAC,KAAK,CAAC;;IAMd;;;OAGG;IACU,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAIlE;;;;OAIG;IACU,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAuBjE,cAAc,CAAC,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBhF;AAED,eAAO,MAAM,mBAAmB,qBAAqC,CAAC"}
|