|
@@ -1,6 +1,7 @@
|
|
|
using Hotline.Api.Controllers;
|
|
|
using Hotline.Application.Tests.Mock;
|
|
|
using Hotline.Caching.Interfaces;
|
|
|
+using Hotline.Configurations;
|
|
|
using Hotline.EventBus;
|
|
|
using Hotline.Identity.Accounts;
|
|
|
using Hotline.Identity.Roles;
|
|
@@ -18,6 +19,7 @@ using Hotline.Users;
|
|
|
using Mapster;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
+using Microsoft.Extensions.Options;
|
|
|
using Shouldly;
|
|
|
using XF.Domain.Repository;
|
|
|
|
|
@@ -32,8 +34,9 @@ public class OrderVisitDomainServiceTest : TestBase
|
|
|
private readonly OrderServiceMock _orderServiceMock;
|
|
|
private readonly ISettingOrderVisitSmsReplyRuleRepository _settingOrderVisitSmsReplyRuleRepository;
|
|
|
private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
|
|
|
+ private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
|
|
|
|
|
|
- public OrderVisitDomainServiceTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IOrderVisitDomainService orderVisitDomainService, IOrderVisitRepository orderVisitRepository, IRepository<OrderVisitDetail> orderVisitDetailRepository, Publisher publisher, IOrderRepository orderRepository, OrderServiceMock orderServiceMock, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ISettingOrderVisitSmsReplyRuleRepository settingOrderVisitSmsReplyRuleRepository, ISystemDicDataCacheManager systemDicDataCacheManager) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount)
|
|
|
+ public OrderVisitDomainServiceTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IOrderVisitDomainService orderVisitDomainService, IOrderVisitRepository orderVisitRepository, IRepository<OrderVisitDetail> orderVisitDetailRepository, Publisher publisher, IOrderRepository orderRepository, OrderServiceMock orderServiceMock, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ISettingOrderVisitSmsReplyRuleRepository settingOrderVisitSmsReplyRuleRepository, ISystemDicDataCacheManager systemDicDataCacheManager, IOptionsSnapshot<AppConfiguration> appOptions) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount)
|
|
|
{
|
|
|
_orderVisitDomainService = orderVisitDomainService;
|
|
|
_orderVisitRepository = orderVisitRepository;
|
|
@@ -43,6 +46,7 @@ public class OrderVisitDomainServiceTest : TestBase
|
|
|
_orderServiceMock = orderServiceMock;
|
|
|
_settingOrderVisitSmsReplyRuleRepository = settingOrderVisitSmsReplyRuleRepository;
|
|
|
_systemDicDataCacheManager = systemDicDataCacheManager;
|
|
|
+ _appOptions = appOptions;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -104,17 +108,22 @@ public class OrderVisitDomainServiceTest : TestBase
|
|
|
}
|
|
|
|
|
|
[Theory]
|
|
|
- [InlineData("4", "SMSUnsatisfied", "2", "不满意", "不满意")]
|
|
|
+ [InlineData("4", "SMSUnsatisfied", "2", "不满意", "不满意", "Published")]
|
|
|
[InlineData("1", "Visited", "5", "非常满意", "非常满意")]
|
|
|
- //[InlineData("非常满意", "Visited", "5", "非常满意")]
|
|
|
[InlineData("2", "Visited", "4", "满意", "满意")]
|
|
|
[InlineData("3", "Visited", "4", "满意", "一般")]
|
|
|
- //[InlineData("不满意", "SMSUnsatisfied", "2", "不满意")]
|
|
|
- [InlineData("5", "SMSUnsatisfied", "2", "不满意", "不满意")]
|
|
|
- [InlineData("0", "Visited", "0", "默认满意", "超过48小时自动回访")]
|
|
|
- [InlineData("都没有办理好", "SMSUnsatisfied", "", "", "都没有办理好")]
|
|
|
- public async Task UpdateSmsReply_Test(string content, string visitState, string orgResuktKey, string orgResuktValue, string visitContent)
|
|
|
+ [InlineData("5", "SMSUnsatisfied", "2", "不满意", "不满意", "Published")]
|
|
|
+ [InlineData("默认满意", "Visited", "0", "默认满意", "超过48小时自动回访")]
|
|
|
+ [InlineData("都没有办理好", "SMSUnsatisfied", "", "", "都没有办理好", "Published", "YiBin")]
|
|
|
+ [InlineData("1", "Visited", "4", "满意", "满意", "Visited", "YiBin")]
|
|
|
+ [InlineData("2", "SMSUnsatisfied", "2", "不满意", "不满意", "Published", "YiBin")]
|
|
|
+ public async Task UpdateSmsReply_Test(string content, string visitState, string orgResuktKey, string orgResuktValue, string visitContent, string visited = "Visited", string appScope = "ZiGong")
|
|
|
{
|
|
|
+ if (appScope != "ZiGong")
|
|
|
+ ChangeAppScopeYiBin();
|
|
|
+ else
|
|
|
+ ChangeAppScopeZiGong();
|
|
|
+ var appScopeFile = _appOptions.Value.AppScope;
|
|
|
SetZuoXi();
|
|
|
var order = _orderServiceMock.CreateOrder()
|
|
|
.办理到一级部门()
|
|
@@ -139,19 +148,18 @@ public class OrderVisitDomainServiceTest : TestBase
|
|
|
await _orderVisitDomainService.UpdateSmsReplyAsync(message);
|
|
|
visit = _orderVisitRepository.Get(visit.Id);
|
|
|
visit.VisitState.ShouldBe(visitState.ToEnum<EVisitState>());
|
|
|
- visit.NowEvaluate.ShouldNotBeNull();
|
|
|
- visit.NowEvaluate.Key.ShouldBe(orgResuktKey);
|
|
|
- visit.NowEvaluate.Value.ShouldBe(orgResuktValue);
|
|
|
+ if (orgResuktKey.NotNullOrEmpty())
|
|
|
+ {
|
|
|
+ visit.NowEvaluate.ShouldNotBeNull();
|
|
|
+ visit.NowEvaluate.Key.ShouldBe(orgResuktKey);
|
|
|
+ visit.NowEvaluate.Value.ShouldBe(orgResuktValue);
|
|
|
+ }
|
|
|
var orderEntity = await _orderRepository.GetAsync(order.Id);
|
|
|
orderEntity.ShouldNotBeNull();
|
|
|
- if (content == "4" || content == "5" || content == "不满意" || content == "非常不满意")
|
|
|
+ orderEntity.Status.ShouldBe(visited.ToEnum<EOrderStatus>());
|
|
|
+ if (content == "4" || content == "5" || content == "不满意" || content == "非常不满意" || content == "都没有办理好")
|
|
|
{
|
|
|
visit.VisitType.ShouldBeNull();
|
|
|
- orderEntity.Status.ShouldNotBe(EOrderStatus.Visited);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- orderEntity.Status.ShouldBe(EOrderStatus.Visited);
|
|
|
}
|
|
|
|
|
|
var smsReply = _orderVisitDomainService.GetVisitEvaluateByReplyTxt(content);
|
|
@@ -160,50 +168,62 @@ public class OrderVisitDomainServiceTest : TestBase
|
|
|
.FirstAsync()
|
|
|
.Then(org =>
|
|
|
{
|
|
|
- org.OrgProcessingResults.ShouldNotBeNull();
|
|
|
- org.OrgProcessingResults.Key.ShouldBe(orgResuktKey);
|
|
|
- org.OrgProcessingResults.Value.ShouldBe(orgResuktValue);
|
|
|
- org.VisitContent.ShouldBe(visitContent);
|
|
|
-
|
|
|
- // 验证跟新工单上的字段是否成功
|
|
|
- if (new string[] { "4", "5", "不满意", "非常不满意" }.Contains(content) == false)
|
|
|
+ if (content != "都没有办理好")
|
|
|
{
|
|
|
- orderEntity.OrgProcessingResults.ShouldNotBeNull();
|
|
|
- orderEntity.OrgProcessingResults.Key.ShouldBe(orgResuktKey);
|
|
|
- orderEntity.OrgProcessingResults.Value.ShouldBe(orgResuktValue);
|
|
|
- }
|
|
|
+ org.OrgProcessingResults.ShouldNotBeNull();
|
|
|
+ org.OrgProcessingResults.Key.ShouldBe(orgResuktKey);
|
|
|
+ org.OrgProcessingResults.Value.ShouldBe(orgResuktValue);
|
|
|
+ org.VisitContent.ShouldBe(visitContent);
|
|
|
|
|
|
- org.OrgHandledAttitude.ShouldNotBeNull();
|
|
|
- org.OrgHandledAttitude.Key.ShouldBe(orgResuktKey);
|
|
|
- org.OrgHandledAttitude.Value.ShouldBe(orgResuktValue);
|
|
|
- if (smsReply.IsReplyToOrgVisitContent == true)
|
|
|
- {
|
|
|
- org.VisitContent = content;
|
|
|
+ // 验证跟新工单上的字段是否成功
|
|
|
+ if (new string[] { "4", "5", "不满意", "非常不满意"}.Contains(content) == false)
|
|
|
+ {
|
|
|
+ if (appScope != "YiBin" && content != "2")
|
|
|
+ {
|
|
|
+ orderEntity.OrgProcessingResults.ShouldNotBeNull();
|
|
|
+ orderEntity.OrgProcessingResults.Key.ShouldBe(orgResuktKey);
|
|
|
+ orderEntity.OrgProcessingResults.Value.ShouldBe(orgResuktValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (appScope != "YiBin")
|
|
|
+ {
|
|
|
+ org.OrgHandledAttitude.ShouldNotBeNull();
|
|
|
+ org.OrgHandledAttitude.Key.ShouldBe(orgResuktKey);
|
|
|
+ org.OrgHandledAttitude.Value.ShouldBe(orgResuktValue);
|
|
|
+ }
|
|
|
+ if (smsReply.IsReplyToOrgVisitContent == true)
|
|
|
+ {
|
|
|
+ org.VisitContent = content;
|
|
|
+ }
|
|
|
}
|
|
|
return Task.CompletedTask;
|
|
|
});
|
|
|
await _orderVisitDetailRepository.Queryable()
|
|
|
.Where(m => m.VisitId == visit.Id && m.VisitTarget == EVisitTarget.Seat)
|
|
|
.FirstAsync()
|
|
|
- .Then( seat =>
|
|
|
+ .Then(seat =>
|
|
|
{
|
|
|
- // 验证跟新工单上的字段是否成功
|
|
|
- if (new string[] { "4", "5", "不满意", "非常不满意" }.Contains(content) == true)
|
|
|
+ if (content != "都没有办理好")
|
|
|
{
|
|
|
- seat.SeatEvaluate.ShouldNotBe(ESeatEvaluate.NoSatisfied);
|
|
|
- seat.SeatEvaluate.ShouldNotBe(ESeatEvaluate.VeryNoSatisfied);
|
|
|
- seat.VoiceEvaluate.ShouldNotBe(EVoiceEvaluate.NoSatisfied);
|
|
|
- seat.VoiceEvaluate.ShouldNotBe(EVoiceEvaluate.VeryNoSatisfied);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (smsReply.SeatEvaluate != null)
|
|
|
- seat.SeatEvaluate.ShouldBe(smsReply.SeatEvaluate);
|
|
|
- if (smsReply.VoiceEvaluate != null)
|
|
|
- seat.VoiceEvaluate.ShouldBe(smsReply.VoiceEvaluate);
|
|
|
- }
|
|
|
|
|
|
+ // 验证跟新工单上的字段是否成功
|
|
|
+ if (new string[] { "4", "5", "不满意", "非常不满意", "都没有办理好" }.Contains(content) == true)
|
|
|
+ {
|
|
|
+ seat.SeatEvaluate.ShouldNotBe(ESeatEvaluate.NoSatisfied);
|
|
|
+ seat.SeatEvaluate.ShouldNotBe(ESeatEvaluate.VeryNoSatisfied);
|
|
|
+ seat.VoiceEvaluate.ShouldNotBe(EVoiceEvaluate.NoSatisfied);
|
|
|
+ seat.VoiceEvaluate.ShouldNotBe(EVoiceEvaluate.VeryNoSatisfied);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (smsReply.SeatEvaluate != null)
|
|
|
+ seat.SeatEvaluate.ShouldBe(smsReply.SeatEvaluate);
|
|
|
+ if (smsReply.VoiceEvaluate != null)
|
|
|
+ seat.VoiceEvaluate.ShouldBe(smsReply.VoiceEvaluate);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
return Task.CompletedTask;
|
|
|
});
|
|
|
}
|
|
@@ -249,15 +269,17 @@ public class OrderVisitDomainServiceTest : TestBase
|
|
|
public async Task Init_SettingOrderVisitSmsReplyRule_Data()
|
|
|
{
|
|
|
IEnumerable<SettingOrderVisitSmsReplyRule> entities = [
|
|
|
- new () {Name = "非常满意的规则", AppScope = "ZiGong", ReplyRegular = "1", VisitContent = "非常满意", VisitState = EVisitState.Visited, SeatEvaluate = null,VoiceEvaluate = null,OrgProcessingResults=5, OrgHandledAttitude = 5, VisitType = EVisitType.SmsVisit},
|
|
|
- new () {Name = "满意的规则", AppScope = "ZiGong", ReplyRegular = "2", VisitContent = "满意", VisitState = EVisitState.Visited, SeatEvaluate = null,VoiceEvaluate = null,OrgProcessingResults=4, OrgHandledAttitude = 4 , VisitType = EVisitType.SmsVisit},
|
|
|
- new () {Name = "一般的规则", AppScope = "ZiGong", ReplyRegular = "3", VisitContent = "一般", VisitState = EVisitState.Visited, SeatEvaluate = null, VoiceEvaluate = null,OrgProcessingResults= 4, OrgHandledAttitude = 4 , VisitType = EVisitType.SmsVisit},
|
|
|
- new () {Name = "不满意的规则", AppScope = "ZiGong", ReplyRegular = "4", VisitContent = "不满意", VisitState = EVisitState.SMSUnsatisfied, SeatEvaluate = null,VoiceEvaluate = null,OrgProcessingResults=2, OrgHandledAttitude = 2 , VisitType = null},
|
|
|
- new () {Name = "非常不满意的规则", AppScope = "ZiGong", ReplyRegular = "5", VisitContent = "非常不满意", VisitState = EVisitState.SMSUnsatisfied, SeatEvaluate = null, VoiceEvaluate = null,OrgProcessingResults=2, OrgHandledAttitude = 2, VisitType = null},
|
|
|
- new () {Name = "默认满意的规则", AppScope = "ZiGong", ReplyRegular = "0", VisitContent = "超过48小时自动回访", VisitState = EVisitState.Visited, SeatEvaluate = null, VoiceEvaluate = null,OrgProcessingResults=0, OrgHandledAttitude = 0, VisitType = EVisitType.SmsVisit},
|
|
|
- new () {Name = "对部门处理结果满意", AppScope = "YiBin", ReplyRegular = "1", VisitContent = "满意", VisitState = EVisitState.Visited, SeatEvaluate = null,VoiceEvaluate = null,OrgProcessingResults = 4 , OrgHandledAttitude = null, VisitType = EVisitType.SmsVisit},
|
|
|
- new () {Name = "默认满意的规则", AppScope = "YiBin", ReplyRegular = "0", VisitContent = "超过48小时自动回访", VisitState = EVisitState.Visited, SeatEvaluate = null,VoiceEvaluate = null,OrgProcessingResults=0, OrgHandledAttitude = 0 , VisitType = EVisitType.SmsVisit},
|
|
|
- new () {Name = "对部门处理结果不满意的规则", AppScope = "YiBin", ReplyRegular = "2", VisitContent = "不满意", VisitState = EVisitState.Visited, SeatEvaluate = null,VoiceEvaluate = null,OrgProcessingResults=0, OrgHandledAttitude = 0 , VisitType = null},
|
|
|
+ new () {Name = "非常满意的规则", AppScope = "ZiGong", ReplyRegular = "1", VisitContent = "非常满意", VisitState = EVisitState.Visited, SeatEvaluate = null,VoiceEvaluate = null,OrgProcessingResults=5, OrgHandledAttitude = 5, VisitType = EVisitType.SmsVisit, SortOrder = 1},
|
|
|
+ new () {Name = "满意的规则", AppScope = "ZiGong", ReplyRegular = "2", VisitContent = "满意", VisitState = EVisitState.Visited, SeatEvaluate = null,VoiceEvaluate = null,OrgProcessingResults=4, OrgHandledAttitude = 4 , VisitType = EVisitType.SmsVisit, SortOrder = 2},
|
|
|
+ new () {Name = "一般的规则", AppScope = "ZiGong", ReplyRegular = "3", VisitContent = "一般", VisitState = EVisitState.Visited, SeatEvaluate = null, VoiceEvaluate = null,OrgProcessingResults= 4, OrgHandledAttitude = 4 , VisitType = EVisitType.SmsVisit, SortOrder = 3},
|
|
|
+ new () {Name = "不满意的规则", AppScope = "ZiGong", ReplyRegular = "4", VisitContent = "不满意", VisitState = EVisitState.SMSUnsatisfied, SeatEvaluate = null,VoiceEvaluate = null,OrgProcessingResults=2, OrgHandledAttitude = 2 , VisitType = null, SortOrder = 4},
|
|
|
+ new () {Name = "非常不满意的规则", AppScope = "ZiGong", ReplyRegular = "5", VisitContent = "不满意", VisitState = EVisitState.SMSUnsatisfied, SeatEvaluate = null, VoiceEvaluate = null,OrgProcessingResults=2, OrgHandledAttitude = 2, VisitType = null, SortOrder = 5},
|
|
|
+ new () {Name = "默认满意的规则", AppScope = "ZiGong", ReplyRegular = "默认满意", VisitContent = "超过48小时自动回访", VisitState = EVisitState.Visited, SeatEvaluate = null, VoiceEvaluate = null,OrgProcessingResults=0, OrgHandledAttitude = 0, VisitType = EVisitType.SmsVisit, SortOrder = 0},
|
|
|
+ new () {Name = "用户回答非1,2,3,4,5的匹配规则", AppScope = "ZiGong", ReplyRegular = "^(?!.*[12345]).*$", VisitContent = "默认满意", VisitState = EVisitState.Visited, SeatEvaluate = null, VoiceEvaluate = null,OrgProcessingResults=0, OrgHandledAttitude = 0, VisitType = EVisitType.SmsVisit, SortOrder = 6},
|
|
|
+ new () {Name = "对部门处理结果满意", AppScope = "YiBin", ReplyRegular = "1", VisitContent = "满意", VisitState = EVisitState.Visited, SeatEvaluate = null,VoiceEvaluate = null,OrgProcessingResults = 4 , OrgHandledAttitude = null, VisitType = EVisitType.SmsVisit, SortOrder = 1},
|
|
|
+ new () {Name = "默认满意的规则", AppScope = "YiBin", ReplyRegular = "默认满意", VisitContent = "超过48小时自动回访", VisitState = EVisitState.Visited, SeatEvaluate = null,VoiceEvaluate = null,OrgProcessingResults=0, OrgHandledAttitude = 0 , VisitType = EVisitType.SmsVisit, SortOrder = 0},
|
|
|
+ new () {Name = "对部门处理结果不满意的规则", AppScope = "YiBin", ReplyRegular = "2", VisitContent = "不满意", VisitState = EVisitState.SMSUnsatisfied, SeatEvaluate = null,VoiceEvaluate = null,OrgProcessingResults=2, OrgHandledAttitude = null , VisitType = null, SortOrder = 2},
|
|
|
+ new () {Name = "用户回复的非1和2的规则", AppScope = "YiBin", ReplyRegular = "^(?!.*[12]).*$", VisitContent = "不满意", VisitState = EVisitState.SMSUnsatisfied, SeatEvaluate = null,VoiceEvaluate = null,OrgProcessingResults= null, OrgHandledAttitude = null , VisitType = null, SortOrder = 3, IsReplyToOrgVisitContent = true},
|
|
|
];
|
|
|
|
|
|
foreach (var item in entities)
|