@timardex/cluemart-server-shared 1.0.300 → 1.0.302
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-6WS5FH7A.mjs → chunk-LOZFYYVW.mjs} +2 -1
- package/dist/index.cjs +17 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.mjs +17 -6
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +17 -6
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +7 -4
- package/dist/service/index.d.ts +7 -4
- package/dist/service/index.mjs +19 -7
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- /package/dist/{chunk-6WS5FH7A.mjs.map → chunk-LOZFYYVW.mjs.map} +0 -0
|
@@ -9170,6 +9170,7 @@ export {
|
|
|
9170
9170
|
EnumNotificationType,
|
|
9171
9171
|
EnumUserLicence,
|
|
9172
9172
|
EnumEventDateStatus,
|
|
9173
|
+
EnumSubscriptionStatus,
|
|
9173
9174
|
dateFormat,
|
|
9174
9175
|
timeFormat,
|
|
9175
9176
|
EnumAdStatus,
|
|
@@ -9215,4 +9216,4 @@ export {
|
|
|
9215
9216
|
SchoolModel,
|
|
9216
9217
|
AffiliateModel
|
|
9217
9218
|
};
|
|
9218
|
-
//# sourceMappingURL=chunk-
|
|
9219
|
+
//# sourceMappingURL=chunk-LOZFYYVW.mjs.map
|
package/dist/index.cjs
CHANGED
|
@@ -9441,8 +9441,8 @@ var AFFILIATE_REWARDS = {
|
|
|
9441
9441
|
value: 5
|
|
9442
9442
|
},
|
|
9443
9443
|
[EnumAffiliateRewardType.ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS]: {
|
|
9444
|
-
description: "
|
|
9445
|
-
value:
|
|
9444
|
+
description: "40 points for active event with vendor registrations (one-time reward)",
|
|
9445
|
+
value: 40
|
|
9446
9446
|
}
|
|
9447
9447
|
};
|
|
9448
9448
|
function createAffiliateReward(rewardType, createdAt) {
|
|
@@ -9457,14 +9457,21 @@ function createAffiliateReward(rewardType, createdAt) {
|
|
|
9457
9457
|
}
|
|
9458
9458
|
|
|
9459
9459
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
9460
|
-
function
|
|
9460
|
+
function isPayingStripeSubscription(stripe) {
|
|
9461
|
+
if (!stripe?.subscriptionId) return false;
|
|
9462
|
+
return stripe.status === EnumSubscriptionStatus.ACTIVE || stripe.status === EnumSubscriptionStatus.TRIALING;
|
|
9463
|
+
}
|
|
9464
|
+
function mapVendorLicenceToSubscriptionRewardType(licences, now = /* @__PURE__ */ new Date(), stripe) {
|
|
9461
9465
|
const validTypes = new Set(
|
|
9462
9466
|
(licences ?? []).filter(
|
|
9463
9467
|
(licence) => new Date(licence.expiryDate).getTime() > now.getTime()
|
|
9464
9468
|
).map((licence) => licence.licenceType)
|
|
9465
9469
|
);
|
|
9466
9470
|
if (validTypes.has(EnumUserLicence.PRO_VENDOR) || validTypes.has(EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
9467
|
-
|
|
9471
|
+
if (isPayingStripeSubscription(stripe)) {
|
|
9472
|
+
return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
9473
|
+
}
|
|
9474
|
+
return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
9468
9475
|
}
|
|
9469
9476
|
if (validTypes.has(EnumUserLicence.STANDARD_VENDOR)) {
|
|
9470
9477
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
@@ -9506,8 +9513,12 @@ async function findEligibleReferredVendor(resourceId, affiliateCode) {
|
|
|
9506
9513
|
}).select("_id name owner.userId").lean().exec();
|
|
9507
9514
|
}
|
|
9508
9515
|
async function resolveSubscriptionRewardTypeForVendorOwner(vendorOwnerUserId, now) {
|
|
9509
|
-
const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences").lean().exec();
|
|
9510
|
-
return mapVendorLicenceToSubscriptionRewardType(
|
|
9516
|
+
const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences stripe").lean().exec();
|
|
9517
|
+
return mapVendorLicenceToSubscriptionRewardType(
|
|
9518
|
+
vendorOwner?.licences,
|
|
9519
|
+
now,
|
|
9520
|
+
vendorOwner?.stripe
|
|
9521
|
+
);
|
|
9511
9522
|
}
|
|
9512
9523
|
async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
9513
9524
|
affiliateId,
|