InstantSms Send Completed

This commit is contained in:
gozareshgir
2026-01-13 15:16:33 +03:30
parent 532065e3a8
commit 4d7923936e
5 changed files with 203 additions and 5 deletions

View File

@@ -1,4 +1,6 @@
namespace CompanyManagment.App.Contracts.InstitutionContract;
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.InstitutionContract;
/// <summary>
/// لیست پیامکهای بدهکاران قرارداد ملی
@@ -113,10 +115,30 @@ public class BlockSmsListData
/// <summary>
/// لیست قراداد های آبی
/// جهت ارسال هشدار یا اقدام قضائی
///پیامک آنی یادآور
/// </summary>
public class BlueWarningSmsData
public class InstantReminderSendSms
{
/// <summary>
/// نام طرف حساب
/// </summary>
public string FullName { get; set; }
/// <summary>
/// مبلغ بدهی
/// </summary>
public string Amount { get; set; }
public List<InstantReminderSmsList> InstantReminderSmsList { get; set; }
}
public class InstantReminderSmsList
{
/// <summary>
/// شماره تماس طرف حساب
/// </summary>
public string PhoneNumber { get; set; }
}

View File

@@ -101,5 +101,19 @@ public interface ISmsSettingApplication
/// <returns></returns>
Task<OperationResult> EditSmsSetting(SmsSettingDto command);
/// <summary>
/// دریافت لیست ارسال آنی
/// </summary>
/// <returns></returns>
Task<List<InstantReminderSendSms>> GetInstantReminderSmsListData(TypeOfSmsSetting typeOfSmsSetting);
/// <summary>
/// ارسال پیامک آنی
/// </summary>
/// <param name="typeOfSmsSetting"></param>
/// <param name="phoneNumbers"></param>
/// <returns></returns>
Task<OperationResult> InstantSmsSendApi(TypeOfSmsSetting typeOfSmsSetting, List<string> phoneNumbers);
#endregion
}

View File

@@ -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<List<InstantReminderSendSms>> GetInstantReminderSmsListData(TypeOfSmsSetting typeOfSmsSetting)
{
var result = new List<InstantReminderSendSms>();
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<OperationResult> InstantSmsSendApi(TypeOfSmsSetting typeOfSmsSetting, List<string> 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
}

View File

@@ -2114,6 +2114,7 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
{
try
{
if (item.TypeOfSmsMethod == "MonthlyBill")
{
var res = await _smsService.MonthlyBill(item.PhoneNumber, item.TemplateId, item.PartyName,

View File

@@ -1,6 +1,7 @@
using _0_Framework.Application;
using _0_Framework.Application.Enums;
using _0_Framework.Application.Sms;
using CompanyManagment.App.Contracts.InstitutionContract;
using CompanyManagment.App.Contracts.SmsResult;
using CompanyManagment.App.Contracts.SmsResult.Dto;
using Microsoft.AspNetCore.Mvc;
@@ -226,5 +227,51 @@ public class SmsReportController : AdminBaseController
{
await _smsSettingApplication.RemoveSetting(id);
}
/// <summary>
/// دریافت لیست ارسال آنی یادآور
/// </summary>
/// <returns></returns>
[HttpGet("GetInstantReminderSmsListData")]
public async Task<List<InstantReminderSendSms>> GetInstantReminderSmsListData()
{
var result =await _smsSettingApplication.GetInstantReminderSmsListData(TypeOfSmsSetting.InstitutionContractDebtReminder);
return result;
}
/// <summary>
/// دریافت لیست ارسال آنی مسدودی
/// </summary>
/// <returns></returns>
[HttpGet("GetInstantBlockSmsListData")]
public async Task<List<InstantReminderSendSms>> GetInstantBlockSmsListData()
{
var result = await _smsSettingApplication.GetInstantReminderSmsListData(TypeOfSmsSetting.BlockContractingParty);
return result;
}
/// <summary>
/// ارسال پیامک آنی یادآور
/// </summary>
/// <param name="phoneNumbers"></param>
/// <returns></returns>
[HttpPost("InstantReminderSmsSend")]
public async Task<ActionResult<OperationResult>> InstantReminderSmsSend([FromBody ]List<string> phoneNumbers)
{
var result = await _smsSettingApplication.InstantSmsSendApi(TypeOfSmsSetting.InstitutionContractDebtReminder, phoneNumbers);
return result;
}
/// <summary>
/// ارسال پیامک آنی مسدودی
/// </summary>
/// <param name="phoneNumbers"></param>
/// <returns></returns>
[HttpPost("InstantBlockSmsSend")]
public async Task<ActionResult<OperationResult>> InstantBlockSmsSend([FromBody] List<string> phoneNumbers)
{
var result = await _smsSettingApplication.InstantSmsSendApi(TypeOfSmsSetting.BlockContractingParty, phoneNumbers);
return result;
}
#endregion
}