Browse Source

修复撤销审核

qinchaoyue 3 tuần trước cách đây
mục cha
commit
53866bf7ce

+ 5 - 8
src/Hotline.Application/Snapshot/IndustryApplication.cs

@@ -99,13 +99,6 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
         var files = await _fileRepository.GetByKeyAsync(id, token);
         var outDto = industry.Adapt<IndustryDetailOutDto>();
         outDto.Files = files.Adapt<IList<IndustryFileDto>>();
-        if (outDto.Files.NotNullOrEmpty())
-            outDto.Files.ToList().ForEach(m =>
-                    {
-                    m.AdditionId = m.Key;
-                    m.Additions = m.Key;
-                    m.FileName = m.Name;
-                    });
         return outDto;
     }
 
@@ -132,6 +125,10 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
             await _fileRepository.Removeable().Where(m => m.Key == entity.Id).ExecuteCommandAsync(requestAborted);
             await _fileRepository.AddRangeAsync(fileEntities, requestAborted);
         }
+        else
+        {
+            await _fileRepository.Removeable().Where(m => m.Key == entity.Id).ExecuteCommandAsync(requestAborted);
+        }
         dto.Adapt(entity);
         await _industryRepository.UpdateAsync(entity, requestAborted);
     }
@@ -407,7 +404,7 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
                 PhoneNumber = volunteer.DeclarePhoneNumber,
                 FullAddress = volunteer.Address + volunteer.FullAddress,
             }, true)
-            .Mapper((item, cache)=> 
+            .Mapper((item, cache) =>
             {
                 item.Files = _fileRepository.Queryable()
                 .Where(file => file.Key == item.Id)

+ 9 - 7
src/Hotline.Application/Snapshot/RedPackApplication.cs

@@ -19,6 +19,7 @@ using Mapster;
 using Microsoft.AspNetCore.Http;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Logging;
+using Microsoft.Identity.Client;
 using SqlSugar;
 using SqlSugar.Extensions;
 using System.ComponentModel;
@@ -357,16 +358,17 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
 
     public async Task RevocationRedPackSpecialAuditAsync(IList<string> ids)
     {
+        var specialRedPackAuditIds = await _specialRedPackAuditRepository.Queryable()
+            .LeftJoin<Order>((special, order) => special.OrderId == order.Id)
+            .LeftJoin<RedPackAudit>((special, order, audit) => order.Id == audit.OrderId)
+            .Where((special, order, audit) => ids.Contains(audit.Id))
+            .Select((special, order, audit) => special.Id).ToListAsync();
         var has = await _specialRedPackAuditRepository.Queryable()
-            .Where(m => m.IsSend == true && ids.Contains(m.Id))
+            .Where(m => m.IsSend == true && specialRedPackAuditIds.Contains(m.Id))
             .AnyAsync();
         if (has) throw new UserFriendlyException("该工单已发放红包,不能撤销审批");
-        await _specialRedPackAuditRepository.Updateable()
-            .SetColumns(m => m.Status, ERedPackAuditStatus.Pending)
-            .SetColumns(m => m.AuditType, null)
-            .SetColumns(m => m.AuditTypeCode, null)
-            .SetColumns(m => m.AuditRemark, null)
-            .Where(m => ids.Contains(m.Id) && m.IsSend == false)
+        await _specialRedPackAuditRepository.Removeable()
+            .Where(m => specialRedPackAuditIds.Contains(m.Id))
             .ExecuteCommandAsync();
     }