@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.
@@ -39,7 +39,7 @@ import {
39
39
  socialShareResourceSchema,
40
40
  termsAgreementSchema,
41
41
  userLicenseSchema
42
- } from "../chunk-6WS5FH7A.mjs";
42
+ } from "../chunk-LOZFYYVW.mjs";
43
43
  export {
44
44
  APP_SETTINGS_ID,
45
45
  AdModel,
@@ -9414,14 +9414,21 @@ function createAffiliateReward(rewardType, createdAt) {
9414
9414
  }
9415
9415
 
9416
9416
  // src/service/affiliate/vendorSubscriptionRewards.ts
9417
- function mapVendorLicenceToSubscriptionRewardType(licences, now = /* @__PURE__ */ new Date()) {
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
- return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
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(vendorOwner?.licences, now);
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,