瀏覽代碼

Merge branch 'test' of http://110.188.24.182:10023/Fengwo/hotline into test

tangjiang 2 周之前
父節點
當前提交
c7508836d4

+ 2 - 3
src/Hotline.Api/Controllers/TestController.cs

@@ -532,15 +532,14 @@ public class TestController : BaseController
         //var r = await _aiVisitService.QueryAiVisitTaskResult(batchId, DateTime.Parse("2024-07-28"), DateTime.Parse("2024-08-01"), HttpContext.RequestAborted);
 
         //var r = _timeLimitDomainService.CalcExpiredTime(DateTime.Now, EFlowDirection.CenterToCenter, batchId);
-        //var r = _timeLimitDomainService.CalcEndTime(DateTime.Parse("2024-09-12 14:45:47"), Share.Enums.Settings.ETimeType.WorkDay, 2, 80, 50);
+        var times = _timeLimitDomainService.CalcEndTime(DateTime.Parse("2025-04-13 23:55:57.050283"), Share.Enums.Settings.ETimeType.Day,60, 80, 50);
         //_capPublisher.PublishDelay((DateTime.Now.AddMinutes(2) - DateTime.Now), EventNames.OrderRelateCall, "123");
         //var times = await _expireTime.CalcExpiredTime(DateTime.Parse("2025-01-14 09:45:00"), DateTime.Parse("2025-01-07 09:16:53.691249"), EFlowDirection.CenterToOrg, new OrderTimeClacInfo() { AcceptTypeCode = "20" });
         //await _expireTime.CalcWorkTimeToDecimal(visit.VisitTime.Value, DateTime.Now, false);
         //var times = await _expireTime.CalcWorkTimeToDecimal(DateTime.Parse("2024-12-16 21:36:27"), DateTime.Parse("2024-12-17 12:47:05"), false);
         //var query = _userRepository.Queryable().Where(x => false);
         //await _capPublisher.PublishDelay(EventNames.OrderRelateCall, "123", cancellationToken: HttpContext.RequestAborted);
-        var times = await _expireTime.CalcWorkTimeEx(
-                       DateTime.Parse("2025-02-21 16:00:11.154098"), DateTime.Parse("2025-02-28 11:27:11.441577"), false);
+        //var times = await _expireTime.CalcExpiredTime(DateTime.Parse("2025-04-13 23:55:57.050283"), DateTime.Parse("2025-04-13 23:55:57.050283"), EFlowDirection.CenterToOrg,);
         return OpenResponse.Ok(times);
     }
 

+ 34 - 24
src/Hotline.Application/Snapshot/BiSnapshotApplication.cs

@@ -128,29 +128,33 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
                 ShouldAmount = industryCase.CitizenReadPackAmount == null ? industry.CitizenReadPackAmount : industryCase.CitizenReadPackAmount,
             }).ToList();
 
-        var redPackOutDto = _redPackAuditRepository.Queryable(includeDeleted: true)
-            .LeftJoin<OrderSnapshot>((audit, snapshot) => audit.OrderId == snapshot.Id)
-            .LeftJoin<RedPackRecord>((audit, snapshot, record) => record.RedPackAuditId == audit.Id)
-            .LeftJoin<SupplementRecord>((audit, snapshot, record, supplement) => supplement.RedPackAuditId == audit.Id)
-            .Where((audit, snapshot) => audit.CreationTime >= dto.StartTime && audit.CreationTime <= dto.EndTime)
-            .GroupBy((audit, snapshot) => new { snapshot.IndustryCase, snapshot.IndustryId, snapshot.IndustryName })
-            .Select((audit, snapshot, record, supplement) => new RedPackStatisticsOutDto
-            {
-                Id = snapshot.IndustryId,
-                Name = snapshot.IndustryName,
-                CaseId = snapshot.IndustryCase,
-                ApprovalAmount = SqlFunc.AggregateSum(SqlFunc.IIF(audit.Status == ERedPackAuditStatus.Agree, audit.ApprovedAmount, 0)), //审批同意总金额
-                ApprovalCount = SqlFunc.AggregateSum(SqlFunc.IIF(audit.Status == ERedPackAuditStatus.Agree, 1, 0)), // 审批同意总个数
-                SentAmount = SqlFunc.AggregateSum(SqlFunc.IIF(audit.IsSend == true, audit.AcutalAmount, 0)), // 发送成功金额
-                SentCount = SqlFunc.AggregateSum(SqlFunc.IIF(audit.IsSend == true, 1, 0)), // 发送成功个数
-                SendFailAmount = SqlFunc.AggregateSum(SqlFunc.IIF(record.DistributionState == EReadPackSendStatus.Fail, record.Amount, 0)), //发送失败金额
-                SendFailCount = SqlFunc.AggregateSum(SqlFunc.IIF(record.DistributionState == EReadPackSendStatus.Fail, 1, 0)), // 发送失败个数
-                PendingAmount = SqlFunc.AggregateSum(SqlFunc.IIF(record.DistributionState == EReadPackSendStatus.Unsend, audit.ApprovedAmount, 0)), // 待发金额
-                PendingCount = SqlFunc.AggregateSum(SqlFunc.IIF(record.DistributionState == EReadPackSendStatus.Unsend, 1, 0)), // 待发个数
-                SupplementAmount = SqlFunc.AggregateSum(supplement.ReplenishAmount), // 补充红包金额
-                SupplementCount = SqlFunc.AggregateCount(supplement.Id), // 补充红包数
-            }).ToList();
+        var query = _redPackAuditRepository.Queryable(includeDeleted: true)
+        .LeftJoin<OrderSnapshot>((audit, snapshot) => audit.OrderId == snapshot.Id)
+        .LeftJoin<RedPackRecord>((audit, snapshot, record) => record.RedPackAuditId == audit.Id)
+        .LeftJoin<SupplementRecord>((audit, snapshot, record, supplement) => supplement.OrderId == snapshot.Id)
+        .Where((audit, snapshot) => audit.CreationTime >= dto.StartTime && audit.CreationTime <= dto.EndTime)
+        .GroupBy((audit, snapshot) => new { snapshot.IndustryCase, snapshot.IndustryId, snapshot.IndustryName })
+        .Select((audit, snapshot, record, supplement) => new RedPackStatisticsOutDto
+        {
+            Id = snapshot.IndustryId,
+            Name = snapshot.IndustryName,
+            CaseId = snapshot.IndustryCase,
+            ApprovalAmount = SqlFunc.AggregateSum(SqlFunc.IIF(audit.Status == ERedPackAuditStatus.Agree, audit.ApprovedAmount, 0)), //审批同意总金额
+            ApprovalCount = SqlFunc.AggregateSum(SqlFunc.IIF(audit.Status == ERedPackAuditStatus.Agree, 1, 0)), // 审批同意总个数
+            SentAmount = SqlFunc.AggregateSum(SqlFunc.IIF(audit.IsSend == true, audit.AcutalAmount, 0)), // 发送成功金额
+            SentCount = SqlFunc.AggregateSum(SqlFunc.IIF(audit.IsSend == true, 1, 0)), // 发送成功个数
+            SendFailAmount = SqlFunc.AggregateSum(SqlFunc.IIF(record.DistributionState == EReadPackSendStatus.Fail, record.Amount, 0)), //发送失败金额
+            SendFailCount = SqlFunc.AggregateSum(SqlFunc.IIF(record.DistributionState == EReadPackSendStatus.Fail, 1, 0)), // 发送失败个数
+            PendingAmount = SqlFunc.AggregateSum(SqlFunc.IIF(record.DistributionState == EReadPackSendStatus.Unsend, audit.ApprovedAmount, 0)), // 待发金额
+            PendingCount = SqlFunc.AggregateSum(SqlFunc.IIF(record.DistributionState == EReadPackSendStatus.Unsend, 1, 0)), // 待发个数
+            SupplementAmount = SqlFunc.AggregateSum(supplement.ReplenishAmount), // 补充红包金额
+            SupplementCount = SqlFunc.AggregateCount(supplement.Id), // 补充红包数
+        });
+#if DEBUG
+        var sql = query.ToSqlString();
+#endif
 
+        var redPackOutDto = query.ToList();
         foreach (var industry in industries)
         {
             var item = redPackOutDto
@@ -765,7 +769,9 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
         dto.FieldName = dto.FieldName.ToLower();
         var query = _orderSnapshotRepository.Queryable(includeDeleted: true)
             .LeftJoin<Order>((snapshot, order) => order.Id == snapshot.Id)
-            .Where((snapshot, order) => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime && order.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == dto.OrgCode);
+            .Where((snapshot, order) => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime)
+            .WhereIF(dto.OrgCode.NotNullOrEmpty(), (snapshot, order) =>
+             order.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == dto.OrgCode);
 
         query = dto.FieldName switch
         {
@@ -776,9 +782,13 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
             "not" => query.Where(snapshot => snapshot.CompliantType == ECompliantType.Not),
             _ => throw new UserFriendlyException($"入参: {dto.FieldName} 异常")
         };
-        return query.Select((snapshot, order) => new CompliantStatisticsDetailsOutDto
+        var b = query.Select((snapshot, order) => new CompliantStatisticsDetailsOutDto
         {
         }, true);
+#if DEBUG
+        var sql = b.ToSqlString();
+#endif
+        return b;
     }
 
     [ExportExcel("随手拍重办统计")]

+ 7 - 0
src/Hotline.Application/Snapshot/Contracts/IOrderSnapshotApplication.cs

@@ -147,4 +147,11 @@ public interface IOrderSnapshotApplication
 
     Task GetOrderDetailAsync(string id, Share.Dtos.Order.OrderDto dto, CancellationToken token);
     Task<string> GetStartflowAsync(string? orderId, CancellationToken requestAborted);
+
+    /// <summary>
+    /// 更新工单
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    Task UpdateOrderAsync(UpdateOrderDto dto, CancellationToken token);
 }

+ 16 - 3
src/Hotline.Application/Snapshot/RedPackApplication.cs

@@ -247,7 +247,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
         var industry = await _industryRepository.Queryable(includeDeleted: true)
             .LeftJoin<OrderSnapshot>((i, o) => i.Id == o.IndustryId)
             .Where((i, o) => o.Id == id)
-            .Select((i, o) => new { i.Id, i.CitizenReadPackAmount, i.ArgeePoints, i.ExtraDeductedPoints, i.RefusePoints , i.IsPoints})
+            .Select((i, o) => new { i.Id, i.CitizenReadPackAmount, i.ArgeePoints, i.ExtraDeductedPoints, i.RefusePoints, i.IsPoints })
             .FirstAsync();
         outDto.Amount = industry.CitizenReadPackAmount;
         outDto.ArgeePoints = industry.ArgeePoints;
@@ -555,6 +555,10 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
     public async Task UpdateRedPackAuditRemarkAsync(UpdateRedPackAuditRemarkInDto dto)
     {
         var audit = await _redPackAuditRepository.GetAsync(dto.RedPackAuditId) ?? throw UserFriendlyException.SameMessage("审核记录不存在");
+        if (audit.AcutalAmount == 0)
+            audit.IsSend = false;
+        else
+            audit.IsSend = dto.IsSend;
         audit.AcutalAmount = dto.AcutalAmount;
         audit.IsSend = dto.IsSend;
         audit.SendRemarks = dto.SendRemarks;
@@ -571,7 +575,16 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
                         record.PickupStatus = ERedPackPickupStatus.Excuse;
                 }
                 if (dto.IsSend)
+                {
                     record.DistributionState = EReadPackSendStatus.Successful;
+                    record.PickupStatus = ERedPackPickupStatus.Received;
+                }
+                if (dto.AcutalAmount == 0)
+                {
+                    record.PickupStatus = ERedPackPickupStatus.Unreceived;
+                    record.DistributionState = EReadPackSendStatus.Unsend;
+                }
+                record.Amount = dto.AcutalAmount;
                 await _redPackRecordRepository.UpdateAsync(record);
             });
 
@@ -586,7 +599,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
     public async Task UpdateRedPackRecordAsync(UpdateRedPackRecordInDto dto)
     {
         await _redPackAuditRepository.Queryable().Where(m => m.Id == dto.RedPackAuditId)
-            .Select(m => new { m.Id, m.OrderId})
+            .Select(m => new { m.Id, m.OrderId })
             .FirstAsync()
             .Then(async audit =>
             {
@@ -763,7 +776,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
             .WhereIF(dto.IndustryId.NotNullOrEmpty(), (supp, order) => supp.IndustryId == dto.IndustryId)
             .WhereIF(dto.BeginCreationTime.HasValue && dto.EndCreationTime.HasValue, (supp, order) => supp.CreationTime >= dto.BeginCreationTime && supp.CreationTime <= dto.EndCreationTime)
             .Select((supp, order) => new SnapshotRedPackRecordSupplementItemsOutDto
-            { 
+            {
                 Remark = supp.ReplenishRemark
             }, true);
         return query;

+ 8 - 5
src/Hotline.Application/Snapshot/SnapshotApplicationBase.cs

@@ -480,7 +480,7 @@ public abstract class SnapshotApplicationBase
     {
         var items = await _redPackRecordRepository.Queryable(includeDeleted: true)
             .Where(m => m.IsDeleted == false)
-            .Where(m => m.WXOpenId == _sessionContext.OpenId || m.PhoneNumber == _sessionContext.Phone)
+            .Where(m => m.WXOpenId == _sessionContext.OpenId)
             .Where(m => m.PickupStatus == dto.Status)
             .Where(m => m.CreationTime.ToString("yyyy-MM") == dto.Time)
             .LeftJoin<Order>((red, order) => red.OrderId == order.Id)
@@ -489,7 +489,8 @@ public abstract class SnapshotApplicationBase
                 OrderId = order.Id,
                 Amount = red.Amount,
                 Title = order.Title,
-                CreationTime = red.CreationTime
+                CreationTime = red.CreationTime,
+                RedPackAuditId = red.RedPackAuditId
             })
             .ToFixedListAsync(dto, cancellationToken);
 
@@ -502,9 +503,11 @@ public abstract class SnapshotApplicationBase
     /// <returns></returns>
     public async Task<string> GetRedPackReceivedTotalAsync(CancellationToken cancellationToken)
     {
-        var member = await _citizenRepository.GetAsync(m => m.Id == _sessionContext.UserId, cancellationToken)
-            ?? throw UserFriendlyException.SameMessage("用户不存在");
-        return (member.TotalAmount ?? 0).ToYuanFinance();
+        var totalAmount = await _redPackRecordRepository.Queryable()
+            .Where(m => m.WXOpenId == _sessionContext.OpenId && m.PickupStatus == ERedPackPickupStatus.Received)
+            .Select(m => SqlFunc.AggregateSum(m.Amount))
+            .FirstAsync(cancellationToken);
+        return totalAmount.ToYuanFinance();
     }
 
     /// <summary>

+ 20 - 2
src/Hotline.Application/Snapshot/SnapshotOrderApplication.cs

@@ -227,7 +227,7 @@ public class SnapshotOrderApplication : IOrderSnapshotApplication, IScopeDepende
             .LeftJoin<Order>((snapshot, order) => snapshot.Id == order.Id)
             .LeftJoin<WorkflowStep>((snapshot, order, step) => step.ExternalId == order.Id && step.Tag == TagDefaults.OrderMark && step.Status != EWorkflowStepStatus.Handled)
             .Where((snapshot, order, step) => snapshot.IndustryName == "安全隐患")
-            .WhereIF(dto.Status == 1, (snapshot, order, step) => step.Id != null && (step.HandlerId == _sessionContext.UserId ||_sessionContext.Roles.Contains(step.RoleId)) && snapshot.IsSafetyDepartment == null) // 待标记
+            .WhereIF(dto.Status == 1, (snapshot, order, step) => step.Id != null && (step.HandlerId == _sessionContext.UserId || _sessionContext.Roles.Contains(step.RoleId)) && snapshot.IsSafetyDepartment == null) // 待标记
             .WhereIF(dto.Status == 2, (snapshot, order, step) => snapshot.IsSafetyDepartment != null && snapshot.SignUserId == _sessionContext.UserId) // 已标记
             .WhereIF(dto.No.NotNullOrEmpty(), (snapshot, order, step) => order.No.Contains(dto.No))
             .WhereIF(dto.Title.NotNullOrEmpty(), (snapshot, order, step) => order.Title.Contains(dto.Title))
@@ -324,7 +324,7 @@ public class SnapshotOrderApplication : IOrderSnapshotApplication, IScopeDepende
     public async Task SaveOrderWorkflowInfo(NextWorkflowDto<OrderHandleFlowDto> dto)
     {
         if (_systemSettingCacheManager.Snapshot == false) return;
-        
+
         var snapshot = await _orderSnapshotRepository.GetAsync(dto.Data.OrderId);
         if (snapshot is null) return;
 
@@ -689,4 +689,22 @@ public class SnapshotOrderApplication : IOrderSnapshotApplication, IScopeDepende
         }
     }
 
+    public async Task UpdateOrderAsync(UpdateOrderDto dto, CancellationToken token)
+    {
+        if (_systemSettingCacheManager.Snapshot == false) return;
+
+        var sspSourceChannel = new List<string>() { "ZGSSP", "SJP12345"};
+        if (sspSourceChannel.Any(m => m == dto.SourceChannelCode) == false)
+        {
+            await _orderSnapshotRepository.Removeable()
+                .Where(m => m.Id == dto.Id)
+                .ExecuteCommandAsync(token);
+            return;
+        }
+        await _orderSnapshotRepository.Updateable()
+            .SetColumns(m => m.IndustryId, dto.IndustryId)
+            .SetColumns(m => m.IndustryName, dto.IndustryName)
+            .Where(m => m.Id == dto.Id)
+            .ExecuteCommandAsync(token);
+    }
 }

+ 2 - 1
src/Hotline.Application/StatisticalReport/OrderReportApplication.cs

@@ -2302,7 +2302,8 @@ namespace Hotline.Application.StatisticalReport
         public ISugarQueryable<Order> DepartmentAcceptanceTypeOrderList(DepartmentKeyWordRequest dto)
         {
             return _orderRepository.Queryable()
-                 .Where(p => p.FiledTime >= dto.StartTime && p.FiledTime <= dto.EndTime && p.Status >= EOrderStatus.Filed)
+                 .WhereIF(dto.TimeType == 2, p => p.FiledTime >= dto.StartTime && p.FiledTime <= dto.EndTime && p.Status >= EOrderStatus.Filed)
+                 .WhereIF(dto.TimeType == 1,p=> p.CreationTime>= dto.StartTime && p.CreationTime<=dto.EndTime)
                  .WhereIF(!string.IsNullOrEmpty(dto.OrgCode) && dto.OrgCode == "001", p => p.ActualHandleOrgCode == dto.OrgCode)
                  .WhereIF(dto.TypeId != null && dto.TypeId == 1, p => p.IdentityType == EIdentityType.Citizen)
                  .WhereIF(dto.TypeId != null && dto.TypeId == 2, p => p.IdentityType == EIdentityType.Enterprise)

+ 5 - 0
src/Hotline.Share/Dtos/Snapshot/RedPackDto.cs

@@ -26,6 +26,11 @@ public class RedPackOutDto
     /// 金额(单位:元)
     /// </summary>
     public double Amount { get; set; }
+
+    /// <summary>
+    /// 红包审核Id
+    /// </summary>
+    public string RedPackAuditId { get; set; }
 }
 
 public class RedPacksInDto : QueryFixedDto

+ 1 - 2
src/Hotline.Share/Dtos/Snapshot/StatisticsDto.cs

@@ -2577,8 +2577,7 @@ public record CompliantStatisticsDetailsInDto : PagedRequest
     /// <summary>
     /// 部门编号
     /// </summary>
-    [Required]
-    public string OrgCode { get; set; }
+    public string? OrgCode { get; set; }
 }
 
 public class CompliantStatisticsDetailsOutDto

+ 1 - 1
src/Hotline/SeedData/SystemDicDataSeedData.cs

@@ -45,7 +45,7 @@ public class SystemDicDataSeedData : ISeedData<SystemDicData>
                 new() {  Id = "08dd289b-a742-4622-8831-0fba6c8233de", DicDataValue = "waqyh", DicDataName = "无安全隐患", Sort = 2},
                 new() {  Id = "08dd287f-a17b-4404-809c-4b9e8cfaee52", DicDataValue = "hg", DicDataName = "合规", Sort = 3},
                 new() {  Id = "08dd287e-9cb5-4587-814f-1dbb0ab7c776", DicDataValue = "bhg", DicDataName = "不合规", Sort = 4},
-                new() {  Id = "08dd287d-fa29-4a2d-82cd-fae7c4ab1612", DicDataValue = "jdhfj", DicDataName = "阶段回复件", Sort = 5},
+                new() {  Id = "08dd287d-fa29-4a2d-82cd-fae7c4ab1612", DicDataValue = "jdhfj", DicDataName = "阶段回复件", Sort = 5},
                 new() {  Id = "08dd287d-f8a5-490f-8894-3a8f25d27258", DicDataValue = "lszg", DicDataName = "临时整改件", Sort = 6},
                 new() {  Id = "08dd287d-1e60-4adf-818a-ead50eb5a8c9", DicDataValue = "ss", DicDataName = "属实", Sort = 7},
                 new() {  Id = "08dd287c-69a4-4c92-899b-3fe7aa8503af", DicDataValue = "yzg", DicDataName = "已整改", Sort = 8},

+ 1 - 1
src/Hotline/Settings/TimeLimits/TimeLimitDomainService.cs

@@ -963,7 +963,7 @@ namespace Hotline.Settings.TimeLimits
                     return new TimeResult { EndTime = beginTime, RuleStr = timeValue + "个工作日", NearlyExpiredTime = startTime , NearlyExpiredTimeOne = startTimeOne };
                 //新增自然日
                 case ETimeType.Day:
-                    return new TimeResult { EndTime = beginTime.AddDays(timeValue), RuleStr = timeValue + "个自然日", NearlyExpiredTime = beginTime };
+                    return new TimeResult { EndTime = beginTime.AddDays(timeValue), RuleStr = timeValue + "个自然日", NearlyExpiredTime = beginTime.AddDays(timeValue*(Percentage/(double)100)), NearlyExpiredTimeOne = beginTime.AddDays(timeValue*(PercentageOne/(double)100)) };
                 default:
                     return null;
             }

+ 27 - 0
test/Hotline.Tests/Application/BiSnapshotApplicationTest.cs

@@ -2,6 +2,7 @@
 using Hotline.Application.Snapshot.Contracts;
 using Hotline.Identity.Accounts;
 using Hotline.Identity.Roles;
+using Hotline.Repository.SqlSugar.Extensions;
 using Hotline.Settings;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Tools;
@@ -110,4 +111,30 @@ public class BiSnapshotApplicationTest : TestBase
         var e = _biSnapshotApplication.GetIndustryStatistics(inDto.Adapt<IndustryStatisticsInDto>());
         e.ShouldNotBeNull();
     }
+
+    [Fact]
+    public async Task GetCompliantStatisticsDetails_Test()
+    {
+        var inDto = new CompliantStatisticsDetailsInDto()
+        {
+            PageIndex = 1,
+            PageSize = 20,
+            StartTime = DateTime.Now.AddDays(-30),
+            EndTime = DateTime.Now,
+            FieldName = "orderCountNum",
+        };
+        var items = await _biSnapshotApplication.GetCompliantStatisticsDetails(inDto).ToPagedListAsync(inDto);
+        items.Total.ShouldNotBe(0);
+    }
+
+    [Fact]
+    public async Task GetRedPackAuditStatistics_Test()
+    {
+        var items = _biSnapshotApplication.GetRedPackAuditStatistics(new RedPackStatisticsInDto()
+        {
+            StartTime = DateTime.Now.AddDays(-7),
+            EndTime = DateTime.Now
+        });
+        items.ShouldNotBeNull();
+    }
 }

+ 32 - 0
test/Hotline.Tests/Application/OrderSnapshotApplicationTest.cs

@@ -1,4 +1,5 @@
 using Hotline.Api.Controllers;
+using Hotline.Application.Snapshot;
 using Hotline.Application.Snapshot.Contracts;
 using Hotline.Caching.Interfaces;
 using Hotline.FlowEngine.WorkflowModules;
@@ -286,6 +287,37 @@ public class OrderSnapshotApplicationTest : TestBase
                 {
                     e.Message.ShouldBe("该工单已发放红包,不能撤销审批");
                 }
+
+                var redPack = await _redPackApplication.GetRedPackAuditItems(new SnapshotOrderAuditItemsInDto() { No = order.No }).FirstAsync();
+
+                await _redPackApplication.UpdateRedPackAuditRemarkAsync(new UpdateRedPackAuditRemarkInDto()
+                {
+                    RedPackAuditId = redPack.Id,
+                    AcutalAmount = 0,
+                    SendRemarks = "单元测试备注",
+                    IsSend = true
+                }); // 添加备注
+
+                SetWeiXin();
+                var redPackItems = await _snapshotApplication.GetRedPacksAsync(new RedPacksInDto() { Status = ERedPackPickupStatus.Unreceived }, CancellationToken.None);
+                var redPackRecord = redPackItems.Where(m => m.OrderId == order.Id).FirstOrDefault();
+                redPackRecord.ShouldNotBeNull();
+                redPackRecord.Amount.ShouldBe(0);
+
+                Set应急管理局();
+                await _redPackApplication.UpdateRedPackAuditRemarkAsync(new UpdateRedPackAuditRemarkInDto()
+                {
+                    RedPackAuditId = redPackRecord.RedPackAuditId,
+                    AcutalAmount = 11,
+                    SendRemarks = "单元测试备注",
+                    IsSend = true
+                }); // 添加备注
+
+                SetWeiXin();
+                redPackItems =  await _snapshotApplication.GetRedPacksAsync(new RedPacksInDto() { Status = ERedPackPickupStatus.Received }, CancellationToken.None);
+                redPackRecord = redPackItems.Where(m => m.OrderId == order.Id).FirstOrDefault();
+                redPackRecord.ShouldNotBeNull();
+                redPackRecord.Amount.ShouldBe(11);
             })
             .GetCreateResult();
         order.Id.ShouldNotBeNull();

+ 5 - 1
test/Hotline.Tests/Application/XingTangCallsSyncJobTest.cs

@@ -1,5 +1,6 @@
 using AutoFixture;
 using Hotline.Application.Jobs;
+using Hotline.Caching.Interfaces;
 using Hotline.Repository.SqlSugar;
 using Quartz;
 using SqlSugar;
@@ -12,18 +13,21 @@ public class XingTangCallsSyncJobTest
     private readonly ISqlSugarClient _db;
     private readonly IFixture _fixture;
     private readonly XingTangCallSatisfactionSyncJob _xingTangCallSatisfactionSyncJob;
+    private readonly ISystemSettingCacheManager _systemSettingCacheManager;
 
-    public XingTangCallsSyncJobTest(XingTangCallsSyncJob xingTangCallsSyncJob, ISugarUnitOfWork<XingTangDbContext> uow, XingTangCallSatisfactionSyncJob xingTangCallSatisfactionSyncJob)
+    public XingTangCallsSyncJobTest(XingTangCallsSyncJob xingTangCallsSyncJob, ISugarUnitOfWork<XingTangDbContext> uow, XingTangCallSatisfactionSyncJob xingTangCallSatisfactionSyncJob, ISystemSettingCacheManager systemSettingCacheManager)
     {
         this.xingTangCallsSyncJob = xingTangCallsSyncJob;
         _db = uow.Db;
         _fixture = new Fixture();
         _xingTangCallSatisfactionSyncJob = xingTangCallSatisfactionSyncJob;
+        _systemSettingCacheManager = systemSettingCacheManager;
     }
 
     [Fact]
     public async Task Handler_Test()
     {
+        var unPushTime = _systemSettingCacheManager.CallSyncUnPushDateTime;
         var second = new Random().Next(0, 60);
         var inDto = _fixture.Create<XingtangCall>();
         inDto.CallStartTime = DateTime.Parse("2024/11/19 18:07:" + second);

+ 28 - 10
test/Hotline.Tests/Mock/OrderServiceMock.cs

@@ -94,13 +94,21 @@ public class OrderServiceMock
         inDto.Latitude = 29.3661181959828;
         inDto.Longitude = 104.41928;
         //inDto.JobType = 
+        var file = 0;
         foreach (var item in inDto.Files)
         {
-            var result = UploadImage().Result;
+            var i = UploadImage();
+            if (i.Code == -1)
+            {
+                file = i.Code;
+                break;
+            }
+            var result = i.Result;
             item.FileName = result.FileName;
             item.Path = result.Path;
             item.AdditionId = result.Id;
         }
+        if (file == -1) inDto.Files = new List<SnapshotFileInDto>();
         CreateOrderOutDto = _snapshotController.AddOrderAsync(inDto).GetAwaiter().GetResult().ToJson().FromJson<CreateOrderOutDto>();
         _orderServiceStartWorkflow.orderServiceMock = this;
         return _orderServiceStartWorkflow;
@@ -430,6 +438,7 @@ public class OrderServiceMock
         var uploadUrl = _systemSettingCacheManager.FileServerUrl + "/file/upload?source=hotline";
         var file = "测试图片" + DateTime.Now.ToString("ss") + ".png";
         var resultJson = UploadFileFromMemory(imageBytes, file, uploadUrl);
+        if (resultJson.IsNullOrEmpty()) return new ApiResponse<FileJson>() { Code = -1 };
         var result = resultJson.FromJson<ApiResponse<FileJson>>();
         return result;
     }
@@ -558,18 +567,27 @@ public class OrderServiceMock
 
     private string UploadFileFromMemory(byte[] fileBytes, string fileName, string uploadUrl)
     {
-        using HttpClient client = new HttpClient();
-        using var multipartContent = new MultipartFormDataContent();
-        var fileContent = new ByteArrayContent(fileBytes);
-        fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("image/jpeg");
+        try
+        {
+            using HttpClient client = new HttpClient();
+            using var multipartContent = new MultipartFormDataContent();
+            var fileContent = new ByteArrayContent(fileBytes);
+            fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("image/jpeg");
 
-        multipartContent.Add(fileContent, "fileData", fileName);
+            multipartContent.Add(fileContent, "fileData", fileName);
 
-        HttpResponseMessage response = client.PostAsync(uploadUrl, multipartContent).GetAwaiter().GetResult();
-        response.EnsureSuccessStatusCode();
+            HttpResponseMessage response = client.PostAsync(uploadUrl, multipartContent).GetAwaiter().GetResult();
+            response.EnsureSuccessStatusCode();
 
-        var result = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
-        return result;
+            var result = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
+            return result;
+
+        }
+        catch (Exception e)
+        {
+            var msg = e.Message;
+        }
+        return string.Empty;
     }
 
     public OrderServiceMock StepHandle(Func<CreateOrderOutDto, OrderServiceMock, Task> handle)