@managesome/eposmatic-toolkit 0.2.289 → 0.2.291
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.
|
@@ -2,16 +2,17 @@ import { OFFER_REWARD_TYPE_ENUM, PLATFORMS_ENUM } from '../../constants';
|
|
|
2
2
|
import { ICustomer, IDiscountDetails, IGiftCard, IOffer, IOrder, IOrderCategory, ITenant, IVoucher } from '../../schemas';
|
|
3
3
|
export declare function getOfferWithPrice<T extends Partial<IOffer> | IOffer>(offer: T, writeable?: boolean): T;
|
|
4
4
|
export declare function convertOffersToWorkableOffers(offers: IOffer[], platform: PLATFORMS_ENUM): IOffer[];
|
|
5
|
-
export declare function calculatePointsRedeemedForOffer(redeemedOffer: IOffer, totalOrderPrice: number, categories: IOrderCategory[] | undefined): number;
|
|
5
|
+
export declare function calculatePointsRedeemedForOffer(redeemedOffer: IOffer, totalOrderPrice: number, categories: IOrderCategory[] | undefined, claimedTimes?: number): number;
|
|
6
6
|
interface ICalculateCustomerLoyaltyPoints {
|
|
7
7
|
customerLoyaltyPoints: number | undefined;
|
|
8
8
|
orderDiscountDetails: IDiscountDetails | null | undefined;
|
|
9
|
+
redeemedOffers?: IOrder['redeemed_offers'] | null | undefined;
|
|
9
10
|
currentItemsPrice: number | undefined;
|
|
10
11
|
totalDiscountApplied: number | undefined;
|
|
11
12
|
categories: IOrderCategory[] | undefined;
|
|
12
13
|
offers: IOffer[];
|
|
13
14
|
}
|
|
14
|
-
export declare function calculateCustomerLoyaltyPoints({ customerLoyaltyPoints, orderDiscountDetails, currentItemsPrice, totalDiscountApplied, categories, offers, }: ICalculateCustomerLoyaltyPoints): {
|
|
15
|
+
export declare function calculateCustomerLoyaltyPoints({ customerLoyaltyPoints, orderDiscountDetails, redeemedOffers, currentItemsPrice, totalDiscountApplied, categories, offers, }: ICalculateCustomerLoyaltyPoints): {
|
|
15
16
|
loyaltyPoints: number;
|
|
16
17
|
addedLoyaltyPoints: number;
|
|
17
18
|
deductedLoyaltyPoints: number;
|
|
@@ -215,12 +215,16 @@ function convertOffersToWorkableOffers(offers, platform) {
|
|
|
215
215
|
return filteredOffers;
|
|
216
216
|
}
|
|
217
217
|
// ====================================================================================================================
|
|
218
|
-
function calculatePointsRedeemedForOffer(redeemedOffer, totalOrderPrice, categories) {
|
|
218
|
+
function calculatePointsRedeemedForOffer(redeemedOffer, totalOrderPrice, categories, claimedTimes) {
|
|
219
219
|
if (redeemedOffer.reward_type !== constants_1.OFFER_REWARD_TYPE_ENUM.POINTS || redeemedOffer.reward_points == null) {
|
|
220
220
|
return 0;
|
|
221
221
|
}
|
|
222
222
|
let times = 1;
|
|
223
223
|
if (!redeemedOffer.reward_points.once_per_order) {
|
|
224
|
+
const getUnlockTimesByOrderAmount = (orderValue, totalAmount) => {
|
|
225
|
+
const safeRequiredAmount = Math.max(1, totalAmount || 1);
|
|
226
|
+
return Math.max(1, Math.floor(orderValue / safeRequiredAmount));
|
|
227
|
+
};
|
|
224
228
|
// This means that we need to see if the condition to unlock the redeemedOffer is met multiple times
|
|
225
229
|
// i.e. if the customer has ordered 2 pizzas, and the redeemedOffer is applicable for 1 pizza
|
|
226
230
|
// then we need to calculate the points redeemed for 2 pizzas
|
|
@@ -254,23 +258,36 @@ function calculatePointsRedeemedForOffer(redeemedOffer, totalOrderPrice, categor
|
|
|
254
258
|
}
|
|
255
259
|
else if (redeemedOffer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ORDERS) {
|
|
256
260
|
if (redeemedOffer.pathway_to_unlock_type_orders != null) {
|
|
257
|
-
const { total_amount } = redeemedOffer.pathway_to_unlock_type_orders;
|
|
258
|
-
if (totalOrderPrice >= total_amount) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
+
const { total_amount, max_amount, max_claims } = redeemedOffer.pathway_to_unlock_type_orders;
|
|
262
|
+
if (totalOrderPrice >= total_amount && (max_amount == null || totalOrderPrice <= max_amount)) {
|
|
263
|
+
const timesForAmount = getUnlockTimesByOrderAmount(totalOrderPrice, total_amount);
|
|
264
|
+
const maxClaims = max_claims == null ? Infinity : Math.max(1, max_claims);
|
|
265
|
+
times = Math.min(timesForAmount, maxClaims);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else if (redeemedOffer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.VOUCHER) {
|
|
270
|
+
if (redeemedOffer.pathway_to_unlock_type_vouchers != null) {
|
|
271
|
+
const { total_amount, max_amount, max_claims } = redeemedOffer.pathway_to_unlock_type_vouchers;
|
|
272
|
+
if (totalOrderPrice >= total_amount && (max_amount == null || totalOrderPrice <= max_amount)) {
|
|
273
|
+
const timesForAmount = getUnlockTimesByOrderAmount(totalOrderPrice, total_amount);
|
|
274
|
+
const maxClaims = max_claims == null ? Infinity : Math.max(1, max_claims);
|
|
275
|
+
times = Math.min(timesForAmount, maxClaims);
|
|
261
276
|
}
|
|
262
277
|
}
|
|
263
278
|
}
|
|
264
279
|
// 💡 NOTE: We don't need to check for pathway_to_unlock_type_points because it is not possible to have
|
|
265
280
|
// pathway_to_unlock_type_points and reward_points at the same time
|
|
266
|
-
|
|
281
|
+
}
|
|
282
|
+
if (claimedTimes != null && Number.isFinite(claimedTimes) && claimedTimes > 0) {
|
|
283
|
+
times = Math.min(times, Math.floor(claimedTimes));
|
|
267
284
|
}
|
|
268
285
|
let pointsRedeemed = redeemedOffer.reward_points.num_of_points ?? 0;
|
|
269
286
|
pointsRedeemed *= times;
|
|
270
287
|
return pointsRedeemed;
|
|
271
288
|
}
|
|
272
289
|
// The purpose of this function is to calculate the total number of points that are applied/consumed by the cart items
|
|
273
|
-
function calculateCustomerLoyaltyPoints({ customerLoyaltyPoints, orderDiscountDetails, currentItemsPrice, totalDiscountApplied, categories, offers, }) {
|
|
290
|
+
function calculateCustomerLoyaltyPoints({ customerLoyaltyPoints, orderDiscountDetails, redeemedOffers, currentItemsPrice, totalDiscountApplied, categories, offers, }) {
|
|
274
291
|
const totalOrderPrice = (currentItemsPrice ?? 0) - (totalDiscountApplied ?? 0);
|
|
275
292
|
let loyaltyPoints = customerLoyaltyPoints ?? 0;
|
|
276
293
|
let addedLoyaltyPoints = loyaltyPoints;
|
|
@@ -287,13 +304,15 @@ function calculateCustomerLoyaltyPoints({ customerLoyaltyPoints, orderDiscountDe
|
|
|
287
304
|
offerConsumedQuantity[redeemedOffer._id] = 0;
|
|
288
305
|
}
|
|
289
306
|
if (!offerConsumedQuantity[redeemedOffer._id]) {
|
|
307
|
+
const rawClaimedTimes = Number(redeemedOffers?.[redeemedOffer._id]);
|
|
308
|
+
const claimedTimes = Number.isFinite(rawClaimedTimes) && rawClaimedTimes > 0 ? Math.floor(rawClaimedTimes) : 1;
|
|
290
309
|
if (redeemedOffer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.POINTS) {
|
|
291
|
-
const points = calculatePointsRedeemedForOffer(redeemedOffer, totalOrderPrice, categories);
|
|
310
|
+
const points = calculatePointsRedeemedForOffer(redeemedOffer, totalOrderPrice, categories, claimedTimes);
|
|
292
311
|
loyaltyPoints += points;
|
|
293
312
|
addedLoyaltyPoints += points;
|
|
294
313
|
}
|
|
295
314
|
else if (redeemedOffer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.POINTS) {
|
|
296
|
-
const points = redeemedOffer.pathway_to_unlock_type_points?.num_of_points ?? 0;
|
|
315
|
+
const points = (redeemedOffer.pathway_to_unlock_type_points?.num_of_points ?? 0) * claimedTimes;
|
|
297
316
|
loyaltyPoints -= points;
|
|
298
317
|
deductedLoyaltyPoints += points;
|
|
299
318
|
}
|
|
@@ -790,6 +809,49 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
790
809
|
totalAmount: currentOrderValue,
|
|
791
810
|
};
|
|
792
811
|
};
|
|
812
|
+
const getOfferMaxUsesPerCustomer = (offerToCheck) => {
|
|
813
|
+
if (offerToCheck.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ORDERS) {
|
|
814
|
+
return offerToCheck.pathway_to_unlock_type_orders?.max_uses_per_customer ?? null;
|
|
815
|
+
}
|
|
816
|
+
if (offerToCheck.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ITEMS) {
|
|
817
|
+
return offerToCheck.pathway_to_unlock_type_items?.max_uses_per_customer ?? null;
|
|
818
|
+
}
|
|
819
|
+
if (offerToCheck.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.POINTS) {
|
|
820
|
+
return offerToCheck.pathway_to_unlock_type_points?.max_uses_per_customer ?? null;
|
|
821
|
+
}
|
|
822
|
+
if (offerToCheck.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.VOUCHER) {
|
|
823
|
+
return offerToCheck.pathway_to_unlock_type_vouchers?.max_uses_per_customer ?? null;
|
|
824
|
+
}
|
|
825
|
+
return null;
|
|
826
|
+
};
|
|
827
|
+
const isOfferUsesPerCustomerExhausted = (offerToCheck) => {
|
|
828
|
+
const maxUsesPerCustomer = getOfferMaxUsesPerCustomer(offerToCheck);
|
|
829
|
+
return maxUsesPerCustomer != null && (customerOfferRedemptionCounts?.[offerToCheck._id] ?? 0) >= maxUsesPerCustomer;
|
|
830
|
+
};
|
|
831
|
+
const getRemainingOfferUsesForCustomer = (offerToCheck) => {
|
|
832
|
+
const maxUsesPerCustomer = getOfferMaxUsesPerCustomer(offerToCheck);
|
|
833
|
+
if (maxUsesPerCustomer == null)
|
|
834
|
+
return Infinity;
|
|
835
|
+
const redeemedByCustomer = customerOfferRedemptionCounts?.[offerToCheck._id] ?? 0;
|
|
836
|
+
return Math.max(0, maxUsesPerCustomer - redeemedByCustomer);
|
|
837
|
+
};
|
|
838
|
+
const getOrderValueClaimTimes = (orderValue, minAmount) => {
|
|
839
|
+
const safeRequiredAmount = Math.max(1, minAmount || 1);
|
|
840
|
+
return Math.max(1, Math.floor(orderValue / safeRequiredAmount));
|
|
841
|
+
};
|
|
842
|
+
const getPointsMaxRedeemableClaims = ({ offerToCheck, pathwayUnlockableClaims, }) => {
|
|
843
|
+
if (offerToCheck.reward_type !== constants_1.OFFER_REWARD_TYPE_ENUM.POINTS || offerToCheck.reward_points == null) {
|
|
844
|
+
return 1;
|
|
845
|
+
}
|
|
846
|
+
if (offerToCheck.reward_points.once_per_order) {
|
|
847
|
+
return 1;
|
|
848
|
+
}
|
|
849
|
+
const normalizedUnlockableClaims = Math.max(0, pathwayUnlockableClaims);
|
|
850
|
+
if (normalizedUnlockableClaims === 0) {
|
|
851
|
+
return 0;
|
|
852
|
+
}
|
|
853
|
+
return Math.min(normalizedUnlockableClaims, getRemainingOfferUsesForCustomer(offerToCheck));
|
|
854
|
+
};
|
|
793
855
|
for (let i = 0; i < offers.length; i++) {
|
|
794
856
|
const offer = offers[i];
|
|
795
857
|
const stats = {
|
|
@@ -927,15 +989,23 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
927
989
|
if (offer.reward_points == null)
|
|
928
990
|
continue;
|
|
929
991
|
const redeemedTimes = getOfferRedeemedTimes(offer._id);
|
|
930
|
-
const
|
|
992
|
+
const maxClaimsPerOrder = offer.pathway_to_unlock_type_orders?.max_claims == null
|
|
993
|
+
? Infinity
|
|
994
|
+
: Math.max(1, offer.pathway_to_unlock_type_orders.max_claims);
|
|
995
|
+
const unlockTimesForAmount = getOrderValueClaimTimes(orderValue, offer.pathway_to_unlock_type_orders?.total_amount);
|
|
996
|
+
const totalUnlockableClaims = Math.min(unlockTimesForAmount, maxClaimsPerOrder);
|
|
997
|
+
const maxRedeemableClaims = getPointsMaxRedeemableClaims({
|
|
998
|
+
offerToCheck: offer,
|
|
999
|
+
pathwayUnlockableClaims: totalUnlockableClaims,
|
|
1000
|
+
});
|
|
1001
|
+
const isClaimable = redeemedTimes < maxRedeemableClaims;
|
|
931
1002
|
stats.redeemed_times = redeemedTimes;
|
|
932
|
-
stats.applicable_quantity =
|
|
933
|
-
|
|
934
|
-
|
|
1003
|
+
stats.applicable_quantity = maxRedeemableClaims;
|
|
1004
|
+
stats.claimable = isClaimable;
|
|
1005
|
+
if (!isClaimable) {
|
|
935
1006
|
stats.message = 'This offer is redeemed ✅';
|
|
936
1007
|
}
|
|
937
1008
|
else {
|
|
938
|
-
stats.claimable = true;
|
|
939
1009
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
940
1010
|
totalClaimableOffers += 1;
|
|
941
1011
|
}
|
|
@@ -1061,6 +1131,13 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1061
1131
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
1062
1132
|
}
|
|
1063
1133
|
}
|
|
1134
|
+
if (stats.progress >= 100 && isOfferUsesPerCustomerExhausted(offer)) {
|
|
1135
|
+
if (stats.claimable) {
|
|
1136
|
+
totalClaimableOffers = Math.max(0, totalClaimableOffers - 1);
|
|
1137
|
+
}
|
|
1138
|
+
stats.claimable = false;
|
|
1139
|
+
stats.message = '⛔️ You have reached your personal limit for this offer ⛔️';
|
|
1140
|
+
}
|
|
1064
1141
|
stats.action_hint = getActionHint(offer, stats.claimable);
|
|
1065
1142
|
offersWithStats.push({
|
|
1066
1143
|
offer,
|
|
@@ -1173,11 +1250,15 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1173
1250
|
if (offer.reward_points == null)
|
|
1174
1251
|
continue;
|
|
1175
1252
|
const redeemedTimes = getOfferRedeemedTimes(offer._id);
|
|
1176
|
-
const
|
|
1253
|
+
const maxRedeemableClaims = getPointsMaxRedeemableClaims({
|
|
1254
|
+
offerToCheck: offer,
|
|
1255
|
+
pathwayUnlockableClaims: totalUnlockableClaims,
|
|
1256
|
+
});
|
|
1257
|
+
const isClaimable = redeemedTimes < maxRedeemableClaims;
|
|
1177
1258
|
stats.redeemed_times = redeemedTimes;
|
|
1178
|
-
stats.applicable_quantity =
|
|
1179
|
-
stats.claimable =
|
|
1180
|
-
if (
|
|
1259
|
+
stats.applicable_quantity = maxRedeemableClaims;
|
|
1260
|
+
stats.claimable = isClaimable;
|
|
1261
|
+
if (!isClaimable) {
|
|
1181
1262
|
stats.message = 'This offer is redeemed ✅';
|
|
1182
1263
|
}
|
|
1183
1264
|
else {
|
|
@@ -1299,6 +1380,13 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1299
1380
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
1300
1381
|
}
|
|
1301
1382
|
}
|
|
1383
|
+
if (stats.progress >= 100 && isOfferUsesPerCustomerExhausted(offer)) {
|
|
1384
|
+
if (stats.claimable) {
|
|
1385
|
+
totalClaimableOffers = Math.max(0, totalClaimableOffers - 1);
|
|
1386
|
+
}
|
|
1387
|
+
stats.claimable = false;
|
|
1388
|
+
stats.message = '⛔️ You have reached your personal limit for this offer ⛔️';
|
|
1389
|
+
}
|
|
1302
1390
|
stats.action_hint = getActionHint(offer, stats.claimable);
|
|
1303
1391
|
offersWithStats.push({
|
|
1304
1392
|
offer,
|
|
@@ -1319,6 +1407,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1319
1407
|
const { addedLoyaltyPoints, loyaltyPoints } = calculateCustomerLoyaltyPoints({
|
|
1320
1408
|
customerLoyaltyPoints: customer?.loyalty_points,
|
|
1321
1409
|
orderDiscountDetails: order_discount_details,
|
|
1410
|
+
redeemedOffers: redeemed_offers,
|
|
1322
1411
|
currentItemsPrice,
|
|
1323
1412
|
categories,
|
|
1324
1413
|
totalDiscountApplied,
|
|
@@ -1413,11 +1502,15 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1413
1502
|
if (offer.reward_points == null)
|
|
1414
1503
|
continue;
|
|
1415
1504
|
const redeemedTimes = getOfferRedeemedTimes(offer._id);
|
|
1416
|
-
const
|
|
1505
|
+
const maxRedeemableClaims = getPointsMaxRedeemableClaims({
|
|
1506
|
+
offerToCheck: offer,
|
|
1507
|
+
pathwayUnlockableClaims: totalUnlockableClaims,
|
|
1508
|
+
});
|
|
1509
|
+
const isClaimable = redeemedTimes < maxRedeemableClaims;
|
|
1417
1510
|
stats.redeemed_times = redeemedTimes;
|
|
1418
|
-
stats.applicable_quantity =
|
|
1419
|
-
stats.claimable =
|
|
1420
|
-
if (
|
|
1511
|
+
stats.applicable_quantity = maxRedeemableClaims;
|
|
1512
|
+
stats.claimable = isClaimable;
|
|
1513
|
+
if (!isClaimable) {
|
|
1421
1514
|
stats.message = 'This offer is redeemed ✅';
|
|
1422
1515
|
}
|
|
1423
1516
|
else {
|
|
@@ -1540,6 +1633,13 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1540
1633
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
1541
1634
|
}
|
|
1542
1635
|
}
|
|
1636
|
+
if (stats.progress >= 100 && isOfferUsesPerCustomerExhausted(offer)) {
|
|
1637
|
+
if (stats.claimable) {
|
|
1638
|
+
totalClaimableOffers = Math.max(0, totalClaimableOffers - 1);
|
|
1639
|
+
}
|
|
1640
|
+
stats.claimable = false;
|
|
1641
|
+
stats.message = '⛔️ You have reached your personal limit for this offer ⛔️';
|
|
1642
|
+
}
|
|
1543
1643
|
stats.action_hint = getActionHint(offer, stats.claimable);
|
|
1544
1644
|
offersWithStats.push({
|
|
1545
1645
|
offer,
|
|
@@ -1558,7 +1658,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1558
1658
|
continue;
|
|
1559
1659
|
}
|
|
1560
1660
|
const orderValue = orderPrice - totalDiscount;
|
|
1561
|
-
const { total_amount, max_amount, voucher_ids } = offer.pathway_to_unlock_type_vouchers;
|
|
1661
|
+
const { total_amount, max_amount, max_claims, voucher_ids } = offer.pathway_to_unlock_type_vouchers;
|
|
1562
1662
|
const voucherReferenceNumber = order_discount_details?.voucher_reference_number;
|
|
1563
1663
|
const normalizedVoucherRef = voucherReferenceNumber?.trim().toUpperCase();
|
|
1564
1664
|
const referencedVouchers = voucher_ids
|
|
@@ -1656,11 +1756,18 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1656
1756
|
if (offer.reward_points == null)
|
|
1657
1757
|
continue;
|
|
1658
1758
|
const redeemedTimes = getOfferRedeemedTimes(offer._id);
|
|
1659
|
-
const
|
|
1759
|
+
const maxClaimsPerOrder = max_claims == null ? Infinity : Math.max(1, max_claims);
|
|
1760
|
+
const unlockTimesForAmount = getOrderValueClaimTimes(orderValue, total_amount);
|
|
1761
|
+
const totalUnlockableClaims = Math.min(unlockTimesForAmount, maxClaimsPerOrder);
|
|
1762
|
+
const maxRedeemableClaims = getPointsMaxRedeemableClaims({
|
|
1763
|
+
offerToCheck: offer,
|
|
1764
|
+
pathwayUnlockableClaims: totalUnlockableClaims,
|
|
1765
|
+
});
|
|
1766
|
+
const isClaimable = redeemedTimes < maxRedeemableClaims;
|
|
1660
1767
|
stats.redeemed_times = redeemedTimes;
|
|
1661
|
-
stats.applicable_quantity =
|
|
1662
|
-
stats.claimable =
|
|
1663
|
-
if (
|
|
1768
|
+
stats.applicable_quantity = maxRedeemableClaims;
|
|
1769
|
+
stats.claimable = isClaimable;
|
|
1770
|
+
if (!isClaimable) {
|
|
1664
1771
|
stats.message = 'This offer is redeemed ✅';
|
|
1665
1772
|
}
|
|
1666
1773
|
else {
|
|
@@ -1783,6 +1890,13 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1783
1890
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
1784
1891
|
}
|
|
1785
1892
|
}
|
|
1893
|
+
if (stats.progress >= 100 && isOfferUsesPerCustomerExhausted(offer)) {
|
|
1894
|
+
if (stats.claimable) {
|
|
1895
|
+
totalClaimableOffers = Math.max(0, totalClaimableOffers - 1);
|
|
1896
|
+
}
|
|
1897
|
+
stats.claimable = false;
|
|
1898
|
+
stats.message = '⛔️ You have reached your personal limit for this offer ⛔️';
|
|
1899
|
+
}
|
|
1786
1900
|
stats.action_hint = getActionHint(offer, stats.claimable);
|
|
1787
1901
|
offersWithStats.push({
|
|
1788
1902
|
offer,
|
|
@@ -368,6 +368,7 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
|
|
|
368
368
|
exclusive_refs: string[];
|
|
369
369
|
total_amount: number;
|
|
370
370
|
item_ids?: import("mongoose").Types.ObjectId[] | null | undefined;
|
|
371
|
+
max_uses_per_customer?: number | null | undefined;
|
|
371
372
|
max_claims?: number | null | undefined;
|
|
372
373
|
min_same_item_quantity?: number | null | undefined;
|
|
373
374
|
max_same_item_quantity?: number | null | undefined;
|
|
@@ -375,20 +376,25 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
|
|
|
375
376
|
} | null | undefined;
|
|
376
377
|
pathway_to_unlock_type_orders?: {
|
|
377
378
|
total_amount: number;
|
|
379
|
+
scope: PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPE_ENUM;
|
|
378
380
|
min_num_of_orders: number;
|
|
379
381
|
max_amount?: number | null | undefined;
|
|
380
|
-
|
|
382
|
+
max_uses_per_customer?: number | null | undefined;
|
|
383
|
+
max_claims?: number | null | undefined;
|
|
381
384
|
max_num_of_orders?: number | null | undefined;
|
|
382
385
|
} | null | undefined;
|
|
383
386
|
pathway_to_unlock_type_points?: {
|
|
384
387
|
num_of_points: number;
|
|
385
388
|
total_amount: number;
|
|
389
|
+
max_uses_per_customer?: number | null | undefined;
|
|
386
390
|
max_claims?: number | null | undefined;
|
|
387
391
|
} | null | undefined;
|
|
388
392
|
pathway_to_unlock_type_vouchers?: {
|
|
389
393
|
voucher_ids: import("mongoose").Types.ObjectId[];
|
|
390
394
|
total_amount: number;
|
|
391
395
|
max_amount?: number | null | undefined;
|
|
396
|
+
max_uses_per_customer?: number | null | undefined;
|
|
397
|
+
max_claims?: number | null | undefined;
|
|
392
398
|
} | null | undefined;
|
|
393
399
|
reward_gift_cards?: {
|
|
394
400
|
gift_card_ids: Map<string, number>;
|
|
@@ -757,6 +763,7 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
|
|
|
757
763
|
exclusive_refs: string[];
|
|
758
764
|
total_amount: number;
|
|
759
765
|
item_ids?: import("mongoose").Types.ObjectId[] | null | undefined;
|
|
766
|
+
max_uses_per_customer?: number | null | undefined;
|
|
760
767
|
max_claims?: number | null | undefined;
|
|
761
768
|
min_same_item_quantity?: number | null | undefined;
|
|
762
769
|
max_same_item_quantity?: number | null | undefined;
|
|
@@ -764,20 +771,25 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
|
|
|
764
771
|
} | null | undefined;
|
|
765
772
|
pathway_to_unlock_type_orders?: {
|
|
766
773
|
total_amount: number;
|
|
774
|
+
scope: PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPE_ENUM;
|
|
767
775
|
min_num_of_orders: number;
|
|
768
776
|
max_amount?: number | null | undefined;
|
|
769
|
-
|
|
777
|
+
max_uses_per_customer?: number | null | undefined;
|
|
778
|
+
max_claims?: number | null | undefined;
|
|
770
779
|
max_num_of_orders?: number | null | undefined;
|
|
771
780
|
} | null | undefined;
|
|
772
781
|
pathway_to_unlock_type_points?: {
|
|
773
782
|
num_of_points: number;
|
|
774
783
|
total_amount: number;
|
|
784
|
+
max_uses_per_customer?: number | null | undefined;
|
|
775
785
|
max_claims?: number | null | undefined;
|
|
776
786
|
} | null | undefined;
|
|
777
787
|
pathway_to_unlock_type_vouchers?: {
|
|
778
788
|
voucher_ids: import("mongoose").Types.ObjectId[];
|
|
779
789
|
total_amount: number;
|
|
780
790
|
max_amount?: number | null | undefined;
|
|
791
|
+
max_uses_per_customer?: number | null | undefined;
|
|
792
|
+
max_claims?: number | null | undefined;
|
|
781
793
|
} | null | undefined;
|
|
782
794
|
reward_gift_cards?: {
|
|
783
795
|
gift_card_ids: Map<string, number>;
|
|
@@ -1146,6 +1158,7 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
|
|
|
1146
1158
|
exclusive_refs: string[];
|
|
1147
1159
|
total_amount: number;
|
|
1148
1160
|
item_ids?: import("mongoose").Types.ObjectId[] | null | undefined;
|
|
1161
|
+
max_uses_per_customer?: number | null | undefined;
|
|
1149
1162
|
max_claims?: number | null | undefined;
|
|
1150
1163
|
min_same_item_quantity?: number | null | undefined;
|
|
1151
1164
|
max_same_item_quantity?: number | null | undefined;
|
|
@@ -1153,20 +1166,25 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
|
|
|
1153
1166
|
} | null | undefined;
|
|
1154
1167
|
pathway_to_unlock_type_orders?: {
|
|
1155
1168
|
total_amount: number;
|
|
1169
|
+
scope: PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPE_ENUM;
|
|
1156
1170
|
min_num_of_orders: number;
|
|
1157
1171
|
max_amount?: number | null | undefined;
|
|
1158
|
-
|
|
1172
|
+
max_uses_per_customer?: number | null | undefined;
|
|
1173
|
+
max_claims?: number | null | undefined;
|
|
1159
1174
|
max_num_of_orders?: number | null | undefined;
|
|
1160
1175
|
} | null | undefined;
|
|
1161
1176
|
pathway_to_unlock_type_points?: {
|
|
1162
1177
|
num_of_points: number;
|
|
1163
1178
|
total_amount: number;
|
|
1179
|
+
max_uses_per_customer?: number | null | undefined;
|
|
1164
1180
|
max_claims?: number | null | undefined;
|
|
1165
1181
|
} | null | undefined;
|
|
1166
1182
|
pathway_to_unlock_type_vouchers?: {
|
|
1167
1183
|
voucher_ids: import("mongoose").Types.ObjectId[];
|
|
1168
1184
|
total_amount: number;
|
|
1169
1185
|
max_amount?: number | null | undefined;
|
|
1186
|
+
max_uses_per_customer?: number | null | undefined;
|
|
1187
|
+
max_claims?: number | null | undefined;
|
|
1170
1188
|
} | null | undefined;
|
|
1171
1189
|
reward_gift_cards?: {
|
|
1172
1190
|
gift_card_ids: Map<string, number>;
|
|
@@ -9,6 +9,11 @@ const PathwayToUnlockTypeItemsSchema = new mongoose_1.Schema({
|
|
|
9
9
|
type: Number,
|
|
10
10
|
required: true,
|
|
11
11
|
},
|
|
12
|
+
max_uses_per_customer: {
|
|
13
|
+
type: Number,
|
|
14
|
+
required: false,
|
|
15
|
+
default: null,
|
|
16
|
+
},
|
|
12
17
|
max_claims: {
|
|
13
18
|
type: Number,
|
|
14
19
|
required: false,
|
|
@@ -56,9 +61,18 @@ const PathwayToUnlockTypeOrdersSchema = new mongoose_1.Schema({
|
|
|
56
61
|
scope: {
|
|
57
62
|
type: String,
|
|
58
63
|
enum: constants_1.ALL_PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPES,
|
|
59
|
-
required: false,
|
|
60
64
|
default: constants_1.PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPE_ENUM.OVERALL,
|
|
61
65
|
},
|
|
66
|
+
max_uses_per_customer: {
|
|
67
|
+
type: Number,
|
|
68
|
+
required: false,
|
|
69
|
+
default: null,
|
|
70
|
+
},
|
|
71
|
+
max_claims: {
|
|
72
|
+
type: Number,
|
|
73
|
+
required: false,
|
|
74
|
+
default: null,
|
|
75
|
+
},
|
|
62
76
|
min_num_of_orders: {
|
|
63
77
|
type: Number,
|
|
64
78
|
required: true,
|
|
@@ -90,6 +104,11 @@ const PathwayToUnlockTypePointsSchema = new mongoose_1.Schema({
|
|
|
90
104
|
type: Number,
|
|
91
105
|
required: true,
|
|
92
106
|
},
|
|
107
|
+
max_uses_per_customer: {
|
|
108
|
+
type: Number,
|
|
109
|
+
required: false,
|
|
110
|
+
default: null,
|
|
111
|
+
},
|
|
93
112
|
max_claims: {
|
|
94
113
|
type: Number,
|
|
95
114
|
required: false,
|
|
@@ -109,6 +128,16 @@ const PathwayToUnlockTypeVouchersSchema = new mongoose_1.Schema({
|
|
|
109
128
|
required: false,
|
|
110
129
|
default: null,
|
|
111
130
|
},
|
|
131
|
+
max_uses_per_customer: {
|
|
132
|
+
type: Number,
|
|
133
|
+
required: false,
|
|
134
|
+
default: null,
|
|
135
|
+
},
|
|
136
|
+
max_claims: {
|
|
137
|
+
type: Number,
|
|
138
|
+
required: false,
|
|
139
|
+
default: null,
|
|
140
|
+
},
|
|
112
141
|
voucher_ids: {
|
|
113
142
|
type: [mongoose_1.Schema.Types.ObjectId],
|
|
114
143
|
required: true,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { MYSTERY_GIFT_TYPE_ENUM, OFFER_REWARD_TYPE_ENUM, PATHWAY_TO_UNLOCK_TYPE_ENUM, PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPE_ENUM, PLATFORMS_ENUM } from '../../constants';
|
|
2
2
|
import { IItemSpecialHour } from './common';
|
|
3
3
|
export interface IPathwayToUnlockTypeOrders {
|
|
4
|
-
scope
|
|
4
|
+
scope: PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPE_ENUM;
|
|
5
|
+
max_uses_per_customer: number | null;
|
|
6
|
+
max_claims: number | null;
|
|
5
7
|
min_num_of_orders: number;
|
|
6
8
|
max_num_of_orders: number | null;
|
|
7
9
|
total_amount: number;
|
|
@@ -9,6 +11,7 @@ export interface IPathwayToUnlockTypeOrders {
|
|
|
9
11
|
}
|
|
10
12
|
export interface IPathwayToUnlockTypeItems {
|
|
11
13
|
num_of_items: number;
|
|
14
|
+
max_uses_per_customer: number | null;
|
|
12
15
|
max_claims: number | null;
|
|
13
16
|
min_same_item_quantity: number | null;
|
|
14
17
|
max_same_item_quantity: number | null;
|
|
@@ -21,11 +24,14 @@ export interface IPathwayToUnlockTypeItems {
|
|
|
21
24
|
export interface IPathwayToUnlockTypePoints {
|
|
22
25
|
num_of_points: number;
|
|
23
26
|
total_amount: number;
|
|
27
|
+
max_uses_per_customer: number | null;
|
|
24
28
|
max_claims: number | null;
|
|
25
29
|
}
|
|
26
30
|
export interface IPathwayToUnlockTypeVouchers {
|
|
27
31
|
total_amount: number;
|
|
28
32
|
max_amount: number | null;
|
|
33
|
+
max_uses_per_customer: number | null;
|
|
34
|
+
max_claims: number | null;
|
|
29
35
|
voucher_ids: string[];
|
|
30
36
|
}
|
|
31
37
|
type IOfferPathwayItems = {
|