Browse Source

Merge branch 'feature/snapshot' into test

qinchaoyue 3 days ago
parent
commit
c27ff088f9

+ 14 - 3
src/Hotline/Snapshot/Services/SnapshotPointsDomainService.cs

@@ -1,4 +1,5 @@
-using Hotline.Share.Enums.Snapshot;
+using Hotline.Orders;
+using Hotline.Share.Enums.Snapshot;
 using Hotline.Snapshot.Contracts;
 using Hotline.Snapshot.IRepository;
 using System;
@@ -27,11 +28,21 @@ public class SnapshotPointsDomainService : ISnapshotPointsDomainService, IScopeD
         if (status == null) return;
         var order = await _orderSnapshotRepository.Queryable()
             .LeftJoin<Industry>((snapshot, industry) => snapshot.IndustryId == industry.Id)
+            .LeftJoin<Order>((snapshot, industry, order) => order.Id == snapshot.Id)
             .Where((snapshot, industry) => snapshot.Id == orderId)
-            .Select((snapshot, industry) => new { snapshot.Id, industry.ReportPoints , industry.ArgeePoints , industry.RefusePoints,  industry.Name,
-                snapshot.CreatorId})
+            .Select((snapshot, industry, order) => new 
+            {
+                snapshot.Id,
+                industry.ReportPoints,
+                industry.ArgeePoints, 
+                industry.RefusePoints,
+                industry.Name,
+                snapshot.CreatorId,
+                order.HotspotId
+            })
             .FirstAsync();
         if (order == null) return;
+        if (order.HotspotId != null && order.HotspotId.StartsWith("18") == true) return;
         
         if (order.ReportPoints.HasValue == false)
             throw new UserFriendlyException($"{order.Name} 行业未配置积分");

+ 35 - 3
test/Hotline.Tests/Application/OrderSnapshotApplicationTest.cs

@@ -11,6 +11,7 @@ using Hotline.Repository.SqlSugar.Snapshot;
 using Hotline.Settings;
 using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.Snapshot;
+using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Enums.Snapshot;
 using Hotline.Share.Requests;
 using Hotline.Share.Tools;
@@ -112,6 +113,37 @@ public class OrderSnapshotApplicationTest : TestBase
             });
     }
 
+    [Theory]
+    [InlineData(true)]
+    [InlineData(false)]
+    public async Task SnapshotOrder_AddPoints_Test(bool 是受理范围)
+    {
+        var order = _orderServiceMock.CreateSnapshotOrder(SetWeiXin, "安全隐患")
+            .StepHandle(async order =>
+            {
+                if (是受理范围 == false)
+                {
+                    var entity = _orderRepository.Get(order.Id);
+                    entity.HotspotId = "181301";
+                    await _orderRepository.UpdateAsync(entity);
+                }
+            })
+            .办理到一级部门(SetZuoXi)
+            .办理到归档(Set一级部门, data =>
+            {
+                data.CompliantType = ECompliantType.First;
+                data.VerifyType = "现场";
+                data.IsCheckList = true;
+            }).GetCreateResult();
+        var points = await _pointsRecordRepository.Queryable()
+            .Where(m => m.OrderId == order.Id && m.Direction == EPointsDirection.In && m.Source == EPointsSource.Report)
+            .FirstAsync();
+        if (是受理范围)
+            points.ShouldNotBeNull();
+        else
+            points.ShouldBeNull();
+    }
+
     /// <summary>
     /// 随手拍网格员超时:
     /// </summary>
@@ -267,7 +299,7 @@ public class OrderSnapshotApplicationTest : TestBase
                 baseData.AuditTypeCode.ShouldNotBeNull();
                 baseData.Amount.ShouldNotBeNull();
 
-                var specialRedAuditItems = await _redPackApplication.GetRedPackSpecialAuditItems(new SnapshotOrderAuditItemsInDto() { PageIndex = 1, PageSize = 10 , No = order.No, Status = 1}).ToListAsync();
+                var specialRedAuditItems = await _redPackApplication.GetRedPackSpecialAuditItems(new SnapshotOrderAuditItemsInDto() { PageIndex = 1, PageSize = 10, No = order.No, Status = 1 }).ToListAsync();
                 var specialRedAudit = specialRedAuditItems.FirstOrDefault();
                 specialRedAudit.ShouldNotBeNull();
                 var a = _systemDicDataCacheManager.SnapshotReplenishType.First();
@@ -288,7 +320,7 @@ public class OrderSnapshotApplicationTest : TestBase
                 };
 
                 await _redPackApplication.UpdateRedPackSpecialRecordAsync(inDto); // 补充发放
-                specialRedAuditItems = await _redPackApplication.GetRedPackSpecialAuditItems(new SnapshotOrderAuditItemsInDto() { PageIndex = 1, PageSize = 10 , Status = 1, No = order.No}).ToListAsync();
+                specialRedAuditItems = await _redPackApplication.GetRedPackSpecialAuditItems(new SnapshotOrderAuditItemsInDto() { PageIndex = 1, PageSize = 10, Status = 1, No = order.No }).ToListAsync();
                 specialRedAudit = specialRedAuditItems.First();
                 specialRedAudit.ShouldNotBeNull();
                 specialRedAudit.BankCardNo.ShouldBe(inDto.BankCardNo);
@@ -329,7 +361,7 @@ public class OrderSnapshotApplicationTest : TestBase
                 }); // 添加备注
 
                 SetWeiXin();
-                redPackItems =  await _snapshotApplication.GetRedPacksAsync(new RedPacksInDto() { Status = ERedPackPickupStatus.Received }, CancellationToken.None);
+                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);

+ 2 - 0
test/Hotline.Tests/Mock/Interfaces/IOrderServiceStartWorkflow.cs

@@ -13,4 +13,6 @@ public interface IOrderServiceStartWorkflow
     CreateOrderOutDto GetCreateResult();
     OrderServiceMock 办理到一级部门(Action action = null);
     OrderServiceMock 办理到归档(Action action = null);
+
+    IOrderServiceStartWorkflow StepHandle(Func<CreateOrderOutDto, Task> handle);
 }

+ 6 - 0
test/Hotline.Tests/Mock/OrderServiceStartWorkflow.cs

@@ -46,6 +46,12 @@ public class OrderServiceStartWorkflow : IOrderServiceStartWorkflow
         return _orderServiceMock.CreateOrderOutDto;
     }
 
+    public IOrderServiceStartWorkflow StepHandle(Func<CreateOrderOutDto, Task> handle)
+    {
+        handle(_orderServiceMock.CreateOrderOutDto).GetAwaiter().GetResult();
+        return this;
+    }
+
     public OrderServiceMock 办理到一级部门(Action action = null)
     {
         action?.Invoke();