diff --git a/0_Framework/Application/Tools.cs b/0_Framework/Application/Tools.cs
index 98f58bb9..23afe3cb 100644
--- a/0_Framework/Application/Tools.cs
+++ b/0_Framework/Application/Tools.cs
@@ -1512,6 +1512,14 @@ public static class Tools
#region Mahan
+ public static bool IsvalidIban(this string iban)
+ {
+ return Regex.IsMatch(iban, @"^IR[0-9]{24}$");
+ }
+ public static bool IsValidCardNumber(this string cardNumber)
+ {
+ return Regex.IsMatch(cardNumber, @"^[0-9]{16}$");
+ }
///
/// این متد حروف عربی را به فارسی در میاورد. مثال: علي را به علی تبدیل میکند
///
diff --git a/0_Framework/Application/UID/IUidService.cs b/0_Framework/Application/UID/IUidService.cs
index c2c26bd5..a3350dfa 100644
--- a/0_Framework/Application/UID/IUidService.cs
+++ b/0_Framework/Application/UID/IUidService.cs
@@ -110,6 +110,53 @@ public interface IUidService
{
Task GetPersonalInfo(string nationalCode , string birthDate);
Task IsMachPhoneWithNationalCode(string nationalCode , string phoneNumber);
+ Task IbanInquiry (string iban);
+ Task AccountToIban(string accountNumber, UidBanks bank);
+ Task CardToIban(string cardNumber);
+}
+
+public class CardToNumberResponse:UidBaseResponse
+{
+ public string Iban { get; set; }
+ public string CardNumber { get; set; }
+}
+
+public class AccountToIbanResponse:UidBaseResponse
+{
+ public string Iban { get; set; }
+}
+
+public class IbanInquiryResponse:UidBaseResponse
+{
+ public IbanInquiryAccountBasicInformation AccountBasicInformation { get; set; }
+ [JsonProperty("owners")]
+ public List Owners { get; set; }
+}
+
+public class IbanInquiryAccountBasicInformation
+{
+ public string Iban { get; set; }
+ public string AccountNumber { get; set; }
+ public IbanInquiryBankInformation BankInformation { get; set; }
+ public string AccountStatus { get; set; }
+
+}
+
+public class IbanInquiryBankInformation
+{
+ public string BankName { get; set; }
+}
+
+public class IbanInquiryOwner
+{
+ [JsonProperty("firstName")]
+ public string FirstName { get; set; }
+ [JsonProperty("lastName")]
+ public string LastName { get; set; }
+ [JsonProperty("nationalIdentifier")]
+ public string NationalIdentifier { get; set; }
+ [JsonProperty("customerType")]
+ public string CustomerType { get; set; }
}
public class MatchMobileWithNationalCodeResponse
@@ -118,4 +165,7 @@ public class MatchMobileWithNationalCodeResponse
public ResponseContext ResponseContext { get; set; }
}
-
+public class UidBaseResponse
+{
+ public ResponseContext ResponseContext { get; set; }
+}
diff --git a/0_Framework/Application/UID/UidBanks.cs b/0_Framework/Application/UID/UidBanks.cs
new file mode 100644
index 00000000..16e0c3d4
--- /dev/null
+++ b/0_Framework/Application/UID/UidBanks.cs
@@ -0,0 +1,117 @@
+using System.ComponentModel;
+
+namespace _0_Framework.Application.UID;
+
+public enum UidBanks
+{
+ [Description("بانک دی")]
+ BANK_DEY = 66,
+
+ [Description("بانک سپه")]
+ BANK_SEPAH = 15,
+
+ [Description("بانک شهر")]
+ BANK_SHAHR = 61,
+
+ [Description("بانک ملت")]
+ BANK_MELAT = 12,
+
+ [Description("بانک ملی")]
+ BANK_MELLI = 17,
+
+ [Description("بانک رفاه کارگران")]
+ BANK_REFAH = 13,
+
+ [Description("بانک سینا")]
+ BANK_SINA = 59,
+
+ [Description("بانک مسکن")]
+ BANK_MASKAN = 14,
+
+ [Description("بانک آینده")]
+ BANK_AYANDEH = 62,
+
+ [Description("بانک انصار")]
+ BANK_ANSAR = 63,
+
+ [Description("بانک تجارت")]
+ BANK_TEJARAT = 18,
+
+ [Description("بانک رسالت")]
+ BANK_RESALAT = 70,
+
+ [Description("بانک سامان")]
+ BANK_SAMAN = 56,
+
+ [Description("بانک مرکزی")]
+ BANK_MARKAZI = 10,
+
+ [Description("بانک سرمایه")]
+ BANK_SARMAYEH = 58,
+
+ [Description("بانک صادرات")]
+ BANK_SADERAT = 19,
+
+ [Description("بانک قوامین")]
+ BANK_GHAVAMIN = 52,
+
+ [Description("بانک پارسیان")]
+ BANK_PARSIAN = 54,
+
+ [Description("بانک کشاورزی")]
+ BANK_KESHAVARZI = 16,
+
+ [Description("بانک گردشگری")]
+ BANK_GARDESHGARI = 64,
+
+ [Description("پست بانک")]
+ BANK_POST_BANK = 21,
+
+ [Description("بانک پاسارگاد")]
+ BANK_PASARGAD = 57,
+
+ [Description("بانک کارآفرین")]
+ BANK_KARAFARIN = 53,
+
+ [Description("بانک خاورمیانه")]
+ BANK_KHAVARMIANEH = 78,
+
+ [Description("بانک ایران زمین")]
+ BANK_IRAN_ZAMIN = 69,
+
+ [Description("بانک مهر اقتصاد")]
+ BANK_MEHR_EQTESAD = 79,
+
+ [Description("بانک صنعت و معدن")]
+ BANK_SANAT_MADAN = 11,
+
+ [Description("بانک اقتصاد نوین")]
+ BANK_EGHTESAD_NOVIN = 55,
+
+ [Description("بانک توسعه تعاون")]
+ BANK_TOSSE_TAAVON = 22,
+
+ [Description("بانک توسعه صادرات")]
+ BANK_TOSSE_SADERAT = 20,
+
+ [Description("بانک ایران و ونزوئلا")]
+ BANK_IRAN_VENEZUELA = 95,
+
+ [Description("بانک حکمت ایرانیان")]
+ BANK_HEKMAT_IRANIAN = 65,
+
+ [Description("بانک قرض الحسنه مهر")]
+ BANK_GHARZOLHASANEH_MEHR = 60,
+
+ [Description("موسسه مالی و اعتباری ملل")]
+ BANK_MOASSASE_MELLAL = 75,
+
+ [Description("موسسه مالی و اعتباری نور")]
+ BANK_MOASSASE_NOOR = 80,
+
+ [Description("موسسه مالی و اعتباری کوثر")]
+ BANK_MOASSASE_KOSAR = 73,
+
+ [Description("موسسه مالی و اعتباری توسعه")]
+ BANK_MOASSASE_TOSSE = 51
+}
\ No newline at end of file
diff --git a/0_Framework/Application/UID/UidBanksExtension.cs b/0_Framework/Application/UID/UidBanksExtension.cs
new file mode 100644
index 00000000..98a46f16
--- /dev/null
+++ b/0_Framework/Application/UID/UidBanksExtension.cs
@@ -0,0 +1,27 @@
+using System;
+using System.ComponentModel;
+using System.Reflection;
+
+namespace _0_Framework.Application.UID
+{
+ public static class UidBanksExtension
+ {
+ ///
+ /// دریافت نام فارسی بانک
+ ///
+ /// بانک
+ /// نام فارسی بانک
+ public static string GetPersianName(this UidBanks bank)
+ {
+ var fieldInfo = bank.GetType().GetField(bank.ToString());
+
+ if (fieldInfo == null)
+ return string.Empty;
+
+ var attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(
+ fieldInfo, typeof(DescriptionAttribute));
+
+ return attribute?.Description ?? bank.ToString();
+ }
+ }
+}
diff --git a/CompanyManagment.App.Contracts/ContractingPartyBankAccounts/IContractingPartyBankAccountsApplication.cs b/CompanyManagment.App.Contracts/ContractingPartyBankAccounts/IContractingPartyBankAccountsApplication.cs
index 379f07df..f4864441 100644
--- a/CompanyManagment.App.Contracts/ContractingPartyBankAccounts/IContractingPartyBankAccountsApplication.cs
+++ b/CompanyManagment.App.Contracts/ContractingPartyBankAccounts/IContractingPartyBankAccountsApplication.cs
@@ -1,8 +1,10 @@
using System.Collections.Generic;
using System.Security.AccessControl;
+using System.Security.Cryptography;
using System.Threading.Tasks;
using System.Transactions;
using _0_Framework.Application;
+using _0_Framework.Application.UID;
using CompanyManagment.App.Contracts.OriginalTitle;
namespace CompanyManagment.App.Contracts.ContractingPartyBankAccounts;
@@ -74,5 +76,27 @@ public interface IContractingPartyBankAccountsApplication
/// نام سلکت شده
///
Task> ContractingPartyNamesSelectList(string search, string selected);
+
+ ///
+ /// احراز هویت اطلاعات بانکی طرف حساب
+ ///
+ ///
+ ///
+ Task InquiryContractingPartyBankDetails(InquiryContractingPartyBankDetailsRequest command);
+
+}
+public class InquiryContractingPartyBankDetailsRequest
+{
+ public string CardNumber { get; set; }
+ public string AccountNumber { get; set; }
+ public string IBan { get; set; }
+ public UidBanks UidBank { get; set; }
+}
+public class ContractingPartyBankInquiryResponse
+{
+ public string FullName { get; set; }
+ public string Iban { get; set; }
+ public string AccountNumber { get; set; }
+ public string CardNumber { get; set; }
}
diff --git a/CompanyManagment.Application/ContractingPartyBankAccountsApplication.cs b/CompanyManagment.Application/ContractingPartyBankAccountsApplication.cs
index e9a81eba..e1e1dc0a 100644
--- a/CompanyManagment.Application/ContractingPartyBankAccountsApplication.cs
+++ b/CompanyManagment.Application/ContractingPartyBankAccountsApplication.cs
@@ -1,6 +1,10 @@
using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
using System.Threading.Tasks;
using _0_Framework.Application;
+using _0_Framework.Application.UID;
+using _0_Framework.Exceptions;
using Company.Domain.ContarctingPartyAgg;
using Company.Domain.ContractingPartyBankAccountsAgg;
using CompanyManagment.App.Contracts.ContractingPartyBankAccounts;
@@ -12,13 +16,15 @@ public class ContractingPartyBankAccountsApplication : IContractingPartyBankAcco
{
private readonly IContractingPartyBankAccountsRepository _contractingPartyBankAccountsRepository;
private readonly IPersonalContractingPartyRepository _personalContractingPartyRepository;
+ private readonly IUidService _uidService;
public ContractingPartyBankAccountsApplication(
IContractingPartyBankAccountsRepository contractingPartyBankAccountsRepository,
- IPersonalContractingPartyRepository personalContractingPartyRepository)
+ IPersonalContractingPartyRepository personalContractingPartyRepository, IUidService uidService)
{
_contractingPartyBankAccountsRepository = contractingPartyBankAccountsRepository;
_personalContractingPartyRepository = personalContractingPartyRepository;
+ _uidService = uidService;
}
public async Task Create(CreateContractingPartyBankAccounts command)
@@ -69,18 +75,19 @@ public class ContractingPartyBankAccountsApplication : IContractingPartyBankAcco
if (string.IsNullOrWhiteSpace(command.IBan))
return operationResult.Failed("شماره شبا خود را وارد کنید");
}
- else if(string.IsNullOrWhiteSpace(command.CardNumber) &&
+ else if (string.IsNullOrWhiteSpace(command.CardNumber) &&
string.IsNullOrWhiteSpace(command.AccountNumber) &&
string.IsNullOrWhiteSpace(command.IBan))
{
- return operationResult.Failed(" حداقل یکی از اطلاعات بانکی را وارد کنید: شماره کارت، شماره حساب یا شماره شبا");
+ return operationResult.Failed(
+ " حداقل یکی از اطلاعات بانکی را وارد کنید: شماره کارت، شماره حساب یا شماره شبا");
}
if (string.IsNullOrWhiteSpace(command.AccountHolderName))
{
return operationResult.Failed("نام صاحب حساب را وارد کنید");
}
-
+
var entity = new ContractingPartyBankAccount(command.ContractingPartyId, command.CardNumber,
command.AccountHolderName, command.AccountNumber, command.IBan, command.IsAuth);
@@ -130,4 +137,83 @@ public class ContractingPartyBankAccountsApplication : IContractingPartyBankAcco
{
return await _contractingPartyBankAccountsRepository.ContractingPartyNamesSelectList(search, selected);
}
+
+ public async Task InquiryContractingPartyBankDetails(
+ InquiryContractingPartyBankDetailsRequest command)
+ {
+ var iBan = command.IBan;
+ var cardNumber = command.CardNumber;
+ var accountNumber = command.AccountNumber;
+ var uidBank = command.UidBank;
+ ContractingPartyBankInquiryResponse result = new ContractingPartyBankInquiryResponse();
+ if (!string.IsNullOrWhiteSpace(iBan))
+ {
+ if (!iBan.IsvalidIban())
+ {
+ throw new BadRequestException("شماره شبا وارد شده معتبر نمی باشد");
+ }
+
+ var response = await _uidService.IbanInquiry(iBan);
+ if (response.ResponseContext.Status.Code != 0)
+ {
+ throw new BadRequestException("خطای احراز هویت. کد خطا: " + response.ResponseContext.Status.Code);
+ }
+
+ var owner = response.Owners.FirstOrDefault();
+ var ownerFirstName = owner != null ? $"{owner.FirstName} {owner.LastName}" : "";
+ result.FullName = ownerFirstName;
+ result.AccountNumber = response.AccountBasicInformation.AccountNumber;
+ result.Iban = response.AccountBasicInformation.Iban;
+ }
+ else if (!string.IsNullOrWhiteSpace(cardNumber))
+ {
+ if (!cardNumber.IsValidCardNumber())
+ {
+ throw new BadRequestException("شماره کارت وارد شده معتبر نمی باشد");
+ }
+
+ var bankCardRes = await _uidService.CardToIban(cardNumber);
+ if (bankCardRes.ResponseContext.Status.Code != 0)
+ {
+ throw new BadRequestException("خطای احراز هویت. کد خطا: " + bankCardRes.ResponseContext.Status.Code);
+ }
+
+ var response = await _uidService.IbanInquiry(bankCardRes.Iban);
+ if (response.ResponseContext.Status.Code != 0)
+ {
+ throw new BadRequestException("خطای احراز هویت. کد خطا: " + response.ResponseContext.Status.Code);
+ }
+
+ var owner = response.Owners.FirstOrDefault();
+ var ownerFirstName = owner != null ? $"{owner.FirstName} {owner.LastName}" : "";
+ result.FullName = ownerFirstName;
+ result.AccountNumber = response.AccountBasicInformation.AccountNumber;
+ result.CardNumber = cardNumber;
+ result.Iban = response.AccountBasicInformation.Iban;
+ }
+ else if (!string.IsNullOrWhiteSpace(accountNumber))
+ {
+ var accountNumberRes = await _uidService.AccountToIban(accountNumber, uidBank);
+ if (accountNumberRes.ResponseContext.Status.Code != 0)
+ {
+ throw new BadRequestException(
+ "خطای احراز هویت. کد خطا: " + accountNumberRes.ResponseContext.Status.Code);
+ }
+
+ var response = await _uidService.IbanInquiry(accountNumberRes.Iban);
+
+ var owner = response.Owners.FirstOrDefault();
+ var ownerFirstName = owner != null ? $"{owner.FirstName} {owner.LastName}" : "";
+ result.FullName = ownerFirstName;
+ result.AccountNumber = response.AccountBasicInformation.AccountNumber;
+ result.Iban = response.AccountBasicInformation.Iban;
+ }
+ else
+ {
+ throw new BadRequestException(
+ "حداقل یکی از اطلاعات بانکی را وارد کنید: شماره کارت، شماره حساب یا شماره شبا");
+ }
+
+ return result;
+ }
}
\ No newline at end of file
diff --git a/CompanyManagment.EFCore/Services/UidService.cs b/CompanyManagment.EFCore/Services/UidService.cs
index f6abc73b..a23bdfd2 100644
--- a/CompanyManagment.EFCore/Services/UidService.cs
+++ b/CompanyManagment.EFCore/Services/UidService.cs
@@ -14,7 +14,11 @@ public class UidService : IUidService
{
private readonly HttpClient _httpClient;
private readonly IAuthorizedPersonApplication _authorizedPersonApplication;
- private const string BaseUrl = "https://json-api.uid.ir/api/inquiry/";
+ private const string BaseUrl = "https://json-api.uid.ir/api/";
+
+ public const string BusinessToken = "5e03dd4e-999d-466f-92d8-7c0b1f66a8e9";
+ public const string BusinessId = "98ed67ca-d441-4978-a748-e8bebce010eb";
+
public UidService(IAuthorizedPersonApplication authorizedPersonApplication)
{
@@ -53,7 +57,7 @@ public class UidService : IUidService
try
{
- var requestResult = await _httpClient.PostAsync("person/v2", contentType);
+ var requestResult = await _httpClient.PostAsync("inquiry/person/v2", contentType);
if (!requestResult.IsSuccessStatusCode)
return null;
var responseResult = await requestResult.Content.ReadFromJsonAsync();
@@ -138,11 +142,58 @@ public class UidService : IUidService
var json = JsonConvert.SerializeObject(request);
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
- var requestResult = await _httpClient.PostAsync("mobile/owner/v2", contentType);
+ var requestResult = await _httpClient.PostAsync("inquiry/mobile/owner/v2", contentType);
if (!requestResult.IsSuccessStatusCode)
return null;
var responseResult = await requestResult.Content.ReadFromJsonAsync();
return responseResult;
}
+
+ public async Task IbanInquiry(string iban)
+ {
+ var request = new
+ {
+ iban,
+ requestContext = new UidRequestContext()
+ };
+ var json = JsonConvert.SerializeObject(request);
+ var contentType = new StringContent(json, Encoding.UTF8, "application/json");
+ var requestResult = await _httpClient.PostAsync("inquiry/iban/v2", contentType);
+ requestResult.EnsureSuccessStatusCode();
+ //var stringRes =await requestResult.Content.ReadAsStringAsync();
+ var responseResult = await requestResult.Content.ReadFromJsonAsync();
+ return responseResult;
+ }
+
+ public async Task AccountToIban(string accountNumber, UidBanks bank)
+ {
+ var request = new
+ {
+ accountNumber,
+ bank,
+ requestContext = new UidRequestContext()
+ };
+ var json = JsonConvert.SerializeObject(request);
+ var contentType = new StringContent(json, Encoding.UTF8, "application/json");
+ var requestResult = await _httpClient.PostAsync("account-to-iban", contentType);
+ requestResult.EnsureSuccessStatusCode();
+ var responseResult = await requestResult.Content.ReadFromJsonAsync();
+ return responseResult;
+ }
+
+ public async Task CardToIban(string cardNumber)
+ {
+ var request = new
+ {
+ cardNumber,
+ requestContext = new UidRequestContext()
+ };
+ var json = JsonConvert.SerializeObject(request);
+ var contentType = new StringContent(json, Encoding.UTF8, "application/json");
+ var requestResult = await _httpClient.PostAsync("inquiry/card", contentType);
+ requestResult.EnsureSuccessStatusCode();
+ var responseResult = await requestResult.Content.ReadFromJsonAsync();
+ return responseResult;
+ }
}
diff --git a/ServiceHost/Areas/Admin/Controllers/DashboardController.cs b/ServiceHost/Areas/Admin/Controllers/DashboardController.cs
index ea66ea81..7ce73f57 100644
--- a/ServiceHost/Areas/Admin/Controllers/DashboardController.cs
+++ b/ServiceHost/Areas/Admin/Controllers/DashboardController.cs
@@ -1,5 +1,6 @@
using _0_Framework.Application;
using _0_Framework.Application.Sms;
+using _0_Framework.Application.UID;
using AccountManagement.Application.Contracts.Task;
using AccountManagement.Application.Contracts.Ticket;
using CompanyManagment.App.Contracts.ClientDashboard;
@@ -16,14 +17,16 @@ public class DashboardController : AdminBaseController
private readonly IHolidayItemApplication _holidayItemApplication;
private readonly ITaskApplication _taskApplication;
private readonly ITicketApplication _ticketApplication;
+ private readonly IUidService _uidService;
private long UserId;
- public DashboardController(ISmsService smsService, IHolidayItemApplication holidayItemApplication, ITaskApplication taskApplication,IAuthHelper authHelper, ITicketApplication ticketApplication)
+ public DashboardController(ISmsService smsService, IHolidayItemApplication holidayItemApplication, ITaskApplication taskApplication,IAuthHelper authHelper, ITicketApplication ticketApplication, IUidService uidService)
{
_smsService = smsService;
_holidayItemApplication = holidayItemApplication;
_taskApplication = taskApplication;
_ticketApplication = ticketApplication;
+ _uidService = uidService;
UserId = authHelper.CurrentAccountId();
}
[HttpGet]
diff --git a/ServiceHost/Areas/Admin/Controllers/PaymentInstrumentController.cs b/ServiceHost/Areas/Admin/Controllers/PaymentInstrumentController.cs
index e5d86ca4..961942e7 100644
--- a/ServiceHost/Areas/Admin/Controllers/PaymentInstrumentController.cs
+++ b/ServiceHost/Areas/Admin/Controllers/PaymentInstrumentController.cs
@@ -229,26 +229,9 @@ public class PaymentInstrumentController:AdminBaseController
[HttpPost("bank-account-inquiry")]
- public async Task>> GetBankInquiry([FromBody]BankInquiryRequest command)
+ public async Task> GetBankInquiry([FromBody]InquiryContractingPartyBankDetailsRequest command)
{
- if ((!string.IsNullOrWhiteSpace(command.AccountNumber) && command.AccountNumber.StartsWith("111111")) || (!string.IsNullOrWhiteSpace(command.CardNumber)&&command.CardNumber.StartsWith("111111")) || (!string.IsNullOrWhiteSpace(command.IBan)&&command.IBan.StartsWith("1111111")))
- {
- return new OperationResult().Succcedded(new BankInquiryResponse()
- {
- AccountNumber = "1111111",
- IBan = "111111111111111111111111",
- CardNumber = "1111111111111111",
- AccountHolderName = "تست تستی",
- BankName = "تست بانک",
- });
- }else if ((!string.IsNullOrWhiteSpace(command.AccountNumber) && command.AccountNumber.StartsWith("222222")) || (!string.IsNullOrWhiteSpace(command.CardNumber)&&command.CardNumber.StartsWith("222222")) || (!string.IsNullOrWhiteSpace(command.CardNumber)&&command.CardNumber.StartsWith("222222")))
- {
- return new OperationResult().Failed("دیتای وارد شده نامعتبر است");
- }
- else
- {
- throw new InternalServerException("ارور سمت سرور");
- }
+ return await _contractingPartyBankAccountsApplication.InquiryContractingPartyBankDetails(command);
}
}