Browse Source

已收款项数据无法保存的Bug修复

jiangjc 10 months ago
parent
commit
a30d2ae36a

+ 35 - 12
OASystem/OASystem.Infrastructure/Repositories/Financial/ProceedsReceivedRepository.cs

@@ -15,7 +15,7 @@ namespace OASystem.Infrastructure.Repositories.Financial
     /// 财务 - 团组已收款项
     /// 雷怡 2023.08.16 15:24
     /// </summary>
-    public class ProceedsReceivedRepository:BaseRepository<Fin_ProceedsReceived,Fin_ProceedsReceivedView>
+    public class ProceedsReceivedRepository : BaseRepository<Fin_ProceedsReceived, Fin_ProceedsReceivedView>
     {
         private readonly IMapper _mapper;
 
@@ -62,7 +62,7 @@ namespace OASystem.Infrastructure.Repositories.Financial
 
 
             var groupReceivablesList = await _sqlSugar.Queryable<Fin_ProceedsReceived>()
-                .Where(fr => fr.IsDel == 0 && diids.Contains(fr.Diid)) .ToListAsync();
+                .Where(fr => fr.IsDel == 0 && diids.Contains(fr.Diid)).ToListAsync();
 
             result.Code = 0;
             result.Msg = "查询成功!";
@@ -284,17 +284,40 @@ namespace OASystem.Infrastructure.Repositories.Financial
                 {
                     var x = _sqlSugar.Storageable(_ProceedsReceived).ToStorage();
                     addCount = x.AsInsertable.ExecuteCommand();        //不存在插入
-                    updateCount = x.AsUpdateable.IgnoreColumns(p => new
+
+                    _sqlSugar.BeginTran();
+                    foreach (var item in _ProceedsReceived)
                     {
-                        p.SectionTime,
-                        p.Price,
-                        p.Currency,
-                        p.ReceivablesType,
-                        p.Client,
-                        p.CustomerName,
-                        p.CustomerTel,
-                        p.Remark
-                    }).ExecuteCommand();    //存在更新
+                        bool res = await UpdateAsync<Fin_ProceedsReceived>(s => s.Id == item.Id, s => new Fin_ProceedsReceived
+                        {
+                            SectionTime = item.SectionTime,
+                            Price = item.Price,
+                            Currency = item.Currency,
+                            ReceivablesType= item.ReceivablesType,
+                            Client = item.Client,
+                            CustomerName= item.CustomerName,
+                            CustomerTel = item.CustomerTel,
+                            Remark= item.Remark
+                        });
+                        if (!res)
+                        {
+                            _sqlSugar.RollbackTran();
+                            break;
+                        }
+                        updateCount++;
+                    }
+                   _sqlSugar.CommitTran();
+                    //updateCount = x.AsUpdateable.IgnoreColumns(p => new
+                    //{
+                    //    p.SectionTime,
+                    //    p.Price,
+                    //    p.Currency,
+                    //    p.ReceivablesType,
+                    //    p.Client,
+                    //    p.CustomerName,
+                    //    p.CustomerTel,
+                    //    p.Remark
+                    //}).ExecuteCommand();    //存在更新
                 }
                 result.Code = 0;
                 result.Msg = string.Format(@"操作成功!添加:{0}条;更新:{1};", addCount, updateCount);