feat: add GetAvailableWeeks query and update protobuf imports
All checks were successful
Build and Deploy / build (push) Successful in 2m18s

This commit is contained in:
masoodafar-web
2025-12-12 05:57:32 +03:30
parent ce3b5db822
commit fe56b8f139
80 changed files with 308 additions and 238 deletions

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.ClubMembership.Protos;
using CMSMicroservice.Protobuf.Protos.ClubMembership;
namespace BackOffice.BFF.Application.ClubMembershipCQ.Commands.ActivateClub;

View File

@@ -1,6 +1,6 @@
using Foursat.BackOffice.BFF.ClubMembership.Protos;
using Foursat.BackOffice.BFF.ClubMembership.Protos;
using CMSMicroservice.Protobuf.Protos.ClubMembership;
namespace BackOffice.BFF.Application.ClubMembershipCQ.Queries.GetAllClubMembers;

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.ClubMembership.Protos;
using CMSMicroservice.Protobuf.Protos.ClubMembership;
namespace BackOffice.BFF.Application.ClubMembershipCQ.Queries.GetClubStatistics;

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.Commission.Protos;
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.CommissionCQ.Commands.ApproveWithdrawal;

View File

@@ -1,5 +1,4 @@
using Foursat.BackOffice.BFF.Commission.Protos;
using Google.Protobuf.WellKnownTypes;
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.CommissionCQ.Commands.ProcessWithdrawal;

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.Commission.Protos;
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.CommissionCQ.Commands.RejectWithdrawal;

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.Commission.Protos;
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.CommissionCQ.Commands.TriggerWeeklyCalculation;

View File

@@ -1,5 +1,7 @@
using Foursat.BackOffice.BFF.Commission.Protos;
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools;

View File

@@ -0,0 +1,7 @@
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetAvailableWeeks;
public class GetAvailableWeeksQuery : IRequest<GetAvailableWeeksResponseDto>
{
public int FutureWeeksCount { get; init; } = 4;
public int PastWeeksCount { get; init; } = 12;
}

View File

@@ -0,0 +1,53 @@
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetAvailableWeeks;
public class GetAvailableWeeksQueryHandler : IRequestHandler<GetAvailableWeeksQuery, GetAvailableWeeksResponseDto>
{
private readonly IApplicationContractContext _context;
public GetAvailableWeeksQueryHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<GetAvailableWeeksResponseDto> Handle(
GetAvailableWeeksQuery request,
CancellationToken cancellationToken)
{
// Call CMS microservice through BFF proto
var cmsRequest = new GetAvailableWeeksRequest
{
FutureWeeksCount = request.FutureWeeksCount,
PastWeeksCount = request.PastWeeksCount
};
var response = await _context.Commissions.GetAvailableWeeksAsync(cmsRequest, cancellationToken: cancellationToken);
// Map to DTO
return new GetAvailableWeeksResponseDto
{
CurrentWeek = MapToDto(response.CurrentWeek),
CalculatedWeeks = response.CalculatedWeeks.Select(MapToDto).ToList(),
PendingWeeks = response.PendingWeeks.Select(MapToDto).ToList(),
FutureWeeks = response.FutureWeeks.Select(MapToDto).ToList()
};
}
private static WeekInfoDto MapToDto(WeekInfo weekInfo)
{
return new WeekInfoDto
{
WeekNumber = weekInfo.WeekNumber,
StartDate = weekInfo.StartDate?.ToDateTime() ?? DateTime.MinValue,
EndDate = weekInfo.EndDate?.ToDateTime() ?? DateTime.MinValue,
IsCalculated = weekInfo.IsCalculated,
CalculatedAt = weekInfo.CalculatedAt?.ToDateTime(),
LastExecutionStatus = weekInfo.LastExecutionStatus,
TotalPoolAmount = weekInfo.TotalPoolAmount != 0 ? weekInfo.TotalPoolAmount : null,
EligibleUsersCount = weekInfo.EligibleUsersCount != 0 ? weekInfo.EligibleUsersCount : null,
DisplayText = weekInfo.DisplayText
};
}
}

View File

@@ -0,0 +1,22 @@
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetAvailableWeeks;
public class GetAvailableWeeksResponseDto
{
public required WeekInfoDto CurrentWeek { get; init; }
public required List<WeekInfoDto> CalculatedWeeks { get; init; }
public required List<WeekInfoDto> PendingWeeks { get; init; }
public required List<WeekInfoDto> FutureWeeks { get; init; }
}
public class WeekInfoDto
{
public required string WeekNumber { get; init; }
public required DateTime StartDate { get; init; }
public required DateTime EndDate { get; init; }
public bool IsCalculated { get; init; }
public DateTime? CalculatedAt { get; init; }
public string? LastExecutionStatus { get; init; }
public long? TotalPoolAmount { get; init; }
public int? EligibleUsersCount { get; init; }
public required string DisplayText { get; init; }
}

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.Commission.Protos;
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserPayouts;

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.Commission.Protos;
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.Commission.Protos;
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWeeklyPool;

View File

@@ -2,58 +2,12 @@ namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWeeklyPool;
public class GetWeeklyPoolResponseDto
{
/// <summary>
/// شناسه Pool
/// </summary>
public long Id { get; set; }
/// <summary>
/// شماره هفته (فرمت: YYYY-Www)
/// </summary>
public string WeekNumber { get; set; } = string.Empty;
/// <summary>
/// مجموع کل Pool (تومان)
/// </summary>
public decimal TotalPoolValue { get; set; }
/// <summary>
/// مجموع مشارکت‌های اولیه (InitialContribution)
/// </summary>
public decimal TotalContributions { get; set; }
/// <summary>
/// مجموع Payout های پرداخت شده
/// </summary>
public decimal TotalPayouts { get; set; }
/// <summary>
/// باقیمانده Pool
/// </summary>
public decimal LeftBalance { get; set; }
/// <summary>
/// تعداد اعضای فعال در این هفته
/// </summary>
public int ActiveMembersCount { get; set; }
/// <summary>
/// آیا محاسبه شده است؟
/// </summary>
public long TotalPoolAmount { get; set; }
public long TotalBalances { get; set; }
public decimal ValuePerBalance { get; set; }
public bool IsCalculated { get; set; }
/// <summary>
/// تاریخ محاسبه
/// </summary>
public DateTime? CalculatedAt { get; set; }
/// <summary>
/// تاریخ ایجاد
/// </summary>
public DateTime CreatedAt { get; set; }
/// <summary>
/// تاریخ آخرین ویرایش
/// </summary>
public DateTime? ModifiedAt { get; set; }
public DateTimeOffset Created { get; set; }
}

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.Commission.Protos;
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalReports;

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.Commission.Protos;
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalRequests;

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.Commission.Protos;
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWorkerExecutionLogs;

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.Commission.Protos;
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWorkerStatus;

View File

@@ -13,15 +13,16 @@ using FMSMicroservice.Protobuf.Protos.FileInfo;
using CMSMicroservice.Protobuf.Protos.DiscountProduct;
using CMSMicroservice.Protobuf.Protos.DiscountCategory;
using CMSMicroservice.Protobuf.Protos.DiscountShoppingCart;
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
using CMSMicroservice.Protobuf.Protos.Tag;
using CMSMicroservice.Protobuf.Protos.ProductTag;
using CMSMicroservice.Protobuf.Protos;
using Foursat.BackOffice.BFF.ClubMembership.Protos;
using Foursat.BackOffice.BFF.Commission.Protos;
using Foursat.BackOffice.BFF.Configuration.Protos;
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
using BackOffice.BFF.ManualPayment.Protobuf;
using CMSMicroservice.Protobuf.Protos.ClubMembership;
using CMSMicroservice.Protobuf.Protos.Commission;
using CMSMicroservice.Protobuf.Protos.Configuration;
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
using CMSMicroservice.Protobuf.Protos.ManualPayment;
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
namespace BackOffice.BFF.Application.Common.Interfaces;

View File

@@ -0,0 +1,21 @@
using BackOffice.BFF.Application.CommissionCQ.Queries.GetWeeklyPool;
using CMSMicroservice.Protobuf.Protos.Commission;
namespace BackOffice.BFF.Application.Common.Mappings;
public class CommissionProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
config.NewConfig< GetWeeklyCommissionPoolResponse,GetWeeklyPoolResponseDto>()
.Map(dest => dest.Id, src => src.Id)
.Map(dest => dest.CalculatedAt, src => src.CalculatedAt)
.Map(dest => dest.IsCalculated, src => src.IsCalculated)
.Map(dest => dest.WeekNumber, src => src.WeekNumber)
.Map(dest => dest.TotalPoolAmount, src => src.TotalPoolAmount)
.Map(dest => dest.ValuePerBalance, src => src.ValuePerBalance)
.Map(dest => dest.TotalBalances, src => src.TotalBalances)
.Map(dest => dest.Created, src => src.Created.ToDateTimeOffset())
;
}
}

View File

@@ -51,6 +51,9 @@ public class GeneralMapping : IRegister
config.NewConfig<TimeSpan?, Duration>()
.MapWith(src => src.HasValue ? Duration.FromTimeSpan(src.Value) : null);
config.NewConfig<DateTimeOffset?, DateTime?>()
.MapWith(src => src.HasValue ? src.Value.DateTime : (DateTime?)null);
config.Default
.UseDestinationValue(member => member.SetterModifier == AccessModifier.None &&
member.Type.IsGenericType &&

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.Configuration.Protos;
using Google.Protobuf.WellKnownTypes;
using CMSMicroservice.Protobuf.Protos.Configuration;
namespace BackOffice.BFF.Application.ConfigurationCQ.Commands.CreateOrUpdateConfiguration;

View File

@@ -1,4 +1,5 @@
using Foursat.BackOffice.BFF.Configuration.Protos;
using CMSMicroservice.Protobuf.Protos.Configuration;
namespace BackOffice.BFF.Application.ConfigurationCQ.Commands.DeactivateConfiguration;

View File

@@ -1,7 +1,5 @@
using BackOffice.BFF.Application.Common.Interfaces;
using Foursat.BackOffice.BFF.Configuration.Protos;
using Google.Protobuf.WellKnownTypes;
using MediatR;
using CMSMicroservice.Protobuf.Protos.Configuration;
using Microsoft.Extensions.Logging;
namespace BackOffice.BFF.Application.ConfigurationCQ.Commands.SetDefaultVatPercentage;

View File

@@ -1,5 +1,3 @@
using FluentValidation;
namespace BackOffice.BFF.Application.ConfigurationCQ.Commands.SetDefaultVatPercentage;
public class SetDefaultVatPercentageCommandValidator : AbstractValidator<SetDefaultVatPercentageCommand>

View File

@@ -1,4 +1,5 @@
using Foursat.BackOffice.BFF.Configuration.Protos;
using CMSMicroservice.Protobuf.Protos.Configuration;
namespace BackOffice.BFF.Application.ConfigurationCQ.Queries.GetAllConfigurations;

View File

@@ -1,6 +1,4 @@
using BackOffice.BFF.Application.Common.Interfaces;
using Foursat.BackOffice.BFF.Configuration.Protos;
using MediatR;
using CMSMicroservice.Protobuf.Protos.Configuration;
using Microsoft.Extensions.Logging;
namespace BackOffice.BFF.Application.ConfigurationCQ.Queries.GetCurrentVatPercentage;

View File

@@ -1,5 +1,5 @@
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
using Mapster;
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
namespace BackOffice.BFF.Application.DiscountOrderCQ.Commands.CompleteOrderPayment;
@@ -14,10 +14,10 @@ public class CompleteOrderPaymentCommandHandler : IRequestHandler<CompleteOrderP
public async Task<CompleteOrderPaymentResponseDto> Handle(CompleteOrderPaymentCommand request, CancellationToken cancellationToken)
{
var grpcRequest = TypeAdapter.Adapt(request, request.GetType(), typeof(CompleteOrderPaymentRequest)) as CompleteOrderPaymentRequest;
var grpcRequest = request.Adapt<CompleteOrderPaymentRequest>();
var response = await _context.DiscountOrders.CompleteOrderPaymentAsync(grpcRequest, cancellationToken: cancellationToken);
return TypeAdapter.Adapt(response, response.GetType(), typeof(CompleteOrderPaymentResponseDto)) as CompleteOrderPaymentResponseDto;
return response.Adapt<CompleteOrderPaymentResponseDto>();
}
}

View File

@@ -1,5 +1,5 @@
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
using Mapster;
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
namespace BackOffice.BFF.Application.DiscountOrderCQ.Commands.PlaceOrder;
@@ -14,10 +14,10 @@ public class PlaceOrderCommandHandler : IRequestHandler<PlaceOrderCommand, Place
public async Task<PlaceOrderResponseDto> Handle(PlaceOrderCommand request, CancellationToken cancellationToken)
{
var grpcRequest = TypeAdapter.Adapt(request, request.GetType(), typeof(PlaceOrderRequest)) as PlaceOrderRequest;
var grpcRequest = request.Adapt<PlaceOrderRequest>();
var response = await _context.DiscountOrders.PlaceOrderAsync(grpcRequest, cancellationToken: cancellationToken);
return TypeAdapter.Adapt(response, response.GetType(), typeof(PlaceOrderResponseDto)) as PlaceOrderResponseDto;
return response.Adapt<PlaceOrderResponseDto>();
}
}

View File

@@ -1,5 +1,5 @@
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
using Mapster;
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
namespace BackOffice.BFF.Application.DiscountOrderCQ.Commands.UpdateOrderStatus;
@@ -14,10 +14,10 @@ public class UpdateOrderStatusCommandHandler : IRequestHandler<UpdateOrderStatus
public async Task<UpdateOrderStatusResponseDto> Handle(UpdateOrderStatusCommand request, CancellationToken cancellationToken)
{
var grpcRequest = TypeAdapter.Adapt(request, request.GetType(), typeof(UpdateOrderStatusRequest)) as UpdateOrderStatusRequest;
var grpcRequest = request.Adapt<UpdateOrderStatusRequest>();
var response = await _context.DiscountOrders.UpdateOrderStatusAsync(grpcRequest, cancellationToken: cancellationToken);
return TypeAdapter.Adapt(response, response.GetType(), typeof(UpdateOrderStatusResponseDto)) as UpdateOrderStatusResponseDto;
return response.Adapt<UpdateOrderStatusResponseDto>();
}
}

View File

@@ -1,5 +1,5 @@
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
using Mapster;
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
namespace BackOffice.BFF.Application.DiscountOrderCQ.Queries.GetOrderById;
@@ -22,6 +22,6 @@ public class GetOrderByIdQueryHandler : IRequestHandler<GetOrderByIdQuery, GetOr
var response = await _context.DiscountOrders.GetOrderByIdAsync(grpcRequest, cancellationToken: cancellationToken);
return TypeAdapter.Adapt(response, response.GetType(), typeof(GetOrderByIdResponseDto)) as GetOrderByIdResponseDto;
return response.Adapt<GetOrderByIdResponseDto>();
}
}

View File

@@ -1,5 +1,5 @@
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
using Mapster;
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
namespace BackOffice.BFF.Application.DiscountOrderCQ.Queries.GetUserOrders;
@@ -26,6 +26,6 @@ public class GetUserOrdersQueryHandler : IRequestHandler<GetUserOrdersQuery, Get
var response = await _context.DiscountOrders.GetUserOrdersAsync(grpcRequest, cancellationToken: cancellationToken);
return TypeAdapter.Adapt(response, response.GetType(), typeof(GetUserOrdersResponseDto)) as GetUserOrdersResponseDto;
return response.Adapt<GetUserOrdersResponseDto>();
}
}

View File

@@ -1,5 +1,3 @@
using BackOffice.BFF.Application.Common.Models;
namespace BackOffice.BFF.Application.DiscountOrderCQ.Queries.GetUserOrders;
public class GetUserOrdersResponseDto

View File

@@ -1,7 +1,9 @@
using Foursat.BackOffice.BFF.ClubMembership.Protos;
using Foursat.BackOffice.BFF.Commission.Protos;
using Foursat.BackOffice.BFF.Configuration.Protos;
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
using CMSMicroservice.Protobuf.Protos.ClubMembership;
using CMSMicroservice.Protobuf.Protos.Commission;
using CMSMicroservice.Protobuf.Protos.Configuration;
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
using Foursat.BackOffice.BFF.Health.Protobuf;
namespace BackOffice.BFF.Application.HealthCQ.Queries.GetSystemHealth;

View File

@@ -1,5 +1,3 @@
using MediatR;
namespace BackOffice.BFF.Application.ManualPaymentCQ.Commands.ApproveManualPayment;
public class ApproveManualPaymentCommand : IRequest<bool>

View File

@@ -1,7 +1,4 @@
using BackOffice.BFF.Application.Common.Interfaces;
using BackOffice.BFF.ManualPayment.Protobuf;
using Google.Protobuf.WellKnownTypes;
using MediatR;
using CMSMicroservice.Protobuf.Protos.ManualPayment;
using Microsoft.Extensions.Logging;
namespace BackOffice.BFF.Application.ManualPaymentCQ.Commands.ApproveManualPayment;

View File

@@ -1,5 +1,3 @@
using FluentValidation;
namespace BackOffice.BFF.Application.ManualPaymentCQ.Commands.ApproveManualPayment;
public class ApproveManualPaymentCommandValidator : AbstractValidator<ApproveManualPaymentCommand>

View File

@@ -1,5 +1,3 @@
using MediatR;
namespace BackOffice.BFF.Application.ManualPaymentCQ.Commands.CreateManualPayment;
public class CreateManualPaymentCommand : IRequest<CreateManualPaymentResponseDto>

View File

@@ -1,7 +1,4 @@
using BackOffice.BFF.Application.Common.Interfaces;
using BackOffice.BFF.ManualPayment.Protobuf;
using Google.Protobuf.WellKnownTypes;
using MediatR;
using CMSMicroservice.Protobuf.Protos.ManualPayment;
using Microsoft.Extensions.Logging;
namespace BackOffice.BFF.Application.ManualPaymentCQ.Commands.CreateManualPayment;
@@ -31,7 +28,7 @@ public class CreateManualPaymentCommandHandler : IRequestHandler<CreateManualPay
{
UserId = request.UserId,
Amount = request.Amount,
Type = request.Type,
Type = (ManualPaymentType)request.Type,
Description = request.Description
};

View File

@@ -1,5 +1,3 @@
using FluentValidation;
namespace BackOffice.BFF.Application.ManualPaymentCQ.Commands.CreateManualPayment;
public class CreateManualPaymentCommandValidator : AbstractValidator<CreateManualPaymentCommand>

View File

@@ -1,5 +1,3 @@
using MediatR;
namespace BackOffice.BFF.Application.ManualPaymentCQ.Commands.RejectManualPayment;
public class RejectManualPaymentCommand : IRequest<bool>

View File

@@ -1,6 +1,4 @@
using BackOffice.BFF.Application.Common.Interfaces;
using BackOffice.BFF.ManualPayment.Protobuf;
using MediatR;
using CMSMicroservice.Protobuf.Protos.ManualPayment;
using Microsoft.Extensions.Logging;
namespace BackOffice.BFF.Application.ManualPaymentCQ.Commands.RejectManualPayment;

View File

@@ -1,5 +1,3 @@
using FluentValidation;
namespace BackOffice.BFF.Application.ManualPaymentCQ.Commands.RejectManualPayment;
public class RejectManualPaymentCommandValidator : AbstractValidator<RejectManualPaymentCommand>

View File

@@ -1,5 +1,3 @@
using MediatR;
namespace BackOffice.BFF.Application.ManualPaymentCQ.Queries.GetManualPayments;
public class GetManualPaymentsQuery : IRequest<GetManualPaymentsResponseDto>

View File

@@ -1,8 +1,5 @@
using BackOffice.BFF.Application.Common.Interfaces;
using BackOffice.BFF.Application.Common.Models;
using BackOffice.BFF.ManualPayment.Protobuf;
using Google.Protobuf.WellKnownTypes;
using MediatR;
using CMSMicroservice.Protobuf.Protos.ManualPayment;
using Microsoft.Extensions.Logging;
namespace BackOffice.BFF.Application.ManualPaymentCQ.Queries.GetManualPayments;
@@ -29,7 +26,7 @@ public class GetManualPaymentsQueryHandler : IRequestHandler<GetManualPaymentsQu
request.Status,
request.Type);
var grpcRequest = new GetManualPaymentsRequest
var grpcRequest = new GetAllManualPaymentsRequest
{
PageNumber = request.PageNumber,
PageSize = request.PageSize,
@@ -38,7 +35,7 @@ public class GetManualPaymentsQueryHandler : IRequestHandler<GetManualPaymentsQu
Type = request.Type
};
var response = await _context.ManualPayments.GetManualPaymentsAsync(grpcRequest, cancellationToken: cancellationToken);
var response = await _context.ManualPayments.GetAllManualPaymentsAsync(grpcRequest, cancellationToken: cancellationToken);
var meta = response.MetaData;
@@ -50,11 +47,11 @@ public class GetManualPaymentsQueryHandler : IRequestHandler<GetManualPaymentsQu
UserFullName = m.UserFullName,
UserMobile = m.UserMobile,
Amount = m.Amount,
Type = m.Type,
Type = m.Type.GetHashCode(),
TypeDisplay = m.TypeDisplay,
Description = m.Description,
ReferenceNumber = m.ReferenceNumber,
Status = m.Status,
Status = m.Status.GetHashCode(),
StatusDisplay = m.StatusDisplay,
RequestedBy = m.RequestedBy,
RequestedByName = m.RequestedByName,

View File

@@ -1,5 +1,3 @@
using BackOffice.BFF.Application.Common.Models;
namespace BackOffice.BFF.Application.ManualPaymentCQ.Queries.GetManualPayments;
public class GetManualPaymentsResponseDto

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkHistory;

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkStatistics;

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkTree;

View File

@@ -1,5 +1,6 @@
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetUserNetworkInfo;

View File

@@ -24,4 +24,5 @@ public record GetAllUserByFilterQuery : IRequest<GetAllUserByFilterResponseDto>
public string? AvatarPath { get; set; }
//شناسه والد
public long? ParentId { get; set; }
public string? SearchText { get; set; }
}

View File

@@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="Afrino.FMSMicroservice.Protobuf" Version="0.0.122" />
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.145" />
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.147" />
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" />

View File

@@ -1,4 +1,3 @@
using System.Diagnostics;
using System.Reflection;
using BackOffice.BFF.Application.Common.Interfaces;
using Grpc.Core;
@@ -18,10 +17,10 @@ public static class ConfigureGrpcServices
.Where(x =>
x.FullName != null &&
(x.FullName.Contains("Microservice.Protobuf") ||
x.FullName.Contains("BFF.Commission.Protobuf") ||
x.FullName.Contains("BFF.NetworkMembership.Protobuf") ||
x.FullName.Contains("BFF.ClubMembership.Protobuf") ||
x.FullName.Contains("BFF.Configuration.Protobuf")) &&
x.FullName.Contains("BackOffice.BFF.Commission.Protobuf") ||
x.FullName.Contains("BackOffice.BFF.NetworkMembership.Protobuf") ||
x.FullName.Contains("BackOffice.BFF.ClubMembership.Protobuf") ||
x.FullName.Contains("BackOffice.BFF.Configuration.Protobuf")) &&
x.GetTypes().Any(type => type.BaseType != null && type.BaseType.Name == "ClientBase`1" && type.BaseType.Namespace == "Grpc.Core")
)
.SelectMany(x => x
@@ -51,10 +50,10 @@ public static class ConfigureGrpcServices
foreach (var grpcClient in grpcClients.Where(t =>
t.AssemblyQualifiedName != null &&
(t.AssemblyQualifiedName.StartsWith($"{msName}Microservice") ||
t.AssemblyQualifiedName.StartsWith("BackOffice.BFF.Commission") ||
t.AssemblyQualifiedName.StartsWith("BackOffice.BFF.NetworkMembership") ||
t.AssemblyQualifiedName.StartsWith("BackOffice.BFF.ClubMembership") ||
t.AssemblyQualifiedName.StartsWith("BackOffice.BFF.Configuration"))
t.AssemblyQualifiedName.StartsWith("Foursat.BackOffice.BFF.Commission") ||
t.AssemblyQualifiedName.StartsWith("Foursat.BackOffice.BFF.NetworkMembership") ||
t.AssemblyQualifiedName.StartsWith("Foursat.BackOffice.BFF.ClubMembership") ||
t.AssemblyQualifiedName.StartsWith("Foursat.BackOffice.BFF.Configuration"))
)
.ToList())
{

View File

@@ -1,12 +1,7 @@
using BackOffice.BFF.Application.Common.Interfaces;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text;
using System.Threading.Tasks;
namespace BackOffice.BFF.Infrastructure.Services;
public class AfrinoIdpService : IAfrinoIdpService

View File

@@ -15,17 +15,18 @@ using FMSMicroservice.Protobuf.Protos.FileInfo;
using CMSMicroservice.Protobuf.Protos.DiscountProduct;
using CMSMicroservice.Protobuf.Protos.DiscountCategory;
using CMSMicroservice.Protobuf.Protos.DiscountShoppingCart;
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
using CMSMicroservice.Protobuf.Protos.Tag;
using CMSMicroservice.Protobuf.Protos.ProductTag;
using CMSMicroservice.Protobuf.Protos;
using CMSMicroservice.Protobuf.Protos.ClubMembership;
using CMSMicroservice.Protobuf.Protos.Commission;
using CMSMicroservice.Protobuf.Protos.Configuration;
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
using CMSMicroservice.Protobuf.Protos.ManualPayment;
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
// BFF Protobuf contracts
using Foursat.BackOffice.BFF.ClubMembership.Protos;
using Foursat.BackOffice.BFF.Commission.Protos;
using Foursat.BackOffice.BFF.Configuration.Protos;
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
using BackOffice.BFF.ManualPayment.Protobuf;
using Microsoft.Extensions.DependencyInjection;

View File

@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
using BackOffice.BFF.Application.Common.Interfaces;
using BackOffice.BFF.Application.Common.Models;
using Microsoft.AspNetCore.Http;

View File

@@ -1,10 +1,5 @@
using System;
using System.Threading.Tasks;
using BackOffice.BFF.Application.Common.Interfaces;
using Grpc.AspNetCore.Server;
using Grpc.Core;
using Grpc.Core.Interceptors;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
namespace BackOffice.BFF.WebApi.Common.Authorization;

View File

@@ -1,8 +1,6 @@
using BackOffice.BFF.Application.CategoryCQ.Queries.GetAllCategoryByFilter;
using BackOffice.BFF.Application.CategoryCQ.Queries.GetCategory;
using BackOffice.BFF.Application.CategoryCQ.Commands.CreateNewCategory;
using BackOffice.BFF.Category.Protobuf.Protos.Category;
using BackOffice.BFF.Protobuf.Common;
namespace BackOffice.BFF.WebApi.Common.Mappings;

View File

@@ -1,7 +1,3 @@
using BackOffice.BFF.Application.ClubMembershipCQ.Queries.GetAllClubMembers;
using Foursat.BackOffice.BFF.ClubMembership.Protos;
using Google.Protobuf.WellKnownTypes;
namespace BackOffice.BFF.WebApi.Common.Mappings;
public class ClubMembershipProfile : IRegister

View File

@@ -1,12 +1,8 @@
using BackOffice.BFF.Application.CommissionCQ.Queries.GetWeeklyPool;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetUserPayouts;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalRequests;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalReports;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetAvailableWeeks;
using Foursat.BackOffice.BFF.Commission.Protos;
using Google.Protobuf.WellKnownTypes;
using BackOffice.BFF.Protobuf.Common;
namespace BackOffice.BFF.WebApi.Common.Mappings;
@@ -20,16 +16,15 @@ public class CommissionProfile : IRegister
{
Id = src.Id,
WeekNumber = src.WeekNumber ?? string.Empty,
// TotalPoolValue = src.TotalPoolValue,
// TotalContributions = src.TotalContributions,
// TotalPayouts = src.TotalPayouts,
// LeftBalance = src.LeftBalance,
// ActiveMembersCount = src.ActiveMembersCount,
TotalBalances = (int)src.TotalBalances,
TotalPoolAmount = src.TotalPoolAmount,
IsCalculated = src.IsCalculated,
CalculatedAt = src.CalculatedAt.HasValue
? Timestamp.FromDateTime(DateTime.SpecifyKind(src.CalculatedAt.Value, DateTimeKind.Utc))
: null,
Created = Timestamp.FromDateTime(DateTime.SpecifyKind(src.CreatedAt, DateTimeKind.Utc))
Created = Timestamp.FromDateTime(DateTime.SpecifyKind(src.Created.DateTime, DateTimeKind.Utc)),
ValuePerBalance = (long)src.ValuePerBalance
});
// GetUserPayoutsResponseDto -> GetUserCommissionPayoutsResponse
@@ -168,5 +163,33 @@ public class CommissionProfile : IRegister
// : null
// }) }
// });
// GetAvailableWeeksResponseDto -> GetAvailableWeeksResponse
config.NewConfig<GetAvailableWeeksResponseDto, GetAvailableWeeksResponse>()
.MapWith(src => new GetAvailableWeeksResponse
{
CurrentWeek = MapWeekInfo(src.CurrentWeek),
CalculatedWeeks = { src.CalculatedWeeks.Select(MapWeekInfo) },
PendingWeeks = { src.PendingWeeks.Select(MapWeekInfo) },
FutureWeeks = { src.FutureWeeks.Select(MapWeekInfo) }
});
}
private static WeekInfo MapWeekInfo(WeekInfoDto dto)
{
return new WeekInfo
{
WeekNumber = dto.WeekNumber,
StartDate = Timestamp.FromDateTime(dto.StartDate.ToUniversalTime()),
EndDate = Timestamp.FromDateTime(dto.EndDate.ToUniversalTime()),
IsCalculated = dto.IsCalculated,
CalculatedAt = dto.CalculatedAt.HasValue
? Timestamp.FromDateTime(dto.CalculatedAt.Value.ToUniversalTime())
: null,
LastExecutionStatus = dto.LastExecutionStatus ?? string.Empty,
TotalPoolAmount = dto.TotalPoolAmount ?? 0,
EligibleUsersCount = dto.EligibleUsersCount ?? 0,
DisplayText = dto.DisplayText
};
}
}

View File

@@ -1,7 +1,5 @@
using BackOffice.BFF.Application.ConfigurationCQ.Queries.GetAllConfigurations;
using Foursat.BackOffice.BFF.Configuration.Protos;
using Google.Protobuf.WellKnownTypes;
using BackOffice.BFF.Protobuf.Common;
namespace BackOffice.BFF.WebApi.Common.Mappings;

View File

@@ -1,11 +1,9 @@
using Mapster;
using BackOffice.BFF.Application.DiscountOrderCQ.Commands.PlaceOrder;
using BackOffice.BFF.Application.DiscountOrderCQ.Commands.CompleteOrderPayment;
using BackOffice.BFF.Application.DiscountOrderCQ.Commands.UpdateOrderStatus;
using BackOffice.BFF.Application.DiscountOrderCQ.Queries.GetOrderById;
using BackOffice.BFF.Application.DiscountOrderCQ.Queries.GetUserOrders;
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
using Google.Protobuf.WellKnownTypes;
namespace BackOffice.BFF.WebApi.Common.Mappings;

View File

@@ -1,9 +1,3 @@
using BackOffice.BFF.Application.ManualPaymentCQ.Queries.GetManualPayments;
using BackOffice.BFF.Application.ManualPaymentCQ.Commands.CreateManualPayment;
using BackOffice.BFF.ManualPayment.Protobuf;
using Google.Protobuf.WellKnownTypes;
using BackOffice.BFF.Protobuf.Common;
namespace BackOffice.BFF.WebApi.Common.Mappings;
public class ManualPaymentProfile : IRegister

View File

@@ -2,8 +2,6 @@ using BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkTree;
using BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetUserNetworkInfo;
using BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkHistory;
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
using BackOffice.BFF.Protobuf.Common;
using Google.Protobuf.WellKnownTypes;
namespace BackOffice.BFF.WebApi.Common.Mappings;

View File

@@ -1,11 +1,5 @@
using Foursat.BackOffice.BFF.PublicMessage.Protobuf;
namespace BackOffice.BFF.WebApi.Common.Mappings;
using BackOffice.BFF.Application.PublicMessageCQ.Queries.GetAllMessages;
using BackOffice.BFF.Application.PublicMessageCQ.Queries.GetActiveMessages;
using Google.Protobuf.WellKnownTypes;
public class PublicMessageProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)

View File

@@ -1,13 +1,5 @@
namespace BackOffice.BFF.WebApi.Common.Mappings;
using BackOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
using BackOffice.BFF.Application.UserOrderCQ.Commands.UpdateOrderStatus;
using BackOffice.BFF.Application.UserOrderCQ.Commands.ApplyDiscountToOrder;
using BackOffice.BFF.Application.UserOrderCQ.Commands.CancelOrder;
using BackOffice.BFF.Application.UserOrderCQ.Queries.GetOrdersByDateRange;
using BackOffice.BFF.Application.UserOrderCQ.Queries.CalculateOrderPV;
using Google.Protobuf.WellKnownTypes;
public class UserOrderProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)

View File

@@ -1,6 +1,5 @@
using System.Security.Claims;
using BackOffice.BFF.Application.Common.Interfaces;
using Microsoft.AspNetCore.Http;
namespace BackOffice.BFF.WebApi.Common.Services;

View File

@@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Server.Kestrel.Core;
using Serilog;
using Serilog.Core;
using Microsoft.OpenApi.Models;
using BackOffice.BFF.WebApi.Common.Authorization;
var builder = WebApplication.CreateBuilder(args);
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))

View File

@@ -2,7 +2,6 @@ using BackOffice.BFF.WebApi.Common.Services;
using BackOffice.BFF.Application.ClubMembershipCQ.Commands.ActivateClub;
using BackOffice.BFF.Application.ClubMembershipCQ.Queries.GetAllClubMembers;
using Foursat.BackOffice.BFF.ClubMembership.Protos;
using Google.Protobuf.WellKnownTypes;
namespace BackOffice.BFF.WebApi.Services;

View File

@@ -5,11 +5,12 @@ using BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalRequests;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalReports;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetAvailableWeeks;
using BackOffice.BFF.Application.CommissionCQ.Commands.ApproveWithdrawal;
using BackOffice.BFF.Application.CommissionCQ.Commands.RejectWithdrawal;
using BackOffice.BFF.Application.CommissionCQ.Commands.ProcessWithdrawal;
using BackOffice.BFF.Application.CommissionCQ.Commands.TriggerWeeklyCalculation;
using Foursat.BackOffice.BFF.Commission.Protos;
using Google.Protobuf.WellKnownTypes;
namespace BackOffice.BFF.WebApi.Services;
@@ -31,6 +32,13 @@ public class CommissionService : CommissionContract.CommissionContractBase
context);
}
public override async Task<TriggerWeeklyCalculationResponse> TriggerWeeklyCalculation(TriggerWeeklyCalculationRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<TriggerWeeklyCalculationRequest, TriggerWeeklyCalculationCommand, TriggerWeeklyCalculationResponse>(
request,
context);
}
public override async Task<GetUserCommissionPayoutsResponse> GetUserCommissionPayouts(
GetUserCommissionPayoutsRequest request,
ServerCallContext context)
@@ -105,4 +113,13 @@ public class CommissionService : CommissionContract.CommissionContractBase
request,
context);
}
public override async Task<GetAvailableWeeksResponse> GetAvailableWeeks(
GetAvailableWeeksRequest request,
ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetAvailableWeeksRequest, GetAvailableWeeksQuery, GetAvailableWeeksResponse>(
request,
context);
}
}

View File

@@ -3,8 +3,6 @@ using BackOffice.BFF.Application.ConfigurationCQ.Commands.CreateOrUpdateConfigur
using BackOffice.BFF.Application.ConfigurationCQ.Commands.DeactivateConfiguration;
using BackOffice.BFF.Application.ConfigurationCQ.Queries.GetAllConfigurations;
using Foursat.BackOffice.BFF.Configuration.Protos;
using Grpc.Core;
using Google.Protobuf.WellKnownTypes;
namespace BackOffice.BFF.WebApi.Services;

View File

@@ -1,7 +1,6 @@
using BackOffice.BFF.Application.HealthCQ.Queries.GetSystemHealth;
using BackOffice.BFF.WebApi.Common.Services;
using Foursat.BackOffice.BFF.Health.Protobuf;
using Grpc.Core;
namespace BackOffice.BFF.WebApi.Services;

View File

@@ -4,9 +4,6 @@ using BackOffice.BFF.Application.ManualPaymentCQ.Commands.CreateManualPayment;
using BackOffice.BFF.Application.ManualPaymentCQ.Commands.ApproveManualPayment;
using BackOffice.BFF.Application.ManualPaymentCQ.Commands.RejectManualPayment;
using BackOffice.BFF.Application.ManualPaymentCQ.Queries.GetManualPayments;
using Google.Protobuf.WellKnownTypes;
using Mapster;
using MediatR;
namespace BackOffice.BFF.WebApi.Services;

View File

@@ -1,6 +1,5 @@
using CMSMicroservice.Protobuf.Protos;
using BackOffice.BFF.WebApi.Common.Services;
using Google.Protobuf.WellKnownTypes;
using BackOffice.BFF.Application.PublicMessageCQ.Queries.GetAllMessages;
using BackOffice.BFF.Application.PublicMessageCQ.Queries.GetActiveMessages;

View File

@@ -11,8 +11,9 @@
},
"GrpcChannelOptions": {
"FMSMSAddress": "https://dl.afrino.co",
"CMSMSAddress": "http://cms-svc:80"
// "CMSMSAddress": "https://cms.foursat.afrino.co"
// "CMSMSAddress": "http://cms-svc:80"
"CMSMSAddress": "https://cms.foursat.afrino.co"
// "CMSMSAddress": "https://localhost:32846"
},
"Authentication": {
"Authority": "https://ids.domain.com/",

View File

@@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<PackageId>Foursat.BackOffice.BFF.Commission.Protobuf</PackageId>
<Version>0.0.6</Version>
<Version>0.0.7</Version>
<Authors>FourSat</Authors>
<Company>FourSat</Company>
<Product>BackOffice.BFF.Commission.Protobuf</Product>

View File

@@ -105,6 +105,11 @@ service CommissionContract
get: "/GetWorkerExecutionLogs"
};
};
rpc GetAvailableWeeks(GetAvailableWeeksRequest) returns (GetAvailableWeeksResponse){
option (google.api.http) = {
get: "/GetAvailableWeeks"
};
};
rpc GetWithdrawalReports(GetWithdrawalReportsRequest) returns (GetWithdrawalReportsResponse){
option (google.api.http) = {
get: "/GetWithdrawalReports"
@@ -457,3 +462,32 @@ message WithdrawalSummary
int32 unique_users = 7;
float success_rate = 8; // Percentage (0-100)
}
// ============ GetAvailableWeeks ============
message GetAvailableWeeksRequest
{
int32 future_weeks_count = 1; // تعداد هفته‌های آینده (پیش‌فرض: 4)
int32 past_weeks_count = 2; // تعداد هفته‌های گذشته (پیش‌فرض: 12)
}
message GetAvailableWeeksResponse
{
WeekInfo current_week = 1;
repeated WeekInfo calculated_weeks = 2;
repeated WeekInfo pending_weeks = 3;
repeated WeekInfo future_weeks = 4;
}
message WeekInfo
{
string week_number = 1; // YYYY-Www format
google.protobuf.Timestamp start_date = 2;
google.protobuf.Timestamp end_date = 3;
bool is_calculated = 4;
google.protobuf.Timestamp calculated_at = 5;
string last_execution_status = 6;
int64 total_pool_amount = 7;
int32 eligible_users_count = 8;
string display_text = 9; // نمایش فارسی برای UI
}

View File

@@ -4,7 +4,7 @@
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.112</Version>
<Version>0.0.113</Version>
<DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>

View File

@@ -99,6 +99,8 @@ message GetAllUserByFilterFilter
google.protobuf.StringValue national_code = 5;
google.protobuf.StringValue avatar_path = 6;
google.protobuf.Int64Value parent_id = 7;
google.protobuf.StringValue search_text = 8;
}
message GetAllUserByFilterResponse
{