@managesome/eposmatic-toolkit 0.2.248 → 0.2.251
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/lib/constants/ENUMS.d.ts +36 -21
- package/lib/constants/ENUMS.js +48 -30
- package/lib/constants/SOCKET.d.ts +6 -0
- package/lib/constants/SOCKET.js +11 -2
- package/lib/helpers/store/cart-actions.d.ts +1 -0
- package/lib/helpers/utils/offers-helpers.d.ts +23 -3
- package/lib/helpers/utils/offers-helpers.js +1071 -389
- package/lib/schemas/models/customers.d.ts +9 -0
- package/lib/schemas/models/customers.js +14 -0
- package/lib/schemas/models/gift_cards.d.ts +113 -0
- package/lib/schemas/models/gift_cards.js +150 -0
- package/lib/schemas/models/index.d.ts +3 -0
- package/lib/schemas/models/index.js +3 -0
- package/lib/schemas/models/offers.d.ts +133 -66
- package/lib/schemas/models/offers.js +112 -12
- package/lib/schemas/models/order.d.ts +3 -0
- package/lib/schemas/models/order.js +5 -0
- package/lib/schemas/models/rewards_usage.d.ts +53 -0
- package/lib/schemas/models/rewards_usage.js +64 -0
- package/lib/schemas/models/vouchers.d.ts +68 -0
- package/lib/schemas/models/vouchers.js +85 -0
- package/lib/schemas/types/customers.d.ts +3 -0
- package/lib/schemas/types/gift_cards.d.ts +91 -0
- package/lib/schemas/types/gift_cards.js +2 -0
- package/lib/schemas/types/index.d.ts +3 -0
- package/lib/schemas/types/index.js +3 -0
- package/lib/schemas/types/offers.d.ts +139 -15
- package/lib/schemas/types/order.d.ts +1 -0
- package/lib/schemas/types/rewards_usage.d.ts +13 -0
- package/lib/schemas/types/rewards_usage.js +2 -0
- package/lib/schemas/types/vouchers.d.ts +17 -0
- package/lib/schemas/types/vouchers.js +2 -0
- package/package.json +2 -2
|
@@ -9,6 +9,16 @@ const PathwayToUnlockTypeItemsSchema = new mongoose_1.Schema({
|
|
|
9
9
|
type: Number,
|
|
10
10
|
required: true,
|
|
11
11
|
},
|
|
12
|
+
max_claims: {
|
|
13
|
+
type: Number,
|
|
14
|
+
required: false,
|
|
15
|
+
default: 1,
|
|
16
|
+
},
|
|
17
|
+
max_same_item_quantity: {
|
|
18
|
+
type: Number,
|
|
19
|
+
required: false,
|
|
20
|
+
default: null,
|
|
21
|
+
},
|
|
12
22
|
total_amount: {
|
|
13
23
|
type: Number,
|
|
14
24
|
required: true,
|
|
@@ -23,21 +33,32 @@ const PathwayToUnlockTypeItemsSchema = new mongoose_1.Schema({
|
|
|
23
33
|
},
|
|
24
34
|
item_ids: {
|
|
25
35
|
type: [mongoose_1.Schema.Types.ObjectId],
|
|
26
|
-
required:
|
|
27
|
-
|
|
36
|
+
required: false,
|
|
37
|
+
default: [],
|
|
38
|
+
},
|
|
39
|
+
category_ids: {
|
|
40
|
+
type: [mongoose_1.Schema.Types.ObjectId],
|
|
41
|
+
required: false,
|
|
42
|
+
default: [],
|
|
28
43
|
},
|
|
29
44
|
}, {
|
|
30
45
|
_id: false,
|
|
31
46
|
minimize: false,
|
|
32
47
|
});
|
|
33
48
|
const PathwayToUnlockTypeOrdersSchema = new mongoose_1.Schema({
|
|
49
|
+
scope: {
|
|
50
|
+
type: String,
|
|
51
|
+
enum: constants_1.ALL_PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPES,
|
|
52
|
+
required: false,
|
|
53
|
+
default: constants_1.PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPE_ENUM.OVERALL,
|
|
54
|
+
},
|
|
34
55
|
min_num_of_orders: {
|
|
35
56
|
type: Number,
|
|
36
57
|
required: true,
|
|
37
58
|
},
|
|
38
59
|
max_num_of_orders: {
|
|
39
60
|
type: Number,
|
|
40
|
-
|
|
61
|
+
required: false,
|
|
41
62
|
},
|
|
42
63
|
total_amount: {
|
|
43
64
|
type: Number,
|
|
@@ -45,7 +66,7 @@ const PathwayToUnlockTypeOrdersSchema = new mongoose_1.Schema({
|
|
|
45
66
|
},
|
|
46
67
|
max_amount: {
|
|
47
68
|
type: Number,
|
|
48
|
-
|
|
69
|
+
required: false,
|
|
49
70
|
},
|
|
50
71
|
}, {
|
|
51
72
|
_id: false,
|
|
@@ -60,6 +81,28 @@ const PathwayToUnlockTypePointsSchema = new mongoose_1.Schema({
|
|
|
60
81
|
type: Number,
|
|
61
82
|
required: true,
|
|
62
83
|
},
|
|
84
|
+
max_claims: {
|
|
85
|
+
type: Number,
|
|
86
|
+
required: false,
|
|
87
|
+
},
|
|
88
|
+
}, {
|
|
89
|
+
_id: false,
|
|
90
|
+
minimize: false,
|
|
91
|
+
});
|
|
92
|
+
const PathwayToUnlockTypeVouchersSchema = new mongoose_1.Schema({
|
|
93
|
+
total_amount: {
|
|
94
|
+
type: Number,
|
|
95
|
+
required: true,
|
|
96
|
+
},
|
|
97
|
+
max_amount: {
|
|
98
|
+
type: Number,
|
|
99
|
+
required: false,
|
|
100
|
+
},
|
|
101
|
+
voucher_ids: {
|
|
102
|
+
type: [mongoose_1.Schema.Types.ObjectId],
|
|
103
|
+
required: true,
|
|
104
|
+
min: 1,
|
|
105
|
+
},
|
|
63
106
|
}, {
|
|
64
107
|
_id: false,
|
|
65
108
|
minimize: false,
|
|
@@ -179,6 +222,47 @@ const RewardPointsSchema = new mongoose_1.Schema({
|
|
|
179
222
|
_id: false,
|
|
180
223
|
minimize: false,
|
|
181
224
|
});
|
|
225
|
+
const RewardCashbackSchema = new mongoose_1.Schema({
|
|
226
|
+
cashback_value: {
|
|
227
|
+
type: Number,
|
|
228
|
+
required: true,
|
|
229
|
+
},
|
|
230
|
+
is_cashback_percentage: {
|
|
231
|
+
type: Boolean,
|
|
232
|
+
default: false,
|
|
233
|
+
},
|
|
234
|
+
max_cashback_amount: {
|
|
235
|
+
type: Number,
|
|
236
|
+
required: false,
|
|
237
|
+
},
|
|
238
|
+
excluded_refs: {
|
|
239
|
+
type: [String],
|
|
240
|
+
default: [],
|
|
241
|
+
},
|
|
242
|
+
}, {
|
|
243
|
+
_id: false,
|
|
244
|
+
minimize: false,
|
|
245
|
+
});
|
|
246
|
+
const RewardGiftCardsSchema = new mongoose_1.Schema({
|
|
247
|
+
gift_card_ids: {
|
|
248
|
+
type: Map,
|
|
249
|
+
of: Number,
|
|
250
|
+
required: true,
|
|
251
|
+
},
|
|
252
|
+
}, {
|
|
253
|
+
_id: false,
|
|
254
|
+
minimize: false,
|
|
255
|
+
});
|
|
256
|
+
const RewardVoucherSchema = new mongoose_1.Schema({
|
|
257
|
+
voucher_ids: {
|
|
258
|
+
type: Map,
|
|
259
|
+
of: Number,
|
|
260
|
+
required: true,
|
|
261
|
+
},
|
|
262
|
+
}, {
|
|
263
|
+
_id: false,
|
|
264
|
+
minimize: false,
|
|
265
|
+
});
|
|
182
266
|
// ================== ==================
|
|
183
267
|
exports.OfferSchema = new mongoose_1.Schema({
|
|
184
268
|
_id: {
|
|
@@ -223,7 +307,7 @@ exports.OfferSchema = new mongoose_1.Schema({
|
|
|
223
307
|
},
|
|
224
308
|
offer_special_hours: {
|
|
225
309
|
type: [item_1.SpecialHoursSchema],
|
|
226
|
-
|
|
310
|
+
required: false,
|
|
227
311
|
},
|
|
228
312
|
auto_apply: {
|
|
229
313
|
type: Boolean,
|
|
@@ -236,15 +320,19 @@ exports.OfferSchema = new mongoose_1.Schema({
|
|
|
236
320
|
},
|
|
237
321
|
pathway_to_unlock_type_items: {
|
|
238
322
|
type: PathwayToUnlockTypeItemsSchema,
|
|
239
|
-
|
|
323
|
+
required: false,
|
|
240
324
|
},
|
|
241
325
|
pathway_to_unlock_type_orders: {
|
|
242
326
|
type: PathwayToUnlockTypeOrdersSchema,
|
|
243
|
-
|
|
327
|
+
required: false,
|
|
244
328
|
},
|
|
245
329
|
pathway_to_unlock_type_points: {
|
|
246
330
|
type: PathwayToUnlockTypePointsSchema,
|
|
247
|
-
|
|
331
|
+
required: false,
|
|
332
|
+
},
|
|
333
|
+
pathway_to_unlock_type_vouchers: {
|
|
334
|
+
type: PathwayToUnlockTypeVouchersSchema,
|
|
335
|
+
required: false,
|
|
248
336
|
},
|
|
249
337
|
reward_type: {
|
|
250
338
|
type: String,
|
|
@@ -253,19 +341,31 @@ exports.OfferSchema = new mongoose_1.Schema({
|
|
|
253
341
|
},
|
|
254
342
|
reward_items: {
|
|
255
343
|
type: RewardItemsSchema,
|
|
256
|
-
|
|
344
|
+
required: false,
|
|
257
345
|
},
|
|
258
346
|
reward_discount: {
|
|
259
347
|
type: RewardDiscountSchema,
|
|
260
|
-
|
|
348
|
+
required: false,
|
|
261
349
|
},
|
|
262
350
|
reward_discount_items: {
|
|
263
351
|
type: RewardDiscountItemsSchema,
|
|
264
|
-
|
|
352
|
+
required: false,
|
|
265
353
|
},
|
|
266
354
|
reward_points: {
|
|
267
355
|
type: RewardPointsSchema,
|
|
268
|
-
|
|
356
|
+
required: false,
|
|
357
|
+
},
|
|
358
|
+
reward_cashback: {
|
|
359
|
+
type: RewardCashbackSchema,
|
|
360
|
+
required: false,
|
|
361
|
+
},
|
|
362
|
+
reward_gift_cards: {
|
|
363
|
+
type: RewardGiftCardsSchema,
|
|
364
|
+
required: false,
|
|
365
|
+
},
|
|
366
|
+
reward_voucher: {
|
|
367
|
+
type: RewardVoucherSchema,
|
|
368
|
+
required: false,
|
|
269
369
|
},
|
|
270
370
|
createdAt: {
|
|
271
371
|
type: mongoose_1.Schema.Types.Date,
|
|
@@ -5184,6 +5184,7 @@ export declare const OrderSchema: Schema<any, import("mongoose").Model<any, any,
|
|
|
5184
5184
|
is_reopened?: boolean | null | undefined;
|
|
5185
5185
|
deferred_settlement?: boolean | null | undefined;
|
|
5186
5186
|
payment_method_expected?: import("../../constants").PAYMENT_METHOD_EXPECTED_ENUM | null | undefined;
|
|
5187
|
+
redeemed_offers?: Map<string, number> | null | undefined;
|
|
5187
5188
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
5188
5189
|
createdAt: NativeDate;
|
|
5189
5190
|
updatedAt: NativeDate;
|
|
@@ -10281,6 +10282,7 @@ export declare const OrderSchema: Schema<any, import("mongoose").Model<any, any,
|
|
|
10281
10282
|
is_reopened?: boolean | null | undefined;
|
|
10282
10283
|
deferred_settlement?: boolean | null | undefined;
|
|
10283
10284
|
payment_method_expected?: import("../../constants").PAYMENT_METHOD_EXPECTED_ENUM | null | undefined;
|
|
10285
|
+
redeemed_offers?: Map<string, number> | null | undefined;
|
|
10284
10286
|
}>> & import("mongoose").FlatRecord<{
|
|
10285
10287
|
createdAt: NativeDate;
|
|
10286
10288
|
updatedAt: NativeDate;
|
|
@@ -15378,6 +15380,7 @@ export declare const OrderSchema: Schema<any, import("mongoose").Model<any, any,
|
|
|
15378
15380
|
is_reopened?: boolean | null | undefined;
|
|
15379
15381
|
deferred_settlement?: boolean | null | undefined;
|
|
15380
15382
|
payment_method_expected?: import("../../constants").PAYMENT_METHOD_EXPECTED_ENUM | null | undefined;
|
|
15383
|
+
redeemed_offers?: Map<string, number> | null | undefined;
|
|
15381
15384
|
}> & Required<{
|
|
15382
15385
|
_id: import("mongoose").Types.ObjectId;
|
|
15383
15386
|
}> & {
|
|
@@ -808,6 +808,11 @@ exports.OrderSchema = new mongoose_1.Schema({
|
|
|
808
808
|
type: StaffDetailsSchema,
|
|
809
809
|
required: false,
|
|
810
810
|
},
|
|
811
|
+
redeemed_offers: {
|
|
812
|
+
type: Map,
|
|
813
|
+
of: Number,
|
|
814
|
+
required: false,
|
|
815
|
+
},
|
|
811
816
|
order_settled_at: {
|
|
812
817
|
type: mongoose_1.Schema.Types.Date,
|
|
813
818
|
required: true,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
export declare const RewardsUsageSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
3
|
+
timestamps: true;
|
|
4
|
+
versionKey: false;
|
|
5
|
+
minimize: false;
|
|
6
|
+
}, {
|
|
7
|
+
createdAt: NativeDate;
|
|
8
|
+
updatedAt: NativeDate;
|
|
9
|
+
} & {
|
|
10
|
+
_id: import("mongoose").Types.ObjectId;
|
|
11
|
+
createdAt: NativeDate;
|
|
12
|
+
updatedAt: NativeDate;
|
|
13
|
+
ref_id: import("mongoose").Types.ObjectId;
|
|
14
|
+
customer_phone: string;
|
|
15
|
+
ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
|
|
16
|
+
used_count: number;
|
|
17
|
+
last_used_at: NativeDate;
|
|
18
|
+
assigned_count: number;
|
|
19
|
+
last_assigned_at: NativeDate;
|
|
20
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
21
|
+
createdAt: NativeDate;
|
|
22
|
+
updatedAt: NativeDate;
|
|
23
|
+
} & {
|
|
24
|
+
_id: import("mongoose").Types.ObjectId;
|
|
25
|
+
createdAt: NativeDate;
|
|
26
|
+
updatedAt: NativeDate;
|
|
27
|
+
ref_id: import("mongoose").Types.ObjectId;
|
|
28
|
+
customer_phone: string;
|
|
29
|
+
ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
|
|
30
|
+
used_count: number;
|
|
31
|
+
last_used_at: NativeDate;
|
|
32
|
+
assigned_count: number;
|
|
33
|
+
last_assigned_at: NativeDate;
|
|
34
|
+
}>> & import("mongoose").FlatRecord<{
|
|
35
|
+
createdAt: NativeDate;
|
|
36
|
+
updatedAt: NativeDate;
|
|
37
|
+
} & {
|
|
38
|
+
_id: import("mongoose").Types.ObjectId;
|
|
39
|
+
createdAt: NativeDate;
|
|
40
|
+
updatedAt: NativeDate;
|
|
41
|
+
ref_id: import("mongoose").Types.ObjectId;
|
|
42
|
+
customer_phone: string;
|
|
43
|
+
ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
|
|
44
|
+
used_count: number;
|
|
45
|
+
last_used_at: NativeDate;
|
|
46
|
+
assigned_count: number;
|
|
47
|
+
last_assigned_at: NativeDate;
|
|
48
|
+
}> & Required<{
|
|
49
|
+
_id: import("mongoose").Types.ObjectId;
|
|
50
|
+
}> & {
|
|
51
|
+
__v: number;
|
|
52
|
+
}>;
|
|
53
|
+
export declare const REWARDS_USAGE_COLLECTION_NAME = "rewards_usage";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REWARDS_USAGE_COLLECTION_NAME = exports.RewardsUsageSchema = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
exports.RewardsUsageSchema = new mongoose_1.Schema({
|
|
7
|
+
_id: {
|
|
8
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
9
|
+
required: true,
|
|
10
|
+
immutable: true,
|
|
11
|
+
},
|
|
12
|
+
ref_id: {
|
|
13
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
14
|
+
required: true,
|
|
15
|
+
immutable: true,
|
|
16
|
+
},
|
|
17
|
+
ref_type: {
|
|
18
|
+
type: String,
|
|
19
|
+
enum: constants_1.ALL_REWARDS_USAGE_REF_TYPES,
|
|
20
|
+
required: true,
|
|
21
|
+
immutable: true,
|
|
22
|
+
},
|
|
23
|
+
customer_phone: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true,
|
|
26
|
+
immutable: true,
|
|
27
|
+
},
|
|
28
|
+
assigned_count: {
|
|
29
|
+
type: Number,
|
|
30
|
+
required: true,
|
|
31
|
+
default: 0,
|
|
32
|
+
},
|
|
33
|
+
last_assigned_at: {
|
|
34
|
+
type: mongoose_1.Schema.Types.Date,
|
|
35
|
+
required: true,
|
|
36
|
+
default: null,
|
|
37
|
+
},
|
|
38
|
+
used_count: {
|
|
39
|
+
type: Number,
|
|
40
|
+
required: true,
|
|
41
|
+
default: 0,
|
|
42
|
+
},
|
|
43
|
+
last_used_at: {
|
|
44
|
+
type: mongoose_1.Schema.Types.Date,
|
|
45
|
+
required: true,
|
|
46
|
+
default: null,
|
|
47
|
+
},
|
|
48
|
+
createdAt: {
|
|
49
|
+
type: mongoose_1.Schema.Types.Date,
|
|
50
|
+
required: true,
|
|
51
|
+
default: () => new Date(),
|
|
52
|
+
immutable: true,
|
|
53
|
+
},
|
|
54
|
+
updatedAt: {
|
|
55
|
+
type: mongoose_1.Schema.Types.Date,
|
|
56
|
+
required: true,
|
|
57
|
+
default: () => new Date(),
|
|
58
|
+
},
|
|
59
|
+
}, {
|
|
60
|
+
timestamps: true,
|
|
61
|
+
versionKey: false,
|
|
62
|
+
minimize: false,
|
|
63
|
+
});
|
|
64
|
+
exports.REWARDS_USAGE_COLLECTION_NAME = 'rewards_usage';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
export declare const VouchersSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
3
|
+
timestamps: true;
|
|
4
|
+
versionKey: false;
|
|
5
|
+
minimize: false;
|
|
6
|
+
}, {
|
|
7
|
+
createdAt: NativeDate;
|
|
8
|
+
updatedAt: NativeDate;
|
|
9
|
+
} & {
|
|
10
|
+
_id: import("mongoose").Types.ObjectId;
|
|
11
|
+
name: string;
|
|
12
|
+
tenants: string[];
|
|
13
|
+
createdAt: NativeDate;
|
|
14
|
+
updatedAt: NativeDate;
|
|
15
|
+
description: string;
|
|
16
|
+
brand_id: string;
|
|
17
|
+
active: boolean;
|
|
18
|
+
code: string;
|
|
19
|
+
is_public: boolean;
|
|
20
|
+
used_count: number;
|
|
21
|
+
max_uses?: number | null | undefined;
|
|
22
|
+
max_uses_per_customer?: number | null | undefined;
|
|
23
|
+
last_used_at?: NativeDate | null | undefined;
|
|
24
|
+
expire_at?: NativeDate | null | undefined;
|
|
25
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
26
|
+
createdAt: NativeDate;
|
|
27
|
+
updatedAt: NativeDate;
|
|
28
|
+
} & {
|
|
29
|
+
_id: import("mongoose").Types.ObjectId;
|
|
30
|
+
name: string;
|
|
31
|
+
tenants: string[];
|
|
32
|
+
createdAt: NativeDate;
|
|
33
|
+
updatedAt: NativeDate;
|
|
34
|
+
description: string;
|
|
35
|
+
brand_id: string;
|
|
36
|
+
active: boolean;
|
|
37
|
+
code: string;
|
|
38
|
+
is_public: boolean;
|
|
39
|
+
used_count: number;
|
|
40
|
+
max_uses?: number | null | undefined;
|
|
41
|
+
max_uses_per_customer?: number | null | undefined;
|
|
42
|
+
last_used_at?: NativeDate | null | undefined;
|
|
43
|
+
expire_at?: NativeDate | null | undefined;
|
|
44
|
+
}>> & import("mongoose").FlatRecord<{
|
|
45
|
+
createdAt: NativeDate;
|
|
46
|
+
updatedAt: NativeDate;
|
|
47
|
+
} & {
|
|
48
|
+
_id: import("mongoose").Types.ObjectId;
|
|
49
|
+
name: string;
|
|
50
|
+
tenants: string[];
|
|
51
|
+
createdAt: NativeDate;
|
|
52
|
+
updatedAt: NativeDate;
|
|
53
|
+
description: string;
|
|
54
|
+
brand_id: string;
|
|
55
|
+
active: boolean;
|
|
56
|
+
code: string;
|
|
57
|
+
is_public: boolean;
|
|
58
|
+
used_count: number;
|
|
59
|
+
max_uses?: number | null | undefined;
|
|
60
|
+
max_uses_per_customer?: number | null | undefined;
|
|
61
|
+
last_used_at?: NativeDate | null | undefined;
|
|
62
|
+
expire_at?: NativeDate | null | undefined;
|
|
63
|
+
}> & Required<{
|
|
64
|
+
_id: import("mongoose").Types.ObjectId;
|
|
65
|
+
}> & {
|
|
66
|
+
__v: number;
|
|
67
|
+
}>;
|
|
68
|
+
export declare const VOUCHERS_COLLECTION_NAME = "vouchers";
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VOUCHERS_COLLECTION_NAME = exports.VouchersSchema = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
exports.VouchersSchema = new mongoose_1.Schema({
|
|
6
|
+
_id: {
|
|
7
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
8
|
+
required: true,
|
|
9
|
+
immutable: true,
|
|
10
|
+
},
|
|
11
|
+
code: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
trim: true,
|
|
15
|
+
uppercase: true,
|
|
16
|
+
},
|
|
17
|
+
brand_id: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true,
|
|
20
|
+
immutable: true,
|
|
21
|
+
ref: 'brands',
|
|
22
|
+
},
|
|
23
|
+
tenants: {
|
|
24
|
+
type: [{ type: String, ref: 'tenants' }],
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
name: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
description: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
active: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: true,
|
|
38
|
+
},
|
|
39
|
+
is_public: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false,
|
|
42
|
+
},
|
|
43
|
+
max_uses: {
|
|
44
|
+
type: Number,
|
|
45
|
+
required: false,
|
|
46
|
+
default: null,
|
|
47
|
+
},
|
|
48
|
+
max_uses_per_customer: {
|
|
49
|
+
type: Number,
|
|
50
|
+
required: false,
|
|
51
|
+
default: null,
|
|
52
|
+
},
|
|
53
|
+
used_count: {
|
|
54
|
+
type: Number,
|
|
55
|
+
required: true,
|
|
56
|
+
default: 0,
|
|
57
|
+
},
|
|
58
|
+
last_used_at: {
|
|
59
|
+
type: mongoose_1.Schema.Types.Date,
|
|
60
|
+
required: false,
|
|
61
|
+
default: null,
|
|
62
|
+
},
|
|
63
|
+
expire_at: {
|
|
64
|
+
type: mongoose_1.Schema.Types.Date,
|
|
65
|
+
required: false,
|
|
66
|
+
default: null,
|
|
67
|
+
},
|
|
68
|
+
createdAt: {
|
|
69
|
+
type: mongoose_1.Schema.Types.Date,
|
|
70
|
+
required: true,
|
|
71
|
+
default: () => new Date(),
|
|
72
|
+
immutable: true,
|
|
73
|
+
},
|
|
74
|
+
updatedAt: {
|
|
75
|
+
type: mongoose_1.Schema.Types.Date,
|
|
76
|
+
required: true,
|
|
77
|
+
default: () => new Date(),
|
|
78
|
+
},
|
|
79
|
+
}, {
|
|
80
|
+
timestamps: true,
|
|
81
|
+
versionKey: false,
|
|
82
|
+
minimize: false,
|
|
83
|
+
});
|
|
84
|
+
exports.VouchersSchema.index({ brand_id: 1, code: 1 }, { unique: true });
|
|
85
|
+
exports.VOUCHERS_COLLECTION_NAME = 'vouchers';
|
|
@@ -43,6 +43,9 @@ export interface ICustomer {
|
|
|
43
43
|
last_order_at: Date | null;
|
|
44
44
|
last_order_id: string | null;
|
|
45
45
|
loyalty_points: number;
|
|
46
|
+
cashback_balance: number;
|
|
47
|
+
gift_cards: Record<string, number>;
|
|
48
|
+
voucher_codes: Record<string, number>;
|
|
46
49
|
address_details: ICustomerAddressDetails | null;
|
|
47
50
|
cards: ICustomerCard[];
|
|
48
51
|
order_ids: string[];
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { GIFT_CARD_REWARD_TYPE_ENUM } from '../../constants';
|
|
2
|
+
import { IRewardTypeCashback, IRewardTypeDiscount, IRewardTypeDiscountItems, IRewardTypeItems, IRewardTypeMysteryGift, IRewardTypePoints, IRewardTypeVoucher } from './offers';
|
|
3
|
+
type IGiftCardRewardItems = {
|
|
4
|
+
reward_type: GIFT_CARD_REWARD_TYPE_ENUM.ITEMS;
|
|
5
|
+
reward_items: IRewardTypeItems;
|
|
6
|
+
reward_discount?: null;
|
|
7
|
+
reward_discount_items?: null;
|
|
8
|
+
reward_points?: null;
|
|
9
|
+
reward_cashback?: null;
|
|
10
|
+
reward_voucher?: null;
|
|
11
|
+
reward_mystery_gift?: null;
|
|
12
|
+
};
|
|
13
|
+
type IGiftCardRewardDiscount = {
|
|
14
|
+
reward_type: GIFT_CARD_REWARD_TYPE_ENUM.DISCOUNT;
|
|
15
|
+
reward_items?: null;
|
|
16
|
+
reward_discount: IRewardTypeDiscount;
|
|
17
|
+
reward_discount_items?: null;
|
|
18
|
+
reward_points?: null;
|
|
19
|
+
reward_cashback?: null;
|
|
20
|
+
reward_voucher?: null;
|
|
21
|
+
reward_mystery_gift?: null;
|
|
22
|
+
};
|
|
23
|
+
type IGiftCardRewardDiscountItems = {
|
|
24
|
+
reward_type: GIFT_CARD_REWARD_TYPE_ENUM.DISCOUNT_ITEMS;
|
|
25
|
+
reward_items?: null;
|
|
26
|
+
reward_discount?: null;
|
|
27
|
+
reward_discount_items: IRewardTypeDiscountItems;
|
|
28
|
+
reward_points?: null;
|
|
29
|
+
reward_cashback?: null;
|
|
30
|
+
reward_voucher?: null;
|
|
31
|
+
reward_mystery_gift?: null;
|
|
32
|
+
};
|
|
33
|
+
type IGiftCardRewardPoints = {
|
|
34
|
+
reward_type: GIFT_CARD_REWARD_TYPE_ENUM.POINTS;
|
|
35
|
+
reward_items?: null;
|
|
36
|
+
reward_discount?: null;
|
|
37
|
+
reward_discount_items?: null;
|
|
38
|
+
reward_points: IRewardTypePoints;
|
|
39
|
+
reward_cashback?: null;
|
|
40
|
+
reward_voucher?: null;
|
|
41
|
+
reward_mystery_gift?: null;
|
|
42
|
+
};
|
|
43
|
+
type IGiftCardRewardCashback = {
|
|
44
|
+
reward_type: GIFT_CARD_REWARD_TYPE_ENUM.CASHBACK;
|
|
45
|
+
reward_items?: null;
|
|
46
|
+
reward_discount?: null;
|
|
47
|
+
reward_discount_items?: null;
|
|
48
|
+
reward_points?: null;
|
|
49
|
+
reward_cashback: IRewardTypeCashback;
|
|
50
|
+
reward_voucher?: null;
|
|
51
|
+
reward_mystery_gift?: null;
|
|
52
|
+
};
|
|
53
|
+
type IGiftCardRewardVoucher = {
|
|
54
|
+
reward_type: GIFT_CARD_REWARD_TYPE_ENUM.VOUCHER;
|
|
55
|
+
reward_items?: null;
|
|
56
|
+
reward_discount?: null;
|
|
57
|
+
reward_discount_items?: null;
|
|
58
|
+
reward_points?: null;
|
|
59
|
+
reward_cashback?: null;
|
|
60
|
+
reward_voucher: IRewardTypeVoucher;
|
|
61
|
+
reward_mystery_gift?: null;
|
|
62
|
+
};
|
|
63
|
+
type IGiftCardRewardMysteryGift = {
|
|
64
|
+
reward_type: GIFT_CARD_REWARD_TYPE_ENUM.MYSTERY_GIFT;
|
|
65
|
+
reward_items?: null;
|
|
66
|
+
reward_discount?: null;
|
|
67
|
+
reward_discount_items?: null;
|
|
68
|
+
reward_points?: null;
|
|
69
|
+
reward_cashback?: null;
|
|
70
|
+
reward_voucher?: null;
|
|
71
|
+
reward_mystery_gift: IRewardTypeMysteryGift;
|
|
72
|
+
};
|
|
73
|
+
export type IGiftCardReward = IGiftCardRewardItems | IGiftCardRewardDiscount | IGiftCardRewardDiscountItems | IGiftCardRewardPoints | IGiftCardRewardCashback | IGiftCardRewardVoucher | IGiftCardRewardMysteryGift;
|
|
74
|
+
interface IBaseGiftCard {
|
|
75
|
+
_id: string;
|
|
76
|
+
code: string;
|
|
77
|
+
brand_id: string;
|
|
78
|
+
tenants: string[];
|
|
79
|
+
name: string;
|
|
80
|
+
description: string;
|
|
81
|
+
active: boolean;
|
|
82
|
+
max_uses: number | null;
|
|
83
|
+
max_uses_per_customer: number | null;
|
|
84
|
+
used_count: number;
|
|
85
|
+
last_used_at: Date | null;
|
|
86
|
+
expire_at: Date | null;
|
|
87
|
+
updatedAt: Date;
|
|
88
|
+
createdAt: Date;
|
|
89
|
+
}
|
|
90
|
+
export type IGiftCard = IBaseGiftCard & IGiftCardReward;
|
|
91
|
+
export {};
|
|
@@ -52,6 +52,7 @@ export * from './tenant_staff';
|
|
|
52
52
|
export * from './terminal_devices';
|
|
53
53
|
export * from './tokens';
|
|
54
54
|
export * from './track_order_number';
|
|
55
|
+
export * from './vouchers';
|
|
55
56
|
export * from './void_order_items';
|
|
56
57
|
export * from './wallet';
|
|
57
58
|
export * from './wallet_transactions';
|
|
@@ -66,3 +67,5 @@ export * from './warehouse_operational_roles';
|
|
|
66
67
|
export * from './warehouse_staff';
|
|
67
68
|
export * from './warehouse_track_order_number';
|
|
68
69
|
export * from './warehouse_vendors';
|
|
70
|
+
export * from './gift_cards';
|
|
71
|
+
export * from './rewards_usage';
|
|
@@ -68,6 +68,7 @@ __exportStar(require("./tenant_staff"), exports);
|
|
|
68
68
|
__exportStar(require("./terminal_devices"), exports);
|
|
69
69
|
__exportStar(require("./tokens"), exports);
|
|
70
70
|
__exportStar(require("./track_order_number"), exports);
|
|
71
|
+
__exportStar(require("./vouchers"), exports);
|
|
71
72
|
__exportStar(require("./void_order_items"), exports);
|
|
72
73
|
__exportStar(require("./wallet"), exports);
|
|
73
74
|
__exportStar(require("./wallet_transactions"), exports);
|
|
@@ -82,3 +83,5 @@ __exportStar(require("./warehouse_operational_roles"), exports);
|
|
|
82
83
|
__exportStar(require("./warehouse_staff"), exports);
|
|
83
84
|
__exportStar(require("./warehouse_track_order_number"), exports);
|
|
84
85
|
__exportStar(require("./warehouse_vendors"), exports);
|
|
86
|
+
__exportStar(require("./gift_cards"), exports);
|
|
87
|
+
__exportStar(require("./rewards_usage"), exports);
|