|
@@ -35,6 +35,8 @@ using Hotline.Quality.Notifications;
|
|
using XF.Utility.EnumExtensions;
|
|
using XF.Utility.EnumExtensions;
|
|
using Hotline.ThirdAccountDomainServices.Interfaces;
|
|
using Hotline.ThirdAccountDomainServices.Interfaces;
|
|
using Hotline.Snapshot.IRepository;
|
|
using Hotline.Snapshot.IRepository;
|
|
|
|
+using Hotline.Share.Enums.CallCenter;
|
|
|
|
+using Hotline.Repository.SqlSugar.Snapshot;
|
|
|
|
|
|
namespace Hotline.Application.Snapshot;
|
|
namespace Hotline.Application.Snapshot;
|
|
|
|
|
|
@@ -78,8 +80,9 @@ public abstract class SnapshotApplicationBase
|
|
private readonly IInviteCodeRecordRepository _inviteCodeRecordRepository;
|
|
private readonly IInviteCodeRecordRepository _inviteCodeRecordRepository;
|
|
private readonly IInviteCodeRepository _inviteCodeRepository;
|
|
private readonly IInviteCodeRepository _inviteCodeRepository;
|
|
private readonly ICitizenRepository _citizenRepository;
|
|
private readonly ICitizenRepository _citizenRepository;
|
|
|
|
+ private readonly ISnapshotPointsRecordRepository _pointsRecordRepository;
|
|
|
|
|
|
- public SnapshotApplicationBase(IThirdIdentiyService thirdLoginService, IIndustryRepository industryRepository, ISnapshotBulletinRepository bulletinRepository, ISessionContext sessionContext, IRepository<RedPackRecord> redPackRecordRepository, IRepository<Order> orderRepository, IThirdAccountRepository thirdAccountRepository, IOrderSnapshotRepository orderSnapshotRepository, ISystemSettingCacheManager systemSettingCacheManager, ISystemAreaDomainService systemAreaDomainService, IFileRepository fileRepository, ISystemDicDataCacheManager systemDicDataCacheManager, ISnapshotOrderPublishRepository snapshotOrderPublishRepository, IRepository<WorkflowTrace> workflowTraceRepository, IPractitionerRepository practitionerRepository, IRepository<SystemArea> systemAreaRepository, IVolunteerRepository volunteerRepository, IVolunteerReportRepository volunteerReportRepository, ISystemLogRepository systemLog, IGuiderSystemService guiderSystemService, ICapPublisher capPublisher, Publisher publisher, IFileDomainService fileDomainService, ICommunityInfoRepository communityInfoRepository, IRedPackAuditRepository redPackAuditRepository, IOrderVisitRepository orderVisitRepository, IOrderVisitDetailRepository orderVisitDetailRepository, IRedPackGuiderAuditRepository redPackGuiderAuditRepository, IInviteCodeRecordRepository inviteCodeRecordRepository, IInviteCodeRepository inviteCodeRepository, ICitizenRepository citizenRepository)
|
|
|
|
|
|
+ public SnapshotApplicationBase(IThirdIdentiyService thirdLoginService, IIndustryRepository industryRepository, ISnapshotBulletinRepository bulletinRepository, ISessionContext sessionContext, IRepository<RedPackRecord> redPackRecordRepository, IRepository<Order> orderRepository, IThirdAccountRepository thirdAccountRepository, IOrderSnapshotRepository orderSnapshotRepository, ISystemSettingCacheManager systemSettingCacheManager, ISystemAreaDomainService systemAreaDomainService, IFileRepository fileRepository, ISystemDicDataCacheManager systemDicDataCacheManager, ISnapshotOrderPublishRepository snapshotOrderPublishRepository, IRepository<WorkflowTrace> workflowTraceRepository, IPractitionerRepository practitionerRepository, IRepository<SystemArea> systemAreaRepository, IVolunteerRepository volunteerRepository, IVolunteerReportRepository volunteerReportRepository, ISystemLogRepository systemLog, IGuiderSystemService guiderSystemService, ICapPublisher capPublisher, Publisher publisher, IFileDomainService fileDomainService, ICommunityInfoRepository communityInfoRepository, IRedPackAuditRepository redPackAuditRepository, IOrderVisitRepository orderVisitRepository, IOrderVisitDetailRepository orderVisitDetailRepository, IRedPackGuiderAuditRepository redPackGuiderAuditRepository, IInviteCodeRecordRepository inviteCodeRecordRepository, IInviteCodeRepository inviteCodeRepository, ICitizenRepository citizenRepository, ISnapshotPointsRecordRepository snapshotPointsRecordRepository)
|
|
{
|
|
{
|
|
_thirdLoginService = thirdLoginService;
|
|
_thirdLoginService = thirdLoginService;
|
|
_industryRepository = industryRepository;
|
|
_industryRepository = industryRepository;
|
|
@@ -112,6 +115,7 @@ public abstract class SnapshotApplicationBase
|
|
_inviteCodeRecordRepository = inviteCodeRecordRepository;
|
|
_inviteCodeRecordRepository = inviteCodeRecordRepository;
|
|
_inviteCodeRepository = inviteCodeRepository;
|
|
_inviteCodeRepository = inviteCodeRepository;
|
|
_citizenRepository = citizenRepository;
|
|
_citizenRepository = citizenRepository;
|
|
|
|
+ _pointsRecordRepository = snapshotPointsRecordRepository;
|
|
}
|
|
}
|
|
|
|
|
|
#region 小程序
|
|
#region 小程序
|
|
@@ -204,10 +208,10 @@ public abstract class SnapshotApplicationBase
|
|
if (indurstry.IndustryType == EIndustryType.Declare)
|
|
if (indurstry.IndustryType == EIndustryType.Declare)
|
|
{
|
|
{
|
|
outDto.AreaTree = (await _systemAreaDomainService.GetAreaTree(parentId: "510300")).Adapt<List<SystemAreaOutDto>>();
|
|
outDto.AreaTree = (await _systemAreaDomainService.GetAreaTree(parentId: "510300")).Adapt<List<SystemAreaOutDto>>();
|
|
- outDto.AreaTree.ToList().ForEach(m =>
|
|
|
|
|
|
+ outDto.AreaTree.ToList().ForEach(m =>
|
|
{
|
|
{
|
|
if (m.Children.IsNullOrEmpty())
|
|
if (m.Children.IsNullOrEmpty())
|
|
- m.Children = new List<SystemAreaOutDto>() { new SystemAreaOutDto { Id = "0", AreaName = "无"} };
|
|
|
|
|
|
+ m.Children = new List<SystemAreaOutDto>() { new SystemAreaOutDto { Id = "0", AreaName = "无" } };
|
|
});
|
|
});
|
|
outDto.Files = (await _fileRepository.GetByKeyAsync(indurstry.Id, requestAborted)).Adapt<List<IndustryFileDto>>();
|
|
outDto.Files = (await _fileRepository.GetByKeyAsync(indurstry.Id, requestAborted)).Adapt<List<IndustryFileDto>>();
|
|
outDto.Files.ToList().ForEach(m => m.Url = fileDownloadApi + m.AdditionId);
|
|
outDto.Files.ToList().ForEach(m => m.Url = fileDownloadApi + m.AdditionId);
|
|
@@ -349,6 +353,35 @@ public abstract class SnapshotApplicationBase
|
|
return items;
|
|
return items;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 积分详情集合
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public async Task<IList<PointItemsOutDto>> GetPointItemsAsync(PointItemsInDto dto, CancellationToken token)
|
|
|
|
+ {
|
|
|
|
+ var items = await _pointsRecordRepository.Queryable()
|
|
|
|
+ .Where(m => m.UserId == _sessionContext.UserId && dto.Direction == m.Direction)
|
|
|
|
+ .Select(m => new PointItemsOutDto(), true)
|
|
|
|
+ .OrderByDescending(m => m.CreationTime)
|
|
|
|
+ .ToFixedListAsync(dto, token);
|
|
|
|
+ return items;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 积分总计
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <param name="requestAborted"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public async Task<int> GetPointsTotalAsync(PointItemsInDto dto, CancellationToken token)
|
|
|
|
+ {
|
|
|
|
+ return await _pointsRecordRepository.Queryable()
|
|
|
|
+ .Where(m => m.UserId == _sessionContext.UserId && dto.Direction == m.Direction)
|
|
|
|
+ .SumAsync(m => m.Points);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 获取工单详情
|
|
/// 获取工单详情
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -409,7 +442,7 @@ public abstract class SnapshotApplicationBase
|
|
/// <param name="id"></param>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public async Task<IList<OrderVisitItemsOutDto>> GetOrderVisitDetailAsync(string id)
|
|
public async Task<IList<OrderVisitItemsOutDto>> GetOrderVisitDetailAsync(string id)
|
|
- {
|
|
|
|
|
|
+ {
|
|
var orderVisitId = await _orderVisitRepository.Queryable()
|
|
var orderVisitId = await _orderVisitRepository.Queryable()
|
|
.Where(m => m.OrderId == id)
|
|
.Where(m => m.OrderId == id)
|
|
.Select(m => m.Id)
|
|
.Select(m => m.Id)
|
|
@@ -427,7 +460,7 @@ public abstract class SnapshotApplicationBase
|
|
}
|
|
}
|
|
var org = orderVisitDetail.Where(m => m.VisitTarget == EVisitTarget.Org).First();
|
|
var org = orderVisitDetail.Where(m => m.VisitTarget == EVisitTarget.Org).First();
|
|
if (org != null)
|
|
if (org != null)
|
|
- {
|
|
|
|
|
|
+ {
|
|
if (org.OrgProcessingResults != null) item.OrgProcessingResults = org.OrgProcessingResults.Value;
|
|
if (org.OrgProcessingResults != null) item.OrgProcessingResults = org.OrgProcessingResults.Value;
|
|
if (org.OrgHandledAttitude != null) item.OrgHandledAttitude = org.OrgHandledAttitude.Value;
|
|
if (org.OrgHandledAttitude != null) item.OrgHandledAttitude = org.OrgHandledAttitude.Value;
|
|
}
|
|
}
|
|
@@ -526,7 +559,7 @@ public abstract class SnapshotApplicationBase
|
|
{
|
|
{
|
|
dto.ValidateObject();
|
|
dto.ValidateObject();
|
|
if (int.TryParse(dto.InvitationCode, out var invitationCode) == false)
|
|
if (int.TryParse(dto.InvitationCode, out var invitationCode) == false)
|
|
- {
|
|
|
|
|
|
+ {
|
|
throw new UserFriendlyException(200, "邀请码格式错误");
|
|
throw new UserFriendlyException(200, "邀请码格式错误");
|
|
}
|
|
}
|
|
var userInfo = await _citizenRepository.GetAsync(_sessionContext.UserId)
|
|
var userInfo = await _citizenRepository.GetAsync(_sessionContext.UserId)
|
|
@@ -833,7 +866,7 @@ public abstract class SnapshotApplicationBase
|
|
{
|
|
{
|
|
var order = await _orderRepository.Queryable()
|
|
var order = await _orderRepository.Queryable()
|
|
.Where(m => m.Id == orderId)
|
|
.Where(m => m.Id == orderId)
|
|
- .Select(m => new { m.Id, m.Status, m.No , m.FromPhone})
|
|
|
|
|
|
+ .Select(m => new { m.Id, m.Status, m.No, m.FromPhone })
|
|
.FirstAsync(cancellationToken) ?? throw new UserFriendlyException($"{orderId} 工单不存在");
|
|
.FirstAsync(cancellationToken) ?? throw new UserFriendlyException($"{orderId} 工单不存在");
|
|
var snapshot = await _orderSnapshotRepository.GetAsync(orderId) ?? throw new UserFriendlyException("工单不存在");
|
|
var snapshot = await _orderSnapshotRepository.GetAsync(orderId) ?? throw new UserFriendlyException("工单不存在");
|
|
if (order.Status != EOrderStatus.Filed) return $"{order.No} 工单状态非 {EOrderStatus.Filed} 不处理;";
|
|
if (order.Status != EOrderStatus.Filed) return $"{order.No} 工单状态非 {EOrderStatus.Filed} 不处理;";
|
|
@@ -901,4 +934,55 @@ public abstract class SnapshotApplicationBase
|
|
await _bulletinRepository.UpdateAsync(bulletin);
|
|
await _bulletinRepository.UpdateAsync(bulletin);
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
+
|
|
|
|
+ #region 积分
|
|
|
|
+ public async Task<PointsRankOutDto> GetPointsRankAsync()
|
|
|
|
+ {
|
|
|
|
+ var outDto = new PointsRankOutDto();
|
|
|
|
+ var record = await _pointsRecordRepository.Queryable()
|
|
|
|
+ .Where(m => m.UserId == _sessionContext.UserId)
|
|
|
|
+ .Select(m => new
|
|
|
|
+ {
|
|
|
|
+ Total = SqlFunc.AggregateSum(m.Points),
|
|
|
|
+ Out = SqlFunc.AggregateSum(SqlFunc.IIF(m.Direction == EPointsDirection.Out, m.Points, 0))
|
|
|
|
+ }).FirstAsync();
|
|
|
|
+ outDto.ValidPoints = record.Total - record.Out;
|
|
|
|
+ var startTime = new DateTime(DateTime.Now.Year, 1, 1, 0, 0, 0);
|
|
|
|
+ var endTime = new DateTime(DateTime.Now.Year, 12, 31, 23, 59, 59);
|
|
|
|
+ var query = _pointsRecordRepository.Queryable()
|
|
|
|
+ .LeftJoin<Citizen>((points, citizen) => points.UserId == citizen.Id)
|
|
|
|
+ .Where((points, citizen) => points.CreationTime >= startTime && points.CreationTime <= endTime)
|
|
|
|
+ .GroupBy((points, citizen) => new { citizen.Id, points.UserId, citizen.IsSecurityMax, citizen.Name, citizen.PhoneNumber })
|
|
|
|
+ .Select((points, citizen) => new PointsRankUserDto
|
|
|
|
+ {
|
|
|
|
+ IsSecurityMax = citizen.IsSecurityMax ?? false,
|
|
|
|
+ Rank = SqlFunc.MappingColumn<int>($@"
|
|
|
|
+ CASE
|
|
|
|
+ WHEN citizen.""Id"" = '{_sessionContext.UserId}' THEN 1
|
|
|
|
+ ELSE DENSE_RANK() OVER (ORDER BY SUM(CASE WHEN ""points"".""Direction"" = 1 THEN ""points"".""Points"" ELSE 0 END) DESC)
|
|
|
|
+ END"),
|
|
|
|
+ Points = SqlFunc.AggregateSum(points.Points),
|
|
|
|
+ UserName = citizen.Name!,
|
|
|
|
+ PhoneNumber = citizen.PhoneNumber,
|
|
|
|
+ CitizenId = citizen.Id,
|
|
|
|
+ }).MergeTable()
|
|
|
|
+ .OrderByDescending(points => points.Rank)
|
|
|
|
+ .Take(11);
|
|
|
|
+
|
|
|
|
+#if DEBUG
|
|
|
|
+ var sql = query.ToSqlString();
|
|
|
|
+#endif
|
|
|
|
+ var item = await query.ToListAsync();
|
|
|
|
+
|
|
|
|
+ item.ForEach(m =>
|
|
|
|
+ {
|
|
|
|
+ if (m.IsSecurityMax)
|
|
|
|
+ m.HeadUrl = _systemDicDataCacheManager.HeaderImages("aqws");
|
|
|
|
+ else
|
|
|
|
+ m.HeadUrl = _systemDicDataCacheManager.HeaderImages("default");
|
|
|
|
+ });
|
|
|
|
+ outDto.Ranks = item;
|
|
|
|
+ return outDto;
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
}
|
|
}
|