瀏覽代碼

新增行业积分

qinchaoyue 1 月之前
父節點
當前提交
363658809f

+ 1 - 1
src/Hotline.Api/Controllers/Snapshot/IndustryController.cs

@@ -67,7 +67,7 @@ public class IndustryController : BaseController
     /// <returns></returns>
     [HttpGet("{id}")]
     public async Task<IndustryDetailOutDto> GetIndustryDetailAsync(string id)
-        => await _industryApplication.GetIndustryDetailAsync(id);
+        => await _industryApplication.GetIndustryDetailAsync(id, HttpContext.RequestAborted);
 
     /// <summary>
     /// 获取行业集合

+ 1 - 1
src/Hotline.Application/Snapshot/IIndustryApplication.cs

@@ -28,7 +28,7 @@ public interface IIndustryApplication
     /// </summary>
     /// <param name="id"></param>
     /// <returns></returns>
-    Task<IndustryDetailOutDto> GetIndustryDetailAsync(string id);
+    Task<IndustryDetailOutDto> GetIndustryDetailAsync(string id, CancellationToken token);
 
     /// <summary>
     /// 修改行业

+ 3 - 2
src/Hotline.Application/Snapshot/IndustryApplication.cs

@@ -58,6 +58,7 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
     /// <exception cref="NotImplementedException"></exception>
     public async Task<string> AddIndustryAsync(AddIndustryDto dto, CancellationToken cancellationToken)
     {
+        dto.ValidateObject();
         if (dto.ApproveOrgId.NotNullOrEmpty() && dto.ApproveOrgName.IsNullOrEmpty())
         {
             await _systemOrganizeRepository.GetAsync(dto.ApproveOrgId, cancellationToken)
@@ -87,12 +88,12 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
         return query;
     }
 
-    public async Task<IndustryDetailOutDto> GetIndustryDetailAsync(string id)
+    public async Task<IndustryDetailOutDto> GetIndustryDetailAsync(string id, CancellationToken token)
     {
         var fileServiceUrl = _sysSetting.FileServerUrl;
         var fileDownloadApi = fileServiceUrl + _sysSetting.FileDownloadApi;
         var industry = await _industryRepository.GetAsync(id);
-        var files = await _fileRepository.GetByKeyAsync(id, CancellationToken.None);
+        var files = await _fileRepository.GetByKeyAsync(id, token);
         var outDto = industry.Adapt<IndustryDetailOutDto>();
         outDto.Files = files.Adapt<IList<IndustryFileDto>>();
         return outDto;

+ 1 - 1
src/Hotline.Application/Snapshot/Notifications/SnapshotHandler.cs

@@ -189,7 +189,7 @@ public class SnapshotStartWorkFlow : INotificationHandler<StartWorkflowNotify>
         try
         {
             if (_sysSetting.Snapshot == false && notification.Workflow.ModuleCode != WorkflowModuleConsts.OrderHandle) return;
-            await _snapshotPointsDomainService.AddPointsAsync(notification.Workflow.ExternalId, EPointsSource.Report, ERedPackAuditStatus.Agree);
+            await _snapshotPointsDomainService.AddPointsAsync(notification.Workflow.ExternalId, EPointsSource.Report, ERedPackAuditStatus.Agree, 0);
         }
         catch (Exception e)
         {

+ 1 - 1
src/Hotline.Application/Snapshot/RedPackApplication.cs

@@ -121,7 +121,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
             await _redPackRecordRepository.AddAsync(entity);
         }
         await _redPackAuditRepository.UpdateAsync(redPackAudit, token);
-        await _snapshotPointsDomainService.AddPointsAsync(order.Id, EPointsSource.Audit, status);
+        await _snapshotPointsDomainService.AddPointsAsync(order.Id, EPointsSource.Audit, status, dto.ExtraDeductedPoints);
         if (dto.IsSendSms)
         {
             var smsTemplate = await _snapshotSMSTemplateRepository.GetAsync(dto.SMSTemplateId);

+ 45 - 0
src/Hotline.Share/Dtos/Snapshot/IndustryDto.cs

@@ -168,6 +168,27 @@ public class IndustryOutDto
     /// 关怀页面Url
     /// </summary>
     public string? PageCareUrl { get; set; }
+
+    /// <summary>
+    /// 上报积分
+    /// </summary>
+    public int ReportPoints { get; set; }
+
+    /// <summary>
+    /// 审核同意积分
+    /// </summary>
+    public int ArgeePoints { get; set; }
+
+    /// <summary>
+    /// 审核不同意扣除积分
+    /// </summary>
+    public int RefusePoints { get; set; }
+
+    /// <summary>
+    /// 额外扣除积分
+    /// </summary>
+    public int ExtraDeductedPoints { get; set; }
+
 }
 
 /// <summary>
@@ -375,6 +396,30 @@ public class AddIndustryDto
     /// 附件集合(小程序上面可以下载的 doc 文件)
     /// </summary>
     public IList<IndustryFileDto> Files { get; set; }
+
+    /// <summary>
+    /// 上报积分
+    /// </summary>
+    [Required]
+    public int ReportPoints { get; set; }
+
+    /// <summary>
+    /// 审核同意积分
+    /// </summary>
+    [Required]
+    public int ArgeePoints { get; set; }
+
+    /// <summary>
+    /// 审核不同意扣除积分
+    /// </summary>
+    [Required]
+    public int RefusePoints { get; set; }
+
+    /// <summary>
+    /// 额外扣除积分
+    /// </summary>
+    [Required]
+    public int ExtraDeductedPoints { get; set; }
 }
 
 public class IndustryCaseItemOutDto : AddIndustryCaseDto

+ 1 - 1
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -274,7 +274,7 @@ namespace Hotline.FlowEngine.Workflows
 
             //publish
             await _publisher.PublishAsync(new StartWorkflowNotify(workflow, dto, startTrace),
-                PublishStrategy.ParallelWhenAll, cancellationToken);
+                PublishStrategy.SyncContinueOnException, cancellationToken);
 
             return (workflow, startStep);
         }

+ 1 - 1
src/Hotline/Snapshot/Contracts/ISnapshotPointsDomainService.cs

@@ -12,5 +12,5 @@ namespace Hotline.Snapshot.Contracts;
 /// </summary>
 public interface ISnapshotPointsDomainService
 {
-    Task AddPointsAsync(string orderId, EPointsSource source, ERedPackAuditStatus status);
+    Task AddPointsAsync(string orderId, EPointsSource source, ERedPackAuditStatus status, int? extraDeductedPoints);
 }

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

@@ -22,12 +22,8 @@ public class SnapshotPointsDomainService : ISnapshotPointsDomainService, IScopeD
         _pointsRecordRepository = snapshotPointsRecordRepository;
     }
 
-    public async Task AddPointsAsync(string orderId, EPointsSource source, ERedPackAuditStatus status)
+    public async Task AddPointsAsync(string orderId, EPointsSource source, ERedPackAuditStatus status, int? extraDeductedPoints)
     {
-        var ineustryId = await _orderSnapshotRepository.Queryable()
-            .Where(m => m.Id == orderId)
-            .Select(m => m.IndustryId)
-            .FirstAsync() ?? throw new UserFriendlyException($"{orderId} 工单不存在");
         var order = await _orderSnapshotRepository.Queryable()
             .LeftJoin<Industry>((snapshot, industry) => snapshot.IndustryId == industry.Id)
             .Where((snapshot, industry) => snapshot.Id == orderId)
@@ -40,9 +36,9 @@ public class SnapshotPointsDomainService : ISnapshotPointsDomainService, IScopeD
         if (source == EPointsSource.Report)
             point = order.ReportPoints.Value;
         if (source == EPointsSource.Audit && status == ERedPackAuditStatus.Agree)
-            point = order.ArgeePoints.Value;
+            point = order.ArgeePoints ?? 0;
         if (source == EPointsSource.Audit && status == ERedPackAuditStatus.Refuse)
-            point = order.RefusePoints.Value;
+            point = order.RefusePoints ?? 0 + extraDeductedPoints ?? 0;
         await _pointsRecordRepository.AddAsync(new SnapshotPointsRecord
         {
             OrderId = orderId,

+ 1 - 1
test/Hotline.Tests/Application/IndustryApplicationTest.cs

@@ -59,7 +59,7 @@ public class IndustryApplicationTest : TestBase
         industry.ApproveOrgId = orgs.First().Key;
         industry.ApproveOrgName = null;
         await _industryApplication.UpdateIndustryAsync(industry, CancellationToken.None);
-        var updateIndustry = await _industryApplication.GetIndustryDetailAsync(item.Id);
+        var updateIndustry = await _industryApplication.GetIndustryDetailAsync(item.Id, CancellationToken.None);
         updateIndustry.ForeachClassProperties(async (industry, property, name, value) =>
         {
             industry.GetType().GetProperty(name).GetValue(industry).ShouldBe(value);

+ 11 - 1
test/Hotline.Tests/Application/SnapshotApplicationTest.cs

@@ -435,6 +435,7 @@ public class SnapshotApplicationTest : TestBase
     [Fact]
     public async Task Industry_Test()
     {
+        SetZuoXi();
         var industry = new AddIndustryDto
         {
             Name = "测试行业",
@@ -455,12 +456,21 @@ public class SnapshotApplicationTest : TestBase
                     FileName ="测试文件" + DateTime.Now.ToShortDateString()  + ".doc",
                     AdditionId = DateTime.Now.ToLongDateString()
                 }
-            }
+            },
+            ArgeePoints = 3,
+            ExtraDeductedPoints = 2,
+            RefusePoints = 1,
+            ReportPoints = 4
         };
         var industryId = await _industryApplication.AddIndustryAsync(industry, CancellationToken.None);
         var pageDto = await _snapshotApplication.GetIndustryBaseAsync(industryId, CancellationToken.None);
+        var industryOut = await _industryApplication.GetIndustryDetailAsync(industryId, CancellationToken.None);
         try
         {
+            industryOut.ArgeePoints.ShouldBe(industry.ArgeePoints);
+            industryOut.ExtraDeductedPoints.ShouldBe(industry.ExtraDeductedPoints);
+            industryOut.RefusePoints.ShouldBe(industry.RefusePoints);
+            industryOut.ReportPoints.ShouldBe(industry.ReportPoints);
             pageDto.ShouldNotBeNull();
             pageDto.Files.ShouldNotBeNull();
             foreach (var file in pageDto.Files)