add list create for payment instrument

This commit is contained in:
MahanCh
2025-08-05 15:51:53 +03:30
parent daa2a0fdc1
commit c7f7b17866
3 changed files with 65 additions and 13 deletions

View File

@@ -16,6 +16,7 @@ public interface IPaymentInstrumentApplication
/// <param name="command"></param>
/// <returns></returns>
Task<OperationResult> CreateBankAccount(CreateBankPaymentInstrument command);
Task<OperationResult> CreateBankAccount(List<CreateBankPaymentInstrument> commands);
/// <summary>
/// ایجاد اطلاعات دستگاه پوز
@@ -23,6 +24,7 @@ public interface IPaymentInstrumentApplication
/// <param name="command"></param>
/// <returns></returns>
Task<OperationResult> CreatePos(CreatePosPaymentInstrument command);
Task<OperationResult> CreatePos(List<CreatePosPaymentInstrument> commands);
/// <summary>
/// گرفتن لیست

View File

@@ -51,6 +51,41 @@ public class PaymentInstrumentApplication:IPaymentInstrumentApplication
}
public async Task<OperationResult> CreateBankAccount(List<CreateBankPaymentInstrument> commands)
{
var op = new OperationResult();
foreach (var command in commands)
{
if (command.IsAuth)
{
if (string.IsNullOrWhiteSpace(command.AccountNumber))
{
return op.Failed("شماره حساب نمیتواند خالی باشد");
}
if (string.IsNullOrWhiteSpace(command.IBan))
{
return op.Failed("شماره شبا نمیتواند خالی باشد");
}
if (string.IsNullOrWhiteSpace(command.CardNumber))
{
return op.Failed("شماره کارت نمیتواند خالی باشد");
}
if (string.IsNullOrWhiteSpace(command.AccountHolderName))
{
return op.Failed("نام صاحب حساب نمیتواند خالی باشد");
}
}
var entity = PaymentInstrument.CreateBankAccount(command.CardNumber, command.AccountHolderName, command.AccountNumber,
command.IBan, command.IsAuth,command.PaymentInstrumentGroupId);
await _paymentInstrumentRepository.CreateAsync(entity);
}
await _paymentInstrumentRepository.SaveChangesAsync();
return op.Succcedded();
}
public async Task<OperationResult> CreatePos(CreatePosPaymentInstrument command)
{
var op = new OperationResult();
@@ -65,6 +100,24 @@ public class PaymentInstrumentApplication:IPaymentInstrumentApplication
return op.Succcedded();
}
public async Task<OperationResult> CreatePos(List<CreatePosPaymentInstrument> commands)
{
var op = new OperationResult();
foreach (var command in commands)
{
if (string.IsNullOrWhiteSpace(command.PosTerminalId))
{
return op.Failed("شناسه دستگاه یوزر نمیتواند خالی باشد");
}
var entity = PaymentInstrument.CreatePosType(command.PosTerminalId, command.Description,command.PaymentInstrumentGroupId);
await _paymentInstrumentRepository.CreateAsync(entity);
}
await _paymentInstrumentRepository.SaveChangesAsync();
return op.Succcedded();
}
public async Task<GetPaymentInstrumentListViewModel> GetList(PaymentInstrumentSearchModel searchModel)
{
return await _paymentInstrumentRepository.GetList(searchModel);

View File

@@ -34,7 +34,7 @@ public class PaymentInstrumentController:AdminBaseController
/// <param name="command"></param>
/// <returns></returns>
[HttpPost("bankAccount")]
public async Task<ActionResult<OperationResult>> CreateBankAccount([FromBody] CreateBankPaymentInstrument command)
public async Task<ActionResult<OperationResult>> CreateBankAccount([FromBody] List<CreateBankPaymentInstrument> command)
{
var result = await _paymentInstrumentApplication.CreateBankAccount(command);
return result;
@@ -230,20 +230,17 @@ public class PaymentInstrumentController:AdminBaseController
[HttpPost("bank-account-inquiry")]
public async Task<ActionResult<OperationResult<BankInquiryResponse>>> GetBankInquiry(BankInquiryRequest command)
{
if ((!string.IsNullOrWhiteSpace(command.AccountNumber) && command.AccountNumber.StartsWith("111111")) || (!string.IsNullOrWhiteSpace(command.AccountNumber)&&command.BankNumber.StartsWith("111111")) || (!string.IsNullOrWhiteSpace(command.AccountNumber)&&command.IBan.StartsWith("1111111")))
if ((!string.IsNullOrWhiteSpace(command.AccountNumber) && command.AccountNumber.StartsWith("111111")) || (!string.IsNullOrWhiteSpace(command.BankNumber)&&command.BankNumber.StartsWith("111111")) || (!string.IsNullOrWhiteSpace(command.IBan)&&command.IBan.StartsWith("1111111")))
{
return new OperationResult<BankInquiryResponse>()
return new OperationResult<BankInquiryResponse>().Succcedded(new BankInquiryResponse()
{
Data = new BankInquiryResponse()
{
AccountNumber = "1111111",
IBan = "111111111111111111111111",
BankNumber = "1111111111111111",
AccountHolderName = "تست تستی",
BankName = "تست بانک",
}
};
}else if (command.AccountNumber.StartsWith("2222222") || command.BankNumber.StartsWith("2222222") || command.IBan.StartsWith("2222222"))
AccountNumber = "1111111",
IBan = "111111111111111111111111",
BankNumber = "1111111111111111",
AccountHolderName = "تست تستی",
BankName = "تست بانک",
});
}else if ((!string.IsNullOrWhiteSpace(command.AccountNumber) && command.AccountNumber.StartsWith("222222")) || (!string.IsNullOrWhiteSpace(command.AccountNumber)&&command.BankNumber.StartsWith("222222")) || (!string.IsNullOrWhiteSpace(command.AccountNumber)&&command.IBan.StartsWith("222222")))
{
return new OperationResult<BankInquiryResponse>().Failed("دیتای وارد شده نامعتبر است");
}