|
@@ -20,14 +20,50 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
|
|
|
private readonly ISnapshotSMSTemplateRepository _snapshotSMSTemplateRepository;
|
|
|
private readonly IIndustryRepository _industryRepository;
|
|
|
private readonly IRedPackAuditRepository _redPackAuditRepository;
|
|
|
+ private readonly IRedPackRecordRepository _redPackRecordRepository;
|
|
|
|
|
|
- public RedPackApplication(IOrderSnapshotRepository orderSnapshotRepository, ISnapshotSMSTemplateRepository snapshotSMSTemplateRepository, IOrderRepository orderRepository, IIndustryRepository industryRepository, IRedPackAuditRepository redPackAuditRepository)
|
|
|
+ public RedPackApplication(IOrderSnapshotRepository orderSnapshotRepository, ISnapshotSMSTemplateRepository snapshotSMSTemplateRepository, IOrderRepository orderRepository, IIndustryRepository industryRepository, IRedPackAuditRepository redPackAuditRepository, IRedPackRecordRepository redPackRecordRepository)
|
|
|
{
|
|
|
_orderSnapshotRepository = orderSnapshotRepository;
|
|
|
_snapshotSMSTemplateRepository = snapshotSMSTemplateRepository;
|
|
|
_orderRepository = orderRepository;
|
|
|
_industryRepository = industryRepository;
|
|
|
_redPackAuditRepository = redPackAuditRepository;
|
|
|
+ _redPackRecordRepository = redPackRecordRepository;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 审核红包发放
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ /// <exception cref="NotImplementedException"></exception>
|
|
|
+ public async Task AuditRedPackAuditAsync(UpdateRedPackAuditInDto dto)
|
|
|
+ {
|
|
|
+ var redPackAudit = await _redPackAuditRepository.GetAsync(dto.RedPackAuditId) ?? throw UserFriendlyException.SameMessage("审核记录不存在");
|
|
|
+ if (redPackAudit.Status != ERedPackAuditStatus.Pending) throw UserFriendlyException.SameMessage("已审核, 不可重复审核");
|
|
|
+ redPackAudit.SMSTemplateId = dto.SMSTemplateId;
|
|
|
+ redPackAudit.Status = dto.Status;
|
|
|
+ redPackAudit.Remark = dto.Opinion;
|
|
|
+ redPackAudit.IsSendSMS = dto.IsSendSms;
|
|
|
+ var order = await _orderRepository.Queryable()
|
|
|
+ .Where(m => m.Id == redPackAudit.OrderId)
|
|
|
+ .Select(m => new { m.Id, m.FromName })
|
|
|
+ .FirstAsync();
|
|
|
+ if (dto.Status == ERedPackAuditStatus.Agree)
|
|
|
+ {
|
|
|
+ var entity = new RedPackRecord
|
|
|
+ {
|
|
|
+ OrderId = redPackAudit.OrderId,
|
|
|
+ PeopleType = EReadPackUserType.Citizen,
|
|
|
+ Name = order.FromName,
|
|
|
+ PickupStatus = ERedPackPickupStatus.Unreceived,
|
|
|
+ DistributionState = EReadPackSendStatus.Unsend,
|
|
|
+ };
|
|
|
+ if (redPackAudit.ApprovedAmount.HasValue)
|
|
|
+ entity.Amount = redPackAudit.ApprovedAmount.Value;
|
|
|
+ await _redPackRecordRepository.AddAsync(entity);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -57,7 +93,8 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
|
|
|
if (count != 0)
|
|
|
outDto.RedPackTxt += $"今天审批【{count}】个";
|
|
|
|
|
|
- outDto.AuditComBox = EnumExts.GetDescriptions<ERedPackAuditStatus>();
|
|
|
+ outDto.AuditComBox = EnumExts.GetDescriptions<ERedPackAuditStatus>()
|
|
|
+ .Where(m => m.Key.ToString() != "0").ToList();
|
|
|
return outDto;
|
|
|
}
|
|
|
|