From bb106ceee472bba1ed7f3a5845ad3043995af094 Mon Sep 17 00:00:00 2001 From: zhaozhenjing Date: Wed, 15 Oct 2025 15:21:17 +0800 Subject: [PATCH] =?UTF-8?q?[MODIFY]=E5=A2=9E=E5=8A=A0=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoMapperProfile/AdminBusinessProfile.cs | 3 + .../Impl/Admins/SMSService.cs | 102 +++++++++++++++++- .../Interfaces/Admins/SMS/ISMSService.cs | 7 +- .../Admins/SMS/Input/SmsGetpageInput.cs | 33 ++++++ .../Admins/SMS/Output/SmsListDto.cs | 50 +++++++++ 5 files changed, 190 insertions(+), 5 deletions(-) create mode 100644 src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/Input/SmsGetpageInput.cs create mode 100644 src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/Output/SmsListDto.cs diff --git a/src/2.services/ATS.NonCustodial.Application/AutoMapperProfile/AdminBusinessProfile.cs b/src/2.services/ATS.NonCustodial.Application/AutoMapperProfile/AdminBusinessProfile.cs index f11be2a..9948f59 100644 --- a/src/2.services/ATS.NonCustodial.Application/AutoMapperProfile/AdminBusinessProfile.cs +++ b/src/2.services/ATS.NonCustodial.Application/AutoMapperProfile/AdminBusinessProfile.cs @@ -2,6 +2,7 @@ using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Deptcode.Output; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Menu.Input; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Menu.Output; +using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS.Output; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Unitcode.Input; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Unitcode.Output; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppAnnouncements.Input; @@ -172,6 +173,8 @@ namespace ATS.NonCustodial.Application.AutoMapperProfile CreateMap(); CreateMap(); CreateMap(); + + CreateMap(); } } } \ No newline at end of file diff --git a/src/2.services/ATS.NonCustodial.Application/Impl/Admins/SMSService.cs b/src/2.services/ATS.NonCustodial.Application/Impl/Admins/SMSService.cs index 06d741e..efb6a9f 100644 --- a/src/2.services/ATS.NonCustodial.Application/Impl/Admins/SMSService.cs +++ b/src/2.services/ATS.NonCustodial.Application/Impl/Admins/SMSService.cs @@ -1,15 +1,24 @@ using ATS.NonCustodial.Application.Base; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS; +using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS.Input; +using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS.Output; +using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement.Input; +using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement.Output; +using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppEarlyWarnings.Input; using ATS.NonCustodial.Domain.Entities.Admins; +using ATS.NonCustodial.Domain.Entities.Business.CaseManagements; +using ATS.NonCustodial.Domain.Entities.Business.EarlyWarning; using ATS.NonCustodial.Domain.Shared.Enums; using ATS.NonCustodial.Domain.Shared.OrmRepositories.Basic.EfCore; using ATS.NonCustodial.DynamicApi; using ATS.NonCustodial.DynamicApi.Attributes; using ATS.NonCustodial.Shared.Common.UnifiedResults; using ATS.NonCustodial.Shared.Configurations.Options; +using ATS.NonCustodial.Shared.Extensions.Collection; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using StackExchange.Profiling.Internal; using TencentCloud.Common; using TencentCloud.Common.Profile; using TencentCloud.Sms.V20210111; @@ -24,11 +33,102 @@ namespace ATS.NonCustodial.Application.Impl.Admins public class SMSService : AdminAppServiceBase, ISMSService, IDynamicApi { private readonly IEfRepository _appSMSRepository; + private readonly IEfRepository _appUserRepository; public SMSService( - IEfRepository appSMSRepository) + IEfRepository appSMSRepository, + IEfRepository appUserRepository) { _appSMSRepository = appSMSRepository; + _appUserRepository = appUserRepository; + + } + + + /// + /// 分页查询 + /// + /// + /// + [HttpPost] + public async Task GetPageAsync(SmsGetpageInput input) + { + //var limits = User.limits; + //var selectLimits = await _appCaseSupervisorRepository.AsQueryable(false, true) + // .Where(w => limits.Contains(w.UnitId.ToString())) + // .ToListAsync(); + //var caseIdList = selectLimits.Select(w => w.CaseId).Distinct().ToList(); + + var express =await GetExpression(input, _appSMSRepository.AsQueryable(false, true)); + + + var rtn = await base.GetPageAsync(input, express); + + foreach (var item in rtn.Data) + { + var peoson = await _appUserRepository.AsQueryable(false, true).Where(w => w.Phone == item.Phone).ToListAsync(); + item.Name = peoson.FirstOrDefault()?.UserName; + switch(item.Type) + { + case "CheckCode": + item.TypeDes = "验证码"; break; + case "Alert": + item.TypeDes = "预警处理通知"; break; + case "RegulatoryAlert": + item.TypeDes = "监管预警通知"; break; + case "Approved": + item.TypeDes = "审批完成通知"; break; + case "ReviewNotification": + item.TypeDes = "审批提醒通知"; break; + default: + break; + } + if(item.Result.Contains("Code")) + { + int codeStart = item.Result.IndexOf("\"Code\":\"") + 8; + int codeEnd = item.Result.IndexOf("\"", codeStart); + string code = item.Result.Substring(codeStart, codeEnd - codeStart); + int msgStart = item.Result.IndexOf("\"Message\":\"") + 11; + int msgEnd = item.Result.IndexOf("\"", msgStart); + string message = item.Result.Substring(msgStart, msgEnd - msgStart); // "send success" + if (code.Equals("Ok")) + { + item.Message = message; + item.Result = "短信发送成功"; + } + else + { + item.Message = message; + item.Result = "短信发送异常"; + } + } + else + { + item.Message = item.Result; + item.Result ="短信发送异常"; + } + } + + + var filteredList = rtn.Data + .WhereIf(input.Name.HasValue(),item => item.Name == input.Name) // 筛选条件 + .ToList(); + rtn.Data = filteredList; + return ResultOutput.Ok(rtn); + } + /// + /// 查询实时预警条件 + /// + /// + /// + /// + private async Task> GetExpression(SmsGetpageInput pageInput, IQueryable query) + { + query = query + .WhereIf(pageInput.Phone.HasValue(), w => w.phone == pageInput.Phone) + .WhereIf(pageInput.SendTimeFrom.HasValue, w => w.sendTime >= pageInput.SendTimeFrom) + .WhereIf(pageInput.SendTimeTo.HasValue, w => w.sendTime <= pageInput.SendTimeTo); + return query; } /// diff --git a/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/ISMSService.cs b/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/ISMSService.cs index 515def1..b49f00c 100644 --- a/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/ISMSService.cs +++ b/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/ISMSService.cs @@ -1,14 +1,13 @@ -using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Auth.Input; -using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Auth.Output; +using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS.Input; using ATS.NonCustodial.Domain.Shared.Enums; -using ATS.NonCustodial.Shared.Captcha.Dto; -using ATS.NonCustodial.Shared.Common.Dtos; using ATS.NonCustodial.Shared.Common.UnifiedResults; namespace ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS { public interface ISMSService { + + Task GetPageAsync(SmsGetpageInput input); /// /// 发送验证码 /// diff --git a/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/Input/SmsGetpageInput.cs b/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/Input/SmsGetpageInput.cs new file mode 100644 index 0000000..a16d3d6 --- /dev/null +++ b/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/Input/SmsGetpageInput.cs @@ -0,0 +1,33 @@ +using ATS.NonCustodial.Domain.Shared.Enums; +using ATS.NonCustodial.Shared.Common.Dtos; + +namespace ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS.Input +{ + /// + /// 短信查询入参 + /// + /// Author:ZZJ + /// CreatedTimed:2025-10-15 10点42分 + public class SmsGetpageInput : PageRequestBaseInput + { + /// + /// 电话号码 + /// + public string? Phone { get; set; } + + /// + /// 姓名 + /// + public string? Name { get; set; } + + /// + /// 开始时间 + /// + public DateTime? SendTimeFrom { get; set; } + + /// + /// 结束时间 + /// + public DateTime? SendTimeTo { get; set; } + } +} \ No newline at end of file diff --git a/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/Output/SmsListDto.cs b/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/Output/SmsListDto.cs new file mode 100644 index 0000000..737fdb4 --- /dev/null +++ b/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/Output/SmsListDto.cs @@ -0,0 +1,50 @@ +using ATS.NonCustodial.Domain.Shared.AggRootEntities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS.Output +{ + public class SmsListDto : EntityFull + { + /// + /// 姓名 + /// + public string? Name { get; set; } + + /// + /// 编码 + /// + public long? Id { get; set; } + /// + /// 电话 + /// + public string? Phone { get; set; } + /// + /// 验证码 + /// + public string? Code { get; set; } + /// + /// 发送时间 + /// + public DateTime? SendTime { get; set; } + /// + /// 通知类型 + /// + public string? Type { get; set; } + /// + /// 通知类型描述 + /// + public string? TypeDes { get; set; } + /// + /// 发送结果 + /// + public string? Result { get; set; } + /// + /// 详细描述 + /// + public string? Message { get; set; } + } +}