From 9f33b481fad4a19b19ab143a09f8e0e669a87f8e Mon Sep 17 00:00:00 2001 From: SamSys Date: Sun, 20 Jul 2025 12:01:28 +0400 Subject: [PATCH 1/3] Add Create transaction metod --- ServiceHost/Controllers/GeneralController.cs | 21 ++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ServiceHost/Controllers/GeneralController.cs b/ServiceHost/Controllers/GeneralController.cs index 0fb71ed1..5964845d 100644 --- a/ServiceHost/Controllers/GeneralController.cs +++ b/ServiceHost/Controllers/GeneralController.cs @@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Mvc; using ServiceHost.BaseControllers; using System.Globalization; using _0_Framework.Application.PaymentGateway; +using CompanyManagment.App.Contracts.FinancialStatment; +using CompanyManagment.App.Contracts.FinancilTransaction; namespace ServiceHost.Controllers; @@ -14,10 +16,12 @@ public class GeneralController : GeneralBaseController private readonly IPaymentTransactionApplication _paymentTransactionApplication; private readonly IPaymentGateway _paymentGateway; + private readonly IFinancialStatmentApplication _financialStatmentApplication; - public GeneralController(IPaymentTransactionApplication paymentTransactionApplication,IHttpClientFactory clientFactory) + public GeneralController(IPaymentTransactionApplication paymentTransactionApplication,IHttpClientFactory clientFactory, IFinancialStatmentApplication financialStatmentApplication) { _paymentTransactionApplication = paymentTransactionApplication; + _financialStatmentApplication = financialStatmentApplication; _paymentGateway = new AqayePardakhtPaymentGateway(clientFactory); } @@ -79,12 +83,25 @@ public class GeneralController : GeneralBaseController if (verifyRes.IsSuccess) { var setSuccessResult = _paymentTransactionApplication.SetSuccess(paymentTransactionId, cardnumber, bank); - //TODO : افزودن دریافت درآمد به وضعیت مالی + if (!setSuccessResult.IsSuccedded) { return new JsonResult(setSuccessResult); } + //TODO : افزودن دریافت درآمد به وضعیت مالی + var command = new CreateFinancialStatment() + { + + ContractingPartyId = 0,// نیاز هست آی دی طرف حساب ارسال بشه + TdateFa = DateTime.Now.ToFarsi(), + Deptor = 0, + Creditor = transaction.Amount, + DeptorString = "درگاه بانکی", + TypeOfTransaction = "credit", + DescriptionOption = "بابت قرارداد مابین (روابط کار)", + }; + var result = _financialStatmentApplication.Create(command); return Redirect(BuildCallbackUrl(transaction.CallBackUrl, true, transaction.Id)); } From e9ab5c40ef84d9c31963b302b4845e6ff007c885 Mon Sep 17 00:00:00 2001 From: SamSys Date: Sun, 20 Jul 2025 13:25:12 +0400 Subject: [PATCH 2/3] Create Financial Transaction --- ServiceHost/Controllers/GeneralController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ServiceHost/Controllers/GeneralController.cs b/ServiceHost/Controllers/GeneralController.cs index 5964845d..88aa0100 100644 --- a/ServiceHost/Controllers/GeneralController.cs +++ b/ServiceHost/Controllers/GeneralController.cs @@ -92,7 +92,7 @@ public class GeneralController : GeneralBaseController var command = new CreateFinancialStatment() { - ContractingPartyId = 0,// نیاز هست آی دی طرف حساب ارسال بشه + ContractingPartyId = transaction.ContractingPartyId, TdateFa = DateTime.Now.ToFarsi(), Deptor = 0, Creditor = transaction.Amount, From bfd66329407d3eda24dcd2dab561d9cb068e8356 Mon Sep 17 00:00:00 2001 From: MahanCh Date: Sun, 20 Jul 2025 14:53:50 +0330 Subject: [PATCH 3/3] change the step from paymentCallBack - set transactionId on create PaymentGateway --- .../IPaymentTransactionApplication.cs | 2 ++ .../PaymentTransactionApplication.cs | 8 ++++++++ .../Client/Controllers/FinancialController.cs | 1 + ServiceHost/Controllers/GeneralController.cs | 14 +++++++------- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CompanyManagment.App.Contracts/PaymentTransaction/IPaymentTransactionApplication.cs b/CompanyManagment.App.Contracts/PaymentTransaction/IPaymentTransactionApplication.cs index 8564d7f5..3e86b7cf 100644 --- a/CompanyManagment.App.Contracts/PaymentTransaction/IPaymentTransactionApplication.cs +++ b/CompanyManagment.App.Contracts/PaymentTransaction/IPaymentTransactionApplication.cs @@ -50,6 +50,8 @@ public interface IPaymentTransactionApplication /// /// OperationResult SetSuccess(long paymentTransactionId, string cardNumber, string bankName); + + Task SetTransactionId(long id, string transactionId); } public class PaymentTransactionDetailsViewModel diff --git a/CompanyManagment.Application/PaymentTransactionApplication.cs b/CompanyManagment.Application/PaymentTransactionApplication.cs index cbe01756..cf4e1e0a 100644 --- a/CompanyManagment.Application/PaymentTransactionApplication.cs +++ b/CompanyManagment.Application/PaymentTransactionApplication.cs @@ -97,4 +97,12 @@ public class PaymentTransactionApplication : IPaymentTransactionApplication return op.Succcedded(); } + + public async Task SetTransactionId(long id, string transactionId) + { + var paymentTransaction = _paymentTransactionRepository.Get(id); + paymentTransaction.SetTransactionId(transactionId); + await _paymentTransactionRepository.SaveChangesAsync(); + return new OperationResult().Succcedded(); + } } \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Controllers/FinancialController.cs b/ServiceHost/Areas/Client/Controllers/FinancialController.cs index 56b8d83d..8cb66001 100644 --- a/ServiceHost/Areas/Client/Controllers/FinancialController.cs +++ b/ServiceHost/Areas/Client/Controllers/FinancialController.cs @@ -88,6 +88,7 @@ public class FinancialController : ClientBaseController if (gatewayResponse.IsSuccess) { + _ = await _paymentTransactionApplication.SetTransactionId(transaction.SendId, gatewayResponse.TransactionId); return op.Succcedded(_paymentGateway.GetStartPayUrl(gatewayResponse.TransactionId)); } diff --git a/ServiceHost/Controllers/GeneralController.cs b/ServiceHost/Controllers/GeneralController.cs index 88aa0100..d11350a1 100644 --- a/ServiceHost/Controllers/GeneralController.cs +++ b/ServiceHost/Controllers/GeneralController.cs @@ -83,12 +83,7 @@ public class GeneralController : GeneralBaseController if (verifyRes.IsSuccess) { var setSuccessResult = _paymentTransactionApplication.SetSuccess(paymentTransactionId, cardnumber, bank); - - if (!setSuccessResult.IsSuccedded) - { - return new JsonResult(setSuccessResult); - } - //TODO : افزودن دریافت درآمد به وضعیت مالی + var command = new CreateFinancialStatment() { @@ -101,7 +96,12 @@ public class GeneralController : GeneralBaseController DescriptionOption = "بابت قرارداد مابین (روابط کار)", }; - var result = _financialStatmentApplication.Create(command); + _financialStatmentApplication.Create(command); + + if (!setSuccessResult.IsSuccedded) + { + return new JsonResult(setSuccessResult); + } return Redirect(BuildCallbackUrl(transaction.CallBackUrl, true, transaction.Id)); }