@managesome/eposmatic-toolkit 0.2.259 → 0.2.261
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/helpers/store/cart-actions.js +95 -78
- package/lib/helpers/utils/common.d.ts +9 -0
- package/lib/helpers/utils/common.js +21 -0
- package/lib/helpers/utils/offers-helpers.d.ts +2 -0
- package/lib/helpers/utils/offers-helpers.js +25 -2
- package/lib/schemas/models/gift_cards.d.ts +328 -39
- package/lib/schemas/models/gift_cards.js +195 -19
- package/lib/schemas/models/offers.d.ts +6 -0
- package/lib/schemas/models/offers.js +10 -0
- package/lib/schemas/types/offers.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1993,60 +1993,82 @@ offers) {
|
|
|
1993
1993
|
};
|
|
1994
1994
|
let hasChanges = false;
|
|
1995
1995
|
const categories = data.categories ?? [];
|
|
1996
|
+
const orderLevelDiscountBaseAmount = categories.reduce((subtotal, category) => {
|
|
1997
|
+
return subtotal + category.items.reduce((itemSubtotal, item) => itemSubtotal + (item.subtotal ?? 0), 0);
|
|
1998
|
+
}, 0);
|
|
1996
1999
|
let order_discount_details = data.order_discount_details;
|
|
2000
|
+
const clearOrderLevelDiscount = (discountType) => {
|
|
2001
|
+
if (order_discount_details == null) {
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
if (discountType === 'loyalty') {
|
|
2005
|
+
order_discount_details = {
|
|
2006
|
+
...order_discount_details,
|
|
2007
|
+
loyalty_discount_id: undefined,
|
|
2008
|
+
loyalty_discount_name: undefined,
|
|
2009
|
+
loyalty_discount: undefined,
|
|
2010
|
+
is_loyalty_discount_percentage: false,
|
|
2011
|
+
};
|
|
2012
|
+
}
|
|
2013
|
+
else {
|
|
2014
|
+
order_discount_details = {
|
|
2015
|
+
...order_discount_details,
|
|
2016
|
+
voucher_discount_id: undefined,
|
|
2017
|
+
voucher_discount_name: undefined,
|
|
2018
|
+
voucher_discount: undefined,
|
|
2019
|
+
is_voucher_discount_percentage: false,
|
|
2020
|
+
};
|
|
2021
|
+
}
|
|
2022
|
+
hasChanges = true;
|
|
2023
|
+
};
|
|
1997
2024
|
if (order_discount_details != null) {
|
|
1998
2025
|
// we check if either the loyalty_discount_id or voucher_discount_id
|
|
1999
2026
|
const loyaltyDiscountId = order_discount_details.loyalty_discount_id;
|
|
2000
2027
|
if (loyaltyDiscountId != null) {
|
|
2001
2028
|
if (unlockedOffersMap[loyaltyDiscountId] == null || unlockedOffersMap[loyaltyDiscountId] <= 0) {
|
|
2002
|
-
|
|
2003
|
-
...order_discount_details,
|
|
2004
|
-
loyalty_discount_id: undefined,
|
|
2005
|
-
loyalty_discount_name: undefined,
|
|
2006
|
-
loyalty_discount: undefined,
|
|
2007
|
-
is_loyalty_discount_percentage: false,
|
|
2008
|
-
};
|
|
2009
|
-
hasChanges = true;
|
|
2029
|
+
clearOrderLevelDiscount('loyalty');
|
|
2010
2030
|
}
|
|
2011
2031
|
else {
|
|
2012
2032
|
// Find the offer to check for excluded_refs
|
|
2013
2033
|
const loyaltyOffer = offers.find((o) => o._id === loyaltyDiscountId);
|
|
2014
2034
|
if (loyaltyOffer?.reward_discount != null) {
|
|
2015
|
-
|
|
2016
|
-
const {
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
};
|
|
2041
|
-
hasChanges = true;
|
|
2035
|
+
const { discount_value, excluded_refs, is_discount_percentage, max_discount_amount, max_discount_percentage, } = loyaltyOffer.reward_discount;
|
|
2036
|
+
const { subtotal: eligibleSubtotal, hasExcludedRefs } = excluded_refs != null && excluded_refs.length > 0
|
|
2037
|
+
? calculateEligibleOfferDiscountDetails(categories, excluded_refs)
|
|
2038
|
+
: {
|
|
2039
|
+
subtotal: orderLevelDiscountBaseAmount,
|
|
2040
|
+
hasExcludedRefs: false,
|
|
2041
|
+
};
|
|
2042
|
+
// Static discounts with exclusions are not supported - silently skip
|
|
2043
|
+
if (hasExcludedRefs && !is_discount_percentage) {
|
|
2044
|
+
clearOrderLevelDiscount('loyalty');
|
|
2045
|
+
}
|
|
2046
|
+
else {
|
|
2047
|
+
const hasRelevantCap = is_discount_percentage &&
|
|
2048
|
+
max_discount_amount != null &&
|
|
2049
|
+
Number.isFinite(max_discount_amount) &&
|
|
2050
|
+
max_discount_amount >= 0;
|
|
2051
|
+
const hasRelevantPercentageCap = !is_discount_percentage &&
|
|
2052
|
+
max_discount_percentage != null &&
|
|
2053
|
+
Number.isFinite(max_discount_percentage) &&
|
|
2054
|
+
max_discount_percentage >= 0;
|
|
2055
|
+
const shouldNormalizeToStatic = hasExcludedRefs || hasRelevantCap || hasRelevantPercentageCap;
|
|
2056
|
+
const discountBaseAmount = hasExcludedRefs ? eligibleSubtotal : orderLevelDiscountBaseAmount;
|
|
2057
|
+
if (shouldNormalizeToStatic) {
|
|
2058
|
+
if (discountBaseAmount <= 0) {
|
|
2059
|
+
clearOrderLevelDiscount('loyalty');
|
|
2042
2060
|
}
|
|
2043
2061
|
else {
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2062
|
+
const calculatedDiscount = (0, utils_1.getCappedOfferDiscountAmount)({
|
|
2063
|
+
baseAmount: discountBaseAmount,
|
|
2064
|
+
discountValue: discount_value,
|
|
2065
|
+
isDiscountPercentage: is_discount_percentage,
|
|
2066
|
+
maxDiscountAmount: max_discount_amount,
|
|
2067
|
+
maxDiscountPercentage: max_discount_percentage,
|
|
2068
|
+
});
|
|
2047
2069
|
order_discount_details = {
|
|
2048
2070
|
...order_discount_details,
|
|
2049
|
-
loyalty_discount: (0, utils_1.parseNum)(
|
|
2071
|
+
loyalty_discount: (0, utils_1.parseNum)(calculatedDiscount),
|
|
2050
2072
|
is_loyalty_discount_percentage: false,
|
|
2051
2073
|
};
|
|
2052
2074
|
hasChanges = true;
|
|
@@ -2060,54 +2082,49 @@ offers) {
|
|
|
2060
2082
|
const voucherDiscountId = order_discount_details.voucher_discount_id;
|
|
2061
2083
|
if (voucherDiscountId != null) {
|
|
2062
2084
|
if (unlockedOffersMap[voucherDiscountId] == null || unlockedOffersMap[voucherDiscountId] <= 0) {
|
|
2063
|
-
|
|
2064
|
-
...order_discount_details,
|
|
2065
|
-
voucher_discount_id: undefined,
|
|
2066
|
-
voucher_discount_name: undefined,
|
|
2067
|
-
voucher_discount: undefined,
|
|
2068
|
-
is_voucher_discount_percentage: false,
|
|
2069
|
-
};
|
|
2070
|
-
hasChanges = true;
|
|
2085
|
+
clearOrderLevelDiscount('voucher');
|
|
2071
2086
|
}
|
|
2072
2087
|
else {
|
|
2073
2088
|
// Find the offer to check for excluded_refs
|
|
2074
2089
|
const voucherOffer = offers.find((o) => o._id === voucherDiscountId);
|
|
2075
2090
|
if (voucherOffer?.reward_discount != null) {
|
|
2076
|
-
|
|
2077
|
-
const {
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
};
|
|
2102
|
-
hasChanges = true;
|
|
2091
|
+
const { discount_value, excluded_refs, is_discount_percentage, max_discount_amount, max_discount_percentage, } = voucherOffer.reward_discount;
|
|
2092
|
+
const { subtotal: eligibleSubtotal, hasExcludedRefs } = excluded_refs != null && excluded_refs.length > 0
|
|
2093
|
+
? calculateEligibleOfferDiscountDetails(categories, excluded_refs)
|
|
2094
|
+
: {
|
|
2095
|
+
subtotal: orderLevelDiscountBaseAmount,
|
|
2096
|
+
hasExcludedRefs: false,
|
|
2097
|
+
};
|
|
2098
|
+
// Static discounts with exclusions are not supported - silently skip
|
|
2099
|
+
if (hasExcludedRefs && !is_discount_percentage) {
|
|
2100
|
+
clearOrderLevelDiscount('voucher');
|
|
2101
|
+
}
|
|
2102
|
+
else {
|
|
2103
|
+
const hasRelevantCap = is_discount_percentage &&
|
|
2104
|
+
max_discount_amount != null &&
|
|
2105
|
+
Number.isFinite(max_discount_amount) &&
|
|
2106
|
+
max_discount_amount >= 0;
|
|
2107
|
+
const hasRelevantPercentageCap = !is_discount_percentage &&
|
|
2108
|
+
max_discount_percentage != null &&
|
|
2109
|
+
Number.isFinite(max_discount_percentage) &&
|
|
2110
|
+
max_discount_percentage >= 0;
|
|
2111
|
+
const shouldNormalizeToStatic = hasExcludedRefs || hasRelevantCap || hasRelevantPercentageCap;
|
|
2112
|
+
const discountBaseAmount = hasExcludedRefs ? eligibleSubtotal : orderLevelDiscountBaseAmount;
|
|
2113
|
+
if (shouldNormalizeToStatic) {
|
|
2114
|
+
if (discountBaseAmount <= 0) {
|
|
2115
|
+
clearOrderLevelDiscount('voucher');
|
|
2103
2116
|
}
|
|
2104
2117
|
else {
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2118
|
+
const calculatedDiscount = (0, utils_1.getCappedOfferDiscountAmount)({
|
|
2119
|
+
baseAmount: discountBaseAmount,
|
|
2120
|
+
discountValue: discount_value,
|
|
2121
|
+
isDiscountPercentage: is_discount_percentage,
|
|
2122
|
+
maxDiscountAmount: max_discount_amount,
|
|
2123
|
+
maxDiscountPercentage: max_discount_percentage,
|
|
2124
|
+
});
|
|
2108
2125
|
order_discount_details = {
|
|
2109
2126
|
...order_discount_details,
|
|
2110
|
-
voucher_discount: (0, utils_1.parseNum)(
|
|
2127
|
+
voucher_discount: (0, utils_1.parseNum)(calculatedDiscount),
|
|
2111
2128
|
is_voucher_discount_percentage: false,
|
|
2112
2129
|
};
|
|
2113
2130
|
hasChanges = true;
|
|
@@ -34,3 +34,12 @@ export declare function formattedStoreName(name: string): string;
|
|
|
34
34
|
export declare const formatFieldName: (field: string) => string;
|
|
35
35
|
export declare function getPercentage(total: number, num: number): number;
|
|
36
36
|
export declare function getPercentageAmount(total: number, percent: number): number;
|
|
37
|
+
interface IGetCappedOfferDiscountAmount {
|
|
38
|
+
baseAmount: number;
|
|
39
|
+
discountValue: number;
|
|
40
|
+
isDiscountPercentage: boolean;
|
|
41
|
+
maxDiscountAmount?: number | null;
|
|
42
|
+
maxDiscountPercentage?: number | null;
|
|
43
|
+
}
|
|
44
|
+
export declare function getCappedOfferDiscountAmount({ baseAmount, discountValue, isDiscountPercentage, maxDiscountAmount, maxDiscountPercentage, }: IGetCappedOfferDiscountAmount): number;
|
|
45
|
+
export {};
|
|
@@ -28,6 +28,7 @@ exports.getFormattedCancellationReason = getFormattedCancellationReason;
|
|
|
28
28
|
exports.formattedStoreName = formattedStoreName;
|
|
29
29
|
exports.getPercentage = getPercentage;
|
|
30
30
|
exports.getPercentageAmount = getPercentageAmount;
|
|
31
|
+
exports.getCappedOfferDiscountAmount = getCappedOfferDiscountAmount;
|
|
31
32
|
const google_libphonenumber_1 = require("google-libphonenumber");
|
|
32
33
|
const moment_1 = __importDefault(require("moment"));
|
|
33
34
|
const constants_1 = require("../../constants");
|
|
@@ -330,3 +331,23 @@ function getPercentage(total, num) {
|
|
|
330
331
|
function getPercentageAmount(total, percent) {
|
|
331
332
|
return (total * percent) / 100;
|
|
332
333
|
}
|
|
334
|
+
function getCappedOfferDiscountAmount({ baseAmount, discountValue, isDiscountPercentage, maxDiscountAmount, maxDiscountPercentage, }) {
|
|
335
|
+
const normalizedBaseAmount = Number.isFinite(baseAmount) ? Math.max(0, baseAmount) : 0;
|
|
336
|
+
const normalizedDiscountValue = Number.isFinite(discountValue) ? Math.max(0, discountValue) : 0;
|
|
337
|
+
if (normalizedBaseAmount <= 0 || normalizedDiscountValue <= 0) {
|
|
338
|
+
return 0;
|
|
339
|
+
}
|
|
340
|
+
if (isDiscountPercentage) {
|
|
341
|
+
let amount = getPercentageAmount(normalizedBaseAmount, normalizedDiscountValue);
|
|
342
|
+
if (maxDiscountAmount != null && Number.isFinite(maxDiscountAmount) && maxDiscountAmount >= 0) {
|
|
343
|
+
amount = Math.min(amount, maxDiscountAmount);
|
|
344
|
+
}
|
|
345
|
+
return Math.min(amount, normalizedBaseAmount);
|
|
346
|
+
}
|
|
347
|
+
let amount = normalizedDiscountValue;
|
|
348
|
+
if (maxDiscountPercentage != null && Number.isFinite(maxDiscountPercentage) && maxDiscountPercentage >= 0) {
|
|
349
|
+
const maxAmountFromPercentage = getPercentageAmount(normalizedBaseAmount, maxDiscountPercentage);
|
|
350
|
+
amount = Math.min(amount, maxAmountFromPercentage);
|
|
351
|
+
}
|
|
352
|
+
return Math.min(amount, normalizedBaseAmount);
|
|
353
|
+
}
|
|
@@ -22,6 +22,8 @@ export interface IRewardPreview {
|
|
|
22
22
|
label: string;
|
|
23
23
|
discount_value?: number;
|
|
24
24
|
is_percentage?: boolean;
|
|
25
|
+
max_discount_amount?: number | null;
|
|
26
|
+
max_discount_percentage?: number | null;
|
|
25
27
|
free_items_count?: number;
|
|
26
28
|
points_value?: number;
|
|
27
29
|
cashback_value?: number;
|
|
@@ -100,6 +100,14 @@ function getOfferWithPrice(offer, writeable) {
|
|
|
100
100
|
delete newOffer.reward_cashback;
|
|
101
101
|
delete newOffer.reward_gift_cards;
|
|
102
102
|
}
|
|
103
|
+
if (newOffer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT && newOffer.reward_discount != null) {
|
|
104
|
+
if (newOffer.reward_discount.is_discount_percentage) {
|
|
105
|
+
newOffer.reward_discount.max_discount_percentage = null;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
newOffer.reward_discount.max_discount_amount = null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
103
111
|
}
|
|
104
112
|
return {
|
|
105
113
|
...newOffer,
|
|
@@ -151,6 +159,12 @@ function getOfferWithPrice(offer, writeable) {
|
|
|
151
159
|
reward_discount: {
|
|
152
160
|
...newOffer.reward_discount,
|
|
153
161
|
discount_value: convertToNum(newOffer.reward_discount.discount_value),
|
|
162
|
+
max_discount_amount: newOffer.reward_discount.max_discount_amount != null
|
|
163
|
+
? convertToNum(newOffer.reward_discount.max_discount_amount)
|
|
164
|
+
: null,
|
|
165
|
+
max_discount_percentage: newOffer.reward_discount.max_discount_percentage != null
|
|
166
|
+
? convertToNum(newOffer.reward_discount.max_discount_percentage)
|
|
167
|
+
: null,
|
|
154
168
|
},
|
|
155
169
|
}
|
|
156
170
|
: {}),
|
|
@@ -506,12 +520,21 @@ function buildRewardPreview(offer) {
|
|
|
506
520
|
case constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT: {
|
|
507
521
|
if (offer.reward_discount == null)
|
|
508
522
|
return null;
|
|
509
|
-
const { discount_value, is_discount_percentage } = offer.reward_discount;
|
|
523
|
+
const { discount_value, is_discount_percentage, max_discount_amount, max_discount_percentage } = offer.reward_discount;
|
|
524
|
+
let label = is_discount_percentage ? `${discount_value}% off` : `${discount_value} off`;
|
|
525
|
+
if (is_discount_percentage && max_discount_amount != null) {
|
|
526
|
+
label += ` (max ${max_discount_amount})`;
|
|
527
|
+
}
|
|
528
|
+
if (!is_discount_percentage && max_discount_percentage != null) {
|
|
529
|
+
label += ` (max ${max_discount_percentage}%)`;
|
|
530
|
+
}
|
|
510
531
|
return {
|
|
511
532
|
type: constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT,
|
|
512
|
-
label
|
|
533
|
+
label,
|
|
513
534
|
discount_value,
|
|
514
535
|
is_percentage: is_discount_percentage,
|
|
536
|
+
max_discount_amount,
|
|
537
|
+
max_discount_percentage,
|
|
515
538
|
};
|
|
516
539
|
}
|
|
517
540
|
case constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from 'mongoose';
|
|
2
|
+
import { GIFT_CARD_REWARD_TYPE_ENUM } from '../../constants';
|
|
2
3
|
export declare const GiftCardsSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
3
4
|
timestamps: true;
|
|
4
5
|
versionKey: false;
|
|
@@ -16,26 +17,122 @@ export declare const GiftCardsSchema: Schema<any, import("mongoose").Model<any,
|
|
|
16
17
|
brand_id: string;
|
|
17
18
|
active: boolean;
|
|
18
19
|
code: string;
|
|
19
|
-
reward_type:
|
|
20
|
+
reward_type: GIFT_CARD_REWARD_TYPE_ENUM;
|
|
20
21
|
used_count: number;
|
|
21
|
-
reward_items?:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
reward_items?: {
|
|
23
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
24
|
+
excluded_refs: string[];
|
|
25
|
+
exclusive_refs: string[];
|
|
26
|
+
num_of_items: number;
|
|
27
|
+
allocation?: import("mongoose").Types.DocumentArray<{
|
|
28
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
29
|
+
quantity: number;
|
|
30
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
31
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
32
|
+
quantity: number;
|
|
33
|
+
}> & {
|
|
34
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
35
|
+
quantity: number;
|
|
36
|
+
}> | null | undefined;
|
|
37
|
+
} | null | undefined;
|
|
38
|
+
reward_discount?: {
|
|
39
|
+
is_discount_percentage: boolean;
|
|
40
|
+
excluded_refs: string[];
|
|
41
|
+
discount_value: number;
|
|
42
|
+
max_discount_amount?: number | null | undefined;
|
|
43
|
+
max_discount_percentage?: number | null | undefined;
|
|
44
|
+
} | null | undefined;
|
|
45
|
+
reward_discount_items?: {
|
|
46
|
+
is_discount_percentage: boolean;
|
|
47
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
48
|
+
excluded_refs: string[];
|
|
49
|
+
exclusive_refs: string[];
|
|
50
|
+
num_of_items: number;
|
|
51
|
+
discount_value: number;
|
|
52
|
+
allocation?: import("mongoose").Types.DocumentArray<{
|
|
53
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
54
|
+
quantity: number;
|
|
55
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
56
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
57
|
+
quantity: number;
|
|
58
|
+
}> & {
|
|
59
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
60
|
+
quantity: number;
|
|
61
|
+
}> | null | undefined;
|
|
62
|
+
} | null | undefined;
|
|
63
|
+
reward_points?: {
|
|
64
|
+
num_of_points: number;
|
|
65
|
+
once_per_order: boolean;
|
|
66
|
+
} | null | undefined;
|
|
67
|
+
reward_cashback?: {
|
|
68
|
+
excluded_refs: string[];
|
|
69
|
+
cashback_value: number;
|
|
70
|
+
is_cashback_percentage: boolean;
|
|
71
|
+
max_cashback_amount?: number | null | undefined;
|
|
72
|
+
} | null | undefined;
|
|
73
|
+
reward_voucher?: {
|
|
74
|
+
voucher_ids: Map<string, number>;
|
|
75
|
+
} | null | undefined;
|
|
27
76
|
max_uses?: number | null | undefined;
|
|
28
77
|
max_uses_per_customer?: number | null | undefined;
|
|
29
78
|
last_used_at?: NativeDate | null | undefined;
|
|
30
79
|
expire_at?: NativeDate | null | undefined;
|
|
31
80
|
reward_mystery_gift?: {
|
|
32
81
|
choice_of_rewards: string[];
|
|
33
|
-
reward_items?:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
82
|
+
reward_items?: {
|
|
83
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
84
|
+
excluded_refs: string[];
|
|
85
|
+
exclusive_refs: string[];
|
|
86
|
+
num_of_items: number;
|
|
87
|
+
allocation?: import("mongoose").Types.DocumentArray<{
|
|
88
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
89
|
+
quantity: number;
|
|
90
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
91
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
92
|
+
quantity: number;
|
|
93
|
+
}> & {
|
|
94
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
95
|
+
quantity: number;
|
|
96
|
+
}> | null | undefined;
|
|
97
|
+
} | null | undefined;
|
|
98
|
+
reward_discount?: {
|
|
99
|
+
is_discount_percentage: boolean;
|
|
100
|
+
excluded_refs: string[];
|
|
101
|
+
discount_value: number;
|
|
102
|
+
max_discount_amount?: number | null | undefined;
|
|
103
|
+
max_discount_percentage?: number | null | undefined;
|
|
104
|
+
} | null | undefined;
|
|
105
|
+
reward_discount_items?: {
|
|
106
|
+
is_discount_percentage: boolean;
|
|
107
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
108
|
+
excluded_refs: string[];
|
|
109
|
+
exclusive_refs: string[];
|
|
110
|
+
num_of_items: number;
|
|
111
|
+
discount_value: number;
|
|
112
|
+
allocation?: import("mongoose").Types.DocumentArray<{
|
|
113
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
114
|
+
quantity: number;
|
|
115
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
116
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
117
|
+
quantity: number;
|
|
118
|
+
}> & {
|
|
119
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
120
|
+
quantity: number;
|
|
121
|
+
}> | null | undefined;
|
|
122
|
+
} | null | undefined;
|
|
123
|
+
reward_points?: {
|
|
124
|
+
num_of_points: number;
|
|
125
|
+
once_per_order: boolean;
|
|
126
|
+
} | null | undefined;
|
|
127
|
+
reward_cashback?: {
|
|
128
|
+
excluded_refs: string[];
|
|
129
|
+
cashback_value: number;
|
|
130
|
+
is_cashback_percentage: boolean;
|
|
131
|
+
max_cashback_amount?: number | null | undefined;
|
|
132
|
+
} | null | undefined;
|
|
133
|
+
reward_voucher?: {
|
|
134
|
+
voucher_ids: Map<string, number>;
|
|
135
|
+
} | null | undefined;
|
|
39
136
|
} | null | undefined;
|
|
40
137
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
41
138
|
createdAt: NativeDate;
|
|
@@ -50,26 +147,122 @@ export declare const GiftCardsSchema: Schema<any, import("mongoose").Model<any,
|
|
|
50
147
|
brand_id: string;
|
|
51
148
|
active: boolean;
|
|
52
149
|
code: string;
|
|
53
|
-
reward_type:
|
|
150
|
+
reward_type: GIFT_CARD_REWARD_TYPE_ENUM;
|
|
54
151
|
used_count: number;
|
|
55
|
-
reward_items?:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
152
|
+
reward_items?: {
|
|
153
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
154
|
+
excluded_refs: string[];
|
|
155
|
+
exclusive_refs: string[];
|
|
156
|
+
num_of_items: number;
|
|
157
|
+
allocation?: import("mongoose").Types.DocumentArray<{
|
|
158
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
159
|
+
quantity: number;
|
|
160
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
161
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
162
|
+
quantity: number;
|
|
163
|
+
}> & {
|
|
164
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
165
|
+
quantity: number;
|
|
166
|
+
}> | null | undefined;
|
|
167
|
+
} | null | undefined;
|
|
168
|
+
reward_discount?: {
|
|
169
|
+
is_discount_percentage: boolean;
|
|
170
|
+
excluded_refs: string[];
|
|
171
|
+
discount_value: number;
|
|
172
|
+
max_discount_amount?: number | null | undefined;
|
|
173
|
+
max_discount_percentage?: number | null | undefined;
|
|
174
|
+
} | null | undefined;
|
|
175
|
+
reward_discount_items?: {
|
|
176
|
+
is_discount_percentage: boolean;
|
|
177
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
178
|
+
excluded_refs: string[];
|
|
179
|
+
exclusive_refs: string[];
|
|
180
|
+
num_of_items: number;
|
|
181
|
+
discount_value: number;
|
|
182
|
+
allocation?: import("mongoose").Types.DocumentArray<{
|
|
183
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
184
|
+
quantity: number;
|
|
185
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
186
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
187
|
+
quantity: number;
|
|
188
|
+
}> & {
|
|
189
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
190
|
+
quantity: number;
|
|
191
|
+
}> | null | undefined;
|
|
192
|
+
} | null | undefined;
|
|
193
|
+
reward_points?: {
|
|
194
|
+
num_of_points: number;
|
|
195
|
+
once_per_order: boolean;
|
|
196
|
+
} | null | undefined;
|
|
197
|
+
reward_cashback?: {
|
|
198
|
+
excluded_refs: string[];
|
|
199
|
+
cashback_value: number;
|
|
200
|
+
is_cashback_percentage: boolean;
|
|
201
|
+
max_cashback_amount?: number | null | undefined;
|
|
202
|
+
} | null | undefined;
|
|
203
|
+
reward_voucher?: {
|
|
204
|
+
voucher_ids: Map<string, number>;
|
|
205
|
+
} | null | undefined;
|
|
61
206
|
max_uses?: number | null | undefined;
|
|
62
207
|
max_uses_per_customer?: number | null | undefined;
|
|
63
208
|
last_used_at?: NativeDate | null | undefined;
|
|
64
209
|
expire_at?: NativeDate | null | undefined;
|
|
65
210
|
reward_mystery_gift?: {
|
|
66
211
|
choice_of_rewards: string[];
|
|
67
|
-
reward_items?:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
212
|
+
reward_items?: {
|
|
213
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
214
|
+
excluded_refs: string[];
|
|
215
|
+
exclusive_refs: string[];
|
|
216
|
+
num_of_items: number;
|
|
217
|
+
allocation?: import("mongoose").Types.DocumentArray<{
|
|
218
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
219
|
+
quantity: number;
|
|
220
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
221
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
222
|
+
quantity: number;
|
|
223
|
+
}> & {
|
|
224
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
225
|
+
quantity: number;
|
|
226
|
+
}> | null | undefined;
|
|
227
|
+
} | null | undefined;
|
|
228
|
+
reward_discount?: {
|
|
229
|
+
is_discount_percentage: boolean;
|
|
230
|
+
excluded_refs: string[];
|
|
231
|
+
discount_value: number;
|
|
232
|
+
max_discount_amount?: number | null | undefined;
|
|
233
|
+
max_discount_percentage?: number | null | undefined;
|
|
234
|
+
} | null | undefined;
|
|
235
|
+
reward_discount_items?: {
|
|
236
|
+
is_discount_percentage: boolean;
|
|
237
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
238
|
+
excluded_refs: string[];
|
|
239
|
+
exclusive_refs: string[];
|
|
240
|
+
num_of_items: number;
|
|
241
|
+
discount_value: number;
|
|
242
|
+
allocation?: import("mongoose").Types.DocumentArray<{
|
|
243
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
244
|
+
quantity: number;
|
|
245
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
246
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
247
|
+
quantity: number;
|
|
248
|
+
}> & {
|
|
249
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
250
|
+
quantity: number;
|
|
251
|
+
}> | null | undefined;
|
|
252
|
+
} | null | undefined;
|
|
253
|
+
reward_points?: {
|
|
254
|
+
num_of_points: number;
|
|
255
|
+
once_per_order: boolean;
|
|
256
|
+
} | null | undefined;
|
|
257
|
+
reward_cashback?: {
|
|
258
|
+
excluded_refs: string[];
|
|
259
|
+
cashback_value: number;
|
|
260
|
+
is_cashback_percentage: boolean;
|
|
261
|
+
max_cashback_amount?: number | null | undefined;
|
|
262
|
+
} | null | undefined;
|
|
263
|
+
reward_voucher?: {
|
|
264
|
+
voucher_ids: Map<string, number>;
|
|
265
|
+
} | null | undefined;
|
|
73
266
|
} | null | undefined;
|
|
74
267
|
}>> & import("mongoose").FlatRecord<{
|
|
75
268
|
createdAt: NativeDate;
|
|
@@ -84,26 +277,122 @@ export declare const GiftCardsSchema: Schema<any, import("mongoose").Model<any,
|
|
|
84
277
|
brand_id: string;
|
|
85
278
|
active: boolean;
|
|
86
279
|
code: string;
|
|
87
|
-
reward_type:
|
|
280
|
+
reward_type: GIFT_CARD_REWARD_TYPE_ENUM;
|
|
88
281
|
used_count: number;
|
|
89
|
-
reward_items?:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
282
|
+
reward_items?: {
|
|
283
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
284
|
+
excluded_refs: string[];
|
|
285
|
+
exclusive_refs: string[];
|
|
286
|
+
num_of_items: number;
|
|
287
|
+
allocation?: import("mongoose").Types.DocumentArray<{
|
|
288
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
289
|
+
quantity: number;
|
|
290
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
291
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
292
|
+
quantity: number;
|
|
293
|
+
}> & {
|
|
294
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
295
|
+
quantity: number;
|
|
296
|
+
}> | null | undefined;
|
|
297
|
+
} | null | undefined;
|
|
298
|
+
reward_discount?: {
|
|
299
|
+
is_discount_percentage: boolean;
|
|
300
|
+
excluded_refs: string[];
|
|
301
|
+
discount_value: number;
|
|
302
|
+
max_discount_amount?: number | null | undefined;
|
|
303
|
+
max_discount_percentage?: number | null | undefined;
|
|
304
|
+
} | null | undefined;
|
|
305
|
+
reward_discount_items?: {
|
|
306
|
+
is_discount_percentage: boolean;
|
|
307
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
308
|
+
excluded_refs: string[];
|
|
309
|
+
exclusive_refs: string[];
|
|
310
|
+
num_of_items: number;
|
|
311
|
+
discount_value: number;
|
|
312
|
+
allocation?: import("mongoose").Types.DocumentArray<{
|
|
313
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
314
|
+
quantity: number;
|
|
315
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
316
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
317
|
+
quantity: number;
|
|
318
|
+
}> & {
|
|
319
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
320
|
+
quantity: number;
|
|
321
|
+
}> | null | undefined;
|
|
322
|
+
} | null | undefined;
|
|
323
|
+
reward_points?: {
|
|
324
|
+
num_of_points: number;
|
|
325
|
+
once_per_order: boolean;
|
|
326
|
+
} | null | undefined;
|
|
327
|
+
reward_cashback?: {
|
|
328
|
+
excluded_refs: string[];
|
|
329
|
+
cashback_value: number;
|
|
330
|
+
is_cashback_percentage: boolean;
|
|
331
|
+
max_cashback_amount?: number | null | undefined;
|
|
332
|
+
} | null | undefined;
|
|
333
|
+
reward_voucher?: {
|
|
334
|
+
voucher_ids: Map<string, number>;
|
|
335
|
+
} | null | undefined;
|
|
95
336
|
max_uses?: number | null | undefined;
|
|
96
337
|
max_uses_per_customer?: number | null | undefined;
|
|
97
338
|
last_used_at?: NativeDate | null | undefined;
|
|
98
339
|
expire_at?: NativeDate | null | undefined;
|
|
99
340
|
reward_mystery_gift?: {
|
|
100
341
|
choice_of_rewards: string[];
|
|
101
|
-
reward_items?:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
342
|
+
reward_items?: {
|
|
343
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
344
|
+
excluded_refs: string[];
|
|
345
|
+
exclusive_refs: string[];
|
|
346
|
+
num_of_items: number;
|
|
347
|
+
allocation?: import("mongoose").Types.DocumentArray<{
|
|
348
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
349
|
+
quantity: number;
|
|
350
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
351
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
352
|
+
quantity: number;
|
|
353
|
+
}> & {
|
|
354
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
355
|
+
quantity: number;
|
|
356
|
+
}> | null | undefined;
|
|
357
|
+
} | null | undefined;
|
|
358
|
+
reward_discount?: {
|
|
359
|
+
is_discount_percentage: boolean;
|
|
360
|
+
excluded_refs: string[];
|
|
361
|
+
discount_value: number;
|
|
362
|
+
max_discount_amount?: number | null | undefined;
|
|
363
|
+
max_discount_percentage?: number | null | undefined;
|
|
364
|
+
} | null | undefined;
|
|
365
|
+
reward_discount_items?: {
|
|
366
|
+
is_discount_percentage: boolean;
|
|
367
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
368
|
+
excluded_refs: string[];
|
|
369
|
+
exclusive_refs: string[];
|
|
370
|
+
num_of_items: number;
|
|
371
|
+
discount_value: number;
|
|
372
|
+
allocation?: import("mongoose").Types.DocumentArray<{
|
|
373
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
374
|
+
quantity: number;
|
|
375
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
376
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
377
|
+
quantity: number;
|
|
378
|
+
}> & {
|
|
379
|
+
item_ids: import("mongoose").Types.ObjectId[];
|
|
380
|
+
quantity: number;
|
|
381
|
+
}> | null | undefined;
|
|
382
|
+
} | null | undefined;
|
|
383
|
+
reward_points?: {
|
|
384
|
+
num_of_points: number;
|
|
385
|
+
once_per_order: boolean;
|
|
386
|
+
} | null | undefined;
|
|
387
|
+
reward_cashback?: {
|
|
388
|
+
excluded_refs: string[];
|
|
389
|
+
cashback_value: number;
|
|
390
|
+
is_cashback_percentage: boolean;
|
|
391
|
+
max_cashback_amount?: number | null | undefined;
|
|
392
|
+
} | null | undefined;
|
|
393
|
+
reward_voucher?: {
|
|
394
|
+
voucher_ids: Map<string, number>;
|
|
395
|
+
} | null | undefined;
|
|
107
396
|
} | null | undefined;
|
|
108
397
|
}> & Required<{
|
|
109
398
|
_id: import("mongoose").Types.ObjectId;
|
|
@@ -3,6 +3,168 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GIFT_CARDS_COLLECTION_NAME = exports.GiftCardsSchema = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
5
|
const constants_1 = require("../../constants");
|
|
6
|
+
const RewardItemsSchema = new mongoose_1.Schema({
|
|
7
|
+
num_of_items: {
|
|
8
|
+
type: Number,
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
excluded_refs: {
|
|
12
|
+
type: [String],
|
|
13
|
+
required: true,
|
|
14
|
+
default: [],
|
|
15
|
+
},
|
|
16
|
+
exclusive_refs: {
|
|
17
|
+
type: [String],
|
|
18
|
+
required: true,
|
|
19
|
+
default: [],
|
|
20
|
+
},
|
|
21
|
+
item_ids: {
|
|
22
|
+
type: [mongoose_1.Schema.Types.ObjectId],
|
|
23
|
+
required: true,
|
|
24
|
+
min: 1,
|
|
25
|
+
},
|
|
26
|
+
allocation: {
|
|
27
|
+
type: [
|
|
28
|
+
{
|
|
29
|
+
quantity: {
|
|
30
|
+
type: Number,
|
|
31
|
+
required: true,
|
|
32
|
+
},
|
|
33
|
+
item_ids: {
|
|
34
|
+
type: [mongoose_1.Schema.Types.ObjectId],
|
|
35
|
+
required: true,
|
|
36
|
+
min: 1,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
required: false,
|
|
41
|
+
},
|
|
42
|
+
}, {
|
|
43
|
+
_id: false,
|
|
44
|
+
minimize: false,
|
|
45
|
+
});
|
|
46
|
+
const RewardDiscountSchema = new mongoose_1.Schema({
|
|
47
|
+
discount_value: {
|
|
48
|
+
type: Number,
|
|
49
|
+
required: true,
|
|
50
|
+
},
|
|
51
|
+
is_discount_percentage: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
required: true,
|
|
54
|
+
},
|
|
55
|
+
max_discount_amount: {
|
|
56
|
+
type: Number,
|
|
57
|
+
required: false,
|
|
58
|
+
default: null,
|
|
59
|
+
},
|
|
60
|
+
max_discount_percentage: {
|
|
61
|
+
type: Number,
|
|
62
|
+
required: false,
|
|
63
|
+
default: null,
|
|
64
|
+
},
|
|
65
|
+
excluded_refs: {
|
|
66
|
+
type: [String],
|
|
67
|
+
required: true,
|
|
68
|
+
default: [],
|
|
69
|
+
},
|
|
70
|
+
}, {
|
|
71
|
+
_id: false,
|
|
72
|
+
minimize: false,
|
|
73
|
+
});
|
|
74
|
+
const RewardDiscountItemsSchema = new mongoose_1.Schema({
|
|
75
|
+
num_of_items: {
|
|
76
|
+
type: Number,
|
|
77
|
+
required: true,
|
|
78
|
+
},
|
|
79
|
+
excluded_refs: {
|
|
80
|
+
type: [String],
|
|
81
|
+
required: true,
|
|
82
|
+
default: [],
|
|
83
|
+
},
|
|
84
|
+
exclusive_refs: {
|
|
85
|
+
type: [String],
|
|
86
|
+
required: true,
|
|
87
|
+
default: [],
|
|
88
|
+
},
|
|
89
|
+
item_ids: {
|
|
90
|
+
type: [mongoose_1.Schema.Types.ObjectId],
|
|
91
|
+
required: true,
|
|
92
|
+
min: 1,
|
|
93
|
+
},
|
|
94
|
+
allocation: {
|
|
95
|
+
type: [
|
|
96
|
+
{
|
|
97
|
+
quantity: {
|
|
98
|
+
type: Number,
|
|
99
|
+
required: true,
|
|
100
|
+
},
|
|
101
|
+
item_ids: {
|
|
102
|
+
type: [mongoose_1.Schema.Types.ObjectId],
|
|
103
|
+
required: true,
|
|
104
|
+
min: 1,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
required: false,
|
|
109
|
+
},
|
|
110
|
+
discount_value: {
|
|
111
|
+
type: Number,
|
|
112
|
+
required: true,
|
|
113
|
+
},
|
|
114
|
+
is_discount_percentage: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
required: true,
|
|
117
|
+
},
|
|
118
|
+
}, {
|
|
119
|
+
_id: false,
|
|
120
|
+
minimize: false,
|
|
121
|
+
});
|
|
122
|
+
const RewardPointsSchema = new mongoose_1.Schema({
|
|
123
|
+
num_of_points: {
|
|
124
|
+
type: Number,
|
|
125
|
+
required: true,
|
|
126
|
+
},
|
|
127
|
+
once_per_order: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
required: true,
|
|
130
|
+
},
|
|
131
|
+
}, {
|
|
132
|
+
_id: false,
|
|
133
|
+
minimize: false,
|
|
134
|
+
});
|
|
135
|
+
const RewardCashbackSchema = new mongoose_1.Schema({
|
|
136
|
+
cashback_value: {
|
|
137
|
+
type: Number,
|
|
138
|
+
required: true,
|
|
139
|
+
},
|
|
140
|
+
is_cashback_percentage: {
|
|
141
|
+
type: Boolean,
|
|
142
|
+
required: true,
|
|
143
|
+
},
|
|
144
|
+
max_cashback_amount: {
|
|
145
|
+
type: Number,
|
|
146
|
+
required: false,
|
|
147
|
+
default: null,
|
|
148
|
+
},
|
|
149
|
+
excluded_refs: {
|
|
150
|
+
type: [String],
|
|
151
|
+
required: true,
|
|
152
|
+
default: [],
|
|
153
|
+
},
|
|
154
|
+
}, {
|
|
155
|
+
_id: false,
|
|
156
|
+
minimize: false,
|
|
157
|
+
});
|
|
158
|
+
const RewardVoucherSchema = new mongoose_1.Schema({
|
|
159
|
+
voucher_ids: {
|
|
160
|
+
type: Map,
|
|
161
|
+
of: Number,
|
|
162
|
+
required: true,
|
|
163
|
+
},
|
|
164
|
+
}, {
|
|
165
|
+
_id: false,
|
|
166
|
+
minimize: false,
|
|
167
|
+
});
|
|
6
168
|
const RewardMysteryGiftSchema = new mongoose_1.Schema({
|
|
7
169
|
choice_of_rewards: {
|
|
8
170
|
type: [String],
|
|
@@ -11,27 +173,27 @@ const RewardMysteryGiftSchema = new mongoose_1.Schema({
|
|
|
11
173
|
min: 1,
|
|
12
174
|
},
|
|
13
175
|
reward_discount: {
|
|
14
|
-
type:
|
|
176
|
+
type: RewardDiscountSchema,
|
|
15
177
|
required: false,
|
|
16
178
|
},
|
|
17
179
|
reward_discount_items: {
|
|
18
|
-
type:
|
|
180
|
+
type: RewardDiscountItemsSchema,
|
|
19
181
|
required: false,
|
|
20
182
|
},
|
|
21
183
|
reward_points: {
|
|
22
|
-
type:
|
|
184
|
+
type: RewardPointsSchema,
|
|
23
185
|
required: false,
|
|
24
186
|
},
|
|
25
187
|
reward_cashback: {
|
|
26
|
-
type:
|
|
188
|
+
type: RewardCashbackSchema,
|
|
27
189
|
required: false,
|
|
28
190
|
},
|
|
29
191
|
reward_items: {
|
|
30
|
-
type:
|
|
192
|
+
type: RewardItemsSchema,
|
|
31
193
|
required: false,
|
|
32
194
|
},
|
|
33
195
|
reward_voucher: {
|
|
34
|
-
type:
|
|
196
|
+
type: RewardVoucherSchema,
|
|
35
197
|
required: false,
|
|
36
198
|
},
|
|
37
199
|
}, {
|
|
@@ -98,32 +260,46 @@ exports.GiftCardsSchema = new mongoose_1.Schema({
|
|
|
98
260
|
required: true,
|
|
99
261
|
},
|
|
100
262
|
reward_items: {
|
|
101
|
-
type:
|
|
102
|
-
required
|
|
263
|
+
type: RewardItemsSchema,
|
|
264
|
+
required() {
|
|
265
|
+
return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.ITEMS;
|
|
266
|
+
},
|
|
103
267
|
},
|
|
104
268
|
reward_discount: {
|
|
105
|
-
type:
|
|
106
|
-
required
|
|
269
|
+
type: RewardDiscountSchema,
|
|
270
|
+
required() {
|
|
271
|
+
return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.DISCOUNT;
|
|
272
|
+
},
|
|
107
273
|
},
|
|
108
274
|
reward_discount_items: {
|
|
109
|
-
type:
|
|
110
|
-
required
|
|
275
|
+
type: RewardDiscountItemsSchema,
|
|
276
|
+
required() {
|
|
277
|
+
return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.DISCOUNT_ITEMS;
|
|
278
|
+
},
|
|
111
279
|
},
|
|
112
280
|
reward_points: {
|
|
113
|
-
type:
|
|
114
|
-
required
|
|
281
|
+
type: RewardPointsSchema,
|
|
282
|
+
required() {
|
|
283
|
+
return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.POINTS;
|
|
284
|
+
},
|
|
115
285
|
},
|
|
116
286
|
reward_cashback: {
|
|
117
|
-
type:
|
|
118
|
-
required
|
|
287
|
+
type: RewardCashbackSchema,
|
|
288
|
+
required() {
|
|
289
|
+
return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.CASHBACK;
|
|
290
|
+
},
|
|
119
291
|
},
|
|
120
292
|
reward_voucher: {
|
|
121
|
-
type:
|
|
122
|
-
required
|
|
293
|
+
type: RewardVoucherSchema,
|
|
294
|
+
required() {
|
|
295
|
+
return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.VOUCHER;
|
|
296
|
+
},
|
|
123
297
|
},
|
|
124
298
|
reward_mystery_gift: {
|
|
125
299
|
type: RewardMysteryGiftSchema,
|
|
126
|
-
required
|
|
300
|
+
required() {
|
|
301
|
+
return this.reward_type === constants_1.GIFT_CARD_REWARD_TYPE_ENUM.MYSTERY_GIFT;
|
|
302
|
+
},
|
|
127
303
|
},
|
|
128
304
|
expire_at: {
|
|
129
305
|
type: mongoose_1.Schema.Types.Date,
|
|
@@ -356,6 +356,8 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
|
|
|
356
356
|
is_discount_percentage: boolean;
|
|
357
357
|
excluded_refs: string[];
|
|
358
358
|
discount_value: number;
|
|
359
|
+
max_discount_amount?: number | null | undefined;
|
|
360
|
+
max_discount_percentage?: number | null | undefined;
|
|
359
361
|
} | null | undefined;
|
|
360
362
|
reward_discount_items?: {
|
|
361
363
|
is_discount_percentage: boolean;
|
|
@@ -743,6 +745,8 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
|
|
|
743
745
|
is_discount_percentage: boolean;
|
|
744
746
|
excluded_refs: string[];
|
|
745
747
|
discount_value: number;
|
|
748
|
+
max_discount_amount?: number | null | undefined;
|
|
749
|
+
max_discount_percentage?: number | null | undefined;
|
|
746
750
|
} | null | undefined;
|
|
747
751
|
reward_discount_items?: {
|
|
748
752
|
is_discount_percentage: boolean;
|
|
@@ -1130,6 +1134,8 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
|
|
|
1130
1134
|
is_discount_percentage: boolean;
|
|
1131
1135
|
excluded_refs: string[];
|
|
1132
1136
|
discount_value: number;
|
|
1137
|
+
max_discount_amount?: number | null | undefined;
|
|
1138
|
+
max_discount_percentage?: number | null | undefined;
|
|
1133
1139
|
} | null | undefined;
|
|
1134
1140
|
reward_discount_items?: {
|
|
1135
1141
|
is_discount_percentage: boolean;
|
|
@@ -168,6 +168,16 @@ const RewardDiscountSchema = new mongoose_1.Schema({
|
|
|
168
168
|
type: Boolean,
|
|
169
169
|
required: true,
|
|
170
170
|
},
|
|
171
|
+
max_discount_amount: {
|
|
172
|
+
type: Number,
|
|
173
|
+
required: false,
|
|
174
|
+
default: null,
|
|
175
|
+
},
|
|
176
|
+
max_discount_percentage: {
|
|
177
|
+
type: Number,
|
|
178
|
+
required: false,
|
|
179
|
+
default: null,
|
|
180
|
+
},
|
|
171
181
|
excluded_refs: {
|
|
172
182
|
type: [String],
|
|
173
183
|
required: true,
|
|
@@ -74,6 +74,8 @@ export interface IRewardTypeDiscount {
|
|
|
74
74
|
*/
|
|
75
75
|
discount_value: number;
|
|
76
76
|
is_discount_percentage: boolean;
|
|
77
|
+
max_discount_amount: number | null;
|
|
78
|
+
max_discount_percentage: number | null;
|
|
77
79
|
excluded_refs: string[];
|
|
78
80
|
}
|
|
79
81
|
export interface IRewardTypeDiscountItems {
|