change smsResult grouping

This commit is contained in:
gozareshgir
2026-01-13 16:26:04 +03:30
parent f5c8888137
commit b5c5be2cb6
7 changed files with 37 additions and 46 deletions

View File

@@ -77,6 +77,9 @@ public class SmsResultRepository : RepositoryBase<long, SmsResult>, ISmsResultRe
case TypeOfSmsSetting.SendInstitutionContractConfirmationCode:
typeOfSms = "کد تاییدیه قرارداد مالی";
break;
case TypeOfSmsSetting.SendInstitutionContractConfirmationLink:
typeOfSms = "لینک تاییدیه ایجاد قرارداد مالی";
break;
case TypeOfSmsSetting.TaskReminder:
typeOfSms = "یادآور وظایف";
break;
@@ -147,7 +150,7 @@ public class SmsResultRepository : RepositoryBase<long, SmsResult>, ISmsResultRe
// مرحله 2: گروه‌بندی و انتخاب آخرین رکورد هر روز روی Client
var grouped = rawQuery
.GroupBy(x => x.DateOnly)
.GroupBy(x => (x.DateOnly, x.TypeOfSms))
.Select(g => g.OrderByDescending(x => x.CreationDate).First())
.OrderByDescending(x => x.CreationDate)
.ToList();
@@ -155,15 +158,16 @@ public class SmsResultRepository : RepositoryBase<long, SmsResult>, ISmsResultRe
// مرحله 3: تبدیل به DTO و ToFarsi
var result = grouped.Select(x => new SmsReportDto
{
SentDate = x.CreationDate.ToFarsi()
SentDate = x.CreationDate.ToFarsi(),
TypeOfSms = x.TypeOfSms
}).ToList();
return result;
}
public async Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date)
public async Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date, string typeOfSmsSetting)
{
if(string.IsNullOrWhiteSpace(date))
if(string.IsNullOrWhiteSpace(date) || string.IsNullOrWhiteSpace(typeOfSmsSetting))
return new List<SmsReportListDto>();
if (date.TryToGeorgianDateTime(out var searchDate) == false)
@@ -198,41 +202,12 @@ public class SmsResultRepository : RepositoryBase<long, SmsResult>, ISmsResultRe
query = query.Where(x => x.Mobile.Contains(searchModel.Mobile)).ToList();
}
if (searchModel.TypeOfSms != TypeOfSmsSetting.All && searchModel.TypeOfSms != TypeOfSmsSetting.Warning)
{
var typeOfSms = "All";
switch (searchModel.TypeOfSms)
{
case TypeOfSmsSetting.InstitutionContractDebtReminder:
typeOfSms = "یادآور بدهی ماهانه";
break;
case TypeOfSmsSetting.MonthlyInstitutionContract:
typeOfSms = "صورت حساب ماهانه";
break;
case TypeOfSmsSetting.BlockContractingParty:
typeOfSms = "اعلام مسدودی طرف حساب";
break;
case TypeOfSmsSetting.LegalAction:
typeOfSms = "اقدام قضایی";
break;
case TypeOfSmsSetting.InstitutionContractConfirm:
typeOfSms = "یادآور تایید قرارداد مالی";
break;
case TypeOfSmsSetting.SendInstitutionContractConfirmationCode:
typeOfSms = "کد تاییدیه قرارداد مالی";
break;
case TypeOfSmsSetting.TaskReminder:
typeOfSms = "یادآور وظایف";
break;
}
query = query.Where(x => x.TypeOfSms == typeOfSms).ToList();
}
if (searchModel.TypeOfSms == TypeOfSmsSetting.Warning)
if (typeOfSmsSetting.Contains("هشدار"))
{
query = query.Where(x => x.TypeOfSms.Contains("هشدار")).ToList();
}
query = query.Where(x => x.TypeOfSms == typeOfSmsSetting).ToList();
if (searchModel.SendStatus != SendStatus.All)
{