using EntitlementBLL.Handlers; using FastEndpoints; using GB5Shared.Authorization; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace EntitlementSL.Endpoints.Scheduler; // Internal system job, dispatched by GB5Framework's Track A scheduler (tracker §45) — replaces // the standalone in-memory Quartz job of the same name that used to run every 15 minutes inside // EntitlementSL's own process. Entitlement↔Payment loose-coupling reconciliation backstop // (§9.1 item 4) — required, not optional, since the Dapr "payorder.statuschanged" subscriber is // genuinely best-effort. [MenuRights("entpayrcn", RightOperation.Update)] public class RunPayOrderReconciliation : BaseEndpoint> { private readonly ISchedulerTasksBLL _SchedulerTasksBLL; public RunPayOrderReconciliation(ISchedulerTasksBLL schedulerTasksBLL) => _SchedulerTasksBLL = schedulerTasksBLL; public override void Configure() { Get("/Entitlement/Scheduler/RunPayOrderReconciliation"); AllowAnonymous(); } public record Params([property: FromHeader] string Login); protected override string? GetCacheKey(Params req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( Params req, LoginDTO loginDTO, CancellationToken ct) { await _SchedulerTasksBLL.RunPayOrderReconciliationAsync(ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( "PayOrderReconciliation run completed.", CacheKeyLevel.NOT_REQUIRED, loginDTO); } }