Feature #10854
openLoyalty & Rewards Management — Omnichannel Tiers, Referral Consolidation & Schema Cleanup
Subtasks
Related issues
Updated by Ajit A 3 days ago
- Due date set to 09/15/2026
- Status changed from In Progress to Resolved
- % Done changed from 0 to 100
1. Backend Services & Engine (evergreen_pos_be)
VIP Tier Upgrade Notification System:
HTML Email Template (
loyaltyTierUpgrade.ejs
): Designed a luxury responsive email template with dynamic theme badges, tier perk highlights, and direct storefront CTA buttons.
Non-blocking Dispatch (
loyaltyEngine.js
): Added asynchronous email triggering via sendTierUpgradeNotification when customer tier increases.
Dual-Scope Tier Progression Engine (ALL_CHANNELS_COMBINED vs CHANNEL_SPECIFIC):
Channel Breakdown Tracking (
loyaltyWalletSchema.js
): Added ordersByChannel and spendByChannel maps on customer wallets.
Dynamic Tier Calculation (
loyaltyEngine.js
,
loyaltyProgram.service.js
):
Omnichannel: Sums all orders across POS, E-Commerce, Services, Quotations, and Subscriptions.
Channel-Specific: Evaluates tier thresholds strictly based on channel-specific orders.
Historical Fallback: Automatically computes channel counts from LoyaltyLedger for existing customers without requiring database migrations.
API Performance & read ECONNRESET Resolution (GET /api/v1/loyalty/programs):
Compound Indexing (
loyaltyProgramSchema.js
): Added indexes for { companyId, isDeleted, createdAt: -1 }, { companyId, isDeleted, isPrimary: -1, priority: -1 }, and { companyId, isDeleted, priority: 1 }.
In-Memory Tenant Caching (
loyaltyProgram.service.js
): Added tenantCompanyCache (5-min TTL) with exact-match fallback to resolve tenant company in 0ms.
Resequencing with bulkWrite: Replaced sequential .save() loops with single-roundtrip MongoDB bulkWrite.
Lightweight Payloads & Transient Retry Wrapper: Excluded heavy actionHistory from list queries (.select("-actionHistory")) and wrapped operations with executeWithRetry.
2. POS Admin Frontend (evergreen_pos_fe)
Membership Tiers & Dynamic Benefits Matrix UI:
Channel Multi-Select (
LoyaltyRewardSettings.tsx
): Added AntSelect multi-select dropdown allowing admins to target perks to specific channels or all channels.
Multiplier Badge Logic: Fixed auto-calculation so multiplier tiers (including Member) consistently display the ⚡ AUTO badge.
Omnichannel Scope Controls: Added UI banner and selector for ALL_CHANNELS_COMBINED vs CHANNEL_SPECIFIC progression modes.
Form Validation & UX:
Added cross-tab modal validation with automatic tab jumping and pulsing error indicators.
Added auto-clearing real-time validation error banner.
Added empty state illustrations and "Retry Now" button for network error handling.
Universal Responsiveness & Horizontal Scrolling:
Set overflowX: 'auto' and -webkit-overflow-scrolling: 'touch' on all screen breakpoints for Loyalty Programs table, Dynamic Benefits Matrix table, Customer Accounts table, and Ledger table.
3. E-Commerce Storefront (evergreenpos_E-commerce_new)
Dynamic Membership Tiers & Benefit Matrix (
RewardsPage.tsx
):
Replaced hardcoded tiers with dynamic tier rendering fetched from the active primary loyalty program.
Added dynamic milestone progress line reflecting customer order count against configured tier minimum order thresholds.
Implemented multi-currency support (currencySymbol / formatCurrency).
Referral Link & Auth Flow (
Login.tsx
,
AllRoutes.tsx
):
Added URL query parameter cleanup (ref, referralCode, refCode, auth) after modal activation.
Auto-detects and switches between email and SMS verification smoothly.
📂 File Changes Summary Table
Repository File Path Status Impact / Changes
evergreen_pos_be src/views/emails/loyaltyTierUpgrade.ejs New Luxury VIP Tier upgrade HTML notification template
evergreen_pos_be src/models/Loyalty/loyaltyProgramSchema.js Modified Added compound MongoDB indexes for query speed
evergreen_pos_be src/models/Loyalty/loyaltyWalletSchema.js Modified Added ordersByChannel and spendByChannel tracking
evergreen_pos_be src/services/loyaltyProgram.service.js Modified Tenant caching, bulkWrite resequencing, transient retry wrapper, channel query support
evergreen_pos_be src/services/loyaltyEngine.js Modified Dual-scope tier evaluation, email notification trigger, historical fallback
evergreen_pos_fe src/pages/Settings/CompanyProfile/LoyaltyRewardSettings.tsx Modified Matrix multi-channel dropdown, cross-tab validation, universal table scrolling
evergreen_pos_fe src/pages/Settings/CompanyProfile/LoyaltyCustomerAnalytics.tsx Modified Touch momentum scrolling & custom scrollbars for Customer & Ledger tables
evergreenpos_E-commerce_new src/features/loyalty/pages/RewardsPage.tsx Modified Dynamic tier rendering, dynamic milestone progress line, multi-currency formatting
evergreenpos_E-commerce_new src/features/auth/pages/Login.tsx Modified URL referral param cleanup and OTP delivery auto-detection
evergreenpos_E-commerce_new src/Routes/AllRoutes.tsx Modified Referral parameter listener and state cleanup