using GB5Shared.DTO.Framework.Login; using GB5Shared.QueueReader; using GB5Shared.Telemetry; using GoodBooks.PAY.PAYBLL.Loyalty; using Microsoft.Extensions.Logging; namespace GoodBooks.PAY.PAYSL.Services.Handlers; // Processes a LOYALTY queue message by expiring all loyalty points that have lapsed for the tenant. // Message payload is ignored — the BLL fetches all expired points from TLOYALTYLEDGER. public sealed class LoyaltyExpiryQueueHandler : IJobQueueHandler { public string MessageType => "LOYALTY"; private readonly ICustomerLoyaltyBLL _bll; private readonly ILogger _logger; public LoyaltyExpiryQueueHandler(ICustomerLoyaltyBLL bll, ILogger logger) { _bll = bll; _logger = logger; } public async Task HandleAsync(string payload, LoginDTO login, long queueId, CancellationToken ct) { GB5Trace.Step("loyalty-expiry-queue-process", new { TenantId = login.ClientId }); _logger.LogInformation("LoyaltyExpiryQueueHandler: expiring lapsed points for tenant {TenantId}", login.ClientId); await _bll.ExpirePointsAsync(login, ct).ConfigureAwait(false); } }