create SendReminderSmsForBackgroundTask methodes
This commit is contained in:
@@ -36,4 +36,44 @@ public interface ISmsService
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region InstitutionContractSMS
|
||||
/// <summary>
|
||||
/// پیامک اهانه جدید
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="tamplateId"></param>
|
||||
/// <param name="fullname"></param>
|
||||
/// <param name="amount"></param>
|
||||
/// <param name="code1"></param>
|
||||
/// <param name="code2"></param>
|
||||
/// <returns></returns>
|
||||
Task<(byte status, string message, int messaeId, bool isSucceded)> MonthlyBillNew(string number, int tamplateId, string fullname, string amount, string code1,
|
||||
string code2);
|
||||
/// <summary>
|
||||
/// پیامک ماهانه قدیم
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="tamplateId"></param>
|
||||
/// <param name="fullname"></param>
|
||||
/// <param name="amount"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="aprove"></param>
|
||||
/// <returns></returns>
|
||||
Task<(byte status, string message, int messaeId, bool isSucceded)> MonthlyBill(string number, int tamplateId, string fullname, string amount, string id, string aprove);
|
||||
|
||||
/// <summary>
|
||||
/// پیامک مسدودی طرف حساب
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="fullname"></param>
|
||||
/// <param name="amount"></param>
|
||||
/// <param name="accountType"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="aprove"></param>
|
||||
/// <returns></returns>
|
||||
Task<(byte status, string message, int messaeId, bool isSucceded)> BlockMessage(string number, string fullname, string amount, string accountType, string id, string aprove);
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -80,11 +80,19 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
|
||||
|
||||
#region DebtReminderSMS
|
||||
|
||||
/// <summary>
|
||||
///دریافت لیست بدهکارن
|
||||
/// جهت ارسال پیامک
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsListData>> GetSmsListData(DateTime checkDate);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک های یاد آور بدهی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task DebtReminderSMS();
|
||||
Task SendReminderSmsToContractingParties(List<SmsListData> smsListData);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
namespace CompanyManagment.App.Contracts.InstitutionContract;
|
||||
|
||||
/// <summary>
|
||||
/// لیست پیامکهای بدهکاران قرارداد ملی
|
||||
/// </summary>
|
||||
public class SmsListData
|
||||
{
|
||||
/// <summary>
|
||||
/// شماره تماس طرف حساب
|
||||
/// </summary>
|
||||
public string PhoneNumber { get; set; }
|
||||
/// <summary>
|
||||
/// تمپلیت آی دی
|
||||
/// </summary>
|
||||
public int TemplateId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام طرف حساب
|
||||
/// </summary>
|
||||
public string PartyName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ بدهی
|
||||
/// </summary>
|
||||
public string Amount { get; set; }
|
||||
/// <summary>
|
||||
/// آی دی طرف حساب
|
||||
/// </summary>
|
||||
public long ContractingPartyId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی صورت حساب مالی
|
||||
/// </summary>
|
||||
public string AproveId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نوع متد ارسال پیامک
|
||||
/// </summary>
|
||||
public string TypeOfSmsMethod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// پابلیک آی دی بخش یک
|
||||
/// </summary>
|
||||
public string Code1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// پابلیک آی دی بخش دو
|
||||
/// </summary>
|
||||
public string Code2 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ای دی قراداد مالی
|
||||
/// </summary>
|
||||
public long InstitutionContractId { get; set; }
|
||||
}
|
||||
@@ -40,8 +40,10 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using MongoDB.Driver;
|
||||
using OfficeOpenXml.Packaging.Ionic.Zip;
|
||||
using PersianTools.Core;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
using SmsResult = CompanyManagment.EFCore.Migrations.SmsResult;
|
||||
using String = System.String;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
@@ -54,6 +56,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
private readonly IMongoCollection<InstitutionContractAmendmentTemp> _institutionAmendmentTemp;
|
||||
private readonly IPlanPercentageRepository _planPercentageRepository;
|
||||
private readonly ISmsService _smsService;
|
||||
private readonly ISmsResultRepository _smsResultRepository;
|
||||
|
||||
private readonly InstitutionContratVerificationParty _firstParty = new()
|
||||
{
|
||||
@@ -67,13 +70,14 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
public InstitutionContractRepository(CompanyContext context, IEmployerRepository employerRepository,
|
||||
IWorkshopRepository workshopRepository, IMongoDatabase database,
|
||||
IPlanPercentageRepository planPercentageRepository, ISmsService smsService) : base(context)
|
||||
IPlanPercentageRepository planPercentageRepository, ISmsService smsService, ISmsResultRepository smsResultRepository) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
_employerRepository = employerRepository;
|
||||
_workshopRepository = workshopRepository;
|
||||
_planPercentageRepository = planPercentageRepository;
|
||||
_smsService = smsService;
|
||||
_smsResultRepository = smsResultRepository;
|
||||
_institutionExtensionTemp =
|
||||
database.GetCollection<InstitutionContractExtensionTemp>("InstitutionContractExtensionTemp");
|
||||
_institutionAmendmentTemp =
|
||||
@@ -2946,20 +2950,30 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public async Task DebtReminderSMS()
|
||||
public async Task<bool> SendReminderSmsForBackgroundTask()
|
||||
{
|
||||
var checkDate = DateTime.Now;
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<SmsListData>> GetSmsListData(DateTime checkDate)
|
||||
{
|
||||
|
||||
|
||||
var smsList = new List<SmsListData>();
|
||||
var currentMonthStart = ($"{(checkDate.ToFarsi()).Substring(0, 8)}01").ToGeorgianDateTime();
|
||||
var previusMonthEnd = currentMonthStart.AddDays(-1);
|
||||
var previusMonthStart = ($"{(previusMonthEnd.ToFarsi()).Substring(0, 8)}01").ToGeorgianDateTime();
|
||||
var typeOfSms = "یادآور بدهی ماهانه";
|
||||
//var rollcallServiceList = _context.RollCallServices.Where(x => x.StartService.Date <= previusMonthStart.Date && x.EndService.Date >= previusMonthEnd.Date).ToList();
|
||||
var institutionContracts =await _context.InstitutionContractSet.AsSplitQuery().Select(x => new InstitutionContractViewModel
|
||||
|
||||
//دریافت اطلاعات بدهکارن و ساخت لیست پیامک
|
||||
#region GetSmsListData
|
||||
|
||||
//var rollcallServiceList = _context.RollCallServices.Where(x => x.StartService.Date <= previusMonthStart.Date && x.EndService.Date >= previusMonthEnd.Date).ToList();
|
||||
var institutionContracts = await _context.InstitutionContractSet.AsSplitQuery().Select(x => new InstitutionContractViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
@@ -2979,7 +2993,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
{
|
||||
try
|
||||
{
|
||||
var contractingParty =await _context.PersonalContractingParties.FirstOrDefaultAsync(x=>x.id == item.ContractingPartyId);
|
||||
var contractingParty = await _context.PersonalContractingParties.FirstOrDefaultAsync(x => x.id == item.ContractingPartyId);
|
||||
//var isSend = sendedSms.Any(x => x.ContractingPatyId == contractingParty.Id);
|
||||
if (!string.IsNullOrWhiteSpace(contractingParty.LName))
|
||||
{
|
||||
@@ -2993,19 +3007,19 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
var isActive = contractingParty.IsActiveString == "true" ? true : false;
|
||||
if (!string.IsNullOrWhiteSpace(contractingParty.IsActiveString) && isActive)
|
||||
{
|
||||
var hasFinancialStatement =await _context.FinancialStatments.Include(x => x.FinancialTransactionList).AnyAsync(
|
||||
var hasFinancialStatement = await _context.FinancialStatments.Include(x => x.FinancialTransactionList).AnyAsync(
|
||||
x => x.ContractingPartyId == item.ContractingPartyId && x.FinancialTransactionList.Count > 0);
|
||||
|
||||
Thread.Sleep(500);
|
||||
var hasPhonNumber =await _context.InstitutionContractContactInfos
|
||||
|
||||
var hasPhonNumber = await _context.InstitutionContractContactInfos
|
||||
.AnyAsync(x => x.InstitutionContractId == item.Id && x.SendSms && x.PhoneType == "شماره همراه" &&
|
||||
x.PhoneNumber.Length == 11);
|
||||
|
||||
Thread.Sleep(500);
|
||||
|
||||
if (hasFinancialStatement && hasPhonNumber)
|
||||
{
|
||||
|
||||
var phoneNumbers =await _context.InstitutionContractContactInfos.Where(n =>
|
||||
|
||||
var phoneNumbers = await _context.InstitutionContractContactInfos.Where(n =>
|
||||
n.InstitutionContractId == item.Id && n.SendSms && n.PhoneType == "شماره همراه" &&
|
||||
!string.IsNullOrWhiteSpace(n.PhoneNumber))
|
||||
.Select(x => new CreateContactInfo
|
||||
@@ -3017,10 +3031,10 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
SendSms = x.SendSms
|
||||
}).Where(x => x.PhoneNumber.Length == 11).ToListAsync();
|
||||
var transactions = GetFinancialByContractingPartyId(contractingParty.id).GetAwaiter().GetResult();
|
||||
Thread.Sleep(500);
|
||||
|
||||
var debtor = transactions.FinancialTransactionViewModels.Sum(x => x.Deptor);
|
||||
var creditor = transactions.FinancialTransactionViewModels.Sum(x => x.Creditor);
|
||||
Thread.Sleep(500);
|
||||
|
||||
|
||||
var id = $"{item.ContractingPartyId}";
|
||||
var aprove = $"{transactions.Id}";
|
||||
@@ -3076,38 +3090,19 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
string publicId = transactions.PublicId;
|
||||
string code1 = publicId.Substring(0, 25);
|
||||
string code2 = publicId.Substring(25);
|
||||
var newSmsResult = _smsService.MonthlyBillNew(number.PhoneNumber, 789638,
|
||||
partyName, balanceToMoney, code1, code2);
|
||||
Thread.Sleep(1000);
|
||||
messageId = newSmsResult.MessageId;
|
||||
message = newSmsResult.Message;
|
||||
isSuccessSend = newSmsResult.IsSuccedded;
|
||||
|
||||
|
||||
smsList.Add(new SmsListData(){PhoneNumber = number.PhoneNumber,TemplateId = 789638,PartyName = partyName,Amount = balanceToMoney,ContractingPartyId = contractingParty.id, AproveId = aprove,TypeOfSmsMethod = "MonthlyBillNew",Code1 = code1,Code2 = code2, InstitutionContractId = item.Id });
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var smsResult = _smsService.MonthlyBill(number.PhoneNumber, 161233,
|
||||
partyName,
|
||||
balanceToMoney, id, aprove);
|
||||
Thread.Sleep(1000);
|
||||
isSuccessSend = smsResult.IsSuccedded;
|
||||
messageId = smsResult.MessageId;
|
||||
message = smsResult.Message;
|
||||
|
||||
smsList.Add(new SmsListData() { PhoneNumber = number.PhoneNumber, TemplateId = 161233, PartyName = partyName, Amount = balanceToMoney, ContractingPartyId = contractingParty.id, AproveId = aprove, TypeOfSmsMethod = "MonthlyBill", Code1 = "", Code2 = "", InstitutionContractId = item.Id});
|
||||
|
||||
}
|
||||
|
||||
if (isSuccessSend)
|
||||
{
|
||||
var createSmsResult = new SmsResult(messageId,
|
||||
message, typeOfSms, partyName, number.PhoneNumber,
|
||||
item.ContractingPartyId, item.Id);
|
||||
_smsResultRepository.Create(createSmsResult);
|
||||
_smsResultRepository.SaveChanges();
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
//Console.ForegroundColor = ConsoleColor.Black;
|
||||
//Console.BackgroundColor = ConsoleColor.Yellow;
|
||||
//Console.WriteLine(number.PhoneNumber + " debt : " + balance + " contractId = " + item.Id);
|
||||
//Console.ResetColor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3130,38 +3125,17 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
string publicId = transactions.PublicId;
|
||||
string code1 = publicId.Substring(0, 25);
|
||||
string code2 = publicId.Substring(25);
|
||||
var newSmsResult = _smsService.MonthlyBillNew(number.PhoneNumber, 789638,
|
||||
partyName, balanceToMoney, code1, code2);
|
||||
Thread.Sleep(1000);
|
||||
messageId = newSmsResult.MessageId;
|
||||
message = newSmsResult.Message;
|
||||
isSuccessSend = newSmsResult.IsSuccedded;
|
||||
smsList.Add(new SmsListData() { PhoneNumber = number.PhoneNumber, TemplateId = 789638, PartyName = partyName, Amount = balanceToMoney, ContractingPartyId = contractingParty.id, AproveId = aprove, TypeOfSmsMethod = "MonthlyBillNew", Code1 = code1, Code2 = code2, InstitutionContractId = item.Id });
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var smsResult = _smsService.MonthlyBill(number.PhoneNumber, 347415,
|
||||
partyName,
|
||||
balanceToMoney, id, aprove);
|
||||
Thread.Sleep(1000);
|
||||
isSuccessSend = smsResult.IsSuccedded;
|
||||
messageId = smsResult.MessageId;
|
||||
message = smsResult.Message;
|
||||
smsList.Add(new SmsListData() { PhoneNumber = number.PhoneNumber, TemplateId = 347415, PartyName = partyName, Amount = balanceToMoney, ContractingPartyId = contractingParty.id, AproveId = aprove, TypeOfSmsMethod = "MonthlyBill", Code1 = "", Code2 = "" , InstitutionContractId = item.Id });
|
||||
|
||||
}
|
||||
|
||||
if (isSuccessSend)
|
||||
{
|
||||
var createSmsResult = new SmsResult(messageId,
|
||||
message, typeOfSms, partyName, number.PhoneNumber,
|
||||
item.ContractingPartyId, item.Id);
|
||||
_smsResultRepository.Create(createSmsResult);
|
||||
_smsResultRepository.SaveChanges();
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
//Console.ForegroundColor = ConsoleColor.Black;
|
||||
//Console.BackgroundColor = ConsoleColor.Yellow;
|
||||
//Console.WriteLine(number.PhoneNumber + " debt : " + balance + " contractId = " + item.Id);
|
||||
//Console.ResetColor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3188,38 +3162,16 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
string publicId = transactions.PublicId;
|
||||
string code1 = publicId.Substring(0, 25);
|
||||
string code2 = publicId.Substring(25);
|
||||
var newSmsResult = _smsService.MonthlyBillNew(number.PhoneNumber, 768277,
|
||||
partyName, balanceToMoney, code1, code2);
|
||||
Thread.Sleep(1000);
|
||||
messageId = newSmsResult.MessageId;
|
||||
message = newSmsResult.Message;
|
||||
isSuccessSend = newSmsResult.IsSuccedded;
|
||||
|
||||
smsList.Add(new SmsListData() { PhoneNumber = number.PhoneNumber, TemplateId = 768277, PartyName = partyName, Amount = balanceToMoney, ContractingPartyId = contractingParty.id, AproveId = aprove, TypeOfSmsMethod = "MonthlyBillNew", Code1 = code1, Code2 = code2, InstitutionContractId = item.Id });
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var smsResult = _smsService.MonthlyBill(number.PhoneNumber, 998180,
|
||||
partyName,
|
||||
balanceToMoney, id, aprove);
|
||||
Thread.Sleep(1000);
|
||||
isSuccessSend = smsResult.IsSuccedded;
|
||||
messageId = smsResult.MessageId;
|
||||
message = smsResult.Message;
|
||||
smsList.Add(new SmsListData() { PhoneNumber = number.PhoneNumber, TemplateId = 998180, PartyName = partyName, Amount = balanceToMoney, ContractingPartyId = contractingParty.id, AproveId = aprove, TypeOfSmsMethod = "MonthlyBill", Code1 = "", Code2 = "", InstitutionContractId = item.Id });
|
||||
}
|
||||
|
||||
if (isSuccessSend)
|
||||
{
|
||||
var createSmsResult = new SmsResult(messageId,
|
||||
message, typeOfSms, partyName, number.PhoneNumber,
|
||||
item.ContractingPartyId, item.Id);
|
||||
_smsResultRepository.Create(createSmsResult);
|
||||
_smsResultRepository.SaveChanges();
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
//Console.ForegroundColor = ConsoleColor.Black;
|
||||
//Console.BackgroundColor = ConsoleColor.Yellow;
|
||||
//Console.WriteLine(number.PhoneNumber + " debt : " + balance + " contractId = " + item.Id);
|
||||
//Console.ResetColor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3243,39 +3195,15 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
string publicId = transactions.PublicId;
|
||||
string code1 = publicId.Substring(0, 25);
|
||||
string code2 = publicId.Substring(25);
|
||||
var newSmsResult = _smsService.MonthlyBillNew(number.PhoneNumber, 768277,
|
||||
partyName, balanceToMoney, code1, code2);
|
||||
Thread.Sleep(1000);
|
||||
messageId = newSmsResult.MessageId;
|
||||
message = newSmsResult.Message;
|
||||
isSuccessSend = newSmsResult.IsSuccedded;
|
||||
smsList.Add(new SmsListData() { PhoneNumber = number.PhoneNumber, TemplateId = 768277, PartyName = partyName, Amount = balanceToMoney, ContractingPartyId = contractingParty.id, AproveId = aprove, TypeOfSmsMethod = "MonthlyBillNew", Code1 = code1, Code2 = code2, InstitutionContractId = item.Id });
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var smsResult = _smsService.MonthlyBill(number.PhoneNumber, 810539,
|
||||
partyName,
|
||||
balanceToMoney, id, aprove);
|
||||
Thread.Sleep(1000);
|
||||
isSuccessSend = smsResult.IsSuccedded;
|
||||
messageId = smsResult.MessageId;
|
||||
message = smsResult.Message;
|
||||
smsList.Add(new SmsListData() { PhoneNumber = number.PhoneNumber, TemplateId = 810539, PartyName = partyName, Amount = balanceToMoney, ContractingPartyId = contractingParty.id, AproveId = aprove, TypeOfSmsMethod = "MonthlyBill", Code1 = "", Code2 = "", InstitutionContractId = item.Id });
|
||||
}
|
||||
|
||||
if (isSuccessSend)
|
||||
{
|
||||
var createSmsResult = new SmsResult(messageId,
|
||||
message, typeOfSms, partyName, number.PhoneNumber,
|
||||
item.ContractingPartyId, item.Id);
|
||||
_smsResultRepository.Create(createSmsResult);
|
||||
_smsResultRepository.SaveChanges();
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
//Console.ForegroundColor = ConsoleColor.Black;
|
||||
//Console.BackgroundColor = ConsoleColor.Yellow;
|
||||
//Console.WriteLine(number.PhoneNumber + " debt : " + balance + " contractId = " + item.Id);
|
||||
////_logger.LogInformation(number.PhoneNumber + " debt : " + balance + " nolegal" + "NotOfficial");
|
||||
//Console.ResetColor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3295,16 +3223,74 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
string name = item.ContractingPartyName.Length > 18 ? item.ContractingPartyName.Substring(0, 18) : item.ContractingPartyName;
|
||||
string errMess = $"{name}-خطا";
|
||||
_smsService.Alarm("09114221321", errMess);
|
||||
_logger.LogError(e, "ReminderSms");
|
||||
// _smsService.Alarm("09114221321", errMess);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
return smsList;
|
||||
|
||||
}
|
||||
|
||||
public async Task SendReminderSmsToContractingParties(List<SmsListData> smsListData)
|
||||
{
|
||||
//ارسال پیامک با اساس لیست
|
||||
#region SendSMSFromList
|
||||
|
||||
#region ExternalMetods
|
||||
var typeOfSms = "یادآور بدهی ماهانه";
|
||||
|
||||
private async Task<FinancialStatmentViewModel>? GetFinancialByContractingPartyId(long contractingPartyId)
|
||||
if (smsListData.Any())
|
||||
{
|
||||
foreach (var item in smsListData)
|
||||
{
|
||||
if (item.TypeOfSmsMethod == "MonthlyBill")
|
||||
{
|
||||
var res = await _smsService.MonthlyBill(item.PhoneNumber, item.TemplateId, item.PartyName, item.Amount,
|
||||
$"{item.ContractingPartyId}", item.AproveId);
|
||||
|
||||
if (res.isSucceded)
|
||||
{
|
||||
var createSmsResult = new Company.Domain.SmsResultAgg.SmsResult(res.messaeId,
|
||||
res.message, typeOfSms, item.PartyName, item.PhoneNumber,
|
||||
item.ContractingPartyId, item.InstitutionContractId);
|
||||
|
||||
await _smsResultRepository.CreateAsync(createSmsResult);
|
||||
await _smsResultRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var res = await _smsService.MonthlyBillNew(item.PhoneNumber, item.TemplateId, item.PartyName, item.Amount, item.Code1, item.Code2);
|
||||
if (res.isSucceded)
|
||||
{
|
||||
var createSmsResult = new Company.Domain.SmsResultAgg.SmsResult(res.messaeId,
|
||||
res.message, typeOfSms, item.PartyName, item.PhoneNumber,
|
||||
item.ContractingPartyId, item.InstitutionContractId);
|
||||
|
||||
await _smsResultRepository.CreateAsync(createSmsResult);
|
||||
await _smsResultRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
}
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region PrivateMetods
|
||||
/// <summary>
|
||||
/// دریافت صورت حساب مالی با آی دی طرف حساب
|
||||
/// </summary>
|
||||
/// <param name="contractingPartyId"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<FinancialStatmentViewModel?> GetFinancialByContractingPartyId(long contractingPartyId)
|
||||
{
|
||||
return await _context.FinancialStatments.Include(x => x.FinancialTransactionList)
|
||||
.Select(x => new FinancialStatmentViewModel
|
||||
@@ -3340,6 +3326,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CustomViewModels
|
||||
|
||||
public class WorkshopsAndEmployeeViewModel
|
||||
@@ -3350,5 +3337,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
public int ArchiveCode { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
28
CompanyManagment.EFCore/Repository/ValueTuple.cs
Normal file
28
CompanyManagment.EFCore/Repository/ValueTuple.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace CompanyManagment.EFCore.Repository
|
||||
{
|
||||
internal class ValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>
|
||||
{
|
||||
private string phoneNumber;
|
||||
private int v1;
|
||||
private string partyName;
|
||||
private string balanceToMoney;
|
||||
private string id;
|
||||
private string aprove;
|
||||
private string v2;
|
||||
private string v3;
|
||||
private string v4;
|
||||
|
||||
public ValueTuple(string phoneNumber, int v1, string partyName, string balanceToMoney, string id, string aprove, string v2, string v3, string v4)
|
||||
{
|
||||
this.phoneNumber = phoneNumber;
|
||||
this.v1 = v1;
|
||||
this.partyName = partyName;
|
||||
this.balanceToMoney = balanceToMoney;
|
||||
this.id = id;
|
||||
this.aprove = aprove;
|
||||
this.v2 = v2;
|
||||
this.v3 = v3;
|
||||
this.v4 = v4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -409,4 +409,83 @@ public class SmsService : ISmsService
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region InstitutionContractSMS
|
||||
|
||||
public async Task<(byte status, string message, int messaeId, bool isSucceded)> MonthlyBillNew(string number, int tamplateId, string fullname, string amount, string code1,
|
||||
string code2)
|
||||
{
|
||||
|
||||
var smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
var result = new ValueTuple<byte, string, int, bool>();
|
||||
var sendResult = await smsIr.VerifySendAsync(number, tamplateId,
|
||||
new VerifySendParameter[]
|
||||
{ new("FULLNAME", fullname), new("AMOUNT", amount), new("CODE1", code1), new("CODE2", code2) });
|
||||
Thread.Sleep(500);
|
||||
|
||||
|
||||
if (sendResult.Message == "موفق")
|
||||
{
|
||||
|
||||
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, false);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public async Task<(byte status, string message, int messaeId, bool isSucceded)> MonthlyBill(string number, int tamplateId, string fullname, string amount, string id,
|
||||
string aprove)
|
||||
{
|
||||
|
||||
var smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
var result = new ValueTuple<byte, string, int, bool>();
|
||||
var sendResult = await smsIr.VerifySendAsync(number, tamplateId,
|
||||
new VerifySendParameter[]
|
||||
{ new("FULLNAME", fullname), new("AMOUNT", amount), new("ID", id), new("APROVE", aprove) });
|
||||
Thread.Sleep(500);
|
||||
|
||||
|
||||
if (sendResult.Message == "موفق")
|
||||
{
|
||||
|
||||
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<(byte status, string message, int messaeId, bool isSucceded)> BlockMessage(string number, string fullname, string amount, string accountType, string id,
|
||||
string aprove)
|
||||
{
|
||||
var tamplateId = 117946;
|
||||
var result = new ValueTuple<byte, string, int, bool>();
|
||||
var smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
|
||||
var sendResult = await smsIr.VerifySendAsync(number, tamplateId,
|
||||
new VerifySendParameter[]
|
||||
{
|
||||
new("FULLNAME", fullname), new("AMOUNT", amount), new("ACCOUNTTYPE", accountType), new("ID", id),
|
||||
new("APROVE", aprove)
|
||||
});
|
||||
Thread.Sleep(500);
|
||||
|
||||
|
||||
if (sendResult.Message == "موفق")
|
||||
{
|
||||
|
||||
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user