This commit is contained in:
2025-12-15 21:14:06 +03:30
9 changed files with 354 additions and 174 deletions

View File

@@ -27,7 +27,7 @@ public interface ISmsService
Task<double> GetCreditAmount();
public Task<bool> SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId);
public Task<bool> SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId, string typeOfSms = null);
public Task<bool> SendInstitutionVerificationCode(string number, string code, string contractingPartyFullName,
long contractingPartyId, long institutionContractId);

View File

@@ -12,6 +12,7 @@
<ProjectReference Include="..\..\0_Framework\0_Framework.csproj" />
<ProjectReference Include="..\..\AccountManagement.Configuration\AccountManagement.Configuration.csproj" />
<ProjectReference Include="..\..\PersonalContractingParty.Config\PersonalContractingParty.Config.csproj" />
<ProjectReference Include="..\..\ProgramManager\src\Infrastructure\GozareshgirProgramManager.Infrastructure\GozareshgirProgramManager.Infrastructure.csproj" />
<ProjectReference Include="..\..\Query.Bootstrapper\Query.Bootstrapper.csproj" />
<ProjectReference Include="..\..\WorkFlow\Infrastructure\WorkFlow.Infrastructure.Config\WorkFlow.Infrastructure.Config.csproj" />
</ItemGroup>

View File

@@ -47,6 +47,11 @@ public class JobSchedulerRegistrator
() => SendBlockSms(),
"*/1 * * * *" // هر 1 دقیقه یکبار چک کن
);
RecurringJob.AddOrUpdate(
"InstitutionContract.SendInstitutionContractConfirmSms",
() => SendInstitutionContractConfirmSms(),
"*/1 * * * *" // هر 1 دقیقه یکبار چک کن
);
}
@@ -146,4 +151,15 @@ public class JobSchedulerRegistrator
await _institutionContractRepository.SendBlockSmsForBackgroundTask();
}
/// <summary>
/// ارسال پیامک یادآور تایید قراداد مالی
/// </summary>
/// <returns></returns>
[DisableConcurrentExecution(timeoutInSeconds: 100)]
public async System.Threading.Tasks.Task SendInstitutionContractConfirmSms()
{
await _institutionContractRepository.SendInstitutionContractConfirmSmsTask();
}
}

View File

@@ -7,11 +7,16 @@ using BackgroundInstitutionContract.Task;
using BackgroundInstitutionContract.Task.Jobs;
using CompanyManagment.App.Contracts.Hubs;
using CompanyManagment.EFCore.Services;
using GozareshgirProgramManager.Application._Bootstrapper;
using GozareshgirProgramManager.Application.Modules.Users.Commands.CreateUser;
using GozareshgirProgramManager.Infrastructure;
using GozareshgirProgramManager.Infrastructure.Persistence.Seed;
using Hangfire;
using Microsoft.AspNetCore.Identity;
using MongoDB.Driver;
using PersonalContractingParty.Config;
using Query.Bootstrapper;
using Shared.Contracts.PmUser.Queries;
using WorkFlow.Infrastructure.Config;
var builder = WebApplication.CreateBuilder(args);
@@ -38,10 +43,15 @@ builder.Services.AddSingleton<IMongoDatabase>(mongoDatabase);
#endregion
builder.Services.AddProgramManagerApplication();
builder.Services.AddProgramManagerInfrastructure(builder.Configuration);
PersonalBootstrapper.Configure(builder.Services, connectionString);
TestDbBootStrapper.Configure(builder.Services, connectionStringTestDb);
AccountManagementBootstrapper.Configure(builder.Services, connectionString);
WorkFlowBootstrapper.Configure(builder.Services, connectionString);
QueryBootstrapper.Configure(builder.Services);
JobsBootstrapper.Configure(builder.Services);
builder.Services.AddHttpClient();

View File

@@ -140,6 +140,11 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
/// <returns></returns>
Task SendReminderSmsToContractingParties(List<SmsListData> smsListData, string typeOfSms, string sendMessStart, string sendMessEnd);
/// <summary>
/// ارسال پیامک یادآور تایید قراداد مالی
/// </summary>
/// <returns></returns>
Task SendInstitutionContractConfirmSmsTask();
#endregion
#region CreateMontlyTransaction

View File

@@ -0,0 +1,12 @@
using System;
namespace CompanyManagment.App.Contracts.InstitutionContract;
public record InstitutionCreationVerificationSmsDto
{
public string Number{ get; set; }
public string FullName { get; set; }
public Guid InstitutionId { get; set; }
public long ContractingPartyId { get; set; }
public long InstitutionContractId { get; set; }
};

View File

@@ -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();

View File

@@ -350,9 +350,12 @@ public class SmsService : ISmsService
}
public async Task<bool> SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId)
public async Task<bool> SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId, string typeOfSms)
{
var full = fullName;
typeOfSms = string.IsNullOrWhiteSpace(typeOfSms) ? "لینک تاییدیه ایجاد قرارداد مالی" : typeOfSms;
var full = fullName;
var fullName1 = fullName;
if (fullName.Length >= 25)
{
@@ -377,8 +380,9 @@ public class SmsService : ISmsService
new("CODE1",firstPart),
new("CODE2",secondPart)
});
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "لینک تاییدیه ایجاد قرارداد مالی",
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, typeOfSms,
fullName, number, contractingPartyId, institutionContractId);
await _smsResultRepository.CreateAsync(smsResult);
await _smsResultRepository.SaveChangesAsync();

View File

@@ -358,6 +358,7 @@
<option value="هشدار دوم"> هشدار دوم </option>
<option value="اقدام قضایی"> اقدام قضایی </option>
<option value="یادآور وظایف"> یادآور وظایف </option>
<option value="یادآور تایید قرارداد مالی"> یادآور تایید قرارداد مالی</option>
</select>
</div>
</div>