From 255d13049ecfcf2bc8c47c9abc6e48d3bfcbe66e Mon Sep 17 00:00:00 2001 From: MahanCh Date: Tue, 8 Jul 2025 16:50:09 +0330 Subject: [PATCH] add payment transaction --- .../IPaymentTransactionRepository.cs | 10 ++ .../PaymentTransaction.cs | 102 ++++++++++++++++++ .../CompanyManagment.App.Contracts.csproj | 2 +- .../GetPaymentTransactionListSearchModel.cs | 38 +++++++ .../GetPaymentTransactionListViewModel.cs | 63 +++++++++++ .../IPaymentTransactionApplication.cs | 72 +++++++++++++ .../PaymentTransactionStatus.cs | 17 +++ .../PaymentTransactionApplication.cs | 42 ++++++++ CompanyManagment.EFCore/CompanyContext.cs | 2 + .../Mapping/PaymentTransactionMapping.cs | 24 +++++ .../PaymentTransactionRepository.cs | 35 ++++++ 11 files changed, 406 insertions(+), 1 deletion(-) create mode 100644 Company.Domain/PaymentTransactionAgg/IPaymentTransactionRepository.cs create mode 100644 Company.Domain/PaymentTransactionAgg/PaymentTransaction.cs create mode 100644 CompanyManagment.App.Contracts/PaymentTransaction/GetPaymentTransactionListSearchModel.cs create mode 100644 CompanyManagment.App.Contracts/PaymentTransaction/GetPaymentTransactionListViewModel.cs create mode 100644 CompanyManagment.App.Contracts/PaymentTransaction/IPaymentTransactionApplication.cs create mode 100644 CompanyManagment.App.Contracts/PaymentTransaction/PaymentTransactionStatus.cs create mode 100644 CompanyManagment.Application/PaymentTransactionApplication.cs create mode 100644 CompanyManagment.EFCore/Mapping/PaymentTransactionMapping.cs create mode 100644 CompanyManagment.EFCore/Repository/PaymentTransactionRepository.cs diff --git a/Company.Domain/PaymentTransactionAgg/IPaymentTransactionRepository.cs b/Company.Domain/PaymentTransactionAgg/IPaymentTransactionRepository.cs new file mode 100644 index 00000000..cccf659d --- /dev/null +++ b/Company.Domain/PaymentTransactionAgg/IPaymentTransactionRepository.cs @@ -0,0 +1,10 @@ +using System.Threading.Tasks; +using _0_Framework.Domain; +using CompanyManagment.App.Contracts.PaymentTransaction; + +namespace Company.Domain.PaymentTransactionAgg; + +public interface IPaymentTransactionRepository:IRepository +{ + Task GetPaymentTransactionList(GetPaymentTransactionListSearchModel searchModel); +} \ No newline at end of file diff --git a/Company.Domain/PaymentTransactionAgg/PaymentTransaction.cs b/Company.Domain/PaymentTransactionAgg/PaymentTransaction.cs new file mode 100644 index 00000000..153b78db --- /dev/null +++ b/Company.Domain/PaymentTransactionAgg/PaymentTransaction.cs @@ -0,0 +1,102 @@ +using System; +using _0_Framework.Domain; +using CompanyManagment.App.Contracts.PaymentTransaction; + +namespace Company.Domain.PaymentTransactionAgg +{ + /// + /// نمایانگر یک تراکنش پرداخت شامل جزئیات طرف قرارداد، اطلاعات بانکی، وضعیت تراکنش و مبلغ. + /// + public class PaymentTransaction:EntityBase + { + /// + /// سازنده کلاس PaymentTransaction با دریافت اطلاعات تراکنش. + /// + /// شناسه طرف قرارداد + /// نام صاحب حساب بانکی + /// نام بانک + /// شماره کارت + /// شماره شبا + /// شماره حساب بانکی + /// وضعیت تراکنش پرداخت + /// مبلغ تراکنش + /// شناسه یکتای تراکنش + public PaymentTransaction( + long contractingPartyId, + string bankAccountHolderName, + string bankName, + string cardNumber, + string shebaNumber, + string accountNumber, + PaymentTransactionStatus status, + double amount, + string transactionId) + { + PaymentDateTime = DateTime.Now; + ContractingPartyId = contractingPartyId; + BankAccountHolderName = bankAccountHolderName; + BankName = bankName; + CardNumber = cardNumber; + ShebaNumber = shebaNumber; + AccountNumber = accountNumber; + Status = status; + Amount = amount; + TransactionId = transactionId; + } + + /// + /// تاریخ و زمان انجام پرداخت + /// + public DateTime PaymentDateTime { get; set; } + + /// + /// شناسه طرف حساب + /// + public long ContractingPartyId { get; set; } + + /// + /// نام طرف حساب + /// + public string ContractingPartyName { get; set; } + + /// + /// نام صاحب حساب بانکی + /// + public string BankAccountHolderName { get; set; } + + /// + /// نام بانک + /// + public string BankName { get; set; } + + /// + /// شماره کارت + /// + public string CardNumber { get; set; } + + /// + /// شماره شبا + /// + public string ShebaNumber { get; set; } + + /// + /// شماره حساب بانکی + /// + public string AccountNumber { get; set; } + + /// + /// وضعیت تراکنش پرداخت + /// + public PaymentTransactionStatus Status { get; set; } + + /// + /// مبلغ تراکنش + /// + public double Amount { get; set; } + + /// + /// شناسه یکتای تراکنش + /// + public string TransactionId { get; set; } + } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/CompanyManagment.App.Contracts.csproj b/CompanyManagment.App.Contracts/CompanyManagment.App.Contracts.csproj index affffa78..b2977176 100644 --- a/CompanyManagment.App.Contracts/CompanyManagment.App.Contracts.csproj +++ b/CompanyManagment.App.Contracts/CompanyManagment.App.Contracts.csproj @@ -1,4 +1,4 @@ - + net8.0 diff --git a/CompanyManagment.App.Contracts/PaymentTransaction/GetPaymentTransactionListSearchModel.cs b/CompanyManagment.App.Contracts/PaymentTransaction/GetPaymentTransactionListSearchModel.cs new file mode 100644 index 00000000..f1d01e7f --- /dev/null +++ b/CompanyManagment.App.Contracts/PaymentTransaction/GetPaymentTransactionListSearchModel.cs @@ -0,0 +1,38 @@ +namespace CompanyManagment.App.Contracts.PaymentTransaction; + +/// +/// مدل جستجو برای دریافت لیست تراکنش‌های پرداخت. +/// شامل فیلترهایی مانند نام طرف قرارداد یا صاحب حساب، بازه تاریخ، بازه مبلغ و وضعیت تراکنش. +/// +public class GetPaymentTransactionListSearchModel +{ + /// + /// نام طرف قرارداد یا صاحب حساب بانکی جهت جستجو + /// + public string ContractingPartyOrAccountHolderName { get; set; } + + /// + /// تاریخ شروع بازه جستجو (به صورت رشته) + /// + public string FromDate { get; set; } + + /// + /// تاریخ پایان بازه جستجو (به صورت رشته) + /// + public string ToDate { get; set; } + + /// + /// حداقل مبلغ تراکنش جهت جستجو + /// + public double FromAmount { get; set; } + + /// + /// حداکثر مبلغ تراکنش جهت جستجو + /// + public double ToAmount { get; set; } + + /// + /// وضعیت تراکنش جهت فیلتر کردن نتایج + /// + public PaymentTransactionStatus? StatusEnum { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/PaymentTransaction/GetPaymentTransactionListViewModel.cs b/CompanyManagment.App.Contracts/PaymentTransaction/GetPaymentTransactionListViewModel.cs new file mode 100644 index 00000000..2307e722 --- /dev/null +++ b/CompanyManagment.App.Contracts/PaymentTransaction/GetPaymentTransactionListViewModel.cs @@ -0,0 +1,63 @@ +namespace CompanyManagment.App.Contracts.PaymentTransaction; + +/// +/// مدل نمایش اطلاعات هر تراکنش پرداخت در لیست تراکنش‌ها. +/// شامل جزئیاتی مانند تاریخ و زمان پرداخت، نام طرف حساب، اطلاعات بانکی، وضعیت و مبلغ تراکنش. +/// +public class GetPaymentTransactionListViewModel +{ + /// + /// تاریخ پرداخت + /// + public string PaymentDate { get; set; } + + /// + /// زمان پرداخت + /// + public string PaymentTime { get; set; } + + /// + /// نام طرف حساب + /// + public string ContractingPartyName { get; set; } + + /// + /// نام صاحب حساب بانکی + /// + public string BankAccountHolderName { get; set; } + + /// + /// نام بانک + /// + public string BankName { get; set; } + + /// + /// شماره کارت + /// + public string CardNumber { get; set; } + + /// + /// شماره شبا + /// + public string ShebaNumber { get; set; } + + /// + /// شماره حساب بانکی + /// + public string AccountNumber { get; set; } + + /// + /// وضعیت تراکنش به صورت متنی + /// + public string Status { get; set; } + + /// + /// وضعیت تراکنش به صورت Enum + /// + public PaymentTransactionStatus StatusEnum { get; set; } + + /// + /// مبلغ تراکنش + /// + public double Amount { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/PaymentTransaction/IPaymentTransactionApplication.cs b/CompanyManagment.App.Contracts/PaymentTransaction/IPaymentTransactionApplication.cs new file mode 100644 index 00000000..879a0c1d --- /dev/null +++ b/CompanyManagment.App.Contracts/PaymentTransaction/IPaymentTransactionApplication.cs @@ -0,0 +1,72 @@ +using System.Threading.Tasks; +using _0_Framework.Application; + +namespace CompanyManagment.App.Contracts.PaymentTransaction; + +/// +/// +/// +public interface IPaymentTransactionApplication +{ + /// + /// لیست تراکنش های پرداخت را بر اساس فیلتر مشخص شده برمی گرداند. + /// + /// + /// + Task GetPaymentTransactionList(GetPaymentTransactionListSearchModel searchModel); + /// + /// ایجاد تراکنش + /// + /// + /// + Task Create(CreatePaymentTransaction command); + +} + +public class CreatePaymentTransaction +{ + /// + /// شناسه طرف قرارداد + /// + public long ContractingPartyId { get; set; } + + /// + /// نام صاحب حساب بانکی + /// + public string BankAccountHolderName { get; set; } + + /// + /// نام بانک + /// + public string BankName { get; set; } + + /// + /// شماره کارت + /// + public string CardNumber { get; set; } + + /// + /// شماره شبا + /// + public string ShebaNumber { get; set; } + + /// + /// شماره حساب بانکی + /// + public string AccountNumber { get; set; } + + /// + /// وضعیت تراکنش پرداخت + /// + public PaymentTransactionStatus Status { get; set; } + + /// + /// مبلغ تراکنش + /// + public double Amount { get; set; } + + /// + /// شناسه یکتای تراکنش + /// + public string TransactionId { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/PaymentTransaction/PaymentTransactionStatus.cs b/CompanyManagment.App.Contracts/PaymentTransaction/PaymentTransactionStatus.cs new file mode 100644 index 00000000..f557d3ae --- /dev/null +++ b/CompanyManagment.App.Contracts/PaymentTransaction/PaymentTransactionStatus.cs @@ -0,0 +1,17 @@ +namespace CompanyManagment.App.Contracts.PaymentTransaction; + +/// +/// وضعیت تراکنش درگاه پرداخت +/// +public enum PaymentTransactionStatus +{ + /// + /// تراکنش با موفقیت انجام شد. + /// + Success, + + /// + /// تراکنش با شکست مواجه شد. + /// + Failed +} \ No newline at end of file diff --git a/CompanyManagment.Application/PaymentTransactionApplication.cs b/CompanyManagment.Application/PaymentTransactionApplication.cs new file mode 100644 index 00000000..a57acb74 --- /dev/null +++ b/CompanyManagment.Application/PaymentTransactionApplication.cs @@ -0,0 +1,42 @@ +using System.Reflection; +using System.Threading.Tasks; +using _0_Framework.Application; +using Company.Domain.PaymentTransactionAgg; +using CompanyManagment.App.Contracts.PaymentTransaction; + +namespace CompanyManagment.Application; + +public class PaymentTransactionApplication : IPaymentTransactionApplication +{ + private readonly IPaymentTransactionRepository _paymentTransactionRepository; + + public PaymentTransactionApplication(IPaymentTransactionRepository paymentTransactionRepository) + { + _paymentTransactionRepository = paymentTransactionRepository; + } + + public async Task GetPaymentTransactionList( + GetPaymentTransactionListSearchModel searchModel) + { + return await _paymentTransactionRepository.GetPaymentTransactionList(searchModel); + } + + public async Task Create(CreatePaymentTransaction command) + { + var operationResult = new OperationResult(); + var entity = new PaymentTransaction( + command.ContractingPartyId, + command.BankAccountHolderName, + command.BankName, + command.CardNumber, + command.ShebaNumber, + command.AccountNumber, + command.Status, + command.Amount, + command.TransactionId); + + await _paymentTransactionRepository.CreateAsync(entity); + await _paymentTransactionRepository.SaveChangesAsync(); + return operationResult.Succcedded(); + } +} \ No newline at end of file diff --git a/CompanyManagment.EFCore/CompanyContext.cs b/CompanyManagment.EFCore/CompanyContext.cs index 3697248b..a0733ef4 100644 --- a/CompanyManagment.EFCore/CompanyContext.cs +++ b/CompanyManagment.EFCore/CompanyContext.cs @@ -77,6 +77,7 @@ using Company.Domain.ModuleTextManagerAgg; using Company.Domain.OriginalTitleAgg; using Company.Domain.PaymentToEmployeeAgg; using Company.Domain.PaymentToEmployeeItemAgg; +using Company.Domain.PaymentTransactionAgg; using Company.Domain.PenaltyTitle; using Company.Domain.PercentageAgg; using Company.Domain.PersonnelCodeAgg; @@ -178,6 +179,7 @@ public class CompanyContext : DbContext public DbSet EmployeeAuthorizeTemps { get; set; } public DbSet AdminMonthlyOverviews { get; set; } + public DbSet PaymentTransactions{ get; set; } #endregion #region Pooya diff --git a/CompanyManagment.EFCore/Mapping/PaymentTransactionMapping.cs b/CompanyManagment.EFCore/Mapping/PaymentTransactionMapping.cs new file mode 100644 index 00000000..9a8742e1 --- /dev/null +++ b/CompanyManagment.EFCore/Mapping/PaymentTransactionMapping.cs @@ -0,0 +1,24 @@ +using Company.Domain.PaymentTransactionAgg; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CompanyManagment.EFCore.Mapping; + +public class PaymentTransactionMapping:IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("PaymentTransactions"); + builder.HasKey(pt => pt.id); + + builder.Property(x => x.TransactionId).HasMaxLength(60); + builder.Property(x => x.CardNumber).HasMaxLength(25); + builder.Property(x => x.AccountNumber).HasMaxLength(25); + builder.Property(x => x.BankName).HasMaxLength(50); + builder.Property(x => x.BankAccountHolderName).HasMaxLength(255); + builder.Property(x => x.Status).HasConversion().HasMaxLength(35); + builder.Property(x => x.ShebaNumber).HasMaxLength(30); + builder.Property(x => x.ContractingPartyName).HasMaxLength(255); + + } +} \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/PaymentTransactionRepository.cs b/CompanyManagment.EFCore/Repository/PaymentTransactionRepository.cs new file mode 100644 index 00000000..003c274e --- /dev/null +++ b/CompanyManagment.EFCore/Repository/PaymentTransactionRepository.cs @@ -0,0 +1,35 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using _0_Framework.InfraStructure; +using Company.Domain.PaymentTransactionAgg; +using CompanyManagment.App.Contracts.PaymentTransaction; +using Microsoft.EntityFrameworkCore; + +namespace CompanyManagment.EFCore.Repository; + +public class PaymentTransactionRepository:RepositoryBase,IPaymentTransactionRepository +{ + private readonly CompanyContext _companyContext; + public PaymentTransactionRepository(DbContext context, CompanyContext companyContext) : base(context) + { + _companyContext = companyContext; + } + + public Task GetPaymentTransactionList(GetPaymentTransactionListSearchModel searchModel) + { + var query = _companyContext.PaymentTransactions.AsQueryable(); + if (!string.IsNullOrWhiteSpace(searchModel.ContractingPartyOrAccountHolderName)) + { + query = query.Where(x=>searchModel.ContractingPartyOrAccountHolderName.Contains(x.ContractingPartyName)|| + searchModel.ContractingPartyOrAccountHolderName.Contains(x.BankAccountHolderName)); + } + + if (!string.IsNullOrWhiteSpace(searchModel.FromDate) && !string.IsNullOrWhiteSpace(searchModel.ToDate)) + { + + } + + throw new NotImplementedException(); + } +} \ No newline at end of file