2023-04-04 19:21:57 +04:00
|
|
|
|
using BankYouBankruptBusinessLogic.OfficePackage.HelperModels;
|
|
|
|
|
using BankYouBankruptBusinessLogic.OfficePackage;
|
|
|
|
|
using BankYouBankruptContracts.BindingModels;
|
|
|
|
|
using BankYouBankruptContracts.BusinessLogicsContracts;
|
|
|
|
|
using BankYouBankruptContracts.SearchModels;
|
|
|
|
|
using BankYouBankruptContracts.StoragesContracts;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2023-05-18 17:56:47 +04:00
|
|
|
|
using BankYouBankruptContracts.ViewModels.Client.Reports;
|
2023-05-18 23:52:40 +04:00
|
|
|
|
using BankYouBankruptContracts.ViewModels;
|
2023-05-19 20:11:24 +04:00
|
|
|
|
using BankYouBankruptDataModels.Enums;
|
|
|
|
|
using BankYouBankruptContracts.ViewModels.Client.Default;
|
2023-04-04 19:21:57 +04:00
|
|
|
|
|
|
|
|
|
namespace BankYouBankruptBusinessLogic.BusinessLogics
|
|
|
|
|
{
|
|
|
|
|
public class ReportClientLogic : IReportClientLogic
|
|
|
|
|
{
|
|
|
|
|
private readonly ICreditingStorage _creditingStorage;
|
|
|
|
|
private readonly IDebitingStorage _debitingStorage;
|
2023-05-19 13:04:22 +04:00
|
|
|
|
private readonly ICardStorage _cardStorage;
|
|
|
|
|
private readonly IMoneyTransferStorage _moneyTransferStorage;
|
2023-04-04 19:21:57 +04:00
|
|
|
|
|
2023-05-19 13:04:22 +04:00
|
|
|
|
private readonly AbstractSaveToExcel _saveToExcel;
|
2023-04-04 19:21:57 +04:00
|
|
|
|
private readonly AbstractSaveToWordClient _saveToWord;
|
2023-05-19 13:04:22 +04:00
|
|
|
|
private readonly AbstractSaveToPdf _saveToPdf;
|
2023-04-04 19:21:57 +04:00
|
|
|
|
|
2023-04-04 19:27:13 +04:00
|
|
|
|
public ReportClientLogic(ICreditingStorage creditingStorage, IDebitingStorage debitingStorage,
|
2023-05-19 13:04:22 +04:00
|
|
|
|
AbstractSaveToExcel saveToExcel, AbstractSaveToWordClient saveToWord, AbstractSaveToPdf saveToPdf,
|
|
|
|
|
ICardStorage cardStorage, IMoneyTransferStorage moneyTransferStorage)
|
2023-04-04 19:21:57 +04:00
|
|
|
|
{
|
|
|
|
|
_creditingStorage = creditingStorage;
|
|
|
|
|
_debitingStorage = debitingStorage;
|
2023-05-19 13:04:22 +04:00
|
|
|
|
_cardStorage = cardStorage;
|
|
|
|
|
_moneyTransferStorage = moneyTransferStorage;
|
2023-04-04 19:21:57 +04:00
|
|
|
|
|
|
|
|
|
_saveToExcel = saveToExcel;
|
|
|
|
|
_saveToWord = saveToWord;
|
|
|
|
|
_saveToPdf = saveToPdf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ReportClientViewModel>? GetCrediting(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
return _creditingStorage.GetFilteredList(new CreditingSearchModel
|
|
|
|
|
{
|
2023-05-16 16:45:35 +04:00
|
|
|
|
DateFrom = model.DateFrom,
|
|
|
|
|
DateTo = model.DateTo,
|
2023-04-04 19:21:57 +04:00
|
|
|
|
}).Select(x => new ReportClientViewModel
|
|
|
|
|
{
|
2023-05-18 11:31:42 +04:00
|
|
|
|
OperationId = x.Id,
|
2023-05-18 00:04:33 +04:00
|
|
|
|
CardNumber = x.CardNumber,
|
|
|
|
|
SumOperation = x.Sum,
|
2023-05-16 16:45:35 +04:00
|
|
|
|
DateComplite = x.DateOpen
|
2023-04-04 19:21:57 +04:00
|
|
|
|
}).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ReportClientViewModel>? GetDebiting(ReportBindingModel model)
|
|
|
|
|
{
|
2023-04-04 19:27:13 +04:00
|
|
|
|
return _debitingStorage.GetFilteredList(new DebitingSearchModel
|
|
|
|
|
{
|
2023-05-16 16:45:35 +04:00
|
|
|
|
DateTo = model.DateFrom,
|
|
|
|
|
DateFrom = model.DateTo,
|
2023-04-04 19:27:13 +04:00
|
|
|
|
}).Select(x => new ReportClientViewModel
|
|
|
|
|
{
|
2023-05-18 11:31:42 +04:00
|
|
|
|
OperationId = x.Id,
|
2023-05-18 00:04:33 +04:00
|
|
|
|
CardNumber = x.CardNumber,
|
2023-04-04 19:27:13 +04:00
|
|
|
|
SumOperation = x.Sum,
|
2023-05-14 15:14:30 +04:00
|
|
|
|
DateComplite = x.DateClose
|
2023-04-04 19:27:13 +04:00
|
|
|
|
}).ToList();
|
2023-04-04 19:21:57 +04:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 20:11:24 +04:00
|
|
|
|
//для excel отчёта по переводам между счетов
|
2023-05-19 13:04:22 +04:00
|
|
|
|
public List<MoneyTransferViewModel>? GetMoneyTransfer(ReportBindingModel model)
|
2023-04-04 19:21:57 +04:00
|
|
|
|
{
|
2023-05-19 18:06:21 +04:00
|
|
|
|
//список счетов по выбранным картам
|
|
|
|
|
List<int> accountId = new();
|
|
|
|
|
|
|
|
|
|
foreach(var index in model.CardList)
|
2023-05-19 13:04:22 +04:00
|
|
|
|
{
|
2023-05-19 18:06:21 +04:00
|
|
|
|
accountId.Add(_cardStorage.GetElement(new CardSearchModel { Id = index}).AccountId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var list = accountId.ToHashSet().ToList();
|
|
|
|
|
|
|
|
|
|
List<MoneyTransferViewModel> totalList = new();
|
2023-04-04 19:21:57 +04:00
|
|
|
|
|
2023-05-19 18:06:21 +04:00
|
|
|
|
foreach (var index in list)
|
2023-05-19 13:04:22 +04:00
|
|
|
|
{
|
2023-05-19 18:06:21 +04:00
|
|
|
|
var result = _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel
|
|
|
|
|
{
|
|
|
|
|
AccountSenderId = index,
|
|
|
|
|
AccountPayeeId = index
|
|
|
|
|
}).OrderBy(x => x.AccountSenderId).ToList();
|
|
|
|
|
|
2023-05-19 20:11:24 +04:00
|
|
|
|
totalList.AddRange(result);
|
2023-05-19 18:06:21 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return totalList;
|
2023-04-04 19:21:57 +04:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 20:11:24 +04:00
|
|
|
|
//для excel отчёта по пополнениям карты
|
|
|
|
|
public List<CreditingViewModel> GetExcelCrediting(ReportBindingModel model)
|
2023-04-04 19:21:57 +04:00
|
|
|
|
{
|
2023-05-19 20:11:24 +04:00
|
|
|
|
List<CreditingViewModel> totalList = new();
|
|
|
|
|
|
|
|
|
|
foreach (var index in model.CardList)
|
2023-05-19 13:04:22 +04:00
|
|
|
|
{
|
2023-05-19 20:11:24 +04:00
|
|
|
|
var result = _creditingStorage.GetFilteredList(new CreditingSearchModel
|
|
|
|
|
{
|
|
|
|
|
CardId = index
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
totalList.AddRange(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return totalList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//для excel отчёта по снятиям с карты
|
|
|
|
|
public List<DebitingViewModel> GetExcelDebiting(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
List<DebitingViewModel> totalList = new();
|
|
|
|
|
|
|
|
|
|
foreach (var index in model.CardList)
|
|
|
|
|
{
|
|
|
|
|
var result = _debitingStorage.GetFilteredList(new DebitingSearchModel
|
|
|
|
|
{
|
|
|
|
|
CardId = index
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
totalList.AddRange(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return totalList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveToExcelFile(ReportBindingModel model, ExcelOperationEnum operationEnum)
|
|
|
|
|
{
|
|
|
|
|
if(operationEnum == ExcelOperationEnum.Между_cчетами)
|
|
|
|
|
{
|
|
|
|
|
_saveToExcel.CreateReport(new ExcelInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Отчёт по переводам",
|
|
|
|
|
MoneyTransfer = GetMoneyTransfer(model)
|
|
|
|
|
}, operationEnum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (operationEnum == ExcelOperationEnum.Пополнение_карт)
|
|
|
|
|
{
|
|
|
|
|
_saveToExcel.CreateReport(new ExcelInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Отчёт по пополнениям (переводам из налички на карту)",
|
|
|
|
|
Crediting = GetExcelCrediting(model)
|
|
|
|
|
}, operationEnum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (operationEnum == ExcelOperationEnum.Cнятие_с_карты)
|
|
|
|
|
{
|
|
|
|
|
_saveToExcel.CreateReport(new ExcelInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Отчёт по снятиям денежных средств",
|
2023-05-19 20:32:27 +04:00
|
|
|
|
Debiting = GetExcelDebiting(model)
|
2023-05-19 20:11:24 +04:00
|
|
|
|
}, operationEnum);
|
|
|
|
|
}
|
2023-05-19 13:04:22 +04:00
|
|
|
|
}
|
2023-04-04 19:21:57 +04:00
|
|
|
|
|
2023-05-19 13:04:22 +04:00
|
|
|
|
public void SaveToWordFile(ReportBindingModel model)
|
2023-04-04 19:21:57 +04:00
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2023-05-18 00:04:33 +04:00
|
|
|
|
|
|
|
|
|
//отчёт в формате PDF для клиента
|
2023-05-18 23:52:40 +04:00
|
|
|
|
public ReportClientViewModelForHTML SaveClientReportToPdfFile(ReportBindingModel model)
|
2023-05-18 00:04:33 +04:00
|
|
|
|
{
|
2023-05-18 23:52:40 +04:00
|
|
|
|
var listCreditings = GetCrediting(model);
|
|
|
|
|
var listDebitings = GetDebiting(model);
|
|
|
|
|
|
2023-05-18 00:47:56 +04:00
|
|
|
|
_saveToPdf.CreateDoc(new PdfInfo
|
2023-05-18 00:04:33 +04:00
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
2023-05-18 11:31:42 +04:00
|
|
|
|
Title = "Отчёт по операциям с картами",
|
2023-05-18 00:04:33 +04:00
|
|
|
|
DateFrom = model.DateFrom!.Value,
|
|
|
|
|
DateTo = model.DateTo!.Value,
|
2023-05-18 23:52:40 +04:00
|
|
|
|
ReportCrediting = listCreditings,
|
|
|
|
|
ReportDebiting = listDebitings
|
2023-05-18 00:04:33 +04:00
|
|
|
|
});
|
2023-05-18 23:52:40 +04:00
|
|
|
|
|
|
|
|
|
//возврат полученных списков для отображения на вебе
|
|
|
|
|
return new ReportClientViewModelForHTML
|
|
|
|
|
{
|
|
|
|
|
ReportCrediting = listCreditings,
|
|
|
|
|
|
|
|
|
|
ReportDebiting = listDebitings
|
|
|
|
|
};
|
2023-05-18 00:04:33 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-04 19:21:57 +04:00
|
|
|
|
}
|