diff --git a/CompanyManagment.App.Contracts/InstitutionContract/SmsListData.cs b/CompanyManagment.App.Contracts/InstitutionContract/SmsListData.cs
index e81a8ecf..9fb58b9e 100644
--- a/CompanyManagment.App.Contracts/InstitutionContract/SmsListData.cs
+++ b/CompanyManagment.App.Contracts/InstitutionContract/SmsListData.cs
@@ -1,4 +1,6 @@
-namespace CompanyManagment.App.Contracts.InstitutionContract;
+using System.Collections.Generic;
+
+namespace CompanyManagment.App.Contracts.InstitutionContract;
///
/// لیست پیامکهای بدهکاران قرارداد ملی
@@ -113,10 +115,30 @@ public class BlockSmsListData
///
-/// لیست قراداد های آبی
-/// جهت ارسال هشدار یا اقدام قضائی
+///پیامک آنی یادآور
///
-public class BlueWarningSmsData
+public class InstantReminderSendSms
{
+ ///
+ /// نام طرف حساب
+ ///
+ public string FullName { get; set; }
+ ///
+ /// مبلغ بدهی
+ ///
+ public string Amount { get; set; }
+ public List InstantReminderSmsList { get; set; }
+}
+
+public class InstantReminderSmsList
+{
+ ///
+ /// شماره تماس طرف حساب
+ ///
+ public string PhoneNumber { get; set; }
+
+
+
+
}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/SmsResult/ISmsSettingApplication.cs b/CompanyManagment.App.Contracts/SmsResult/ISmsSettingApplication.cs
index 813d7540..1da9deb4 100644
--- a/CompanyManagment.App.Contracts/SmsResult/ISmsSettingApplication.cs
+++ b/CompanyManagment.App.Contracts/SmsResult/ISmsSettingApplication.cs
@@ -101,5 +101,19 @@ public interface ISmsSettingApplication
///
Task EditSmsSetting(SmsSettingDto command);
+ ///
+ /// دریافت لیست ارسال آنی
+ ///
+ ///
+ Task> GetInstantReminderSmsListData(TypeOfSmsSetting typeOfSmsSetting);
+
+ ///
+ /// ارسال پیامک آنی
+ ///
+ ///
+ ///
+ ///
+ Task InstantSmsSendApi(TypeOfSmsSetting typeOfSmsSetting, List phoneNumbers);
+
#endregion
}
\ No newline at end of file
diff --git a/CompanyManagment.Application/SmsSettingApplication.cs b/CompanyManagment.Application/SmsSettingApplication.cs
index 37894b2e..0536735e 100644
--- a/CompanyManagment.Application/SmsSettingApplication.cs
+++ b/CompanyManagment.Application/SmsSettingApplication.cs
@@ -9,6 +9,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Hosting;
namespace CompanyManagment.Application;
@@ -17,12 +19,15 @@ public class SmsSettingApplication : ISmsSettingApplication
private readonly ISmsSettingsRepository _smsSettingsRepository;
private readonly IInstitutionContractRepository _institutionContractRepository;
private readonly IInstitutionContractSmsServiceRepository _institutionContractSmsServiceRepository;
+ private readonly IHostEnvironment _hostEnvironment;
- public SmsSettingApplication(ISmsSettingsRepository smsSettingsRepository, IInstitutionContractRepository institutionContractRepository, IInstitutionContractSmsServiceRepository institutionContractSmsServiceRepository)
+ public SmsSettingApplication(ISmsSettingsRepository smsSettingsRepository, IInstitutionContractRepository institutionContractRepository, IInstitutionContractSmsServiceRepository institutionContractSmsServiceRepository, IHostEnvironment hostEnvironment)
{
_smsSettingsRepository = smsSettingsRepository;
_institutionContractRepository = institutionContractRepository;
_institutionContractSmsServiceRepository = institutionContractSmsServiceRepository;
+ _hostEnvironment = hostEnvironment;
+
}
@@ -217,5 +222,114 @@ public class SmsSettingApplication : ISmsSettingApplication
return op.Succcedded();
}
+
+
+ public async Task> GetInstantReminderSmsListData(TypeOfSmsSetting typeOfSmsSetting)
+ {
+ var result = new List();
+
+
+ if (typeOfSmsSetting == TypeOfSmsSetting.InstitutionContractDebtReminder)
+ {
+ var data = await _institutionContractSmsServiceRepository.GetSmsListData(DateTime.Now, TypeOfSmsSetting.InstitutionContractDebtReminder);
+
+ if (data.Any())
+ {
+ result = data.GroupBy(x => x.PartyName).Select(m => new InstantReminderSendSms()
+ {
+ FullName = m.Key,
+ Amount = m.Select(c => c.Amount).First(),
+ InstantReminderSmsList = m.Select(c => new InstantReminderSmsList()
+ {
+ PhoneNumber = c.PhoneNumber,
+ }).ToList()
+
+
+ }).ToList();
+ }
+ }
+
+ if (typeOfSmsSetting == TypeOfSmsSetting.BlockContractingParty)
+ {
+ var data = await _institutionContractSmsServiceRepository.GetBlockListData(DateTime.Now);
+
+ if (data.Any())
+ {
+ result = data.GroupBy(x => x.PartyName).Select(m => new InstantReminderSendSms()
+ {
+ FullName = m.Key,
+ Amount = m.Select(c => c.Amount).First(),
+ InstantReminderSmsList = m.Select(c => new InstantReminderSmsList()
+ {
+ PhoneNumber = c.PhoneNumber,
+ }).ToList()
+
+
+ }).ToList();
+ }
+ }
+
+ return result;
+ }
+
+ public async Task InstantSmsSendApi(TypeOfSmsSetting typeOfSmsSetting, List phoneNumbers)
+ {
+
+ var op = new OperationResult();
+ if (_hostEnvironment.IsDevelopment())
+ {
+ var str = "";
+ foreach (var item in phoneNumbers)
+ {
+ str += $" {item}, ";
+ }
+ return op.Failed(" در محیط توسعه امکان ارسال وجود ندارد " + " لیست ارسال شما " + str);
+
+ }
+ if (typeOfSmsSetting == TypeOfSmsSetting.InstitutionContractDebtReminder)
+ {
+ if (phoneNumbers.Any())
+ {
+ var data = await _institutionContractSmsServiceRepository.GetSmsListData(DateTime.Now, TypeOfSmsSetting.InstitutionContractDebtReminder);
+
+ if (data.Any())
+ {
+ phoneNumbers = phoneNumbers.Where(x => x.Length == 11).ToList();
+ var sendItems = data.Where(x => phoneNumbers.Contains(x.PhoneNumber)).ToList();
+ var res = await InstantSendReminderSms(sendItems);
+ return res;
+
+ }
+
+ return op.Succcedded();
+ }
+
+ return op.Failed("موردی انتخاب نشده است");
+
+ }
+
+ if (typeOfSmsSetting == TypeOfSmsSetting.BlockContractingParty)
+ {
+ if (phoneNumbers.Any())
+ {
+ var data = await _institutionContractSmsServiceRepository.GetBlockListData(DateTime.Now);
+
+ if (data.Any())
+ {
+ phoneNumbers = phoneNumbers.Where(x => x.Length == 11).ToList();
+ var sendItems = data.Where(x => phoneNumbers.Contains(x.PhoneNumber)).ToList();
+ var res = await InstantSendBlockSms(sendItems);
+ return res;
+ }
+ return op.Succcedded();
+ }
+ return op.Failed("موردی انتخاب نشده است");
+ }
+
+
+
+
+ return op.Failed("خطای انتخاب نوع ارسال");
+ }
#endregion
}
\ No newline at end of file
diff --git a/CompanyManagment.EFCore/Repository/InstitutionContractSmsServiceRepository.cs b/CompanyManagment.EFCore/Repository/InstitutionContractSmsServiceRepository.cs
index ef8b77e1..fa3e9d70 100644
--- a/CompanyManagment.EFCore/Repository/InstitutionContractSmsServiceRepository.cs
+++ b/CompanyManagment.EFCore/Repository/InstitutionContractSmsServiceRepository.cs
@@ -2114,6 +2114,7 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase
+ /// دریافت لیست ارسال آنی یادآور
+ ///
+ ///
+ [HttpGet("GetInstantReminderSmsListData")]
+ public async Task> GetInstantReminderSmsListData()
+ {
+ var result =await _smsSettingApplication.GetInstantReminderSmsListData(TypeOfSmsSetting.InstitutionContractDebtReminder);
+ return result;
+ }
+
+ ///
+ /// دریافت لیست ارسال آنی مسدودی
+ ///
+ ///
+ [HttpGet("GetInstantBlockSmsListData")]
+ public async Task> GetInstantBlockSmsListData()
+ {
+ var result = await _smsSettingApplication.GetInstantReminderSmsListData(TypeOfSmsSetting.BlockContractingParty);
+ return result;
+ }
+
+ ///
+ /// ارسال پیامک آنی یادآور
+ ///
+ ///
+ ///
+ [HttpPost("InstantReminderSmsSend")]
+ public async Task> InstantReminderSmsSend([FromBody ]List phoneNumbers)
+ {
+ var result = await _smsSettingApplication.InstantSmsSendApi(TypeOfSmsSetting.InstitutionContractDebtReminder, phoneNumbers);
+ return result;
+ }
+
+ ///
+ /// ارسال پیامک آنی مسدودی
+ ///
+ ///
+ ///
+ [HttpPost("InstantBlockSmsSend")]
+ public async Task> InstantBlockSmsSend([FromBody] List phoneNumbers)
+ {
+ var result = await _smsSettingApplication.InstantSmsSendApi(TypeOfSmsSetting.BlockContractingParty, phoneNumbers);
+ return result;
+ }
#endregion
}
\ No newline at end of file