update block sms method
This commit is contained in:
@@ -25,23 +25,23 @@ public class JobSchedulerRegistrator
|
||||
public void Register()
|
||||
{
|
||||
|
||||
//RecurringJob.AddOrUpdate(
|
||||
// "InstitutionContract.CreateFinancialTransaction",
|
||||
// () => CreateFinancialTransaction(),
|
||||
// "*/30 * * * *" // هر 30 دقیقه یکبار چک کن
|
||||
//);
|
||||
RecurringJob.AddOrUpdate(
|
||||
"InstitutionContract.CreateFinancialTransaction",
|
||||
() => CreateFinancialTransaction(),
|
||||
"*/30 * * * *" // هر 30 دقیقه یکبار چک کن
|
||||
);
|
||||
|
||||
//RecurringJob.AddOrUpdate(
|
||||
// "InstitutionContract.SendMonthlySms",
|
||||
// () => SendMonthlySms(),
|
||||
// "*/20 * * * *" // هر 30 دقیقه یکبار چک کن
|
||||
//);
|
||||
RecurringJob.AddOrUpdate(
|
||||
"InstitutionContract.SendMonthlySms",
|
||||
() => SendFirstDayOfMonthSms(),
|
||||
"*/20 * * * *" // هر 30 دقیقه یکبار چک کن
|
||||
);
|
||||
|
||||
//RecurringJob.AddOrUpdate(
|
||||
// "InstitutionContract.SendReminderSms",
|
||||
// () => SendReminderSms(),
|
||||
// "*/1 * * * *" // هر 1 دقیقه یکبار چک کن
|
||||
//);
|
||||
RecurringJob.AddOrUpdate(
|
||||
"InstitutionContract.SendReminderSms",
|
||||
() => SendReminderSms(),
|
||||
"*/1 * * * *" // هر 1 دقیقه یکبار چک کن
|
||||
);
|
||||
RecurringJob.AddOrUpdate(
|
||||
"InstitutionContract.SendBlockSms",
|
||||
() => SendBlockSms(),
|
||||
@@ -98,8 +98,8 @@ public class JobSchedulerRegistrator
|
||||
/// ارسال پیامک صورت حساب ماهانه
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 1000)]
|
||||
public async System.Threading.Tasks.Task SendMonthlySms()
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 600)]
|
||||
public async System.Threading.Tasks.Task SendFirstDayOfMonthSms()
|
||||
{
|
||||
//var now = new DateTime(2025,11,21, 10,30,0);
|
||||
var now = DateTime.Now;
|
||||
|
||||
@@ -3168,11 +3168,24 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
x.ContractAmountDouble > 0).GroupBy(x => x.ContractingPartyId).Select(x => x.First()).ToListAsync();
|
||||
|
||||
|
||||
var contractingPartyList = await _context.PersonalContractingParties
|
||||
.Where(x => institutionContracts.Select(ins => ins.ContractingPartyId).Contains(x.id)).ToListAsync();
|
||||
|
||||
var financialStatmentList = await _context.FinancialStatments.AsSplitQuery()
|
||||
.Where(x => institutionContracts.Select(ins => ins.ContractingPartyId).Contains(x.ContractingPartyId))
|
||||
.Include(x => x.FinancialTransactionList).Where(
|
||||
x => x.FinancialTransactionList.Count > 0).ToListAsync();
|
||||
|
||||
var phoneNumberList = await _context.InstitutionContractContactInfos
|
||||
.Where(x => institutionContracts.Select(ins => ins.Id).Contains(x.InstitutionContractId))
|
||||
.Where(x => x.SendSms && x.PhoneType == "شماره همراه" && !string.IsNullOrWhiteSpace(x.PhoneNumber) &&
|
||||
x.PhoneNumber.Length == 11).ToListAsync();
|
||||
|
||||
foreach (var item in institutionContracts)
|
||||
{
|
||||
try
|
||||
{
|
||||
var contractingParty = await _context.PersonalContractingParties.FirstOrDefaultAsync(x => x.id == item.ContractingPartyId);
|
||||
var contractingParty = contractingPartyList.FirstOrDefault(x => x.id == item.ContractingPartyId);
|
||||
if (contractingParty != null && contractingParty.IsBlock == "true")
|
||||
{
|
||||
|
||||
@@ -3184,26 +3197,25 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
var isLegal = contractingParty.IsLegal == "حقوقی" ? true : false;
|
||||
|
||||
var hasFinancialStatment =await _context.FinancialStatments.Include(x => x.FinancialTransactionList).AnyAsync(
|
||||
x => x.ContractingPartyId == item.ContractingPartyId && x.FinancialTransactionList.Count > 0);
|
||||
|
||||
var hasPhonNumber =await _context.InstitutionContractContactInfos
|
||||
.AnyAsync(x => x.InstitutionContractId == item.Id && x.SendSms && x.PhoneType == "شماره همراه" &&
|
||||
x.PhoneNumber.Length == 11);
|
||||
var hasFinancialStatment =
|
||||
financialStatmentList.Any(x => x.ContractingPartyId == item.ContractingPartyId & x.FinancialTransactionList.Count > 0);
|
||||
|
||||
|
||||
var hasPhonNumber = phoneNumberList.Any(x => x.InstitutionContractId == item.Id);
|
||||
|
||||
|
||||
|
||||
|
||||
if (hasFinancialStatment && hasPhonNumber)
|
||||
{
|
||||
|
||||
var transactions = GetFinancialByContractingPartyId(contractingParty.id).GetAwaiter().GetResult();
|
||||
|
||||
var debtor = transactions.FinancialTransactionViewModels.Sum(x => x.Deptor);
|
||||
var creditor = transactions.FinancialTransactionViewModels.Sum(x => x.Creditor);
|
||||
var transactions = financialStatmentList.FirstOrDefault(x => x.ContractingPartyId == item.ContractingPartyId);
|
||||
|
||||
var debtor = transactions.FinancialTransactionList.Sum(x => x.Deptor);
|
||||
var creditor = transactions.FinancialTransactionList.Sum(x => x.Creditor);
|
||||
|
||||
|
||||
var id = $"{item.ContractingPartyId}";
|
||||
var aprove = $"{transactions.Id}";
|
||||
var aprove = $"{transactions.id}";
|
||||
var balance = debtor - creditor;
|
||||
if (balance > 0)
|
||||
{
|
||||
@@ -3211,10 +3223,10 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
var taxAndFinancial = "بابت قرارداد مابین (حسابداری و مالیات)";
|
||||
|
||||
|
||||
var jobRelationContract = transactions.FinancialTransactionViewModels
|
||||
var jobRelationContract = transactions.FinancialTransactionList
|
||||
.OrderByDescending(x => x.TdateGr).FirstOrDefault(x =>
|
||||
x.TypeOfTransaction == "debt" && x.DescriptionOption == jobRelation);
|
||||
var taxAndFinancialContract = transactions.FinancialTransactionViewModels
|
||||
var taxAndFinancialContract = transactions.FinancialTransactionList
|
||||
.OrderByDescending(x => x.TdateGr).FirstOrDefault(x =>
|
||||
x.TypeOfTransaction == "debt" && x.DescriptionOption == taxAndFinancial);
|
||||
|
||||
@@ -3227,9 +3239,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
if (balance >= sumOfAmounts)
|
||||
{
|
||||
var phoneNumbers = new List<CreateContactInfo>();
|
||||
phoneNumbers = await _context.InstitutionContractContactInfos.Where(n =>
|
||||
n.InstitutionContractId == item.Id && n.SendSms && n.PhoneType == "شماره همراه" &&
|
||||
!string.IsNullOrWhiteSpace(n.PhoneNumber))
|
||||
phoneNumbers = phoneNumberList.Where(x => x.InstitutionContractId == item.Id)
|
||||
.Select(x => new CreateContactInfo
|
||||
{
|
||||
PhoneType = x.PhoneType,
|
||||
@@ -3237,7 +3247,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
InstitutionContractId = x.InstitutionContractId,
|
||||
SendSms = x.SendSms
|
||||
}).Where(x => x.PhoneNumber.Length == 11).ToListAsync();
|
||||
}).Where(x => x.PhoneNumber.Length == 11).ToList();
|
||||
|
||||
|
||||
var accountType = item.OfficialCompany == "Official" ? "ol" : "nol";
|
||||
|
||||
@@ -3309,7 +3320,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
var contractingPartyList = await _context.PersonalContractingParties
|
||||
.Where(x=> institutionContracts.Select(ins => ins.ContractingPartyId).Contains(x.id)).ToListAsync();
|
||||
|
||||
var financialStamentList = await _context.FinancialStatments.AsSplitQuery()
|
||||
var financialStatmentList = await _context.FinancialStatments.AsSplitQuery()
|
||||
.Where(x=> institutionContracts.Select(ins => ins.ContractingPartyId).Contains(x.ContractingPartyId))
|
||||
.Include(x => x.FinancialTransactionList).Where(
|
||||
x => x.FinancialTransactionList.Count > 0).ToListAsync();
|
||||
@@ -3343,7 +3354,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
if (!string.IsNullOrWhiteSpace(contractingParty.IsActiveString) && isActive)
|
||||
{
|
||||
var hasFinancialStatement =
|
||||
financialStamentList.Any(x => x.ContractingPartyId == item.ContractingPartyId);
|
||||
financialStatmentList.Any(x => x.ContractingPartyId == item.ContractingPartyId);
|
||||
|
||||
|
||||
var hasPhonNumber = phoneNumberList.Any(x => x.InstitutionContractId == item.Id);
|
||||
@@ -3362,7 +3373,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
SendSms = x.SendSms
|
||||
}).Where(x => x.PhoneNumber.Length == 11).ToList();
|
||||
|
||||
var transactions = financialStamentList.FirstOrDefault(x=>x.ContractingPartyId == item.ContractingPartyId);
|
||||
var transactions = financialStatmentList.FirstOrDefault(x=>x.ContractingPartyId == item.ContractingPartyId);
|
||||
|
||||
var debtor = transactions.FinancialTransactionList.Sum(x => x.Deptor);
|
||||
var creditor = transactions.FinancialTransactionList.Sum(x => x.Creditor);
|
||||
|
||||
Reference in New Issue
Block a user