changes
This commit is contained in:
@@ -104,7 +104,6 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
}).Where(x => x.IsActiveString == "blue" &&
|
||||
x.ContractAmountDouble > 0).GroupBy(x => x.ContractingPartyId).Select(x => x.First()).ToListAsync();
|
||||
|
||||
var institutionContractsIds = institutionContracts.Select(x => x.Id).ToList();
|
||||
|
||||
// قرارداد هایی که بطور یکجا پرداخت شده اند
|
||||
var paidInFull = institutionContracts.Where(x =>
|
||||
@@ -126,7 +125,7 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
x.PhoneNumber.Length == 11).ToListAsync();
|
||||
var legalActionSentSms = await _context.SmsResults
|
||||
.Where(x => x.TypeOfSms == "اقدام قضایی").AsNoTracking().ToListAsync();
|
||||
var warningSentSms = await _context.SmsResults.Where(x => x.TypeOfSms.Contains("هشدار")).AsNoTracking().ToListAsync();
|
||||
|
||||
|
||||
var oldInstitutionContract = institutionContracts.Where(x => x.IsInstallment == false).ToList();
|
||||
var electronicInstitutionContract = institutionContracts.Where(x => x.IsInstallment == true).ToList();
|
||||
@@ -151,10 +150,10 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
if (partyName.Length > 25) partyName = $"{partyName.Substring(0, 25)}";
|
||||
|
||||
var isLegal = contractingParty.IsLegal == "حقوقی" ? true : false;
|
||||
var isBlock = contractingParty.IsBlock == "true" ? true : false;
|
||||
var isActive = contractingParty.IsActiveString == "true" ? true : false;
|
||||
if (!string.IsNullOrWhiteSpace(contractingParty.IsActiveString))
|
||||
{
|
||||
//var isBlock = contractingParty.IsBlock == "true" ? true : false;
|
||||
//var isActive = contractingParty.IsActiveString == "true" ? true : false;
|
||||
|
||||
|
||||
var hasFinancialStatement =
|
||||
financialStatmentList.Any(x => x.ContractingPartyId == item.ContractingPartyId);
|
||||
|
||||
@@ -180,7 +179,7 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
var creditor = transactions.FinancialTransactionList.Sum(x => x.Creditor);
|
||||
|
||||
|
||||
var id = $"{item.ContractingPartyId}";
|
||||
//var id = $"{item.ContractingPartyId}";
|
||||
var aprove = $"{transactions.id}";
|
||||
var balance = debtor - creditor;
|
||||
|
||||
@@ -220,7 +219,7 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
smsList.Add(new SmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
TemplateId = 608443,
|
||||
TemplateId = typeOfSmsSetting == TypeOfSmsSetting.Warning ? 608443 : 0,
|
||||
PartyName = partyName,
|
||||
Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
@@ -263,7 +262,7 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
smsList.Add(new SmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
TemplateId = 351691,
|
||||
TemplateId = typeOfSmsSetting == TypeOfSmsSetting.Warning ? 351691 : 0,
|
||||
PartyName = partyName,
|
||||
Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
@@ -310,7 +309,7 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
smsList.Add(new SmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
TemplateId = 190430,
|
||||
TemplateId = typeOfSmsSetting == TypeOfSmsSetting.Warning ? 190430 : 0,
|
||||
PartyName = partyName,
|
||||
Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
@@ -354,7 +353,7 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
smsList.Add(new SmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
TemplateId = 412829,
|
||||
TemplateId = typeOfSmsSetting == TypeOfSmsSetting.Warning ? 412829 : 0,
|
||||
PartyName = partyName,
|
||||
Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
@@ -372,7 +371,7 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -386,6 +385,103 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach (var item in electronicInstitutionContract)
|
||||
{
|
||||
try
|
||||
{
|
||||
var contractingParty = contractingPartyList.FirstOrDefault(x => x.id == item.ContractingPartyId);
|
||||
bool hasLegalActionSentSms = legalActionSentSms.Any(x => x.InstitutionContractId == item.Id);
|
||||
int year = Convert.ToInt32(item.ContractEndFa.Substring(0, 4));
|
||||
int month = Convert.ToInt32(item.ContractEndFa.Substring(5, 2));
|
||||
var endOfContractNextMonthStart = new PersianDateTime(year, month, 1).AddMonths(1);
|
||||
var endOfContractNextMonthEnd = (($"{endOfContractNextMonthStart}").FindeEndOfMonth()).ToGeorgianDateTime();
|
||||
var now = DateTime.Now;
|
||||
if (!string.IsNullOrWhiteSpace(contractingParty.LName) && !hasLegalActionSentSms && now.Date <= endOfContractNextMonthEnd.Date)
|
||||
{
|
||||
var partyName = contractingParty.IsLegal == "حقیقی"
|
||||
? $"{contractingParty.FName} {contractingParty.LName}"
|
||||
: $"{contractingParty.LName}";
|
||||
if (!string.IsNullOrWhiteSpace(contractingParty.SureName))
|
||||
partyName = $"{partyName} ({contractingParty.SureName})";
|
||||
|
||||
if (partyName.Length > 25) partyName = $"{partyName.Substring(0, 25)}";
|
||||
|
||||
//var isLegal = contractingParty.IsLegal == "حقوقی" ? true : false;
|
||||
//var isBlock = contractingParty.IsBlock == "true" ? true : false;
|
||||
//var isActive = contractingParty.IsActiveString == "true" ? true : false;
|
||||
|
||||
|
||||
var hasFinancialStatement =
|
||||
financialStatmentList.Any(x => x.ContractingPartyId == item.ContractingPartyId);
|
||||
|
||||
|
||||
var hasPhonNumber = phoneNumberList.Any(x => x.InstitutionContractId == item.Id);
|
||||
|
||||
if (hasFinancialStatement && hasPhonNumber)
|
||||
{
|
||||
var phoneNumbers = phoneNumberList.Where(x => x.InstitutionContractId == item.Id)
|
||||
.Select(x => new CreateContactInfo
|
||||
{
|
||||
PhoneType = x.PhoneType,
|
||||
PhoneNumber = x.PhoneNumber,
|
||||
|
||||
InstitutionContractId = x.InstitutionContractId,
|
||||
SendSms = x.SendSms
|
||||
}).Where(x => x.PhoneNumber.Length == 11).ToList();
|
||||
|
||||
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 balance = debtor - creditor;
|
||||
int templateId = 0;
|
||||
//انتخاب قالب پیامک بر اساس حقیق/حقوقی
|
||||
|
||||
|
||||
if (balance > 0) // اگر بدهکار بود
|
||||
{
|
||||
var balanceToMoney = balance.ToMoney();
|
||||
|
||||
foreach (var number in phoneNumbers)
|
||||
{
|
||||
string publicId = transactions.PublicIdStr;
|
||||
string code1 = publicId.Substring(0, 25);
|
||||
string code2 = publicId.Substring(25);
|
||||
|
||||
|
||||
smsList.Add(new SmsListData()
|
||||
{
|
||||
PhoneNumber = number.PhoneNumber,
|
||||
TemplateId = 530657,
|
||||
PartyName = partyName,
|
||||
Amount = balanceToMoney,
|
||||
ContractingPartyId = contractingParty.id,
|
||||
AproveId = aprove,
|
||||
TypeOfSmsMethod = "MonthlyBillNew",
|
||||
Code1 = code1,
|
||||
Code2 = code2,
|
||||
InstitutionContractId = item.Id
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError($"ContractingPartyId : {item.ContractingPartyId} - ContractingPartyName : {item.ContractingPartyName} - InstitutionContractId : {item.Id} خطای دریافت لیست بدهکاران ");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
return smsList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,22 +381,7 @@ builder.Services.AddParbad().ConfigureGateways(gateways =>
|
||||
|
||||
|
||||
// فقط Serilog برای File استفاده میشه، کنسول از لاگر پیشفرض ASP.NET استفاده میکنه
|
||||
builder.Host.UseSerilog((context, services, configuration) =>
|
||||
{
|
||||
var logConfig = configuration
|
||||
.ReadFrom.Configuration(context.Configuration)
|
||||
.ReadFrom.Services(services)
|
||||
.Enrich.FromLogContext();
|
||||
|
||||
|
||||
logConfig.WriteTo.File(
|
||||
path: Path.Combine(logDirectory, "gozareshgir_log.txt"),
|
||||
rollingInterval: RollingInterval.Day,
|
||||
retainedFileCountLimit: 30,
|
||||
shared: true,
|
||||
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}"
|
||||
);
|
||||
}, writeToProviders: true); // این باعث میشه کنسول پیشفرض هم کار کنه
|
||||
builder.Host.UseSerilog(); // این باعث میشه کنسول پیشفرض هم کار کنه
|
||||
|
||||
Log.Information("SERILOG STARTED SUCCESSFULLY");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user