yuanrf 1 рік тому
батько
коміт
646224a153

+ 25 - 30
OASystem/OASystem.Infrastructure/Repositories/Groups/CarTouristGuideGroundRepository.cs

@@ -425,30 +425,27 @@ namespace OASystem.Infrastructure.Repositories.Groups
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
-        public async  Task<Result> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
+        public async Task<Result> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
             try
             {
                 BeginTran();
-                List<Grp_CarTouristGuideGroundReservationsContent> carTouristList = new List<Grp_CarTouristGuideGroundReservationsContent>();
-                foreach (var item in dto.OPContentList)
+                List<Grp_CarTouristGuideGroundReservationsContent> carTouristList = dto.OPContentList.Select(item => new Grp_CarTouristGuideGroundReservationsContent
                 {
-                    Grp_CarTouristGuideGroundReservationsContent s = new Grp_CarTouristGuideGroundReservationsContent();
-                    s.Id= item.Id;
-                    s.DiId = dto.DiId;
-                    s.CTGGRId = dto.CTGGRId;
-                    s.SId = item.SId;
-                    s.Price=item.Price;
-                    s.PriceContent = item.priceContent;
-                    s.Currency = dto.Currency;
-                    //s.Remark=item.Remark;
-                    s.CreateUserId = dto.CreateUserId;
-                    s.Units = item.Units;
-                    s.DatePrice = item.DatePrice;
-                    s.Count = item.Count;
-                    carTouristList.Add(s);
-                }
+                    Id = item.Id,
+                    DiId = dto.DiId,
+                    CTGGRId = dto.CTGGRId,
+                    SId = item.SId,
+                    Price = item.Price,
+                    PriceContent = item.priceContent,
+                    Currency = dto.Currency,
+                    CreateUserId = dto.CreateUserId,
+                    Units = item.Units,
+                    DatePrice = item.DatePrice,
+                    Count = item.Count,
+                }).ToList();
+                
                 foreach (var item in carTouristList)
                 {
                    
@@ -457,7 +454,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     {
                         int id = await _sqlSugar.Insertable(item).ExecuteReturnIdentityAsync();
                         if (id == 0)
-                        {
+                        { 
                             RollbackTran();
                             return result = new Result() { Code = -2, Msg = "添加失败" };
                         }
@@ -483,12 +480,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 }
                 //修改C表数据
                 List<Grp_CarTouristGuideGroundReservationsContent> carTouristListEnd = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a=>a.DiId==dto.DiId && a.CTGGRId==dto.CTGGRId && a.IsDel==0).ToList();
-                Grp_CreditCardPayment c=new Grp_CreditCardPayment();
+                Grp_CreditCardPayment c = new Grp_CreditCardPayment();
                 c.PaymentCurrency = dto.Currency;
-                foreach (var item in carTouristListEnd)
-                {
-                    c.PayMoney += item.Price;
-                }
+                c.PayMoney = carTouristListEnd.Sum(x => x.Price);
                 c.PayPercentage = dto.PayPercentage;
                 c.ConsumptionDate= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 c.CTable = 79;
@@ -536,7 +530,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         IsPay = c.IsPay,
                         RMBPrice = c.RMBPrice,
                         DayRate = c.DayRate,
+
                     }).ExecuteCommandAsync();
+
                     if (CTable == 0)
                     {
                         RollbackTran();
@@ -554,11 +550,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 }
                 int CarTouristGuideCTable = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservations>().Where(a => a.Id == dto.CTGGRId && a.DiId == dto.DiId).SetColumns(a => new Grp_CarTouristGuideGroundReservations
                 {
-                    
-                CId=dto.Currency,
-                ServiceQuotedPrice=c.PayMoney,
-                OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer,
+                    CId = dto.Currency,
+                    ServiceQuotedPrice = c.PayMoney,
+                    OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer,
                 }).ExecuteCommandAsync();
+
                 if (CarTouristGuideCTable == 0)
                 {
                     RollbackTran();
@@ -567,10 +563,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 result = new Result() { Code =0, Msg = "保存成功" };
                 CommitTran();
             }
-            catch (Exception)
+            catch (Exception ex)
             {
                 return result = new Result() { Code = -2, Msg = "未知错误" };
-                throw;
             }
             return result;
         }