Merge branch 'Feature/InstitutionContract/add-registration-style' into Main
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Application.Sms;
|
||||
using _0_Framework.Application.UID;
|
||||
using _0_Framework.Exceptions;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using Company.Domain.ContarctingPartyAgg;
|
||||
@@ -25,6 +26,7 @@ using CompanyManagment.App.Contracts.InstitutionContractContactinfo;
|
||||
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using CompanyManagment.EFCore.Migrations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OfficeOpenXml.Packaging.Ionic.Zip;
|
||||
using PersianTools.Core;
|
||||
using ConnectedPersonnelViewModel = CompanyManagment.App.Contracts.Workshop.ConnectedPersonnelViewModel;
|
||||
@@ -47,6 +49,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
private readonly IContactInfoApplication _contactInfoApplication;
|
||||
private readonly IAccountApplication _accountApplication;
|
||||
private readonly ISmsService _smsService;
|
||||
private readonly IUidService _uidService;
|
||||
|
||||
|
||||
public InstitutionContractApplication(IInstitutionContractRepository institutionContractRepository,
|
||||
@@ -56,7 +59,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
IFinancialStatmentApplication financialStatmentApplication, IWorkshopApplication workshopApplication,
|
||||
IContractingPartyTempRepository contractingPartyTempRepository,
|
||||
IFinancialStatmentRepository financialStatmentRepository, IContactInfoApplication contactInfoApplication,
|
||||
IAccountApplication accountApplication, ISmsService smsService)
|
||||
IAccountApplication accountApplication, ISmsService smsService, IUidService uidService)
|
||||
{
|
||||
_institutionContractRepository = institutionContractRepository;
|
||||
_contractingPartyRepository = contractingPartyRepository;
|
||||
@@ -71,6 +74,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
_contactInfoApplication = contactInfoApplication;
|
||||
_accountApplication = accountApplication;
|
||||
_smsService = smsService;
|
||||
_uidService = uidService;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateInstitutionContract command)
|
||||
@@ -1149,11 +1153,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<OperationResult> ExtensionAsync(CreateInstitutionContractRequest command)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
public Task<List<RegistrationWorkflowMainListViewModel>> RegistrationWorkflowMainList()
|
||||
{
|
||||
@@ -1276,30 +1276,120 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
return res;
|
||||
}
|
||||
|
||||
public async Task<InstitutionContractExtensionInquiryResult> GetExtenstionInquiry(long previousContractId)
|
||||
public async Task<InstitutionContractExtensionInquiryResult> GetExtensionInquiry(long previousContractId)
|
||||
{
|
||||
return await _institutionContractRepository.GetExtenstionInquiry(previousContractId);
|
||||
return await _institutionContractRepository.GetExtensionInquiry(previousContractId);
|
||||
}
|
||||
|
||||
public async Task<InstitutionContractExtensionWorkshopsResponse> GetExtenstionWorkshops(
|
||||
public async Task<InstitutionContractExtensionWorkshopsResponse> GetExtensionWorkshops(
|
||||
InstitutionContractExtensionWorkshopsRequest request)
|
||||
{
|
||||
return await _institutionContractRepository.GetExtenstionWorkshops(request);
|
||||
return await _institutionContractRepository.GetExtensionWorkshops(request);
|
||||
}
|
||||
|
||||
public async Task<InstitutionContractExtensionPlanResponse> GetExtenstionInstitutionPlan(InstitutionContractExtensionPlanRequest request)
|
||||
public async Task<InstitutionContractExtensionPlanResponse> GetExtensionInstitutionPlan(InstitutionContractExtensionPlanRequest request)
|
||||
{
|
||||
return await _institutionContractRepository.GetExtenstionInstitutionPlan(request);
|
||||
return await _institutionContractRepository.GetExtensionInstitutionPlan(request);
|
||||
}
|
||||
|
||||
public async Task<InstitutionContractExtensionPaymentResponse> GetExtenstionPaymentMethod(InstitutionContractExtensionPaymentRequest request)
|
||||
public async Task<InstitutionContractExtensionPaymentResponse> GetExtensionPaymentMethod(InstitutionContractExtensionPaymentRequest request)
|
||||
{
|
||||
return await _institutionContractRepository.GetExtenstionPaymentMethod(request);
|
||||
return await _institutionContractRepository.GetExtensionPaymentMethod(request);
|
||||
}
|
||||
|
||||
public async Task<OperationResult> ExtenstionComplete(InstitutionContractExtensionCompleteRequest request)
|
||||
public async Task<OperationResult> ExtensionComplete(InstitutionContractExtensionCompleteRequest request)
|
||||
{
|
||||
return await _institutionContractRepository.ExtenstionComplete(request);
|
||||
return await _institutionContractRepository.ExtensionComplete(request);
|
||||
}
|
||||
|
||||
public async Task<OperationResult> ExtensionInquiry(InstitutionContractExtensionInquiryRequest command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
|
||||
#region Validations
|
||||
if (string.IsNullOrWhiteSpace(command.NationalCode) || string.IsNullOrWhiteSpace(command.BirthDate) ||
|
||||
string.IsNullOrWhiteSpace(command.Mobile))
|
||||
return op.Failed("هیچ یک از فیلد ها نمیتواند خالی باشد");
|
||||
|
||||
if (command.NationalCode.NationalCodeValid() != "valid")
|
||||
return op.Failed("کد ملی نا معتبر است");
|
||||
|
||||
if (!command.BirthDate.TryToGeorgianDateTime(out var dateOfBirthGr))
|
||||
return op.Failed("تاریخ تولد نا معتبر است");
|
||||
|
||||
if (!command.Mobile.IsMobileValid())
|
||||
return op.Failed("شماره همراه نا معتبر است");
|
||||
#endregion
|
||||
|
||||
var contractingParty = _contractingPartyRepository.Get(command.ContractingPartyId);
|
||||
|
||||
if (contractingParty == null)
|
||||
return op.Failed("طرف حسابی یافت نشد");
|
||||
|
||||
// بررسی اینکه آیا طرف حساب قبلا احراز هویت شده یا نه
|
||||
if (contractingParty.IsAuthenticated)
|
||||
return op.Failed("طرف حساب قبلا احراز هویت شده است");
|
||||
|
||||
|
||||
|
||||
// // بررسی تطابق تاریخ تولد
|
||||
// if (contractingParty.DateOfBirth != null && contractingParty.DateOfBirth != dateOfBirthGr)
|
||||
// return op.Failed("تاریخ تولد مطابقت ندارد");
|
||||
|
||||
// // بررسی تطابق شماره تماس
|
||||
// if (contractingParty.Phone != command.Mobile)
|
||||
// return op.Failed("شما قبلا با شماره همراه دیگری ثبت نام نموده اید");
|
||||
|
||||
// چک کردن مطابقت شماره همراه و کد ملی
|
||||
var isMachMobilAndNationalCode = await _uidService.IsMachPhoneWithNationalCode(command.NationalCode, command.Mobile);
|
||||
if (isMachMobilAndNationalCode == null)
|
||||
return op.Failed("خطا در سرویس احراز هویت");
|
||||
if (!isMachMobilAndNationalCode.IsMatched)
|
||||
return op.Failed("شماره همراه وارد شده با کد ملی مطابقت ندارد");
|
||||
|
||||
// دریافت اطلاعات احراز هویت
|
||||
var apiResponse = await _uidService.GetPersonalInfo(command.NationalCode, command.BirthDate);
|
||||
|
||||
if (apiResponse == null)
|
||||
throw new InternalServerException("خطا در سرویس احراز هویت");
|
||||
|
||||
if (apiResponse.ResponseContext.Status.Code == 14)
|
||||
throw new InternalServerException("سیستم احراز هویت در دسترس نمی باشد");
|
||||
|
||||
if (apiResponse.ResponseContext.Status.Code != 0)
|
||||
return op.Failed($"{apiResponse.ResponseContext.Status.Message}");
|
||||
|
||||
var idNumber = apiResponse.IdentificationInformation.ShenasnamehNumber == "0"
|
||||
? apiResponse.IdentificationInformation.NationalId
|
||||
: apiResponse.IdentificationInformation.ShenasnamehNumber;
|
||||
|
||||
if (contractingParty.IsLegal =="حقیقی")
|
||||
{
|
||||
// انجام احراز هویت طرف حساب
|
||||
contractingParty.Authentication(apiResponse.BasicInformation.FirstName,
|
||||
apiResponse.BasicInformation.LastName,
|
||||
apiResponse.BasicInformation.FatherName,
|
||||
idNumber,
|
||||
apiResponse.IdentificationInformation.ShenasnameSeri,
|
||||
apiResponse.IdentificationInformation.ShenasnameSerial,
|
||||
command.BirthDate,
|
||||
apiResponse.BasicInformation.GenderEnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
contractingParty.LegalAuthentication(apiResponse.BasicInformation.FirstName,
|
||||
apiResponse.BasicInformation.LastName,
|
||||
apiResponse.BasicInformation.FatherName,
|
||||
idNumber,
|
||||
apiResponse.IdentificationInformation.ShenasnameSeri,
|
||||
apiResponse.IdentificationInformation.ShenasnameSerial,
|
||||
command.BirthDate,
|
||||
apiResponse.BasicInformation.GenderEnum);
|
||||
}
|
||||
// ذخیره تغییرات
|
||||
await _contractingPartyRepository.SaveChangesAsync();
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
private async Task<OperationResult<PersonalContractingParty>> CreateLegalContractingPartyEntity(
|
||||
@@ -1504,4 +1594,4 @@ public class WorkshopsAndEmployeeViewModel
|
||||
public int ArchiveCode { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user