@timardex/cluemart-server-shared 1.0.300 → 1.0.301
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 +15 -4
- 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 +15 -4
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +15 -4
- 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 +17 -5
- package/dist/service/index.mjs.map +1 -1
- package/package.json +1 -1
- /package/dist/{chunk-6WS5FH7A.mjs.map → chunk-LOZFYYVW.mjs.map} +0 -0
package/dist/mongoose/index.mjs
CHANGED
package/dist/service/index.cjs
CHANGED
|
@@ -9414,14 +9414,21 @@ function createAffiliateReward(rewardType, createdAt) {
|
|
|
9414
9414
|
}
|
|
9415
9415
|
|
|
9416
9416
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
9417
|
-
function
|
|
9417
|
+
function isPayingStripeSubscription(stripe) {
|
|
9418
|
+
if (!stripe?.subscriptionId) return false;
|
|
9419
|
+
return stripe.status === EnumSubscriptionStatus.ACTIVE || stripe.status === EnumSubscriptionStatus.TRIALING;
|
|
9420
|
+
}
|
|
9421
|
+
function mapVendorLicenceToSubscriptionRewardType(licences, now = /* @__PURE__ */ new Date(), stripe) {
|
|
9418
9422
|
const validTypes = new Set(
|
|
9419
9423
|
(licences ?? []).filter(
|
|
9420
9424
|
(licence) => new Date(licence.expiryDate).getTime() > now.getTime()
|
|
9421
9425
|
).map((licence) => licence.licenceType)
|
|
9422
9426
|
);
|
|
9423
9427
|
if (validTypes.has(EnumUserLicence.PRO_VENDOR) || validTypes.has(EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
9424
|
-
|
|
9428
|
+
if (isPayingStripeSubscription(stripe)) {
|
|
9429
|
+
return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
9430
|
+
}
|
|
9431
|
+
return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
9425
9432
|
}
|
|
9426
9433
|
if (validTypes.has(EnumUserLicence.STANDARD_VENDOR)) {
|
|
9427
9434
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
@@ -9463,8 +9470,12 @@ async function findEligibleReferredVendor(resourceId, affiliateCode) {
|
|
|
9463
9470
|
}).select("_id name owner.userId").lean().exec();
|
|
9464
9471
|
}
|
|
9465
9472
|
async function resolveSubscriptionRewardTypeForVendorOwner(vendorOwnerUserId, now) {
|
|
9466
|
-
const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences").lean().exec();
|
|
9467
|
-
return mapVendorLicenceToSubscriptionRewardType(
|
|
9473
|
+
const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences stripe").lean().exec();
|
|
9474
|
+
return mapVendorLicenceToSubscriptionRewardType(
|
|
9475
|
+
vendorOwner?.licences,
|
|
9476
|
+
now,
|
|
9477
|
+
vendorOwner?.stripe
|
|
9478
|
+
);
|
|
9468
9479
|
}
|
|
9469
9480
|
async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
9470
9481
|
affiliateId,
|