tangjiang 1 тиждень тому
батько
коміт
9784faed3b

+ 5 - 0
src/Push.Share/Dtos/PushMessageDto.cs

@@ -68,5 +68,10 @@ namespace Push.Share.Dtos
         /// 发送失败原因等
         /// </summary>
         public string? Reason { get; set; }
+
+        /// <summary>
+        /// 手机号
+        /// </summary>
+        public string TelNumber { get; set; }
     }
 }

+ 59 - 15
src/yibin/Push.YiBin/PushDomainService.cs

@@ -8,10 +8,12 @@ using Push.Share.Dtos.FWMessage;
 using Push.Share.Enums;
 using Push.YiBin.Dtos;
 using System.Net;
+using System.Security.Cryptography;
 using System.Xml;
 using XF.Domain.Cache;
 using XF.Domain.Dependency;
 using XF.Domain.Exceptions;
+using static System.Runtime.InteropServices.JavaScript.JSType;
 
 namespace Push.YiBin;
 
@@ -33,6 +35,7 @@ public class PushDomainService : IPushDomainService, IScopeDependency
     private readonly ILogger<PushDomainService> _logger;
     private readonly IRepository<WaitMessage> _waitMessageRepository;
     private readonly FwClient _fwClient;
+    private readonly IRepository<RecordData> _recordDataRepository;
 
     /// <summary>
     /// 
@@ -44,13 +47,18 @@ public class PushDomainService : IPushDomainService, IScopeDependency
     /// <param name="mediator"></param>
     /// <param name="cacheWaitSendId"></param>
     /// <param name="capPublisher"></param>
+    /// <param name="logger"></param>
+    /// <param name="waitMessageRepository"></param>
+    /// <param name="fwClient"></param>
+    /// <param name="recordDataRepository"></param>
     public PushDomainService(IRepository<Message> messageRepository, IHttpClientFactory httpClientFactory
         , IMapper mapper, IConfiguration config, IMediator mediator,
         ITypedCache<CacheWaitSendId> cacheWaitSendId,
         ICapPublisher capPublisher,
         ILogger<PushDomainService> logger,
         IRepository<WaitMessage> waitMessageRepository,
-       FwClient fwClient)
+       FwClient fwClient,
+       IRepository<RecordData> recordDataRepository)
     {
         _messageRepository = messageRepository;
         _httpClientFactory = httpClientFactory;
@@ -63,6 +71,7 @@ public class PushDomainService : IPushDomainService, IScopeDependency
         _logger = logger;
         _waitMessageRepository = waitMessageRepository;
         _fwClient = fwClient;
+        _recordDataRepository = recordDataRepository;
     }
 
     #endregion
@@ -343,6 +352,41 @@ public class PushDomainService : IPushDomainService, IScopeDependency
             return strResult;
         }
 
+        #region 处理接收数据
+        try
+        {
+            RecordData recordData = new()
+            {
+                Msgid = receiveMessageDto.msgid,
+                Sendtime = receiveMessageDto.sendtime,
+                Msgcount = receiveMessageDto.msgcount,
+                State = receiveMessageDto.state,
+                Errormsg = receiveMessageDto.errormsg,
+                Sfid = receiveMessageDto.sfid,
+                Telnumall = receiveMessageDto.telnumall,
+                Sign = receiveMessageDto.sign,
+                Msg = receiveMessageDto.msg,
+                Mobile = receiveMessageDto.mobile,
+                Destcode = receiveMessageDto.destcode,
+                Motime = receiveMessageDto.motime,
+                Fsfid = receiveMessageDto.fsfid,
+            };
+            await _recordDataRepository.AddAsync(recordData, cancellationToken: default);
+
+            var dataPush = new PushMessageDto
+            {
+                Type = "2",
+                TelNumber = receiveMessageDto.mobile,
+            };
+            await _capPublisher.PublishAsync(Push.Share.EventNames.UpdateSendSmsState, dataPush, cancellationToken: default);
+        }
+        catch (Exception)
+        {
+
+        }
+
+        #endregion
+
         var data = await _messageRepository.Queryable()
             .Where(p => p.TelNumber == receiveMessageDto.mobile && p.IsSmsReply == false && p.SmsReplyTime == null)
             .OrderByDescending(p => p.CreationTime)
@@ -353,20 +397,20 @@ public class PushDomainService : IPushDomainService, IScopeDependency
             data.SmsReplyTime = Convert.ToDateTime(receiveMessageDto.motime);
             data.SmsReplyContent = receiveMessageDto.msg;
             await _messageRepository.UpdateAsync(data);
-            try
-            {
-                if (data.ClientId == "Hotline")
-                {
-                    var dataPush = _mapper.Map<PushMessageDto>(data);
-                    dataPush.Type = "2";
-                    await _capPublisher.PublishAsync(Push.Share.EventNames.UpdateSendSmsState, dataPush, cancellationToken: default);
-                    //    await _fwClient.RequestNoTokenAsync<Reponse>("api/v1/PushMessage/update-send-sms-state", "Post", System.Text.Json.JsonSerializer.Serialize(dataPush), cancellationToken: default);
-                }
-            }
-            catch (Exception)
-            {
-
-            }
+            //try
+            //{
+            //    if (data.ClientId == "Hotline")
+            //    {
+            //        var dataPush = _mapper.Map<PushMessageDto>(data);
+            //        dataPush.Type = "2";
+            //        await _capPublisher.PublishAsync(Push.Share.EventNames.UpdateSendSmsState, dataPush, cancellationToken: default);
+            //        //    await _fwClient.RequestNoTokenAsync<Reponse>("api/v1/PushMessage/update-send-sms-state", "Post", System.Text.Json.JsonSerializer.Serialize(dataPush), cancellationToken: default);
+            //    }
+            //}
+            //catch (Exception)
+            //{
+
+            //}
         }
 
         // 成功返回值必须是ok

+ 73 - 0
src/yibin/Push.YiBin/RecordData.cs

@@ -0,0 +1,73 @@
+namespace Push.YiBin
+{
+    /// <summary>
+    /// 接收数据
+    /// </summary>
+    public class RecordData : CreationEntity
+    {
+        /// <summary>
+        /// 短信中心短信待发送ID,同短信发送接口返回值ID
+        /// </summary>
+        public string? Msgid { get; set; }
+
+        /// <summary>
+        /// 短信发送时间
+        /// </summary>
+        public string? Sendtime { get; set; }
+
+        /// <summary>
+        /// 发送短信使用的数量
+        /// </summary>
+        public int? Msgcount { get; set; }
+
+        /// <summary>
+        /// 发送状态:0:未发送  1:发送中  2:发送失败  3:发送成功
+        /// </summary>
+        public int? State { get; set; }
+
+        /// <summary>
+        /// 错误消息
+        /// </summary>
+        public string? Errormsg { get; set; }
+
+        /// <summary>
+        /// 短信中心短信已发送ID
+        /// </summary>
+        public int? Sfid { get; set; }
+
+        /// <summary>
+        /// 手机号码
+        /// </summary>
+        public string? Telnumall { get; set; }
+
+        /// <summary>
+        /// 短信签名
+        /// </summary>
+        public string? Sign { get; set; }
+
+        /// <summary>
+        /// 回复短信内容
+        /// </summary>
+        public string? Msg { get; set; }
+
+        /// <summary>
+        /// 回复手机号码
+        /// </summary>
+        public string? Mobile { get; set; }
+
+        /// <summary>
+        /// 短信接收平台号码
+        /// </summary>
+        public string? Destcode { get; set; }
+
+        /// <summary>
+        /// 回复时间
+        /// </summary>
+        public string? Motime { get; set; }
+
+        /// <summary>
+        /// 短信平台回复短信ID
+        /// </summary>
+        public string? Fsfid { get; set; }
+    }
+}