feat(commission): add per-package filtering to commission & balance queries
- Proto: add package_id filter to 4 request messages, package_id/package_title to 4 response models - Queries: add PackageId filter to GetUserWeeklyBalances, GetUserCommissionPayouts, GetMyCommissionPayouts, GetMyWeeklyBalances - Handlers: include Package navigation, filter by PackageId, map PackageId/PackageTitle - DTOs: add PackageId + PackageTitle to all response models - Mappings: update CommissionProfile with PackageId/PackageTitle for all admin+customer mappings - NuGet: bump proto version to 0.0.187
This commit is contained in:
+4
@@ -15,6 +15,10 @@ public record GetUserWeeklyBalancesQuery : IRequest<GetUserWeeklyBalancesRespons
|
||||
/// </summary>
|
||||
public long? WeekDefinitionId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// فیلتر بر اساس پکیج (اختیاری)
|
||||
/// </summary>
|
||||
public long? PackageId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// فقط موارد Expired نشده؟
|
||||
|
||||
+10
-1
@@ -18,6 +18,7 @@ public class GetUserWeeklyBalancesQueryHandler : IRequestHandler<GetUserWeeklyBa
|
||||
var query = _context.NetworkWeeklyBalances
|
||||
.Include(x => x.WeekDefinition)
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Package)
|
||||
.AsNoTracking()
|
||||
.AsQueryable();
|
||||
|
||||
@@ -43,6 +44,12 @@ public class GetUserWeeklyBalancesQueryHandler : IRequestHandler<GetUserWeeklyBa
|
||||
query = query.Where(x => !x.IsExpired);
|
||||
}
|
||||
|
||||
// فیلتر بر اساس پکیج
|
||||
if (request.PackageId.HasValue && request.PackageId.Value > 0)
|
||||
{
|
||||
query = query.Where(x => x.PackageId == request.PackageId.Value);
|
||||
}
|
||||
|
||||
// مرتبسازی بر اساس WeekDefinitionId (نزولی = جدیدترین اول)
|
||||
query = query.ApplyOrder(sortBy: request.SortBy ?? "-WeekDefinitionId");
|
||||
|
||||
@@ -67,7 +74,9 @@ public class GetUserWeeklyBalancesQueryHandler : IRequestHandler<GetUserWeeklyBa
|
||||
WeeklyPoolContribution = x.WeeklyPoolContribution,
|
||||
CalculatedAt = x.CalculatedAt,
|
||||
IsExpired = x.IsExpired,
|
||||
Created = x.Created
|
||||
Created = x.Created,
|
||||
PackageId = x.PackageId,
|
||||
PackageTitle = x.Package != null ? x.Package.Title : ""
|
||||
})
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
|
||||
+4
@@ -29,4 +29,8 @@ public class GetUserWeeklyBalancesResponseModel
|
||||
public DateTime? CalculatedAt { get; set; }
|
||||
public bool IsExpired { get; set; }
|
||||
public DateTimeOffset Created { get; set; }
|
||||
|
||||
// Package info
|
||||
public long PackageId { get; set; }
|
||||
public string PackageTitle { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user