qinchaoyue hai 1 mes
pai
achega
4221283557
Modificáronse 40 ficheiros con 308 adicións e 39 borrados
  1. 1 1
      src/Hotline.Api/Controllers/OrderController.cs
  2. 2 2
      src/Hotline.Api/Controllers/Snapshot/BiSnapshotController.cs
  3. 1 1
      src/Hotline.Api/Controllers/Snapshot/IndustryController.cs
  4. 1 1
      src/Hotline.Api/Controllers/Snapshot/InviteCodeController.cs
  5. 40 0
      src/Hotline.Api/Controllers/Snapshot/PointsController.cs
  6. 2 2
      src/Hotline.Api/Controllers/Snapshot/RedPackController.cs
  7. 1 1
      src/Hotline.Api/Controllers/Snapshot/SnapshotBulletinController.cs
  8. 1 2
      src/Hotline.Api/Controllers/Snapshot/SnapshotController.cs
  9. 2 0
      src/Hotline.Api/Controllers/Snapshot/SnapshotOrderController.cs
  10. 2 1
      src/Hotline.Application/Snapshot/BiSnapshotApplication.cs
  11. 1 1
      src/Hotline.Application/Snapshot/Contracts/IBiSnapshotApplication.cs
  12. 1 1
      src/Hotline.Application/Snapshot/Contracts/IIndustryApplication.cs
  13. 1 1
      src/Hotline.Application/Snapshot/Contracts/IInviteCodeApplication.cs
  14. 1 1
      src/Hotline.Application/Snapshot/Contracts/IOrderSnapshotApplication.cs
  15. 15 0
      src/Hotline.Application/Snapshot/Contracts/IPointsRecordApplication.cs
  16. 1 1
      src/Hotline.Application/Snapshot/Contracts/IRedPackApplication.cs
  17. 1 1
      src/Hotline.Application/Snapshot/Contracts/ISnapshotApplication.cs
  18. 1 1
      src/Hotline.Application/Snapshot/Contracts/ISnapshotBulletinApplication.cs
  19. 1 0
      src/Hotline.Application/Snapshot/DefaultSnapshotApplication.cs
  20. 1 0
      src/Hotline.Application/Snapshot/IndustryApplication.cs
  21. 2 1
      src/Hotline.Application/Snapshot/InviteCodeApplication.cs
  22. 1 0
      src/Hotline.Application/Snapshot/Notifications/SnapshotHandler.cs
  23. 62 0
      src/Hotline.Application/Snapshot/PointsRecordApplication.cs
  24. 3 2
      src/Hotline.Application/Snapshot/RedPackApplication.cs
  25. 2 1
      src/Hotline.Application/Snapshot/SnapshotBulletinApplication.cs
  26. 1 0
      src/Hotline.Application/Snapshot/SnapshotOrderApplication.cs
  27. 1 0
      src/Hotline.Application/Snapshot/ZiGongSnapshotApplication.cs
  28. 87 0
      src/Hotline.Share/Dtos/Snapshot/PointsDto.cs
  29. 7 1
      src/Hotline.Share/Enums/Snapshot/EPointsSource.cs
  30. 6 0
      src/Hotline/Orders/Citizen.cs
  31. 0 7
      src/Hotline/Snapshot/OrderSnapshot.cs
  32. 3 1
      src/Hotline/Snapshot/Services/SnapshotPointsDomainService.cs
  33. 8 2
      src/Hotline/Snapshot/SnapshotPointsRecord.cs
  34. 1 1
      test/Hotline.Tests/Application/BiSnapshotApplicationTest.cs
  35. 1 1
      test/Hotline.Tests/Application/IndustryApplicationTest.cs
  36. 1 1
      test/Hotline.Tests/Application/InviteCodeApplicationTest.cs
  37. 1 1
      test/Hotline.Tests/Application/OrderSnapshotApplicationTest.cs
  38. 42 0
      test/Hotline.Tests/Application/PointsRecordApplicationTest.cs
  39. 1 1
      test/Hotline.Tests/Application/RedPackApplicationTest.cs
  40. 1 1
      test/Hotline.Tests/Application/SnapshotApplicationTest.cs

+ 1 - 1
src/Hotline.Api/Controllers/OrderController.cs

@@ -6,7 +6,7 @@ using Hotline.Application.ExportExcel;
 using Hotline.Application.FlowEngine;
 using Hotline.Application.OrderApp;
 using Hotline.Application.Quality;
-using Hotline.Application.Snapshot;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Application.Systems;
 using Hotline.Article;
 using Hotline.Authentications;

+ 2 - 2
src/Hotline.Api/Controllers/Snapshot/BiSnapshotController.cs

@@ -1,5 +1,4 @@
-using Hotline.Application.Snapshot;
-using Hotline.Share.Dtos;
+using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.Snapshot;
 using Microsoft.AspNetCore.Mvc;
 using Hotline.Repository.SqlSugar.Extensions;
@@ -21,6 +20,7 @@ using XF.Domain.Repository;
 using Hotline.Configurations;
 using Microsoft.Extensions.Options;
 using Hotline.Snapshot.IRepository;
+using Hotline.Application.Snapshot.Contracts;
 
 namespace Hotline.Api.Controllers.Snapshot;
 

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

@@ -1,5 +1,5 @@
 using Amazon.Runtime.Internal.Transform;
-using Hotline.Application.Snapshot;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Caching.Interfaces;
 using Hotline.Configurations;
 using Hotline.Repository.SqlSugar.Extensions;

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

@@ -1,4 +1,4 @@
-using Hotline.Application.Snapshot;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Repository.SqlSugar.Extensions;
 using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.Snapshot;

+ 40 - 0
src/Hotline.Api/Controllers/Snapshot/PointsController.cs

@@ -0,0 +1,40 @@
+using Hotline.Application.Snapshot.Contracts;
+using Hotline.Share.Dtos;
+using Hotline.Share.Dtos.Snapshot;
+using Microsoft.AspNetCore.Mvc;
+using System.ComponentModel;
+using Hotline.Repository.SqlSugar.Extensions;
+using Hotline.Share.Tools;
+
+namespace Hotline.Api.Controllers.Snapshot;
+
+
+/// <summary>
+/// 积分管理
+/// </summary>
+[Description("积分管理")]
+public class PointsController : BaseController
+{
+    private readonly IPointsRecordApplication _pointsRecordApplication;
+
+    public PointsController(IPointsRecordApplication pointsRecordApplication)
+    {
+        _pointsRecordApplication = pointsRecordApplication;
+    }
+
+    /// <summary>
+    /// 积分集合
+    /// </summary>
+    /// <returns></returns>
+    [HttpGet]
+    public async Task<PagedDto<PointsItemsOutDto>> GetPointsItemsAsync([FromQuery]PointsItemsInDto dto)
+        => (await _pointsRecordApplication.GetPointsItems(dto).ToPagedListAsync(dto)).ToPaged();
+
+    /// <summary>
+    /// 设置用户是安全卫士
+    /// </summary>
+    /// <returns></returns>
+    [HttpPut("securitymax")]
+    public async Task UpdateIsSecurityMaxAsync([FromBody] UpdateIsSecurityMaxAsync dto)
+        => await _pointsRecordApplication.UpdateIsSecurityMaxAsync(dto, HttpContext.RequestAborted);
+}

+ 2 - 2
src/Hotline.Api/Controllers/Snapshot/RedPackController.cs

@@ -1,5 +1,4 @@
-using Hotline.Application.Snapshot;
-using Hotline.Share.Dtos;
+using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.Snapshot;
 using Microsoft.AspNetCore.Mvc;
 using Hotline.Repository.SqlSugar.Extensions;
@@ -12,6 +11,7 @@ using Hotline.Orders;
 using XF.Domain.Exceptions;
 using Mapster;
 using Hotline.Snapshot.IRepository;
+using Hotline.Application.Snapshot.Contracts;
 
 namespace Hotline.Api.Controllers.Snapshot;
 

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

@@ -3,7 +3,6 @@ using Hotline.Share.Dtos.Article;
 using Microsoft.AspNetCore.Mvc;
 using Hotline.Repository.SqlSugar.Extensions;
 using Mapster;
-using Hotline.Application.Snapshot;
 using XF.Domain.Exceptions;
 using Hotline.Share.Enums.Article;
 using XF.Domain.Authentications;
@@ -15,6 +14,7 @@ using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Tools;
 using XF.Utility.EnumExtensions;
 using Hotline.Snapshot.IRepository;
+using Hotline.Application.Snapshot.Contracts;
 
 namespace Hotline.Api.Controllers.Snapshot;
 

+ 1 - 2
src/Hotline.Api/Controllers/Snapshot/SnapshotController.cs

@@ -1,7 +1,7 @@
 using AngleSharp.Dom;
 using Fw.Utility.UnifyResponse;
 using Hotline.Api.Filter;
-using Hotline.Application.Snapshot;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Caching.Interfaces;
 using Hotline.File;
 using Hotline.Orders;
@@ -118,7 +118,6 @@ public class SnapshotController : BaseController
         }
         var orderSnapshot = dto.Adapt<OrderSnapshot>();
         orderSnapshot.Id = order.Id;
-        orderSnapshot.SnapshotUserId = _sessionContext.UserId;
         orderSnapshot.IndustryId = dto.IndustryId;
         orderSnapshot.IndustryName = industry.Name;
         orderSnapshot.CompanyName = dto.CompanyName;

+ 2 - 0
src/Hotline.Api/Controllers/Snapshot/SnapshotOrderController.cs

@@ -1,5 +1,7 @@
 using Amazon.Runtime.Internal.Transform;
 using Hotline.Application.FlowEngine;
+using Hotline.Application.Orders;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Application.Snapshot;
 using Hotline.Caching.Interfaces;
 using Hotline.Caching.Services;

+ 2 - 1
src/Hotline.Application/Snapshot/BiSnapshotApplication.cs

@@ -1,4 +1,5 @@
-using Hotline.Configurations;
+using Hotline.Application.Snapshot.Contracts;
+using Hotline.Configurations;
 using Hotline.Orders;
 using Hotline.Settings;
 using Hotline.Settings.Hotspots;

+ 1 - 1
src/Hotline.Application/Snapshot/IBiSnapshotApplication.cs → src/Hotline.Application/Snapshot/Contracts/IBiSnapshotApplication.cs

@@ -8,7 +8,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace Hotline.Application.Snapshot;
+namespace Hotline.Application.Snapshot.Contracts;
 public interface IBiSnapshotApplication
 {
     /// <summary>

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

@@ -7,7 +7,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace Hotline.Application.Snapshot;
+namespace Hotline.Application.Snapshot.Contracts;
 public interface IIndustryApplication
 {
     /// <summary>

+ 1 - 1
src/Hotline.Application/Snapshot/IInviteCodeApplication.cs → src/Hotline.Application/Snapshot/Contracts/IInviteCodeApplication.cs

@@ -8,7 +8,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace Hotline.Application.Snapshot;
+namespace Hotline.Application.Snapshot.Contracts;
 public interface IInviteCodeApplication
 {
     Task<string> AddInviteCodeAsync(AddInviteCodeInDto dto);

+ 1 - 1
src/Hotline.Application/Snapshot/IOrderSnapshotApplication.cs → src/Hotline.Application/Snapshot/Contracts/IOrderSnapshotApplication.cs

@@ -11,7 +11,7 @@ using System.Text;
 using System.Threading.Tasks;
 using Hotline.Share.Dtos.FlowEngine.Workflow;
 
-namespace Hotline.Application.Snapshot;
+namespace Hotline.Application.Snapshot.Contracts;
 public interface IOrderSnapshotApplication
 {
 

+ 15 - 0
src/Hotline.Application/Snapshot/Contracts/IPointsRecordApplication.cs

@@ -0,0 +1,15 @@
+using Hotline.Share.Dtos.Snapshot;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Application.Snapshot.Contracts;
+public interface IPointsRecordApplication
+{
+    ISugarQueryable<PointsItemsOutDto> GetPointsItems(PointsItemsInDto dto);
+    Task UpdateIsSecurityMaxAsync(UpdateIsSecurityMaxAsync dto, CancellationToken token);
+}
+

+ 1 - 1
src/Hotline.Application/Snapshot/IRedPackApplication.cs → src/Hotline.Application/Snapshot/Contracts/IRedPackApplication.cs

@@ -7,7 +7,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace Hotline.Application.Snapshot;
+namespace Hotline.Application.Snapshot.Contracts;
 public interface IRedPackApplication
 {
     /// <summary>

+ 1 - 1
src/Hotline.Application/Snapshot/ISnapshotApplication.cs → src/Hotline.Application/Snapshot/Contracts/ISnapshotApplication.cs

@@ -3,7 +3,7 @@ using Hotline.Share.Dtos.Article;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Snapshot;
 
-namespace Hotline.Application.Snapshot;
+namespace Hotline.Application.Snapshot.Contracts;
 public interface ISnapshotApplication
 {
     /// <summary>

+ 1 - 1
src/Hotline.Application/Snapshot/ISnapshotBulletinApplication.cs → src/Hotline.Application/Snapshot/Contracts/ISnapshotBulletinApplication.cs

@@ -6,7 +6,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace Hotline.Application.Snapshot;
+namespace Hotline.Application.Snapshot.Contracts;
 public interface ISnapshotBulletinApplication
 {
 

+ 1 - 0
src/Hotline.Application/Snapshot/DefaultSnapshotApplication.cs

@@ -1,4 +1,5 @@
 using DotNetCore.CAP;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Caching.Interfaces;
 using Hotline.DI;
 using Hotline.EventBus;

+ 1 - 0
src/Hotline.Application/Snapshot/IndustryApplication.cs

@@ -1,5 +1,6 @@
 using DocumentFormat.OpenXml.Office2010.Excel;
 using DocumentFormat.OpenXml.Wordprocessing;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Caching.Interfaces;
 using Hotline.File;
 using Hotline.Repository.SqlSugar.Extensions;

+ 2 - 1
src/Hotline.Application/Snapshot/InviteCodeApplication.cs

@@ -1,4 +1,5 @@
-using Hotline.Share.Dtos.Snapshot;
+using Hotline.Application.Snapshot.Contracts;
+using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Tools;
 using Hotline.Snapshot;
 using Hotline.Snapshot.IRepository;

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

@@ -31,6 +31,7 @@ using Hotline.Snapshot.Contracts;
 using Hotline.FlowEngine.WorkflowModules;
 using XF.Domain.Entities;
 using Hotline.Share.Enums.Snapshot;
+using Hotline.Application.Snapshot.Contracts;
 
 namespace Hotline.Application.Snapshot.Notifications;
 

+ 62 - 0
src/Hotline.Application/Snapshot/PointsRecordApplication.cs

@@ -0,0 +1,62 @@
+using Hotline.Application.Snapshot.Contracts;
+using Hotline.Orders;
+using Hotline.Share.Dtos.Snapshot;
+using Hotline.Share.Enums.CallCenter;
+using Hotline.Share.Enums.Snapshot;
+using Hotline.Share.Tools;
+using Hotline.Snapshot.IRepository;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using XF.Domain.Dependency;
+
+namespace Hotline.Application.Snapshot;
+
+public class PointsRecordApplication : IPointsRecordApplication, IScopeDependency
+{
+    private readonly ISnapshotPointsRecordRepository _snapshotPointsRecordRepository;
+    private readonly ICitizenRepository _citizenRepository;
+
+    public PointsRecordApplication(ISnapshotPointsRecordRepository snapshotPointsRecordRepository, ICitizenRepository citizenRepository)
+    {
+        _snapshotPointsRecordRepository = snapshotPointsRecordRepository;
+        _citizenRepository = citizenRepository;
+    }
+
+    public ISugarQueryable<PointsItemsOutDto> GetPointsItems(PointsItemsInDto dto)
+    {
+        var query = _snapshotPointsRecordRepository.Queryable()
+            .LeftJoin<Citizen>((points, citizen) => points.UserId == citizen.Id)
+            .WhereIF(dto.PhoneNumber.NotNullOrEmpty(), (points, citizen) => dto.PhoneNumber == citizen.PhoneNumber)
+            .Where((points, citizen) => points.CreationTime >= dto.StartTime && points.CreationTime <= dto.EndTime)
+            .GroupBy((points, citizen) => new { points.UserId, citizen.IsSecurityMax, citizen.Name, citizen.PhoneNumber })
+            .Select((points, citizen) => new PointsItemsOutDto
+            {
+                IsSecurityMax = citizen.IsSecurityMax ?? false,
+                Rank = SqlFunc.MappingColumn<int>("DENSE_RANK() OVER (ORDER BY SUM(CASE WHEN \"points\".\"Direction\" = 1 THEN \"points\".\"Points\" ELSE 0 END) DESC)"),
+                OutTotalPoint = SqlFunc.AggregateSum(SqlFunc.IIF(points.Direction == EPointsDirection.Out, points.Points, 0)),
+                OutPoints = SqlFunc.AggregateSum(SqlFunc.IIF(points.Direction == EPointsDirection.Out && points.Source == EPointsSource.Audit, points.Points, 0)),
+                TotalPoints = SqlFunc.AggregateSum(points.Points),
+                InTotalPoint = SqlFunc.AggregateSum(SqlFunc.IIF(points.Direction == EPointsDirection.In, points.Points, 0)),
+                UserName = citizen.Name,
+                PhoneNumber = citizen.PhoneNumber
+            })
+            .OrderByPropertyNameIF(dto.SortField.NotNullOrEmpty() && dto.SortRule == 0, dto.SortField, OrderByType.Desc)
+            .OrderByPropertyNameIF(dto.SortField.NotNullOrEmpty() && dto.SortRule == 1, dto.SortField, OrderByType.Asc);
+#if DEBUG
+        var sql = query.ToSqlString();
+#endif
+        return query;
+    }
+
+    public async Task UpdateIsSecurityMaxAsync(UpdateIsSecurityMaxAsync dto, CancellationToken token)
+    {
+        await _citizenRepository.Updateable()
+            .SetColumns(citizen => citizen.IsSecurityMax, dto.IsSecurityMax)
+            .Where(citizen => citizen.Id == dto.UserId)
+            .ExecuteCommandAsync(token);
+    }
+}

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

@@ -1,4 +1,5 @@
 using DocumentFormat.OpenXml.Office2010.Excel;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Caching.Interfaces;
 using Hotline.Orders;
 using Hotline.Push.FWMessage;
@@ -105,11 +106,11 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
         var order = await _orderRepository.Queryable()
             .LeftJoin<OrderSnapshot>((order, snapshot) => order.Id == snapshot.Id)
             .Where((order, snapshot) => order.Id == redPackAudit.OrderId)
-            .Select((order, snapshot) => new { order.Id, order.No, order.FromName, order.FromPhone, snapshot.SnapshotUserId })
+            .Select((order, snapshot) => new { order.Id, order.No, order.FromName, order.FromPhone, snapshot.CreatorId })
             .FirstAsync(token) ?? throw UserFriendlyException.SameMessage("工单不存在");
         if (status == ERedPackAuditStatus.Agree)
         {
-            var third = await _thirdAccountRepository.GetByExternalIdAsync(order.SnapshotUserId, token);
+            var third = await _thirdAccountRepository.GetByExternalIdAsync(order.CreatorId, token);
             var entity = new RedPackRecord
             {
                 OrderId = redPackAudit.OrderId,

+ 2 - 1
src/Hotline.Application/Snapshot/SnapshotBulletinApplication.cs

@@ -1,4 +1,5 @@
-using Hotline.Caching.Interfaces;
+using Hotline.Application.Snapshot.Contracts;
+using Hotline.Caching.Interfaces;
 using Hotline.Settings;
 using Hotline.Share.Attributes;
 using Hotline.Share.Dtos.Snapshot;

+ 1 - 0
src/Hotline.Application/Snapshot/SnapshotOrderApplication.cs

@@ -31,6 +31,7 @@ using XF.Domain.Dependency;
 using XF.Domain.Exceptions;
 using XF.Utility.EnumExtensions;
 using Hotline.Snapshot.IRepository;
+using Hotline.Application.Snapshot.Contracts;
 
 namespace Hotline.Application.Snapshot;
 public class SnapshotOrderApplication : IOrderSnapshotApplication, IScopeDependency

+ 1 - 0
src/Hotline.Application/Snapshot/ZiGongSnapshotApplication.cs

@@ -1,4 +1,5 @@
 using DotNetCore.CAP;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Caching.Interfaces;
 using Hotline.DI;
 using Hotline.EventBus;

+ 87 - 0
src/Hotline.Share/Dtos/Snapshot/PointsDto.cs

@@ -0,0 +1,87 @@
+using Hotline.Share.Requests;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Text.Json.Serialization;
+using System.Threading.Tasks;
+
+namespace Hotline.Share.Dtos.Snapshot;
+
+public class PointsDto
+{
+}
+
+public class UpdateIsSecurityMaxAsync
+{
+    /// <summary>
+    /// 用户Id
+    /// </summary>
+    [Required]
+    public string UserId { get; set; }
+
+    /// <summary>
+    /// 是否安全卫士
+    /// </summary>
+    [Required]
+    public bool IsSecurityMax { get; set; }
+}
+
+public record PointsItemsInDto : PagedKeywordRequest
+{
+    /// <summary>
+    /// 联系方式
+    /// </summary>
+    public string? PhoneNumber { get; set; }
+}
+
+public class PointsItemsOutDto
+{
+    /// <summary>
+    /// 联系方式
+    /// </summary>
+    public string PhoneNumber { get; set; }
+
+    /// <summary>
+    /// 姓名
+    /// </summary>
+    public string UserName { get; set; }
+
+    /// <summary>
+    /// 总积分
+    /// </summary>
+    public int TotalPoints { get; set; }
+
+    /// <summary>
+    /// 已兑换积分
+    /// </summary>
+    public int OutPoints { get; set; }
+
+    /// <summary>
+    /// 当前可用积分
+    /// </summary>
+    public int ValidPoints => TotalPoints - OutPoints;
+
+    /// <summary>
+    /// 已使用积分
+    /// </summary>
+    [JsonIgnore]
+    [Newtonsoft.Json.JsonIgnore]
+    public int OutTotalPoint { get; set; }
+
+    /// <summary>
+    /// 排名
+    /// </summary>
+    public int Rank { get; set; }
+
+    /// <summary>
+    /// 是否安全卫士
+    /// </summary>
+    public bool IsSecurityMax { get; set; }
+
+    [JsonIgnore]
+    [Newtonsoft.Json.JsonIgnore]
+    public int InTotalPoint { get; set; }
+}
+

+ 7 - 1
src/Hotline.Share/Enums/Snapshot/EPointsSource.cs

@@ -19,5 +19,11 @@ public enum EPointsSource
     /// 审核积分
     /// </summary>
     [Description("审核积分")]
-    Audit = 1
+    Audit = 1,
+
+    /// <summary>
+    /// 积分兑换
+    /// </summary>
+    [Description("积分兑换")]
+    Exchange = 3,
 }

+ 6 - 0
src/Hotline/Orders/Citizen.cs

@@ -110,6 +110,12 @@ namespace Hotline.Orders
         /// </summary>
         [SugarColumn(ColumnDescription = "用户类型")]
         public EReadPackUserType? CitizenType { get; set; }
+
+		/// <summary>
+		/// 是否安全卫士
+		/// </summary>
+		[SugarColumn(ColumnDescription = "是否安全卫士")]
+        public bool? IsSecurityMax { get; set; }
         #endregion
 
     }

+ 0 - 7
src/Hotline/Snapshot/OrderSnapshot.cs

@@ -14,13 +14,6 @@ namespace Hotline.Snapshot;
 [Description("工单表扩展")]
 public class OrderSnapshot : CreationSoftDeleteEntity
 {
-    /// <summary>
-    /// 上报用户的Id
-    /// <inheritdoc cref="SnapshotUserInfo"/>
-    /// </summary>
-    [SugarColumn(ColumnDescription = "上报用户的Id")]
-    public string? SnapshotUserId { get; set; }
-
     /// <summary>
     /// 行业Id
     /// <inheritdoc cref="Industry"/> 表的Id

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

@@ -27,7 +27,8 @@ public class SnapshotPointsDomainService : ISnapshotPointsDomainService, IScopeD
         var order = await _orderSnapshotRepository.Queryable()
             .LeftJoin<Industry>((snapshot, industry) => snapshot.IndustryId == industry.Id)
             .Where((snapshot, industry) => snapshot.Id == orderId)
-            .Select((snapshot, industry) => new { snapshot.Id, industry.ReportPoints , industry.ArgeePoints , industry.RefusePoints,  industry.Name})
+            .Select((snapshot, industry) => new { snapshot.Id, industry.ReportPoints , industry.ArgeePoints , industry.RefusePoints,  industry.Name,
+                snapshot.CreatorId})
             .FirstAsync() ?? throw new UserFriendlyException($"{orderId} 工单不存在");
         if (order.ReportPoints.HasValue == false)
             throw new UserFriendlyException($"{order.Name} 行业未配置积分");
@@ -41,6 +42,7 @@ public class SnapshotPointsDomainService : ISnapshotPointsDomainService, IScopeD
             point = order.RefusePoints ?? 0 + extraDeductedPoints ?? 0;
         await _pointsRecordRepository.AddAsync(new SnapshotPointsRecord
         {
+            UserId = order.CreatorId,
             OrderId = orderId,
             Points = order.ReportPoints.Value,
             Source = source

+ 8 - 2
src/Hotline/Snapshot/SnapshotPointsRecord.cs

@@ -16,10 +16,15 @@ namespace Hotline.Snapshot;
 [Description("积分记录")]
 public class SnapshotPointsRecord : CreationEntity
 {
+    /// <summary>
+    /// 用户Id
+    /// </summary>
+    public string UserId { get; set; }
+
     /// <summary>
     /// 方向
     /// </summary>
-    public EPointsDirection direction { get; set; }
+    public EPointsDirection Direction { get; set; }
 
     /// <summary>
     /// 积分来源
@@ -30,5 +35,6 @@ public class SnapshotPointsRecord : CreationEntity
     /// 积分
     /// </summary>
     public int Points { get; set; }
-    public string OrderId { get; internal set; }
+
+    public string OrderId { get; set; }
 }

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

@@ -1,5 +1,5 @@
 using Hotline.Api.Controllers;
-using Hotline.Application.Snapshot;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Identity.Accounts;
 using Hotline.Identity.Roles;
 using Hotline.Settings;

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

@@ -1,6 +1,5 @@
 using AutoFixture;
 using Hotline.Api.Controllers;
-using Hotline.Application.Snapshot;
 using Hotline.Identity.Accounts;
 using Hotline.Identity.Roles;
 using Hotline.Settings;
@@ -18,6 +17,7 @@ using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.ThirdAccountDomainServices;
 using Hotline.Repository.SqlSugar.Extensions;
 using Hotline.Snapshot.IRepository;
+using Hotline.Application.Snapshot.Contracts;
 
 namespace Hotline.Tests.Application;
 public class IndustryApplicationTest : TestBase

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

@@ -1,5 +1,5 @@
 using Hotline.Api.Controllers;
-using Hotline.Application.Snapshot;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Identity.Accounts;
 using Hotline.Identity.Roles;
 using Hotline.Orders;

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

@@ -1,5 +1,5 @@
 using Hotline.Api.Controllers;
-using Hotline.Application.Snapshot;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Caching.Interfaces;
 using Hotline.Identity.Accounts;
 using Hotline.Identity.Roles;

+ 42 - 0
test/Hotline.Tests/Application/PointsRecordApplicationTest.cs

@@ -0,0 +1,42 @@
+using Hotline.Api.Controllers;
+using Hotline.Application.Snapshot.Contracts;
+using Hotline.Identity.Accounts;
+using Hotline.Identity.Roles;
+using Hotline.Settings;
+using Hotline.Share.Dtos.Snapshot;
+using Hotline.ThirdAccountDomainServices;
+using Hotline.ThirdAccountDomainServices.Interfaces;
+using Hotline.Users;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.DependencyInjection;
+using Shouldly;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using XF.Domain.Cache;
+using XF.Domain.Repository;
+
+namespace Hotline.Tests.Application;
+
+public class PointsRecordApplicationTest : TestBase
+{
+    private readonly IPointsRecordApplication _pointsRecordApplication;
+    public PointsRecordApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, ITypedCache<SystemSetting> cacheSettingData, ThirdAccounSupplierFactory thirdAccountDomainFactory, IPointsRecordApplication pointsRecordApplication) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
+    {
+        _pointsRecordApplication = pointsRecordApplication;
+    }
+
+    [Fact]
+    public async Task GetPointsItems_Test()
+    {
+        var inDto = new PointsItemsInDto
+        {
+            StartTime = DateTime.Now.AddDays(-1),
+            EndTime = DateTime.Now
+        };
+        var items = await _pointsRecordApplication.GetPointsItems(inDto).ToListAsync();
+        items.ShouldNotBeNull();
+    }
+}

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

@@ -1,5 +1,5 @@
 using Hotline.Api.Controllers;
-using Hotline.Application.Snapshot;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Caching.Interfaces;
 using Hotline.Identity.Accounts;
 using Hotline.Identity.Roles;

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

@@ -1,7 +1,7 @@
 using AutoFixture;
 using Hotline.Api.Controllers;
 using Hotline.Application.Identity;
-using Hotline.Application.Snapshot;
+using Hotline.Application.Snapshot.Contracts;
 using Hotline.Caching.Interfaces;
 using Hotline.File;
 using Hotline.Identity.Accounts;