Sfoglia il codice sorgente

Merge branch 'feature/snapshot' into test

qinchaoyue 2 mesi fa
parent
commit
f2c8ad0827

+ 44 - 10
src/Hotline.Application/Snapshot/RedPackApplication.cs

@@ -1,13 +1,18 @@
 using Hotline.Orders;
+using Hotline.Push.FWMessage;
 using Hotline.Share.Attributes;
 using Hotline.Share.Dtos;
+using Hotline.Share.Dtos.Push;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Enums.Order;
+using Hotline.Share.Enums.Push;
 using Hotline.Share.Enums.Snapshot;
 using Hotline.Share.Tools;
 using Hotline.Snapshot;
 using Hotline.Snapshot.Interfaces;
 using Mapster;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
 using SqlSugar;
 using SqlSugar.Extensions;
 using System.ComponentModel;
@@ -31,8 +36,10 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
     private readonly IRedPackGuiderAuditRepository _redPackGuiderAuditRepository;
     private readonly IThirdAccountRepository _thirdAccountRepository;
     private readonly ISupplementRecordRepository _supplementRecordRepository;
+    private readonly IPushDomainService _pushDomainService;
+    private readonly ILogger<RedPackApplication> _logger;
 
-    public RedPackApplication(IOrderSnapshotRepository orderSnapshotRepository, ISnapshotSMSTemplateRepository snapshotSMSTemplateRepository, IOrderRepository orderRepository, IIndustryRepository industryRepository, IRedPackAuditRepository redPackAuditRepository, IRedPackRecordRepository redPackRecordRepository, IRepository<OrderSpecial> orderSpecialRepository, ISessionContext sessionContext, IRedPackGuiderAuditRepository redPackGuiderAuditRepository, IThirdAccountRepository thirdAccountRepository, ISupplementRecordRepository supplementRecordRepository)
+    public RedPackApplication(IOrderSnapshotRepository orderSnapshotRepository, ISnapshotSMSTemplateRepository snapshotSMSTemplateRepository, IOrderRepository orderRepository, IIndustryRepository industryRepository, IRedPackAuditRepository redPackAuditRepository, IRedPackRecordRepository redPackRecordRepository, IRepository<OrderSpecial> orderSpecialRepository, ISessionContext sessionContext, IRedPackGuiderAuditRepository redPackGuiderAuditRepository, IThirdAccountRepository thirdAccountRepository, ISupplementRecordRepository supplementRecordRepository, IPushDomainService pushDomainService, ILogger<RedPackApplication> logger)
     {
         _orderSnapshotRepository = orderSnapshotRepository;
         _snapshotSMSTemplateRepository = snapshotSMSTemplateRepository;
@@ -45,6 +52,8 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
         _redPackGuiderAuditRepository = redPackGuiderAuditRepository;
         _thirdAccountRepository = thirdAccountRepository;
         _supplementRecordRepository = supplementRecordRepository;
+        _pushDomainService = pushDomainService;
+        _logger = logger;
     }
 
     /// <summary>
@@ -87,6 +96,26 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
             await _redPackRecordRepository.AddAsync(entity);
         }
         await _redPackAuditRepository.UpdateAsync(redPackAudit);
+        if (dto.IsSendSms)
+        {
+            var smsTemplate = await _snapshotSMSTemplateRepository.GetAsync(dto.SMSTemplateId);
+            if (smsTemplate == null) return;
+            var inDto = new MessageDto
+            {
+                TelNumber = order.FromPhone,
+                Content = smsTemplate.Content,
+                PushBusiness = EPushBusiness.Snapshot,
+                Name = order.FromName,
+            };
+            try
+            {
+                await _pushDomainService.PushMsgAsync(inDto, CancellationToken.None);
+            }
+            catch (Exception e)
+            {
+                _logger.LogError("随手拍发送短信异常:" + e.Message, e);
+            }
+        }
     }
 
     /// <summary>
@@ -305,16 +334,16 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
             .LeftJoin<Order>((redPackAudit, order) => redPackAudit.OrderId == order.Id)
             .LeftJoin<OrderSnapshot>((redPackAudit, order, snapshot) => redPackAudit.OrderId == snapshot.Id)
             .LeftJoin<Industry>((redPackAudit, order, snapshot, industry) => snapshot.IndustryId == industry.Id)
-            .Where((redPackAudit, order, snapshot,  industry) => order.Status >= EOrderStatus.Filed)
-            .WhereIF(dto.No.NotNullOrEmpty(), (redPackAudit, order, snapshot,  industry) => order.No.Contains(dto.No))
-            .WhereIF(dto.Title.NotNullOrEmpty(), (redPackAudit, order, snapshot,  industry) => order.Title.Contains(dto.Title))
-            .WhereIF(areaCode.NotNullOrEmpty(), (redPackAudit, order, snapshot,  industry) => order.AreaCode == areaCode);
+            .Where((redPackAudit, order, snapshot, industry) => order.Status >= EOrderStatus.Filed)
+            .WhereIF(dto.No.NotNullOrEmpty(), (redPackAudit, order, snapshot, industry) => order.No.Contains(dto.No))
+            .WhereIF(dto.Title.NotNullOrEmpty(), (redPackAudit, order, snapshot, industry) => order.Title.Contains(dto.Title))
+            .WhereIF(areaCode.NotNullOrEmpty(), (redPackAudit, order, snapshot, industry) => order.AreaCode == areaCode);
 
         var orgName = _sessionContext.OrgName ?? string.Empty;
         if (orgName.Contains("应急管理局") && status != null)
-            query = query.Where((redPackAudit, order, snapshot,  industry) => redPackAudit.LevelOneStatus == ERedPackAuditStatus.Agree && redPackAudit.LevelTwoStatus == status);
+            query = query.Where((redPackAudit, order, snapshot, industry) => redPackAudit.LevelOneStatus == ERedPackAuditStatus.Agree && redPackAudit.LevelTwoStatus == status);
         else if (status != null)
-            query = query.Where((redPackAudit, order, snapshot,  industry) => redPackAudit.LevelOneStatus == status);
+            query = query.Where((redPackAudit, order, snapshot, industry) => redPackAudit.LevelOneStatus == status);
 
         query = query.OrderByDescending(redPackAudit => redPackAudit.CreationTime);
         return query.Select((redPackAudit, order, snapshot, industry) => new SnapshotOrderGuiderAuditItemsOutDto
@@ -399,6 +428,11 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
         await _redPackAuditRepository.UpdateAsync(audit);
     }
 
+    /// <summary>
+    /// 添加补充发放信息
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
     public async Task UpdateRedPackRecordAsync(UpdateRedPackRecordInDto dto)
     {
         var record = await _redPackRecordRepository.Queryable()
@@ -498,8 +532,8 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
     public ISugarQueryable<SnapshotRedPackRecordSendOutDto> GetRedPackRecordDetail(SnapshotRedPackRecordSendInDto dto)
     {
         var query = _redPackRecordRepository.Queryable()
-            .LeftJoin<OrderSnapshot>((m , snapshot) => m.OrderId == snapshot.Id)
-            .LeftJoin<Order>((m , snapshot, order) => m.OrderId == order.Id)
+            .LeftJoin<OrderSnapshot>((m, snapshot) => m.OrderId == snapshot.Id)
+            .LeftJoin<Order>((m, snapshot, order) => m.OrderId == order.Id)
             .Where(m => m.DistributionState != EReadPackSendStatus.Unsend)
             .WhereIF(dto.Status == 1, m => m.PickupStatus == ERedPackPickupStatus.Received)
             .WhereIF(dto.Status == 2, m => m.PickupStatus == ERedPackPickupStatus.Back)
@@ -514,7 +548,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
             .WhereIF(dto.IsReceive.HasValue && dto.IsReceive == false, m => m.PickupStatus == ERedPackPickupStatus.Unreceived)
             .WhereIF(dto.BeginCreationTime.HasValue && dto.EndCreationTime.HasValue, m => m.CreationTime >= dto.BeginCreationTime && m.CreationTime <= dto.EndCreationTime)
             .Select((m, snapshot, order) => new SnapshotRedPackRecordSendOutDto
-            { 
+            {
                 OrderId = m.OrderId,
                 UserType = m.PeopleType,
                 IndustryName = snapshot.IndustryName,

+ 2 - 0
src/Hotline.Share/Enums/Push/EPushBusiness.cs

@@ -85,4 +85,6 @@ public enum EPushBusiness
     [Description("查询短信")]
     SearchSms = 12,
 
+    [Description("随手拍短信")]
+    Snapshot = 13,
 }