add InstitutionContract Confirm Reminder Sms completed
This commit is contained in:
@@ -1,15 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Application.Sms;
|
||||
using _0_Framework.Exceptions;
|
||||
@@ -38,6 +27,7 @@ using CompanyManagment.App.Contracts.Law;
|
||||
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using CompanyManagment.App.Contracts.WorkshopPlan;
|
||||
using CompanyManagment.EFCore.Migrations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -47,10 +37,23 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using MongoDB.Driver;
|
||||
using OfficeOpenXml.Packaging.Ionic.Zip;
|
||||
using PersianTools.Core;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
using SmsResult = CompanyManagment.EFCore.Migrations.SmsResult;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using ContractingPartyAccount = Company.Domain.ContractingPartyAccountAgg.ContractingPartyAccount;
|
||||
using FinancialStatment = Company.Domain.FinancialStatmentAgg.FinancialStatment;
|
||||
using String = System.String;
|
||||
using Workshop = Company.Domain.WorkshopAgg.Workshop;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
@@ -102,69 +105,69 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
public EditInstitutionContract GetDetails(long id)
|
||||
{
|
||||
return _context.InstitutionContractSet.Select(x => new EditInstitutionContract()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractNo = x.ContractNo,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
RepresentativeName = x.RepresentativeName,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractDateFa = x.ContractDateFa,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address,
|
||||
Description = x.Description,
|
||||
WorkshopManualCount = x.WorkshopManualCount,
|
||||
EmployeeManualCount = x.EmployeeManualCount,
|
||||
ContractAmountString = x.ContractAmount.ToMoney(),
|
||||
ContractAmount = x.ContractAmount,
|
||||
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
||||
ObligationString = x.Obligation.ToMoney(),
|
||||
TotalAmountString = x.TotalAmount.ToMoney(),
|
||||
ExtensionNo = x.ExtensionNo,
|
||||
OfficialCompany = x.OfficialCompany,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
Signature = x.Signature,
|
||||
HasValueAddedTax = x.HasValueAddedTax,
|
||||
ValueAddedTax = x.ValueAddedTax,
|
||||
})
|
||||
{
|
||||
Id = x.id,
|
||||
ContractNo = x.ContractNo,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
RepresentativeName = x.RepresentativeName,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractDateFa = x.ContractDateFa,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address,
|
||||
Description = x.Description,
|
||||
WorkshopManualCount = x.WorkshopManualCount,
|
||||
EmployeeManualCount = x.EmployeeManualCount,
|
||||
ContractAmountString = x.ContractAmount.ToMoney(),
|
||||
ContractAmount = x.ContractAmount,
|
||||
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
||||
ObligationString = x.Obligation.ToMoney(),
|
||||
TotalAmountString = x.TotalAmount.ToMoney(),
|
||||
ExtensionNo = x.ExtensionNo,
|
||||
OfficialCompany = x.OfficialCompany,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
Signature = x.Signature,
|
||||
HasValueAddedTax = x.HasValueAddedTax,
|
||||
ValueAddedTax = x.ValueAddedTax,
|
||||
})
|
||||
.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
public EditInstitutionContract GetFirstContract(long contractingPartyId, string typeOfContract)
|
||||
{
|
||||
return _context.InstitutionContractSet.Select(x => new EditInstitutionContract()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractNo = x.ContractNo,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
RepresentativeName = x.RepresentativeName,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractDateFa = x.ContractDateFa,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address,
|
||||
Description = x.Description,
|
||||
WorkshopManualCount = x.WorkshopManualCount,
|
||||
EmployeeManualCount = x.EmployeeManualCount,
|
||||
ContractAmountString = x.ContractAmount.ToMoney(),
|
||||
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
||||
ObligationString = x.Obligation.ToMoney(),
|
||||
TotalAmountString = x.TotalAmount.ToMoney(),
|
||||
ExtensionNo = x.ExtensionNo,
|
||||
OfficialCompany = x.OfficialCompany,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
Signature = x.Signature
|
||||
})
|
||||
{
|
||||
Id = x.id,
|
||||
ContractNo = x.ContractNo,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
RepresentativeName = x.RepresentativeName,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractDateFa = x.ContractDateFa,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address,
|
||||
Description = x.Description,
|
||||
WorkshopManualCount = x.WorkshopManualCount,
|
||||
EmployeeManualCount = x.EmployeeManualCount,
|
||||
ContractAmountString = x.ContractAmount.ToMoney(),
|
||||
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
||||
ObligationString = x.Obligation.ToMoney(),
|
||||
TotalAmountString = x.TotalAmount.ToMoney(),
|
||||
ExtensionNo = x.ExtensionNo,
|
||||
OfficialCompany = x.OfficialCompany,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
Signature = x.Signature
|
||||
})
|
||||
.Where(x => x.ContractingPartyId == contractingPartyId && x.TypeOfContract == typeOfContract)
|
||||
.OrderBy(x => x.ExtensionNo).FirstOrDefault();
|
||||
}
|
||||
@@ -582,40 +585,40 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
}).ToList(),
|
||||
}).ToList();
|
||||
listQuery = listQuery.Select(x => new InstitutionContractViewModel()
|
||||
{
|
||||
Id = x.Id,
|
||||
ContractNo = x.ContractNo,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
RepresentativeName = x.RepresentativeName,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractAmount = x.ContractAmount,
|
||||
TotalAmount = x.TotalAmount,
|
||||
SearchAmount = x.SearchAmount,
|
||||
IsActiveString = x.IsActiveString,
|
||||
OfficialCompany = x.OfficialCompany,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
Signature = x.Signature,
|
||||
ExpireColor = x.ExpireColor,
|
||||
IsExpier = x.IsExpier,
|
||||
BalanceDouble = x.BalanceDouble,
|
||||
BalanceStr = x.BalanceStr,
|
||||
EmployerViewModels = x.EmployerViewModels,
|
||||
EmployerNo = x.EmployerNo,
|
||||
EmployerName = x.EmployerViewModels.Select(n => n.FullName).FirstOrDefault(),
|
||||
WorkshopViewModels = x.WorkshopViewModels,
|
||||
WorkshopCount = x.WorkshopCount,
|
||||
IsContractingPartyBlock = x.IsContractingPartyBlock,
|
||||
BlockTimes = x.BlockTimes,
|
||||
EmployeeCount =
|
||||
{
|
||||
Id = x.Id,
|
||||
ContractNo = x.ContractNo,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
RepresentativeName = x.RepresentativeName,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractAmount = x.ContractAmount,
|
||||
TotalAmount = x.TotalAmount,
|
||||
SearchAmount = x.SearchAmount,
|
||||
IsActiveString = x.IsActiveString,
|
||||
OfficialCompany = x.OfficialCompany,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
Signature = x.Signature,
|
||||
ExpireColor = x.ExpireColor,
|
||||
IsExpier = x.IsExpier,
|
||||
BalanceDouble = x.BalanceDouble,
|
||||
BalanceStr = x.BalanceStr,
|
||||
EmployerViewModels = x.EmployerViewModels,
|
||||
EmployerNo = x.EmployerNo,
|
||||
EmployerName = x.EmployerViewModels.Select(n => n.FullName).FirstOrDefault(),
|
||||
WorkshopViewModels = x.WorkshopViewModels,
|
||||
WorkshopCount = x.WorkshopCount,
|
||||
IsContractingPartyBlock = x.IsContractingPartyBlock,
|
||||
BlockTimes = x.BlockTimes,
|
||||
EmployeeCount =
|
||||
((x.WorkshopViewModels.Sum(w => w.LeftWorkIds.Count)) + (x.WorkshopViewModels.Sum(w =>
|
||||
w.InsuranceLeftWorkIds.Count(c => !w.LeftWorkIds.Contains(c))))).ToString(),
|
||||
ArchiveCode = x.WorkshopViewModels.Count > 0 ? ArchiveCodeFinder(x.WorkshopViewModels) : 0,
|
||||
}).OrderBy(x => x.WorkshopCount != "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
|
||||
ArchiveCode = x.WorkshopViewModels.Count > 0 ? ArchiveCodeFinder(x.WorkshopViewModels) : 0,
|
||||
}).OrderBy(x => x.WorkshopCount != "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
|
||||
.ThenBy(x => x.WorkshopCount == "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
|
||||
.ThenBy(x => x.IsExpier == "true")
|
||||
.ThenBy(x => x.ExpireColor == "purple")
|
||||
@@ -640,17 +643,17 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
var op = new OperationResult();
|
||||
var institutionContarct = _context.InstitutionContractSet
|
||||
.FirstOrDefault(x => x.id == id);
|
||||
|
||||
|
||||
var prevInstitutionContracts = _context.InstitutionContractSet
|
||||
.Where(x => x.ContractingPartyId == institutionContarct.ContractingPartyId)
|
||||
.OrderByDescending(x => x.ContractEndGr).Skip(1).FirstOrDefault();
|
||||
|
||||
|
||||
var transaction = _context.Database.BeginTransaction();
|
||||
|
||||
|
||||
var contactInfo = _context.InstitutionContractContactInfos
|
||||
.Where(x => x.InstitutionContractId == id)
|
||||
.ToList();
|
||||
|
||||
|
||||
if (contactInfo.Count > 0)
|
||||
{
|
||||
foreach (var item in contactInfo)
|
||||
@@ -673,20 +676,20 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
var financialStatement =
|
||||
_context.FinancialStatments
|
||||
.Include(x => x.FinancialTransactionList)
|
||||
.FirstOrDefault(x=>x.ContractingPartyId == institutionContarct.ContractingPartyId);
|
||||
.FirstOrDefault(x => x.ContractingPartyId == institutionContarct.ContractingPartyId);
|
||||
if (financialStatement != null)
|
||||
{
|
||||
|
||||
var sumDebtor = financialStatement.FinancialTransactionList
|
||||
.Sum(x => x.Deptor);
|
||||
|
||||
var sumDebtor = financialStatement.FinancialTransactionList
|
||||
.Sum(x => x.Deptor);
|
||||
var sumCreditor = financialStatement.FinancialTransactionList
|
||||
.Sum(x => x.Creditor);
|
||||
var balance = sumDebtor - sumCreditor;
|
||||
if (balance>0 && prevInstitutionContracts.ContractEndGr<now)
|
||||
{
|
||||
prevInstitutionContracts.DeActiveBlue();
|
||||
_context.SaveChanges();
|
||||
}
|
||||
if (balance > 0 && prevInstitutionContracts.ContractEndGr < now)
|
||||
{
|
||||
prevInstitutionContracts.DeActiveBlue();
|
||||
_context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3573,19 +3576,19 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
var smsList = new List<BlockSmsListData>();
|
||||
|
||||
var institutionContracts = await _context.InstitutionContractSet.Select(x => new InstitutionContractViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
IsActiveString = x.IsActiveString,
|
||||
ContractAmountDouble = x.ContractAmount,
|
||||
OfficialCompany = x.OfficialCompany
|
||||
}).Where(x => x.ContractStartGr < checkDate && x.ContractEndGr >= checkDate &&
|
||||
x.ContractAmountDouble > 0).GroupBy(x => x.ContractingPartyId).Select(x => x.First())
|
||||
{
|
||||
Id = x.id,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
IsActiveString = x.IsActiveString,
|
||||
ContractAmountDouble = x.ContractAmount,
|
||||
OfficialCompany = x.OfficialCompany
|
||||
}).Where(x => x.ContractStartGr < checkDate && x.ContractEndGr >= checkDate &&
|
||||
x.ContractAmountDouble > 0).GroupBy(x => x.ContractingPartyId).Select(x => x.First())
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
@@ -3679,9 +3682,12 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
{
|
||||
smsList.Add(new BlockSmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber, PartyName = partyName,
|
||||
AccountType = accountType, Amount = amount,
|
||||
ContractingPartyId = contractingParty.id, InstitutionContractId = item.Id,
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
PartyName = partyName,
|
||||
AccountType = accountType,
|
||||
Amount = amount,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
InstitutionContractId = item.Id,
|
||||
AproveId = aprove
|
||||
});
|
||||
}
|
||||
@@ -3869,11 +3875,16 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
smsList.Add(new SmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber, TemplateId = templateId,
|
||||
PartyName = partyName, Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id, AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBillNew", Code1 = code1,
|
||||
Code2 = code2, InstitutionContractId = item.Id
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
TemplateId = templateId,
|
||||
PartyName = partyName,
|
||||
Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBillNew",
|
||||
Code1 = code1,
|
||||
Code2 = code2,
|
||||
InstitutionContractId = item.Id
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -3887,10 +3898,15 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
smsList.Add(new SmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber, TemplateId = templateId,
|
||||
PartyName = partyName, Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id, AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBill", Code1 = "", Code2 = "",
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
TemplateId = templateId,
|
||||
PartyName = partyName,
|
||||
Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBill",
|
||||
Code1 = "",
|
||||
Code2 = "",
|
||||
InstitutionContractId = item.Id
|
||||
});
|
||||
}
|
||||
@@ -3922,11 +3938,16 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
smsList.Add(new SmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber, TemplateId = templateId,
|
||||
PartyName = partyName, Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id, AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBillNew", Code1 = code1,
|
||||
Code2 = code2, InstitutionContractId = item.Id
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
TemplateId = templateId,
|
||||
PartyName = partyName,
|
||||
Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBillNew",
|
||||
Code1 = code1,
|
||||
Code2 = code2,
|
||||
InstitutionContractId = item.Id
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -3940,10 +3961,15 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
smsList.Add(new SmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber, TemplateId = templateId,
|
||||
PartyName = partyName, Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id, AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBill", Code1 = "", Code2 = "",
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
TemplateId = templateId,
|
||||
PartyName = partyName,
|
||||
Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBill",
|
||||
Code1 = "",
|
||||
Code2 = "",
|
||||
InstitutionContractId = item.Id
|
||||
});
|
||||
}
|
||||
@@ -3979,11 +4005,16 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
smsList.Add(new SmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber, TemplateId = templateId,
|
||||
PartyName = partyName, Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id, AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBillNew", Code1 = code1,
|
||||
Code2 = code2, InstitutionContractId = item.Id
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
TemplateId = templateId,
|
||||
PartyName = partyName,
|
||||
Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBillNew",
|
||||
Code1 = code1,
|
||||
Code2 = code2,
|
||||
InstitutionContractId = item.Id
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -3997,10 +4028,15 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
smsList.Add(new SmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber, TemplateId = templateId,
|
||||
PartyName = partyName, Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id, AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBill", Code1 = "", Code2 = "",
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
TemplateId = templateId,
|
||||
PartyName = partyName,
|
||||
Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBill",
|
||||
Code1 = "",
|
||||
Code2 = "",
|
||||
InstitutionContractId = item.Id
|
||||
});
|
||||
}
|
||||
@@ -4035,11 +4071,16 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
string code2 = publicId.Substring(25);
|
||||
smsList.Add(new SmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber, TemplateId = templateId,
|
||||
PartyName = partyName, Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id, AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBillNew", Code1 = code1,
|
||||
Code2 = code2, InstitutionContractId = item.Id
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
TemplateId = templateId,
|
||||
PartyName = partyName,
|
||||
Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBillNew",
|
||||
Code1 = code1,
|
||||
Code2 = code2,
|
||||
InstitutionContractId = item.Id
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -4053,10 +4094,15 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
smsList.Add(new SmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber, TemplateId = templateId,
|
||||
PartyName = partyName, Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id, AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBill", Code1 = "", Code2 = "",
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
TemplateId = templateId,
|
||||
PartyName = partyName,
|
||||
Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBill",
|
||||
Code1 = "",
|
||||
Code2 = "",
|
||||
InstitutionContractId = item.Id
|
||||
});
|
||||
}
|
||||
@@ -4217,6 +4263,9 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#region PrivateMetods
|
||||
|
||||
/// <summary>
|
||||
@@ -4258,6 +4307,88 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
.FirstOrDefaultAsync(x => x.ContractingPartyId == contractingPartyId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region InstitutionContractConfirm
|
||||
/// <summary>
|
||||
/// ارسال پیامک یادآور تایید قراداد مالی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task SendInstitutionContractConfirmSmsTask()
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
|
||||
|
||||
// تبدیل تاریخ میلادی به شمسی
|
||||
var persianNow = now.ToFarsi();
|
||||
var persianEndOfMonth = int.Parse(persianNow.FindeEndOfMonth().Substring(8, 2));
|
||||
var dayOfMonth = int.Parse(persianNow.Substring(8, 2));
|
||||
var hour = now.Hour;
|
||||
var minute = now.Minute;
|
||||
var checkAnyToExecute = false;
|
||||
|
||||
//اگر آخرین روز ماه باشد
|
||||
//اگر روز مثلا عدد روز 31 بود ولی آخرین روز ماه 30 بود
|
||||
if (dayOfMonth == persianEndOfMonth)
|
||||
{
|
||||
checkAnyToExecute = await _context.SmsSettings
|
||||
.AnyAsync(x =>
|
||||
x.DayOfMonth >= dayOfMonth && /// اگر بزرگتر یا مساوی رو جاری بود
|
||||
x.TimeOfDay.Hours == hour &&
|
||||
x.TimeOfDay.Minutes == minute &&
|
||||
x.TypeOfSmsSetting == TypeOfSmsSetting.InstitutionContractConfirm &&
|
||||
x.IsActive
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
checkAnyToExecute = await _context.SmsSettings
|
||||
.AnyAsync(x =>
|
||||
x.DayOfMonth == dayOfMonth &&
|
||||
x.TimeOfDay.Hours == hour &&
|
||||
x.TimeOfDay.Minutes == minute &&
|
||||
x.TypeOfSmsSetting == TypeOfSmsSetting.InstitutionContractConfirm &&
|
||||
x.IsActive
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (checkAnyToExecute)
|
||||
{
|
||||
//اجرای تسک
|
||||
|
||||
//دریافت لیست قراداد های تایید نشده
|
||||
var fromAmonthAgo = now.AddDays(-30);
|
||||
var pendingContracts = await _context.InstitutionContractSet
|
||||
.Where(x => x.CreationDate >= fromAmonthAgo && x.CreationDate.Date != now.Date && x.VerificationStatus == InstitutionContractVerificationStatus.PendingForVerify)
|
||||
.Join(_context.PersonalContractingParties,
|
||||
contract => contract.ContractingPartyId,
|
||||
contractingParty => contractingParty.id,
|
||||
(contract, contractingParty) => new { contract, contractingParty }).Select(x => new InstitutionCreationVerificationSmsDto
|
||||
{
|
||||
Number = x.contractingParty.Phone,
|
||||
FullName = x.contractingParty.IsLegal == "حقیقی" ? $"{x.contractingParty.FName} {x.contractingParty.LName}" : $"{x.contractingParty.LName}",
|
||||
ContractingPartyId = x.contract.ContractingPartyId,
|
||||
InstitutionContractId = x.contract.id,
|
||||
InstitutionId = x.contract.PublicId,
|
||||
}).ToListAsync();
|
||||
|
||||
string typeOfSms = "یادآور تایید قرارداد مالی";
|
||||
foreach (var item in pendingContracts)
|
||||
{
|
||||
var sendResult = await _smsService.SendInstitutionCreationVerificationLink(item.Number, item.FullName,
|
||||
item.InstitutionId, item.ContractingPartyId, item.InstitutionContractId, typeOfSms);
|
||||
}
|
||||
|
||||
Console.WriteLine("executed at : " + persianNow + " - " + hour + ":" + minute);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
@@ -4301,7 +4432,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
VerificationStatus = x.VerificationStatus,
|
||||
InstallmentList = x.Installments
|
||||
.Select(ins => new InstitutionContractInstallmentViewModel
|
||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||
.OrderBy(ins => ins.InstallmentDateGr).Skip(1).ToList(),
|
||||
}).Where(x =>
|
||||
x.ContractStartGr < endOfMonthGr && x.ContractEndGr >= endOfMonthGr && x.ContractAmountDouble > 0)
|
||||
@@ -4345,7 +4476,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
VerificationStatus = x.VerificationStatus,
|
||||
InstallmentList = x.Installments
|
||||
.Select(ins => new InstitutionContractInstallmentViewModel
|
||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||
.OrderBy(ins => ins.InstallmentDateGr).Skip(1).ToList(),
|
||||
}).ToListAsync();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user