|
@@ -1,4 +1,6 @@
|
|
|
-using Hotline.Orders;
|
|
|
+using DocumentFormat.OpenXml.Office2010.Excel;
|
|
|
+using Hotline.Caching.Interfaces;
|
|
|
+using Hotline.Orders;
|
|
|
using Hotline.Push.FWMessage;
|
|
|
using Hotline.Share.Attributes;
|
|
|
using Hotline.Share.Dtos;
|
|
@@ -21,6 +23,7 @@ using XF.Domain.Dependency;
|
|
|
using XF.Domain.Exceptions;
|
|
|
using XF.Domain.Repository;
|
|
|
using XF.Utility.EnumExtensions;
|
|
|
+using static NPOI.SS.Format.CellNumberFormatter;
|
|
|
|
|
|
namespace Hotline.Application.Snapshot;
|
|
|
public class RedPackApplication : IRedPackApplication, IScopeDependency
|
|
@@ -29,6 +32,11 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
|
|
|
private readonly IOrderRepository _orderRepository;
|
|
|
private readonly ISnapshotSMSTemplateRepository _snapshotSMSTemplateRepository;
|
|
|
private readonly IIndustryRepository _industryRepository;
|
|
|
+ private readonly ISpecialRedPackAuditRepository _specialRedPackAuditRepository;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 市民红包审核仓储
|
|
|
+ /// </summary>
|
|
|
private readonly IRedPackAuditRepository _redPackAuditRepository;
|
|
|
private readonly IRedPackRecordRepository _redPackRecordRepository;
|
|
|
private readonly IRepository<OrderSpecial> _orderSpecialRepository;
|
|
@@ -38,8 +46,9 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
|
|
|
private readonly ISupplementRecordRepository _supplementRecordRepository;
|
|
|
private readonly IPushDomainService _pushDomainService;
|
|
|
private readonly ILogger<RedPackApplication> _logger;
|
|
|
+ private readonly ISystemDicDataCacheManager _systemDic;
|
|
|
|
|
|
- public RedPackApplication(IOrderSnapshotRepository orderSnapshotRepository, ISnapshotSMSTemplateRepository snapshotSMSTemplateRepository, IOrderRepository orderRepository, IIndustryRepository industryRepository, IRedPackAuditRepository redPackAuditRepository, IRedPackRecordRepository redPackRecordRepository, IRepository<OrderSpecial> orderSpecialRepository, ISessionContext sessionContext, IRedPackGuiderAuditRepository redPackGuiderAuditRepository, IThirdAccountRepository thirdAccountRepository, ISupplementRecordRepository supplementRecordRepository, IPushDomainService pushDomainService, ILogger<RedPackApplication> logger)
|
|
|
+ public RedPackApplication(IOrderSnapshotRepository orderSnapshotRepository, ISnapshotSMSTemplateRepository snapshotSMSTemplateRepository, IOrderRepository orderRepository, IIndustryRepository industryRepository, IRedPackAuditRepository redPackAuditRepository, IRedPackRecordRepository redPackRecordRepository, IRepository<OrderSpecial> orderSpecialRepository, ISessionContext sessionContext, IRedPackGuiderAuditRepository redPackGuiderAuditRepository, IThirdAccountRepository thirdAccountRepository, ISupplementRecordRepository supplementRecordRepository, IPushDomainService pushDomainService, ILogger<RedPackApplication> logger, ISpecialRedPackAuditRepository specialRedPackAuditRepository, ISystemDicDataCacheManager systemDic)
|
|
|
{
|
|
|
_orderSnapshotRepository = orderSnapshotRepository;
|
|
|
_snapshotSMSTemplateRepository = snapshotSMSTemplateRepository;
|
|
@@ -54,6 +63,8 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
|
|
|
_supplementRecordRepository = supplementRecordRepository;
|
|
|
_pushDomainService = pushDomainService;
|
|
|
_logger = logger;
|
|
|
+ _specialRedPackAuditRepository = specialRedPackAuditRepository;
|
|
|
+ _systemDic = systemDic;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -70,8 +81,13 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
|
|
|
if (redPackAudit.Status != ERedPackAuditStatus.Pending) throw UserFriendlyException.SameMessage("已审核, 不可重复审核");
|
|
|
redPackAudit.SMSTemplateId = dto.SMSTemplateId;
|
|
|
redPackAudit.Status = status;
|
|
|
- redPackAudit.Remark = dto.Opinion;
|
|
|
+ redPackAudit.AuditRemark = dto.Opinion;
|
|
|
redPackAudit.IsSendSMS = dto.IsSendSms;
|
|
|
+ redPackAudit.AuditId = _sessionContext.UserId;
|
|
|
+ redPackAudit.AuditName = _sessionContext.UserName;
|
|
|
+ redPackAudit.AuditTime = DateTime.Now;
|
|
|
+ redPackAudit.AuditOrgId = _sessionContext.OrgId;
|
|
|
+ redPackAudit.AuditOrgName = _sessionContext.OrgName;
|
|
|
var order = await _orderRepository.Queryable()
|
|
|
.Where(m => m.Id == redPackAudit.OrderId)
|
|
|
.Select(m => new { m.Id, m.No, m.FromName, m.FromPhone })
|
|
@@ -232,6 +248,67 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
|
|
|
return outDto;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 特殊红包审批列表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ExportExcel("特殊红包审批")]
|
|
|
+ public ISugarQueryable<SnapshotOrderAuditItemsOutDto> GetRedPackSpecialAuditItems(SnapshotOrderAuditItemsInDto dto)
|
|
|
+ {
|
|
|
+ var beginTime = new DateTime(2024, 8, 1);
|
|
|
+ var endTime = new DateTime(2024, 9, 30, 23, 59, 59);
|
|
|
+ var query = _redPackAuditRepository.Queryable()
|
|
|
+ .LeftJoin<OrderSnapshot>((redPackAudit, snapshot) => redPackAudit.OrderId == snapshot.Id)
|
|
|
+ .LeftJoin<Order>((redPackAudit, snapshot, order) => redPackAudit.OrderId == order.Id)
|
|
|
+ .LeftJoin<SpecialRedPackAudit>((redPackAudit, snapshot, order, special) => redPackAudit.OrderId == special.OrderId)
|
|
|
+ .Where((redPackAudit, snapshot, order, special) => (snapshot.IndustryName == "安全隐患" && order.OrderTagCode!.Contains("DHZY")) || (order.CreationTime >=beginTime && order.CreationTime <= endTime && redPackAudit.ApprovedAmount == 20 && order.AcceptTypeCode != "30" && snapshot.IndustryName != "电气焊作业申报"))
|
|
|
+ .WhereIF(dto.Status == 0, (redPackAudit, snapshot, order, special) => special.Id == null)
|
|
|
+ .WhereIF(dto.Status == 1, (redPackAudit, snapshot, order, special) => special.Status == ERedPackAuditStatus.Agree)
|
|
|
+ .WhereIF(dto.Status == 2, (redPackAudit, snapshot, order, special) => special.Status == ERedPackAuditStatus.Refuse)
|
|
|
+ .OrderByDescending((redPackAudit, snapshot, order, special) => redPackAudit.CreationTime)
|
|
|
+ .Select((redPackAudit, snapshot,order) => new SnapshotOrderAuditItemsOutDto
|
|
|
+ {
|
|
|
+ Id = redPackAudit.Id,
|
|
|
+ RedPackAuditId = redPackAudit.Id,
|
|
|
+ OrderId = order.Id,
|
|
|
+ No = order.No,
|
|
|
+ Title = order.Title,
|
|
|
+ IndustryName = snapshot.IndustryName,
|
|
|
+ IndustryId = snapshot.IndustryId,
|
|
|
+ SourceChannel = order.SourceChannel,
|
|
|
+ SourceChannelCode = order.SourceChannelCode,
|
|
|
+ Status = order.Status,
|
|
|
+ IsDanger = snapshot.IsDanger,
|
|
|
+ FromPhone = order.FromPhone,
|
|
|
+ FromName = order.FromName,
|
|
|
+ AuditTime = redPackAudit.AuditTime,
|
|
|
+ ApprovedAmount = redPackAudit.ApprovedAmount,
|
|
|
+ AcutalAmount = redPackAudit.AcutalAmount,
|
|
|
+ IsIssued = redPackAudit.IsIssued,
|
|
|
+ //RecordRemark = record.Remark,
|
|
|
+ County = order.County,
|
|
|
+ // IsRectify = s.IsRepetition
|
|
|
+ IsDeal = snapshot.IsDeal,
|
|
|
+ NetworkENumber = snapshot.NetworkENumber,
|
|
|
+ IsTruth = snapshot.IsTruth,
|
|
|
+ IsTruthDepartment = snapshot.IsTruthDepartment,
|
|
|
+ IsRepetition = snapshot.IsRepetition,
|
|
|
+ CreationTime = order.CreationTime,
|
|
|
+ OrgLevelOneCode = order.OrgLevelOneCode,
|
|
|
+ OrgLevelOneName = order.OrgLevelOneName,
|
|
|
+ AuditId = redPackAudit.AuditId,
|
|
|
+ AuditName = redPackAudit.AuditName,
|
|
|
+ AuditOrgId = redPackAudit.AuditOrgId,
|
|
|
+ AuditOrgName = redPackAudit.AuditOrgName,
|
|
|
+ AuditRemark = redPackAudit.AuditRemark,
|
|
|
+ //BankCardNo = record.BankCardNo,
|
|
|
+ //OpenBank = record.OpenBank,
|
|
|
+ AuditStatus = redPackAudit.Status,
|
|
|
+ });
|
|
|
+ return query;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 红包审核集合
|
|
|
/// </summary>
|
|
@@ -438,10 +515,50 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
|
|
|
var record = await _redPackRecordRepository.Queryable()
|
|
|
.Where(m => m.RedPackAuditId == dto.RedPackAuditId)
|
|
|
.FirstAsync() ?? throw UserFriendlyException.SameMessage("审核记录不存在");
|
|
|
+ record.DistributionState = EReadPackSendStatus.Successful;
|
|
|
+ record.PickupStatus = ERedPackPickupStatus.Received;
|
|
|
var audit = await _redPackAuditRepository.GetAsync(dto.RedPackAuditId) ?? throw UserFriendlyException.SameMessage("审核记录不存在");
|
|
|
|
|
|
dto.Adapt(audit);
|
|
|
await _redPackAuditRepository.UpdateAsync(audit);
|
|
|
+ await _redPackRecordRepository.UpdateAsync(record);
|
|
|
+
|
|
|
+ var entity = dto.Adapt<SupplementRecord>();
|
|
|
+ var industryName = await _orderSnapshotRepository.Queryable()
|
|
|
+ .Where(m => m.Id == record.OrderId)
|
|
|
+ .Select(m => new { m.IndustryName, m.IndustryId })
|
|
|
+ .FirstAsync();
|
|
|
+ entity.OrderId = record.OrderId;
|
|
|
+ entity.RedPackRecordId = record.Id;
|
|
|
+ entity.RedPackAuditId = audit.Id;
|
|
|
+ entity.No = record.No;
|
|
|
+ entity.IndustryName = industryName.IndustryName;
|
|
|
+ entity.IndustryId = industryName.IndustryId;
|
|
|
+ await _supplementRecordRepository.AddAsync(entity);
|
|
|
+
|
|
|
+ if (dto.IsSendSMS)
|
|
|
+ {
|
|
|
+ // TODO: 发送短信
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 添加补充发放信息(特殊红包)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task UpdateRedPackSpecialRecordAsync(UpdateRedPackRecordInDto dto)
|
|
|
+ {
|
|
|
+ var record = await _redPackRecordRepository.Queryable()
|
|
|
+ .Where(m => m.RedPackAuditId == dto.RedPackAuditId)
|
|
|
+ .FirstAsync() ?? throw UserFriendlyException.SameMessage("审核记录不存在");
|
|
|
+ record.DistributionState = EReadPackSendStatus.Successful;
|
|
|
+ record.PickupStatus = ERedPackPickupStatus.Received;
|
|
|
+ var audit = await _specialRedPackAuditRepository.GetAsync(dto.RedPackAuditId) ?? throw UserFriendlyException.SameMessage("审核记录不存在");
|
|
|
+
|
|
|
+ dto.Adapt(audit);
|
|
|
+ await _specialRedPackAuditRepository.UpdateAsync(audit);
|
|
|
+ await _redPackRecordRepository.UpdateAsync(record);
|
|
|
|
|
|
var entity = dto.Adapt<SupplementRecord>();
|
|
|
var industryName = await _orderSnapshotRepository.Queryable()
|
|
@@ -462,6 +579,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
#region 红包发放记录
|
|
|
|
|
|
/// <summary>
|
|
@@ -577,6 +695,75 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
|
|
|
return query;
|
|
|
}
|
|
|
|
|
|
+ public async Task AuditRedPackSpecialAuditAsync(UpdateRedPackSpecialAuditInDto dto)
|
|
|
+ {
|
|
|
+ var audit = await _redPackAuditRepository.GetAsync(dto.RedPackAuditId) ?? throw UserFriendlyException.SameMessage("审核记录不存在");
|
|
|
+ if (_specialRedPackAuditRepository.ExistByOrderId(audit.OrderId)) throw UserFriendlyException.SameMessage("已审核, 不可重复审核");
|
|
|
+ var specialAudit = audit.Adapt<SpecialRedPackAudit>();
|
|
|
+ if (dto.AuditTypeId.NotNullOrEmpty())
|
|
|
+ {
|
|
|
+ var specialType = _systemDic.SnapshotRedPackSpecialType.FirstOrDefault(m => m.Id == dto.AuditTypeId);
|
|
|
+ if (specialType != null)
|
|
|
+ {
|
|
|
+ specialAudit.AuditType = specialType.DicDataName;
|
|
|
+ specialAudit.AuditTypeCode = specialType.DicDataValue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ specialAudit.Status = dto.Status;
|
|
|
+ specialAudit.ApprovedAmount = dto.ApprovedAmount;
|
|
|
+ specialAudit.AuditId = _sessionContext.UserId;
|
|
|
+ specialAudit.AuditName = _sessionContext.UserName;
|
|
|
+ specialAudit.AuditOrgId = _sessionContext.OrgId;
|
|
|
+ specialAudit.AuditOrgName = _sessionContext.OrgName;
|
|
|
+ await _specialRedPackAuditRepository.AddAsync(specialAudit);
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task<SnapshotOrderAuditSpecialDetailOutDto> GetRedPackSpecialAuditBaseDataAsync(string id)
|
|
|
+ {
|
|
|
+ var outDto = new SnapshotOrderAuditSpecialDetailOutDto();
|
|
|
+ var order = await _orderRepository.GetAsync(id) ?? throw new UserFriendlyException("工单不存在");
|
|
|
+ outDto.Order = order.Adapt<SnapshotOrderAuditOrderDetailOutDto>();
|
|
|
+ outDto.AuditType = _systemDic.SnapshotRedPackSpecialType;
|
|
|
+ outDto.AuditComBox = EnumExts.GetDescriptions<ERedPackAuditStatus>().Where(m => m.Key != 0).ToList();
|
|
|
+ var audit = await _redPackAuditRepository.GetAsync(m => m.OrderId == id);
|
|
|
+ outDto.AuditDetail = audit.Adapt<SnapshotOrderAuditSpecialAuditDetailOutDto>();
|
|
|
+ return outDto;
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task<GetRedPackRecordBaseDataOutDto> GetRedPackRecordBaseDataAsync(string orderId)
|
|
|
+ {
|
|
|
+ var snapshot = await _orderSnapshotRepository.Queryable()
|
|
|
+ .Where(m => m.Id == orderId)
|
|
|
+ .Select(m => new
|
|
|
+ {
|
|
|
+ m.Id,
|
|
|
+ m.AwardBankCardNo,
|
|
|
+ m.AwardOpenBank,
|
|
|
+ m.AwardName,
|
|
|
+ m.AwardAmount
|
|
|
+ })
|
|
|
+ .FirstAsync();
|
|
|
+ var outDto = new GetRedPackRecordBaseDataOutDto();
|
|
|
+ if (snapshot != null)
|
|
|
+ {
|
|
|
+ outDto.BankCardNo = snapshot.AwardBankCardNo;
|
|
|
+ outDto.OpenBank = snapshot.AwardOpenBank;
|
|
|
+ outDto.Name = snapshot.AwardName;
|
|
|
+ outDto.Amount = snapshot.AwardAmount;
|
|
|
+ }
|
|
|
+ var audit = await _specialRedPackAuditRepository.Queryable().Where(m => m.OrderId == orderId).FirstAsync()
|
|
|
+ ?? throw new UserFriendlyException("审核记录不存在");
|
|
|
+ if (audit != null)
|
|
|
+ {
|
|
|
+ outDto.AuditType = audit.AuditType;
|
|
|
+ outDto.AuditTypeCode = audit.AuditTypeCode;
|
|
|
+ outDto.RedPackAuditId = audit.Id;
|
|
|
+ }
|
|
|
+ outDto.OrderId = orderId;
|
|
|
+ outDto.ReplenishType = _systemDic.SnapshotReplenishType;
|
|
|
+ return outDto;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
#endregion
|
|
|
}
|