|
@@ -29,6 +29,7 @@ using System.Net.Http.Headers;
|
|
|
using Hotline.Share.Dtos;
|
|
|
using Hotline.FlowEngine.Notifications;
|
|
|
using Hotline.Api.Controllers.Bi;
|
|
|
+using XF.Domain.Exceptions;
|
|
|
|
|
|
namespace Hotline.Application.Tests.Mock;
|
|
|
public class OrderServiceMock
|
|
@@ -43,8 +44,9 @@ public class OrderServiceMock
|
|
|
public readonly IFixture _fixture;
|
|
|
public readonly ISessionContext _sessionContext;
|
|
|
public readonly IOrderServiceStartWorkflow _orderServiceStartWorkflow;
|
|
|
+ public readonly RedPackController _redPackController;
|
|
|
|
|
|
- public OrderServiceMock(OrderController orderController, IRepository<Order> orderRepository, IOrderVisitRepository orderVisitRepository, SnapshotController snapshotController, ISessionContext sessionContext, IOrderServiceStartWorkflow orderServiceStartWorkflow, ISystemSettingCacheManager systemSettingCacheManager)
|
|
|
+ public OrderServiceMock(OrderController orderController, IRepository<Order> orderRepository, IOrderVisitRepository orderVisitRepository, SnapshotController snapshotController, ISessionContext sessionContext, IOrderServiceStartWorkflow orderServiceStartWorkflow, ISystemSettingCacheManager systemSettingCacheManager, RedPackController redPackController)
|
|
|
{
|
|
|
_orderController = orderController;
|
|
|
_orderController.ControllerContext = new ControllerContext
|
|
@@ -62,6 +64,11 @@ public class OrderServiceMock
|
|
|
_sessionContext = sessionContext;
|
|
|
_orderServiceStartWorkflow = orderServiceStartWorkflow;
|
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
|
+ _redPackController = redPackController;
|
|
|
+ _redPackController.ControllerContext = new ControllerContext
|
|
|
+ {
|
|
|
+ HttpContext = new DefaultHttpContext(),
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
public IOrderServiceStartWorkflow CreateSnapshotOrder(Action action)
|
|
@@ -281,9 +288,9 @@ public class OrderServiceMock
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public OrderServiceMock 办理一级部门汇总(Action aciton = null)
|
|
|
+ public OrderServiceMock 办理一级部门汇总(Action action = null)
|
|
|
{
|
|
|
- aciton?.Invoke();
|
|
|
+ action?.Invoke();
|
|
|
var stepNextInfo = _orderController.GetNextStepsWithRecommend(CreateOrderOutDto.Id).GetAwaiter().GetResult().ToJson().FromJson<NextStepsDto<NextStepOption>>();
|
|
|
var stepInfo = stepNextInfo.Steps.FirstOrDefault(m => m.Value == "一级部门汇总");
|
|
|
var stepOrg = stepInfo.Items.FirstOrDefault(m => m.OrgName == "测试部门");
|
|
@@ -326,9 +333,9 @@ public class OrderServiceMock
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public OrderServiceMock 发布工单(Action aciton = null, IList<Kv>? snapshotLabels = null)
|
|
|
+ public OrderServiceMock 发布工单(Action action = null, IList<Kv>? snapshotLabels = null)
|
|
|
{
|
|
|
- aciton?.Invoke();
|
|
|
+ action?.Invoke();
|
|
|
var baseData = _orderController.PublishOrderPageBase(CreateOrderOutDto.Id).GetAwaiter().GetResult();
|
|
|
var inDto = new PublishOrderDto
|
|
|
{
|
|
@@ -347,9 +354,48 @@ public class OrderServiceMock
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public OrderServiceMock 发送回访短信(Action aciton = null)
|
|
|
+ public OrderServiceMock 部门审核网格员红包(Action action = null)
|
|
|
+ {
|
|
|
+ action?.Invoke();
|
|
|
+ var baseData = _redPackController.GetRedPackGuiderAuditItems(new SnapshotOrderGuiderAuditItemsInDto(null, null, 0)).GetAwaiter().GetResult();
|
|
|
+ var item = baseData.Items.FirstOrDefault(m => m.No == CreateOrderOutDto.No);
|
|
|
+ if (item == null)
|
|
|
+ throw UserFriendlyException.SameMessage("获取审核红包信息错误, 不存在被测试的对象.");
|
|
|
+ var inDto = new UpdateRedPackGuiderAuditInDto
|
|
|
+ {
|
|
|
+ RedPackAuditId = item.RedPackAuditId,
|
|
|
+ Status = ESnapshotSMSStatus.Agree,
|
|
|
+ Opinion = "红包审核通过",
|
|
|
+ };
|
|
|
+
|
|
|
+ _redPackController.UpdateRedPackGuiderAuditAsync(inDto).GetAwaiter().GetResult();
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public OrderServiceMock 部门审核市民红包(Action action = null)
|
|
|
{
|
|
|
- aciton?.Invoke();
|
|
|
+ action?.Invoke();
|
|
|
+ var baseData = _redPackController.GetRedPackAuditItems(new SnapshotOrderAuditItemsInDto(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 0)).GetAwaiter().GetResult();
|
|
|
+ var item = baseData.Items.FirstOrDefault(m => m.No == CreateOrderOutDto.No);
|
|
|
+ if (item == null)
|
|
|
+ throw UserFriendlyException.SameMessage("获取审核红包信息错误, 不存在被测试的对象.");
|
|
|
+ var inDto = new UpdateRedPackAuditInDto
|
|
|
+ {
|
|
|
+ SMSTemplateId = "",
|
|
|
+ IsSendSms = false,
|
|
|
+ RedPackAuditId = item.RedPackAuditId,
|
|
|
+ Status = ESnapshotSMSStatus.Agree,
|
|
|
+ Opinion = "红包审核通过",
|
|
|
+ };
|
|
|
+
|
|
|
+ _redPackController.UpdateRedPackAuditAsync(inDto).GetAwaiter().GetResult();
|
|
|
+ return this;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public OrderServiceMock 发送回访短信(Action action = null)
|
|
|
+ {
|
|
|
+ action?.Invoke();
|
|
|
var id = _orderVisitRepository.Queryable()
|
|
|
.Where(m => m.No == CreateOrderOutDto.No)
|
|
|
.Select(m => m.Id)
|
|
@@ -430,4 +476,5 @@ public class OrderServiceMock
|
|
|
_orderController.Handle(handleDto).GetAwaiter().GetResult();
|
|
|
return this;
|
|
|
}
|
|
|
+
|
|
|
}
|