703 lines
27 KiB
C#
703 lines
27 KiB
C#
using System.Transactions;
|
||
using _0_Framework.Application;
|
||
using _0_Framework.Application.Enums;
|
||
using AccountManagement.Application.Contracts.Account;
|
||
using CompanyManagement.Infrastructure.Excel.InstitutionContract;
|
||
using CompanyManagment.App.Contracts.Employer;
|
||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||
using CompanyManagment.App.Contracts.InstitutionContractContactinfo;
|
||
using CompanyManagment.App.Contracts.InstitutionPlan;
|
||
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
||
using CompanyManagment.App.Contracts.Representative;
|
||
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||
using CompanyManagment.App.Contracts.Workshop;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||
using ServiceHost.Areas.Client.Pages.Company.PaymentToEmployee;
|
||
using ServiceHost.BaseControllers;
|
||
|
||
namespace ServiceHost.Areas.Admin.Controllers;
|
||
|
||
/// <summary>
|
||
/// کنترلر قرارداد های مالی موسسه
|
||
/// </summary>
|
||
public class institutionContractController : AdminBaseController
|
||
{
|
||
private readonly IInstitutionContractApplication _institutionContractApplication;
|
||
private readonly IPersonalContractingPartyApp _contractingPartyApplication;
|
||
private readonly IContactInfoApplication _contactInfoApplication;
|
||
private readonly IAccountApplication _accountApplication;
|
||
private readonly IEmployerApplication _employerApplication;
|
||
private readonly IWorkshopApplication _workshopApplication;
|
||
private readonly ITemporaryClientRegistrationApplication _temporaryClientRegistration;
|
||
|
||
|
||
public institutionContractController(IInstitutionContractApplication institutionContractApplication,
|
||
IPersonalContractingPartyApp contractingPartyApplication, IContactInfoApplication contactInfoApplication,
|
||
IAccountApplication accountApplication, IEmployerApplication employerApplication,
|
||
IWorkshopApplication workshopApplication, ITemporaryClientRegistrationApplication temporaryClientRegistration)
|
||
{
|
||
_institutionContractApplication = institutionContractApplication;
|
||
_contractingPartyApplication = contractingPartyApplication;
|
||
_contactInfoApplication = contactInfoApplication;
|
||
_accountApplication = accountApplication;
|
||
_employerApplication = employerApplication;
|
||
_workshopApplication = workshopApplication;
|
||
_temporaryClientRegistration = temporaryClientRegistration;
|
||
}
|
||
|
||
/// <summary>
|
||
/// لیست قرارداد های مالی
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet]
|
||
public async Task<ActionResult<PagedResult<GetInstitutionContractListItemsViewModel>>> GetList(
|
||
InstitutionContractListSearchModel searchModel)
|
||
{
|
||
return await _institutionContractApplication.GetList(searchModel);
|
||
}
|
||
|
||
/// <summary>
|
||
/// وضعیت تب ها
|
||
/// </summary>
|
||
/// <param name="searchModel"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("stats")]
|
||
public async Task<ActionResult<GetInstitutionContractListStatsViewModel>> GetListStats(
|
||
InstitutionContractListSearchModel searchModel)
|
||
{
|
||
return await _institutionContractApplication.GetListStats(searchModel);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// ویرایش
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
public async Task<ActionResult<OperationResult>> Edit([FromBody] EditInstitutionContractRequest command)
|
||
{
|
||
var op = new OperationResult();
|
||
var phoneNumber = command.ContactInfos.FirstOrDefault(x =>
|
||
x.SendSmsString == "true" && x.Position == "طرف قرارداد" && x.PhoneType == "شماره همراه");
|
||
var conractingParty = _contractingPartyApplication.GetDetails(command.ContractingPartyId);
|
||
|
||
if (conractingParty.IsLegal == "حقیقی" && string.IsNullOrWhiteSpace(conractingParty.Nationalcode))
|
||
return new JsonResult(op.Failed("کد ملی طرف حساب وجود ندارد"));
|
||
if (conractingParty.IsLegal == "حقوقی" && string.IsNullOrWhiteSpace(conractingParty.NationalId))
|
||
return new JsonResult(op.Failed("شناسه ملی طرف حساب وجود ندارد"));
|
||
if (phoneNumber == null)
|
||
return new JsonResult(op.Failed("تعیین شماره همراه با سمت طرف قرارداد اجباریست"));
|
||
//if (string.IsNullOrWhiteSpace(command.HasValueAddedTax))
|
||
// command.HasValueAddedTax = "false";
|
||
var result = await _institutionContractApplication.EditAsync(command);
|
||
var contractingPartyId = _institutionContractApplication.GetDetails(result.SendId);
|
||
var counter = command.ContactInfos.Count;
|
||
var getOldContarct = _institutionContractApplication.NewSearch(new InstitutionContractSearchModel()
|
||
{ ContractingPartyId = contractingPartyId.ContractingPartyId, IsActiveString = "both" })
|
||
.Where(x => x.IsActiveString == "false" || x.IsActiveString == "blue").ToList();
|
||
if (result.IsSuccedded && counter > 0)
|
||
{
|
||
if (getOldContarct.Count > 0)
|
||
{
|
||
foreach (var item in getOldContarct)
|
||
{
|
||
_contactInfoApplication.RemoveContactInfo(item.Id);
|
||
foreach (var phone in command.ContactInfos)
|
||
{
|
||
if (phone.PhoneNumber != null)
|
||
{
|
||
var contactinfo = new CreateContactInfo
|
||
{
|
||
InstitutionContractId = item.Id,
|
||
PhoneType = phone.PhoneType,
|
||
Position = phone.Position,
|
||
PhoneNumber = phone.PhoneNumber,
|
||
FnameLname = phone.FnameLname,
|
||
SendSms = phone.SendSmsString == "true" ? true : false
|
||
};
|
||
_contactInfoApplication.Create(contactinfo);
|
||
}
|
||
|
||
Thread.Sleep(500);
|
||
}
|
||
}
|
||
}
|
||
|
||
_contactInfoApplication.RemoveContactInfo(command.Id);
|
||
foreach (var item in command.ContactInfos)
|
||
{
|
||
if (item.PhoneNumber != null)
|
||
{
|
||
var contactinfo = new CreateContactInfo
|
||
{
|
||
InstitutionContractId = result.SendId,
|
||
PhoneType = item.PhoneType,
|
||
Position = item.Position,
|
||
PhoneNumber = item.PhoneNumber,
|
||
FnameLname = item.FnameLname,
|
||
SendSms = item.SendSmsString == "true" ? true : false
|
||
};
|
||
_contactInfoApplication.Create(contactinfo);
|
||
}
|
||
|
||
Thread.Sleep(500);
|
||
}
|
||
|
||
|
||
//ساخت اکانت کلاینت
|
||
var userPass = conractingParty.IsLegal == "حقیقی"
|
||
? conractingParty.Nationalcode
|
||
: conractingParty.NationalId;
|
||
var checkExistAccount = _accountApplication.CheckExistClientAccount(userPass);
|
||
if (!checkExistAccount)
|
||
{
|
||
var createAcc = new RegisterAccount
|
||
{
|
||
Fullname = conractingParty.LName,
|
||
Username = userPass,
|
||
Password = userPass,
|
||
Mobile = phoneNumber.PhoneNumber,
|
||
NationalCode = userPass
|
||
};
|
||
var res = _accountApplication.RegisterClient(createAcc);
|
||
if (res.IsSuccedded)
|
||
_institutionContractApplication.CreateContractingPartyAccount(command.ContractingPartyId,
|
||
res.SendId);
|
||
}
|
||
}
|
||
//Thread.Sleep(500);
|
||
//for (int i = 0; i <= counter - 1; i++)
|
||
//{
|
||
// if (command.ContactInformationList[i].PhoneNumber != null)
|
||
// {
|
||
|
||
// var contactinfo = new CreateContactInfo()
|
||
// {
|
||
// InstitutionContractId = result.SendId,
|
||
// PhoneType = command.ContactInformationList[i].PhoneType,
|
||
// Position = command.ContactInformationList[i].Position,
|
||
// PhoneNumber = command.ContactInformationList[i].PhoneNumber,
|
||
// FnameLname = command.ContactInformationList[i].FnameLname,
|
||
// SendSms = command.ContactInformationList[i].SendSmsString == "true" ? true : false
|
||
// };
|
||
// _contactInfoApplication.Create(contactinfo);
|
||
|
||
// }
|
||
// Thread.Sleep(500);
|
||
//}
|
||
|
||
|
||
return new JsonResult(result);
|
||
}
|
||
|
||
[HttpPost("deActive/{id}")]
|
||
public ActionResult<OperationResult> DeActive(long id, string balance)
|
||
{
|
||
var result = new OperationResult();
|
||
if (balance == "0")
|
||
{
|
||
result = _institutionContractApplication.DeActive(id);
|
||
if (result.IsSuccedded) result = _institutionContractApplication.DeActiveAllConnections(id);
|
||
}
|
||
else
|
||
{
|
||
result = _institutionContractApplication.DeActiveBlue(id);
|
||
if (result.IsSuccedded)
|
||
result = _institutionContractApplication.DeActiveAllConnections(id);
|
||
}
|
||
|
||
|
||
return result;
|
||
}
|
||
|
||
/// <summary>
|
||
/// غیر فعال
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
[HttpPost("active/{id}")]
|
||
public ActionResult<OperationResult> IsActive(long id)
|
||
{
|
||
var result = _institutionContractApplication.Active(id);
|
||
if (result.IsSuccedded)
|
||
{
|
||
result = _institutionContractApplication.ReActiveAllConnections(id);
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
[HttpPost("sign/{id}")]
|
||
public ActionResult<OperationResult> Sign(long Id)
|
||
{
|
||
var result = _institutionContractApplication.Sign(Id);
|
||
if (result.IsSuccedded)
|
||
return new JsonResult(new
|
||
{
|
||
isSuccedded = true
|
||
});
|
||
return new JsonResult(new
|
||
{
|
||
isSuccedded = false
|
||
});
|
||
}
|
||
|
||
[HttpPost("unsign/{id}")]
|
||
public ActionResult<OperationResult> UnSign(long Id)
|
||
{
|
||
var id = Convert.ToInt64(Id);
|
||
var result = _institutionContractApplication.UnSign(Id);
|
||
if (result.IsSuccedded)
|
||
return new JsonResult(new
|
||
{
|
||
isSuccedded = true
|
||
});
|
||
return new JsonResult(new
|
||
{
|
||
isSuccedded = false
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// بلاک طرف حساب
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
[HttpPost("block-contracting-party/{id}")]
|
||
public IActionResult OnPostBlockContractingParty(long id)
|
||
{
|
||
var result = _contractingPartyApplication.Block(id);
|
||
var afterActtion = _contractingPartyApplication.GetDetails(id);
|
||
return new JsonResult(new
|
||
{
|
||
isSuccedded = result.IsSuccedded,
|
||
isBlock = afterActtion.IsBlock,
|
||
blockTimes = afterActtion.BlockTimes
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// آنبلاک طرف حساب
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
[HttpPost("unblock-contracting-party/{id}")]
|
||
public IActionResult OnPostUnBlockContractingParty(long id)
|
||
{
|
||
var result = _contractingPartyApplication.DisableBlock(id);
|
||
var afterActtion = _contractingPartyApplication.GetDetails(id);
|
||
return new JsonResult(new
|
||
{
|
||
isSuccedded = result.IsSuccedded,
|
||
isBlock = afterActtion.IsBlock,
|
||
blockTimes = afterActtion.BlockTimes
|
||
});
|
||
}
|
||
|
||
[HttpGet("extension/{id}")]
|
||
public ActionResult<EditInstitutionContract> OnGetExtension(long id)
|
||
{
|
||
var todayGr = DateTime.Now;
|
||
var todayFa = todayGr.ToFarsi();
|
||
var previusContract = _institutionContractApplication.GetDetails(id);
|
||
var previusContractEnd = previusContract.ContractEndGr.AddDays(1);
|
||
var startFa = previusContractEnd.ToFarsi();
|
||
var endFa = startFa.FindeEndOfYear();
|
||
|
||
|
||
var representativList = new List<RepresentativeViewModel>();
|
||
var contractingPartyList = new List<PersonalContractingPartyViewModel>();
|
||
var res = _institutionContractApplication.GetDetails(id);
|
||
var representative = new RepresentativeViewModel
|
||
{
|
||
Id = res.RepresentativeId,
|
||
FullName = res.RepresentativeName
|
||
};
|
||
representativList.Add(representative);
|
||
var contractingParty = new PersonalContractingPartyViewModel
|
||
{
|
||
id = res.ContractingPartyId,
|
||
FullName = _contractingPartyApplication.GetFullName(res.ContractingPartyId)
|
||
};
|
||
contractingPartyList.Add(contractingParty);
|
||
res.RepresentativeSelectList =
|
||
new SelectList(representativList, "Id", "FullName");
|
||
res.ContractingPartiesSelectList =
|
||
new SelectList(contractingPartyList, "id", "FullName");
|
||
|
||
var employer = _employerApplication.GetEmployerByContracrtingPartyID(res.ContractingPartyId);
|
||
var emplId = employer.Select(x => x.Id).ToList();
|
||
|
||
var w = _workshopApplication.GetWorkshopsByEmployerId(emplId);
|
||
var workshopIds = w.Select(x => x.Id).ToList();
|
||
var workshopCount = Convert.ToString(w.Count);
|
||
|
||
var pCount = 0;
|
||
if (workshopIds.Count > 0)
|
||
{
|
||
foreach (var workshopId in workshopIds)
|
||
{
|
||
var p = _workshopApplication.PersonnelCount(workshopId);
|
||
pCount += p;
|
||
}
|
||
|
||
res.EmployeeCount = Convert.ToString(pCount);
|
||
}
|
||
else
|
||
{
|
||
res.EmployeeCount = "0";
|
||
}
|
||
|
||
|
||
//var left = _leftWorkApplication.GetLeftPersonelByWorkshopId(workshopIds);
|
||
|
||
res.WorkshopCount = workshopCount;
|
||
|
||
res.WorkshopManualCount = workshopCount;
|
||
res.EmployeeManualCount = res.EmployeeCount;
|
||
|
||
res.ContractDateFa = todayFa;
|
||
res.ContractStartFa = startFa;
|
||
res.ContractEndFa = endFa;
|
||
res.ContractAmountString = "0";
|
||
res.DailyCompenseationString = "0";
|
||
res.ObligationString = "0";
|
||
res.TotalAmountString = "0";
|
||
res.PrviousContractId = id;
|
||
|
||
|
||
if (!string.IsNullOrWhiteSpace(res.EmployeeManualCount))
|
||
{
|
||
var countPerson = Convert.ToInt32(res.EmployeeCount);
|
||
var finalAmount = _institutionContractApplication.GetcontractAmount(countPerson);
|
||
|
||
var syear = Convert.ToInt32(startFa.Substring(0, 4));
|
||
var smonth = Convert.ToInt32(startFa.Substring(5, 2));
|
||
var sday = Convert.ToInt32(startFa.Substring(8, 2));
|
||
|
||
|
||
var eyear = Convert.ToInt32(endFa.Substring(0, 4));
|
||
var emonth = Convert.ToInt32(endFa.Substring(5, 2));
|
||
var eday = Convert.ToInt32(endFa.Substring(8, 2));
|
||
emonth += 1;
|
||
|
||
var def = (eyear - syear) * 12 + emonth - smonth;
|
||
|
||
|
||
//رند ماهیانه
|
||
//int rightMDigits = (int)(finalAmount % 1000000);
|
||
//if (rightMDigits < 500000)
|
||
//{
|
||
// finalAmount = (int)(finalAmount / 100000) * 100000;
|
||
//}
|
||
//else
|
||
//{
|
||
// finalAmount = (int)(finalAmount / 100000 + 1) * 100000;
|
||
//}
|
||
finalAmount = (int)(finalAmount / 1000000) * 1000000;
|
||
|
||
double compute = 0;
|
||
double tenPercent = 0;
|
||
if (res.HasValueAddedTax == "true")
|
||
{
|
||
tenPercent = finalAmount * 10 / 100;
|
||
res.ContractAmountOAlone = finalAmount.ToMoney();
|
||
|
||
//افزودن 10 درصد
|
||
finalAmount += tenPercent;
|
||
res.ContractAmountString = finalAmount.ToMoney();
|
||
res.ValueAddedTaxStr = tenPercent.ToMoney();
|
||
compute = finalAmount * def;
|
||
res.ObligationString = compute.ToMoney();
|
||
res.TotalAmountString = res.ObligationString;
|
||
}
|
||
else
|
||
{
|
||
res.ContractAmountOAlone = finalAmount.ToMoney();
|
||
res.ContractAmountString = res.ContractAmountOAlone;
|
||
res.ValueAddedTaxStr = "0";
|
||
compute = finalAmount * def;
|
||
res.ObligationString = compute.ToMoney();
|
||
res.TotalAmountString = res.ObligationString;
|
||
}
|
||
|
||
|
||
//رند سالانه
|
||
|
||
//int rightYDigits = (int)(compute % 10000000);
|
||
//if (rightYDigits < 5000000)
|
||
|
||
//compute = (int)(compute / 1000000) * 1000000;
|
||
}
|
||
|
||
var contactInfo = _contactInfoApplication.GetContactInfolist(id);
|
||
if (contactInfo.Count > 0)
|
||
{
|
||
res.ContactInfoCounter = contactInfo.Count;
|
||
res.ContactInformationList = contactInfo;
|
||
}
|
||
else
|
||
{
|
||
res.ContactInfoCounter = 0;
|
||
}
|
||
|
||
|
||
return res;
|
||
}
|
||
|
||
[HttpPost("extension")]
|
||
public async Task<ActionResult<OperationResult>> OnPostExtension(
|
||
[FromBody] ExtenstionInstitutionContractRequest command)
|
||
{
|
||
var op = new OperationResult();
|
||
|
||
var phoneNumber = command.ContactInfos.FirstOrDefault(x =>
|
||
x.SendSmsString == "true" && x.Position == "طرف قرارداد" && x.PhoneType == "شماره همراه");
|
||
var conractingParty = _contractingPartyApplication.GetDetails(command.ContractingPartyId);
|
||
|
||
if (conractingParty.IsLegal == "حقیقی" && string.IsNullOrWhiteSpace(conractingParty.Nationalcode))
|
||
return new JsonResult(op.Failed("کد ملی طرف حساب وجود ندارد"));
|
||
if (conractingParty.IsLegal == "حقوقی" && string.IsNullOrWhiteSpace(conractingParty.NationalId))
|
||
return new JsonResult(op.Failed("شناسه ملی طرف حساب وجود ندارد"));
|
||
if (phoneNumber == null)
|
||
return new JsonResult(op.Failed("تعیین شماره همراه با سمت طرف قرارداد اجباریست"));
|
||
|
||
|
||
var counter = command.ContactInfos.Count;
|
||
|
||
var result = await _institutionContractApplication.ExtensionَAsync(command);
|
||
|
||
if (result.IsSuccedded && counter > 0)
|
||
{
|
||
for (var i = 0; i <= counter - 1; i++)
|
||
{
|
||
if (command.ContactInfos[i].PhoneNumber != null)
|
||
{
|
||
var contactinfo = new CreateContactInfo
|
||
{
|
||
InstitutionContractId = result.SendId,
|
||
PhoneType = command.ContactInfos[i].PhoneType,
|
||
Position = command.ContactInfos[i].Position,
|
||
PhoneNumber = command.ContactInfos[i].PhoneNumber,
|
||
FnameLname = command.ContactInfos[i].FnameLname,
|
||
SendSms = command.ContactInfos[i].SendSmsString == "true" ? true : false
|
||
};
|
||
_contactInfoApplication.Create(contactinfo);
|
||
}
|
||
|
||
Thread.Sleep(500);
|
||
}
|
||
}
|
||
|
||
|
||
if (result.IsSuccedded)
|
||
{
|
||
_institutionContractApplication.DeActive(command.PreviousContractId);
|
||
_institutionContractApplication.ReActiveAllAfterCreateNew(command.ContractingPartyId);
|
||
}
|
||
|
||
var contractingPartyId = _institutionContractApplication.GetDetails(result.SendId);
|
||
|
||
var getOldContarct = _institutionContractApplication.NewSearch(new InstitutionContractSearchModel()
|
||
{ ContractingPartyId = contractingPartyId.ContractingPartyId, IsActiveString = "both" })
|
||
.Where(x => x.IsActiveString == "false" || x.IsActiveString == "blue").ToList();
|
||
if (result.IsSuccedded && counter > 0)
|
||
{
|
||
if (getOldContarct.Count > 0)
|
||
{
|
||
foreach (var item in getOldContarct)
|
||
{
|
||
_contactInfoApplication.RemoveContactInfo(item.Id);
|
||
foreach (var phone in command.ContactInfos)
|
||
{
|
||
if (phone.PhoneNumber != null)
|
||
{
|
||
var contactinfo = new CreateContactInfo
|
||
{
|
||
InstitutionContractId = item.Id,
|
||
PhoneType = phone.PhoneType,
|
||
Position = phone.Position,
|
||
PhoneNumber = phone.PhoneNumber,
|
||
FnameLname = phone.FnameLname,
|
||
SendSms = phone.SendSmsString == "true" ? true : false
|
||
};
|
||
_contactInfoApplication.Create(contactinfo);
|
||
}
|
||
|
||
Thread.Sleep(500);
|
||
}
|
||
}
|
||
|
||
//ساخت اکانت کلاینت
|
||
var userPass = conractingParty.IsLegal == "حقیقی"
|
||
? conractingParty.Nationalcode
|
||
: conractingParty.NationalId;
|
||
var checkExistAccount = _accountApplication.CheckExistClientAccount(userPass);
|
||
if (!checkExistAccount)
|
||
{
|
||
var createAcc = new RegisterAccount
|
||
{
|
||
Fullname = conractingParty.LName,
|
||
Username = userPass,
|
||
Password = userPass,
|
||
Mobile = phoneNumber.PhoneNumber,
|
||
NationalCode = userPass
|
||
};
|
||
var res = _accountApplication.RegisterClient(createAcc);
|
||
if (res.IsSuccedded)
|
||
_institutionContractApplication.CreateContractingPartyAccount(command.ContractingPartyId,
|
||
res.SendId);
|
||
}
|
||
}
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// دانلود اکسل
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet("excel")]
|
||
public IActionResult OnGetDownloadExcel()
|
||
{
|
||
var institutionContractViewModels =
|
||
_institutionContractApplication.NewSearch(new() { IsActiveString = "both", TypeOfContract = "both" });
|
||
var bytes = InstitutionContractExcelGenerator.GenerateExcel(institutionContractViewModels);
|
||
return File(bytes,
|
||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||
$"قرارداد های مالی.xlsx");
|
||
}
|
||
|
||
[HttpPost("create/inquiry")]
|
||
public async Task<ActionResult<OperationResult<ContractingPartyTempViewModel>>> CreateInquiry(
|
||
[FromBody] CreateInquiryRequest request)
|
||
{
|
||
var res = await _temporaryClientRegistration.CreateContractingPartyTemp(request.NationalCode,
|
||
request.DateOfBirth,
|
||
request.Mobile);
|
||
return res;
|
||
}
|
||
|
||
[HttpPost("create/workshop-service-calculator")]
|
||
public ActionResult<WorkshopServiceCalculatorResponse> WorkshopServiceCalculator([FromBody]CreateWorkshopTemp command)
|
||
{
|
||
var workshopTemp = new WorkshopTempViewModel
|
||
{
|
||
WorkshopName = command.WorkshopName,
|
||
CountPerson = command.CountPerson,
|
||
ContractAndCheckout = command.ContractAndCheckout,
|
||
Insurance = command.Insurance,
|
||
RollCall = command.RollCall,
|
||
CustomizeCheckout = command.CustomizeCheckout,
|
||
ContractAndCheckoutInPerson = command.ContractAndCheckoutInPerson,
|
||
InsuranceInPerson = command.InsuranceInPerson
|
||
};
|
||
|
||
var response = _temporaryClientRegistration.GetInstitutionPlanForWorkshop(workshopTemp);
|
||
|
||
var result = new WorkshopServiceCalculatorResponse
|
||
{
|
||
TotalAmount = response.OnlineAndInPersonSumAmountStr
|
||
};
|
||
return result;
|
||
}
|
||
|
||
[HttpPost("create/institution-plan-calculator")]
|
||
public async Task<ActionResult<InstitutionPlanCalculatorResponse>> InstitutionPlanCalculator(
|
||
[FromBody] InstitutionPlanCalculatorRequest request)
|
||
{
|
||
var res = await _temporaryClientRegistration.GetTotalPaymentAndWorkshopList(request.TotalAmountMonth,duration: request.Duration);
|
||
var response = new InstitutionPlanCalculatorResponse
|
||
{
|
||
Installments = res.MonthlyInstallments,
|
||
OneTimeTotalAmountWithoutTax = res.OneTimeWithoutTaxPaymentStr,
|
||
MonthlyTotalAmountWithoutTax = res.MonthlyWithoutTaxPaymentStr,
|
||
OneTimeTotalAmount = res.OneTimeTotalPaymentStr,
|
||
MonthlyTotalAmount= res.MonthlyTotalPaymentStr,
|
||
TotalTax = res.ValueAddedTaxStr,
|
||
ContractStart = res.ContractStartFa,
|
||
ContractEnd = res.ContractEndFa,
|
||
Discount = res.Discount??"0",
|
||
|
||
};
|
||
return response;
|
||
}
|
||
|
||
/// <summary>
|
||
/// ایجاد
|
||
/// </summary>
|
||
/// <param name="command"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task<ActionResult<OperationResult>> Create([FromBody]CreateInstitutionContractRequest command)
|
||
{
|
||
var res =await _institutionContractApplication.CreateAsync(command);
|
||
return res;
|
||
}
|
||
|
||
/// <summary>
|
||
/// ارسال لینک تایید قوانین و مقررات به طرف حساب
|
||
/// </summary>
|
||
/// <param name="contractingPartyTempId"></param>
|
||
/// <returns></returns>
|
||
[HttpPost("create/send-link/{contractingPartyTempId}")]
|
||
public async Task<ActionResult<OperationResult>> SendAgreementLink(long contractingPartyTempId)
|
||
{
|
||
return await _temporaryClientRegistration.SendAgreementLink(contractingPartyTempId);
|
||
}
|
||
|
||
[HttpPost("create/verify-code")]
|
||
public async Task<ActionResult<OperationResult>> CheckVerifyCode(VerifyCodeRequest request)
|
||
{
|
||
using var transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
|
||
var operationResult =
|
||
await _temporaryClientRegistration.CheckVerifyCodeIsTrue(request.ContractingPartyId, request.verifyCode);
|
||
if (!operationResult.IsSuccedded)
|
||
return operationResult;
|
||
|
||
operationResult = await _temporaryClientRegistration.PayOffCompleted(request.ContractingPartyId);
|
||
|
||
if (operationResult.IsSuccedded)
|
||
transaction.Complete();
|
||
|
||
return operationResult;
|
||
}
|
||
}
|
||
|
||
public class InstitutionPlanCalculatorResponse
|
||
{
|
||
public string TotalAmountWithTax { get; set; }
|
||
public string OneTimeTotalAmountWithoutTax { get; set; }
|
||
public string TotalTax { get; set; }
|
||
public List<MonthlyInstallment> Installments { get; set; }
|
||
public string OneTimeTotalAmount { get; set; }
|
||
public string MonthlyTotalAmount { get; set; }
|
||
public string MonthlyTotalAmountWithoutTax { get; set; }
|
||
public string ContractStart { get; set; }
|
||
public string ContractEnd { get; set; }
|
||
public string Discount { get; set; }
|
||
}
|
||
|
||
public class WorkshopServiceCalculatorResponse
|
||
{
|
||
public string TotalAmount { get; set; }
|
||
}
|
||
|
||
public record InstitutionPlanCalculatorRequest(double TotalAmountMonth,
|
||
InstitutionContractDuration Duration = InstitutionContractDuration.TwelveMonths);
|
||
|
||
public class CreateInquiryRequest
|
||
{
|
||
public string NationalCode { get; set; }
|
||
public string DateOfBirth { get; set; }
|
||
public string Mobile { get; set; }
|
||
}
|
||
|
||
public class VerifyCodeRequest
|
||
{
|
||
public long ContractingPartyId { get; set; }
|
||
public string verifyCode { get; set; }
|
||
} |