feat: add PackageId to CalculateWeeklyCommissionPoolCommand and related logic for package-specific calculations
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m43s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m43s
This commit is contained in:
@@ -159,14 +159,16 @@ public class WeeklyCommissionJob
|
||||
long weekDefinitionId,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
// Check idempotency: Skip if already calculated
|
||||
var existingPool = await _context.WeeklyCommissionPools
|
||||
.FirstOrDefaultAsync(x => x.WeekDefinitionId == weekDefinitionId, cancellationToken);
|
||||
// Skip only when all pools for the week are already calculated.
|
||||
var hasAnyPool = await _context.WeeklyCommissionPools
|
||||
.AnyAsync(x => x.WeekDefinitionId == weekDefinitionId, cancellationToken);
|
||||
var hasPendingPool = await _context.WeeklyCommissionPools
|
||||
.AnyAsync(x => x.WeekDefinitionId == weekDefinitionId && !x.IsCalculated, cancellationToken);
|
||||
|
||||
if (existingPool != null && existingPool.IsCalculated)
|
||||
if (hasAnyPool && !hasPendingPool)
|
||||
{
|
||||
_logger.LogWarning(
|
||||
"⚠️ [{ExecutionId}] WeekDefinitionId={WeekDefinitionId} already calculated. Skipping.",
|
||||
"⚠️ [{ExecutionId}] WeekDefinitionId={WeekDefinitionId} already fully calculated. Skipping.",
|
||||
executionId, weekDefinitionId);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user