feat: add phone number to authentication methods and improve temporary client registration validation
This commit is contained in:
@@ -222,7 +222,8 @@ public class PersonalContractingParty : EntityBase
|
||||
IsAuthenticated = true;
|
||||
}
|
||||
|
||||
public void Authentication(string fName, string lName, string fatherName,string idNumber, string idNumberSeri, string idNumberSerial, string dateOfBirth, Gender gender)
|
||||
public void Authentication(string fName, string lName, string fatherName,string idNumber,
|
||||
string idNumberSeri, string idNumberSerial, string dateOfBirth, Gender gender,string phone)
|
||||
{
|
||||
this.FName = fName;
|
||||
this.LName = lName;
|
||||
@@ -233,10 +234,11 @@ public class PersonalContractingParty : EntityBase
|
||||
this.IdNumber = idNumber;
|
||||
this.Gender = gender;
|
||||
this.IsAuthenticated = true;
|
||||
Phone = phone;
|
||||
}
|
||||
|
||||
public void LegalAuthentication(string fName, string lName, string fatherName,string idNumber, string idNumberSeri,
|
||||
string idNumberSerial, string dateOfBirth, Gender gender)
|
||||
string idNumberSerial, string dateOfBirth, Gender gender,string phone)
|
||||
{
|
||||
CeoFName = fName;
|
||||
CeoLName = lName;
|
||||
@@ -247,6 +249,7 @@ public class PersonalContractingParty : EntityBase
|
||||
this.IdNumber = idNumber;
|
||||
this.Gender = gender;
|
||||
this.IsAuthenticated = true;
|
||||
Phone = phone;
|
||||
}
|
||||
|
||||
public void RegisterComplete(string fatherName, string idNumberSeri, string idNumberSerial, DateTime dateOfBirth, Gender gender)
|
||||
|
||||
@@ -98,7 +98,7 @@ public class InstitutionContractExtensionTempWorkshop
|
||||
{
|
||||
public InstitutionContractExtensionTempWorkshop(string workshopName, int countPerson, bool contractAndCheckout, bool contractAndCheckoutInPerson,
|
||||
bool insurance, bool insuranceInPerson,
|
||||
bool rollCall,bool rollCallInPerson, bool customizeCheckout,double price)
|
||||
bool rollCall,bool rollCallInPerson, bool customizeCheckout,double price,long workshopId)
|
||||
{
|
||||
WorkshopName = workshopName;
|
||||
CountPerson = countPerson;
|
||||
@@ -110,8 +110,11 @@ public class InstitutionContractExtensionTempWorkshop
|
||||
InsuranceInPerson = insuranceInPerson;
|
||||
RollCallInPerson = rollCallInPerson;
|
||||
Price = price;
|
||||
WorkshopId = workshopId;
|
||||
}
|
||||
|
||||
public long WorkshopId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کارگاه
|
||||
/// </summary>
|
||||
|
||||
@@ -15,4 +15,6 @@ public class WorkshopTempViewModel : CreateWorkshopTemp
|
||||
/// فارسی
|
||||
/// </summary>
|
||||
public string WorkshopServicesAmountStr { get; set; }
|
||||
|
||||
public long WorkshopId { get; set; }
|
||||
}
|
||||
@@ -1343,7 +1343,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
if (request.IsAuth)
|
||||
{
|
||||
legalContractingParty.LegalAuthentication(request.FName,request.LName,request.FatherName,
|
||||
request.IdNumber,null,null,request.BirthDateFa,request.Gender);
|
||||
request.IdNumber,null,null,request.BirthDateFa,request.Gender,request.PhoneNumber);
|
||||
}
|
||||
|
||||
await _contractingPartyRepository.CreateAsync(legalContractingParty);
|
||||
@@ -1388,7 +1388,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
if (request.IsAuth)
|
||||
{
|
||||
personalContractingParty.Authentication(request.FName, request.LName, request.FatherName,
|
||||
request.IdNumber, null,null, request.BirthDateFa, request.Gender);
|
||||
request.IdNumber, null,null, request.BirthDateFa, request.Gender,request.PhoneNumber);
|
||||
}
|
||||
|
||||
await _contractingPartyRepository.CreateAsync(personalContractingParty);
|
||||
|
||||
@@ -111,15 +111,22 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
if (contractingParty.DateOfBirth != null &&contractingParty.DateOfBirth != dateOfBirthGr)
|
||||
return op.Failed("تاریخ تولد مطابقت ندارد");
|
||||
|
||||
if (contractingParty.Phone != mobile)
|
||||
return op.Failed("شما قبلا با شماره همراه دیگری ثبت نام نموده اید");
|
||||
|
||||
|
||||
var idNumberParty = contractingParty.IdNumber;
|
||||
if (!contractingParty.IsAuthenticated)
|
||||
{
|
||||
|
||||
//دریافت اطلاعات احراز هویت
|
||||
var apiResponsParty = await _uidService.GetPersonalInfo(nationalCode, dateOfBirth);
|
||||
|
||||
|
||||
//چک کردن مطابقت شماره همراه و کد ملی
|
||||
var isMachMobilAndNationalCode = await _uidService.IsMachPhoneWithNationalCode(nationalCode, mobile);
|
||||
if (isMachMobilAndNationalCode == null)
|
||||
return op.Failed("خطا در سرویس احراز هویت");
|
||||
if (!isMachMobilAndNationalCode.IsMatched)
|
||||
return op.Failed("شماره همراه وارد شده با کد ملی مطابقت ندارد");
|
||||
|
||||
if (apiResponsParty == null)
|
||||
throw new InternalServerException("خطا در سرویس احراز هویت");
|
||||
|
||||
@@ -135,13 +142,16 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
|
||||
contractingParty.Authentication(apiResponsParty.BasicInformation.FirstName, apiResponsParty.BasicInformation.LastName,
|
||||
apiResponsParty.BasicInformation.FatherName,idNumberParty,apiResponsParty.IdentificationInformation.ShenasnameSeri,
|
||||
apiResponsParty.IdentificationInformation.ShenasnameSerial,dateOfBirth,apiResponsParty.BasicInformation.GenderEnum);
|
||||
apiResponsParty.IdentificationInformation.ShenasnameSerial,dateOfBirth,apiResponsParty.BasicInformation.GenderEnum,
|
||||
mobile);
|
||||
|
||||
|
||||
await _contractingPartyTempRepository.SaveChangesAsync();
|
||||
|
||||
|
||||
}
|
||||
if (contractingParty.Phone != mobile)
|
||||
return op.Failed("شما قبلا با شماره همراه دیگری احراز هویت شده اید");
|
||||
|
||||
result.Id = contractingParty.id;
|
||||
result.FName = contractingParty.FName;
|
||||
@@ -160,71 +170,74 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
|
||||
return op.Succcedded(result);
|
||||
}
|
||||
//اگر طرف حساب موقت قبلا ایجاد شده دیتای آن را برمیگرداند
|
||||
if (getExistTemp != null)
|
||||
else
|
||||
{
|
||||
var institutionContractTemp = await
|
||||
_institutionContractTempRepository.GetInstitutionContractTemp(0, getExistTemp.Id);
|
||||
|
||||
if (institutionContractTemp != null)
|
||||
//اگر طرف حساب موقت قبلا ایجاد شده دیتای آن را برمیگرداند
|
||||
if (getExistTemp != null)
|
||||
{
|
||||
if (institutionContractTemp.RegistrationStatus == InstitutionContractTempStatus.Completed)
|
||||
return op.Failed("شما قبلا ثبت نام خود را تکمیل نموده اید");
|
||||
var institutionContractTemp = await
|
||||
_institutionContractTempRepository.GetInstitutionContractTemp(0, getExistTemp.Id);
|
||||
|
||||
if (institutionContractTemp != null)
|
||||
{
|
||||
if (institutionContractTemp.RegistrationStatus == InstitutionContractTempStatus.Completed)
|
||||
return op.Failed("شما قبلا ثبت نام خود را تکمیل نموده اید");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (getExistTemp.DateOfBirth != dateOfBirthGr)
|
||||
return op.Failed("تاریخ تولد مطابقت ندارد");
|
||||
if (getExistTemp.Phone != mobile)
|
||||
return op.Failed("شما قبلا با شماره همراه دیگری ثبت نام نموده اید");
|
||||
return op.Succcedded(getExistTemp);
|
||||
}
|
||||
|
||||
|
||||
//چک کردن مطابقت شماره همراه و کد ملی
|
||||
var isMachMobilAndNationalCode = await _uidService.IsMachPhoneWithNationalCode(nationalCode, mobile);
|
||||
if (isMachMobilAndNationalCode == null)
|
||||
return op.Failed("خطا در سرویس احراز هویت");
|
||||
if (!isMachMobilAndNationalCode.IsMatched)
|
||||
return op.Failed("شماره همراه وارد شده با کد ملی مطابقت ندارد");
|
||||
|
||||
//دریافت اطلاعات احراز هویت
|
||||
var apiRespons = await _uidService.GetPersonalInfo(nationalCode, dateOfBirth);
|
||||
|
||||
if (apiRespons == null)
|
||||
throw new InternalServerException("خطا در سرویس احراز هویت");
|
||||
|
||||
if (apiRespons.ResponseContext.Status.Code == 14)
|
||||
throw new InternalServerException("سیستم احراز هویت در دسترس نمی باشد");
|
||||
|
||||
if (apiRespons.ResponseContext.Status.Code != 0)
|
||||
return op.Failed($"{apiRespons.ResponseContext.Status.Message}");
|
||||
|
||||
var idNumber = apiRespons.IdentificationInformation.ShenasnamehNumber == "0"
|
||||
? apiRespons.IdentificationInformation.NationalId
|
||||
: apiRespons.IdentificationInformation.ShenasnamehNumber;
|
||||
|
||||
//ایجاد طرف حساب موقت
|
||||
var createTemp = new ContractingPartyTemp(apiRespons.BasicInformation.FirstName,
|
||||
apiRespons.BasicInformation.LastName, nationalCode, idNumber, mobile,
|
||||
apiRespons.BasicInformation.FatherName, "", "", "",
|
||||
apiRespons.IdentificationInformation.ShenasnameSeri,
|
||||
apiRespons.IdentificationInformation.ShenasnameSerial, apiRespons.BasicInformation.GenderEnum,
|
||||
dateOfBirthGr);
|
||||
await _contractingPartyTempRepository.CreateAsync(createTemp);
|
||||
await _contractingPartyTempRepository.SaveChangesAsync();
|
||||
|
||||
result.Id = createTemp.id;
|
||||
result.FName = createTemp.FName;
|
||||
result.LName = createTemp.LName;
|
||||
result.DateOfBirthFa = dateOfBirth;
|
||||
result.FatherName = createTemp.FatherName;
|
||||
result.IdNumberSerial = createTemp.IdNumberSerial;
|
||||
result.IdNumber = idNumber;
|
||||
result.NationalCode = createTemp.NationalCode;
|
||||
|
||||
|
||||
if (getExistTemp.DateOfBirth != dateOfBirthGr)
|
||||
return op.Failed("تاریخ تولد مطابقت ندارد");
|
||||
if (getExistTemp.Phone != mobile)
|
||||
return op.Failed("شما قبلا با شماره همراه دیگری ثبت نام نموده اید");
|
||||
return op.Succcedded(getExistTemp);
|
||||
return op.Succcedded(result);
|
||||
}
|
||||
|
||||
//چک کردن مطابقت شماره همراه و کد ملی
|
||||
var isMachMobilAndNationalCode = await _uidService.IsMachPhoneWithNationalCode(nationalCode, mobile);
|
||||
if (isMachMobilAndNationalCode == null)
|
||||
return op.Failed("خطا در سرویس احراز هویت");
|
||||
if (!isMachMobilAndNationalCode.IsMatched)
|
||||
return op.Failed("شماره همراه وارد شده با کد ملی مطابقت ندارد");
|
||||
|
||||
//دریافت اطلاعات احراز هویت
|
||||
var apiRespons = await _uidService.GetPersonalInfo(nationalCode, dateOfBirth);
|
||||
|
||||
if (apiRespons == null)
|
||||
throw new InternalServerException("خطا در سرویس احراز هویت");
|
||||
|
||||
if (apiRespons.ResponseContext.Status.Code ==14)
|
||||
throw new InternalServerException("سیستم احراز هویت در دسترس نمی باشد");
|
||||
|
||||
if (apiRespons.ResponseContext.Status.Code != 0)
|
||||
return op.Failed($"{apiRespons.ResponseContext.Status.Message}");
|
||||
|
||||
var idNumber = apiRespons.IdentificationInformation.ShenasnamehNumber == "0"
|
||||
? apiRespons.IdentificationInformation.NationalId
|
||||
: apiRespons.IdentificationInformation.ShenasnamehNumber;
|
||||
|
||||
//ایجاد طرف حساب موقت
|
||||
var createTemp = new ContractingPartyTemp(apiRespons.BasicInformation.FirstName,
|
||||
apiRespons.BasicInformation.LastName, nationalCode, idNumber, mobile,
|
||||
apiRespons.BasicInformation.FatherName, "", "", "",
|
||||
apiRespons.IdentificationInformation.ShenasnameSeri,
|
||||
apiRespons.IdentificationInformation.ShenasnameSerial, apiRespons.BasicInformation.GenderEnum,
|
||||
dateOfBirthGr);
|
||||
await _contractingPartyTempRepository.CreateAsync(createTemp);
|
||||
await _contractingPartyTempRepository.SaveChangesAsync();
|
||||
|
||||
result.Id = createTemp.id;
|
||||
result.FName = createTemp.FName;
|
||||
result.LName = createTemp.LName;
|
||||
result.DateOfBirthFa = dateOfBirth;
|
||||
result.FatherName = createTemp.FatherName;
|
||||
result.IdNumberSerial = createTemp.IdNumberSerial;
|
||||
result.IdNumber = idNumber;
|
||||
result.NationalCode = createTemp.NationalCode;
|
||||
|
||||
|
||||
return op.Succcedded(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,12 @@ public class ContractingPartyTempRepository : RepositoryBase<long, ContractingPa
|
||||
var idNumber = apiRespons.IdentificationInformation.ShenasnamehNumber == "0"
|
||||
? apiRespons.IdentificationInformation.NationalId
|
||||
: apiRespons.IdentificationInformation.ShenasnamehNumber;
|
||||
contractingParty.Authentication(apiRespons.BasicInformation.FirstName, apiRespons.BasicInformation.LastName,apiRespons.BasicInformation.FatherName,idNumber,apiRespons.IdentificationInformation.ShenasnameSeri,apiRespons.IdentificationInformation.ShenasnameSerial, apiRespons.IdentificationInformation.BirthDate,apiRespons.BasicInformation.GenderEnum);
|
||||
_context.SaveChanges();
|
||||
contractingParty
|
||||
.Authentication(apiRespons.BasicInformation.FirstName, apiRespons.BasicInformation.LastName,
|
||||
apiRespons.BasicInformation.FatherName,idNumber,apiRespons.IdentificationInformation.ShenasnameSeri,
|
||||
apiRespons.IdentificationInformation.ShenasnameSerial,
|
||||
apiRespons.IdentificationInformation.BirthDate,apiRespons.BasicInformation.GenderEnum,contractingParty.Phone);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1953,8 +1953,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
InsuranceInPerson = service.InsuranceInPerson,
|
||||
RollCall = service.RollCall,
|
||||
WorkshopName = x.WorkshopName,
|
||||
RollCallInPerson = service.RollCallInPerson
|
||||
|
||||
RollCallInPerson = service.RollCallInPerson,
|
||||
};
|
||||
var institutionPlanForWorkshop = _planPercentageRepository.GetInstitutionPlanForWorkshop(command);
|
||||
price = institutionPlanForWorkshop.OnlineAndInPersonSumAmountDouble;
|
||||
@@ -1972,7 +1971,9 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
RollCall = service.RollCall,
|
||||
WorkshopName = workshop?.WorkshopName ?? "فاقد کارگاه",
|
||||
WorkshopServicesAmount = price,
|
||||
WorkshopServicesAmountStr = price.ToMoney()
|
||||
WorkshopServicesAmountStr = price.ToMoney(),
|
||||
WorkshopId = workshop?.id ?? 0,
|
||||
RollCallInPerson = service.RollCallInPerson
|
||||
};
|
||||
}).ToList();
|
||||
var res = new InstitutionContractExtensionWorkshopsResponse()
|
||||
@@ -2029,7 +2030,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
res.ThreeMonths =
|
||||
CalculateInstitutionPlan(InstitutionContractDuration.ThreeMonths, amount, false, newContractStart);
|
||||
|
||||
res.SixMonths =
|
||||
res.SixMonths =
|
||||
CalculateInstitutionPlan(InstitutionContractDuration.SixMonths, amount, false, newContractStart);
|
||||
|
||||
res.TwelveMonths = CalculateInstitutionPlan(InstitutionContractDuration.TwelveMonths, amount, false,
|
||||
@@ -2040,7 +2041,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
.Select(x => new InstitutionContractExtensionTempWorkshop(x.WorkshopName, x.CountPerson,
|
||||
x.ContractAndCheckout, x.ContractAndCheckoutInPerson,
|
||||
x.Insurance, x.InsuranceInPerson, x.RollCall, x.RollCall,
|
||||
x.RollCallInPerson, x.WorkshopServicesAmount)).ToList();
|
||||
x.RollCallInPerson, x.WorkshopServicesAmount,x.WorkshopId)).ToList();
|
||||
|
||||
institutionTemp.SetWorkshopsAndPlanAmounts(workshops, res.OneMonth, res.ThreeMonths, res.SixMonths,
|
||||
res.TwelveMonths, hasInPerson);
|
||||
@@ -2200,11 +2201,11 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
|
||||
var contractingPartyFullName = previousInstitutionContract.ContractingPartyName;
|
||||
|
||||
|
||||
var totalAmount = payment.PaymentAmount.MoneyToDouble();
|
||||
|
||||
|
||||
var transaction = await _context.Database.BeginTransactionAsync();
|
||||
|
||||
|
||||
var entity = new InstitutionContract(contractNo, previousInstitutionContract.RepresentativeId,
|
||||
previousInstitutionContract.RepresentativeName,
|
||||
previousInstitutionContract.ContractingPartyId,
|
||||
@@ -2237,7 +2238,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
var today = DateTime.Today;
|
||||
if (request.IsInstallment && payment is InstitutionContractExtensionPaymentMonthly monthly)
|
||||
{
|
||||
|
||||
var installments = monthly.Installments.Select(x =>
|
||||
new InstitutionContractInstallment(x.InstalmentDate.ToGeorgianDateTime(),
|
||||
x.InstallmentAmountStr.MoneyToDouble(), "")).ToList();
|
||||
@@ -2252,7 +2252,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
// ایجاد قسط جدید با تاریخ امروز
|
||||
var todayInstallment = new InstitutionContractInstallment(DateTime.Today, firstInstallmentAmount, "");
|
||||
|
||||
var financialTransaction = new FinancialTransaction(0,today, today.ToFarsi(),
|
||||
var financialTransaction = new FinancialTransaction(0, today, today.ToFarsi(),
|
||||
"قسط اول سرویس", "debt", "بابت خدمات", firstInstallmentAmount, 0, 0);
|
||||
|
||||
financialStatement.AddFinancialTransaction(financialTransaction);
|
||||
@@ -2265,25 +2265,22 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
else
|
||||
{
|
||||
var financialTransaction = new FinancialTransaction(0, today, today.ToFarsi(),
|
||||
"پرداخت کل سرویس", "debt", "بابت خدمات",totalAmount , 0, 0);
|
||||
"پرداخت کل سرویس", "debt", "بابت خدمات", totalAmount, 0, 0);
|
||||
financialStatement.AddFinancialTransaction(financialTransaction);
|
||||
}
|
||||
|
||||
|
||||
await CreateAsync(entity);
|
||||
await SaveChangesAsync();
|
||||
|
||||
foreach (var contactInfo in institutionContractTemp.ContactInfos)
|
||||
{
|
||||
if (contactInfo.PhoneNumber != null)
|
||||
{
|
||||
var contactinfo = new InstitutionContractContactInfo(contactInfo.PhoneType,
|
||||
contactInfo.Position,contactInfo.PhoneNumber,contactInfo.FnameLname,entity.id,contactInfo.SendSmsString == "true");
|
||||
|
||||
contactInfo.Position, contactInfo.PhoneNumber, contactInfo.FnameLname, entity.id,
|
||||
contactInfo.SendSmsString == "true");
|
||||
|
||||
_context.InstitutionContractContactInfos.Add(contactinfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
await SaveChangesAsync();
|
||||
|
||||
await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName,
|
||||
|
||||
Reference in New Issue
Block a user