ソースを参照

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

LEIYI 6 ヶ月 前
コミット
5538f385af

+ 48 - 21
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -33,6 +33,8 @@ using System.Data.OleDb;
 using System.Diagnostics;
 using System.Globalization;
 using System.IO.Compression;
+using System.IO.Pipelines;
+
 namespace OASystem.API.Controllers
 {
     /// <summary>
@@ -3770,14 +3772,12 @@ Group by PriceType ", dto.diId);
                 return Ok(JsonView(false, "团组信息有误!"));
             }
 
-            Dictionary<int, int> dicSoure = new
-                 Dictionary<int, int>()
+            Dictionary<int, int> dicSoure = new Dictionary<int, int>()
             {
                 {1077,1074 },
                 {1078,1075 },
                 {1079,1076 }
             };
-
             Dictionary<int, int> mealsDic = new Dictionary<int, int>()
                     {
                         {988,1074},
@@ -3785,8 +3785,12 @@ Group by PriceType ", dto.diId);
                         {989,1076},
                     };
 
+            var checkBoxDataArr = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 17).ToList();
+            var CurrDataArr = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
+
             var joinTable =  _sqlSugar.Queryable<Fin_GroupExtraCost, Grp_CreditCardPayment, Sys_SetData, Grp_NationalTravelFee ,
-                Fin_LocalGuideRelevancyOverspend , Grp_CarTouristGuideGroundReservations, Sys_SetData,Grp_DelegationInfo>((f, c, s, g, r ,l, s1,i) => new JoinQueryInfos(
+                Fin_LocalGuideRelevancyOverspend , Grp_CarTouristGuideGroundReservations, Sys_SetData,Grp_DelegationInfo>(
+                (f, c, s, g, r ,l, s1,i) => new JoinQueryInfos(
                     JoinType.Left, f.Id == c.CId && c.CTable == 1015 && c.IsDel == 0,
                     JoinType.Left, c.PaymentCurrency == s.Id && s.IsDel == 0,
                     JoinType.Left, g.IsDel == 0 && g.Id == f.Area,
@@ -3824,47 +3828,70 @@ Group by PriceType ", dto.diId);
                 .ToList()
                 .Select(x =>
                 {
-                    var costPirce = x.Price;
-
-                    decimal rateValue = x.DayRate;
+                    var costPirce = x.Price; 
                     decimal costRMBPrice = x.RMBPrice;
-                    decimal DayRate = x.DayRate;
+                    decimal costDayRate = x.DayRate;
+                    string remake = x.Remark;
 
-                    if (x.VisitPNumber > 0 && x.toCurr != x.PaymentCurrency)
+                    if (x.VisitPNumber > 0 && x.PriceDetailType != 1088)
                     {
                         decimal.TryParse(x.FoodCost, out decimal cost);
                         cost /= 2;
 
-                        var rate = _setDataRep.PostCurrencyByDiid(x.DiId, 1015, x.toCurr).Result;
-                        if (rate.Code == 0)
+                        decimal oldPrice = costPirce;
+                        costPirce *= x.Rate; //转换币种
+
+                        if (x.toCurr != x.PaymentCurrency)
                         {
-                            var rateData = rate.Data as CurrencyInfo;
-                            if (rateData != null)
+                            var rate = _setDataRep.PostCurrencyByDiid(x.DiId, 1015, x.toCurr).Result;
+                            if (rate.Code == 0)
                             {
-                                rateValue = rateData.Rate;
+                                var rateData = rate.Data as CurrencyInfo;
+                                if (rateData != null)
+                                {
+                                    costDayRate = rateData.Rate;
+                                }
                             }
                         }
 
-                        costPirce *= x.Rate;
                         if (dicSoure.Keys.Contains(x.PriceDetailType))
                         {
                             var CarCenter = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(x1 => x1.CTGGRId == x.CarParentId && x1.IsDel == 0
                             && x1.SId == mealsDic.First(x2 => x2.Value == dicSoure[x.PriceDetailType]).Key ).ToList().First(x1=> (DateTime.Compare(x1.DatePrice.ObjToDate(), x.PriceDt) == 0));
                             costPirce += (CarCenter.Price * CarCenter.Count * x.Rate);
-                            costPirce = costPirce - x.VisitPNumber * cost;
+                            oldPrice += (CarCenter.Price * CarCenter.Count);
+
+                            var costResultPirce = costPirce - x.VisitPNumber * cost;
+                            costResultPirce = Convert.ToInt32(Math.Round(costResultPirce));
+
+                            var findCheck = checkBoxDataArr.Find(s => s.Id == CarCenter.SId);
+
+                            if (x.toCurr != x.PaymentCurrency)
+                            {
+                                remake += $"{x.PriceDt.ToString("M/d")} {findCheck?.Name} {x.PaymentCurrencyStr} {(int)Math.Round(oldPrice)}( 折算{x.toCurrStr} {(int)Math.Round(costPirce)}) - 财政{cost} * {x.VisitPNumber}  = {x.toCurrStr}{costResultPirce}";
+                            }
+                            else
+                            {
+                                remake += $"{x.PriceDt.ToString("M/d")} {findCheck?.Name}{x.PaymentCurrencyStr} {(int)Math.Round(costPirce)} - 财政{cost} * {x.VisitPNumber}  = {x.PaymentCurrencyStr}{costResultPirce}";
+                            }
+
+                            costPirce = costResultPirce;
+                        }
+                        else
+                        {
+                            costPirce = Convert.ToInt32(Math.Round(costPirce));
                         }
-                        costPirce = Convert.ToInt32(Math.Round(costPirce));
-                        costRMBPrice = Convert.ToInt32(Math.Round(costPirce * rateValue));
-                        DayRate = rateValue;
+                        
+                        costRMBPrice = Convert.ToInt32(Math.Round(costPirce * costDayRate));
                     }
 
                     return new
                     {
                         x.PaymentCurrency,
-                        DayRate,
+                        DayRate = costDayRate,
                         x.PaymentCurrencyStr,
                         x.PriceName,
-                        x.Remark,
+                        Remark = remake,
                         x.PriceCount,
                         Price = costPirce,
                         x.PayMoney,

+ 73 - 105
OASystem/OASystem.Infrastructure/Repositories/Groups/CarTouristGuideGroundRepository.cs

@@ -768,23 +768,16 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     Count = item.Count,
                 }).ToList();
 
+                #region 旧数据处理
                 string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm ss");
-
                 var ids = carTouristList.Select(x1 => x1.Id);
-
-                _ = _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(x => x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId).SetColumns(x => new Grp_CarTouristGuideGroundReservationsContent
+                _ = _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(x => x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId  && !ids.Contains(x.Id)).SetColumns(x => new Grp_CarTouristGuideGroundReservationsContent
                 {
                     IsDel = 1,
-                    DeleteTime = time ,
+                    DeleteTime = time,
                     DeleteUserId = dto.CreateUserId,
-                }) .ExecuteCommand();
-
-                _ = _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(x => x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId  &&  ids.Contains(x.Id)).SetColumns(x => new Grp_CarTouristGuideGroundReservationsContent
-                {
-                    IsDel = 0,
-                    DeleteTime = "",
-                    DeleteUserId = null,
                 }).ExecuteCommand();
+                #endregion
 
                 if (carTouristList.Count > 0)
                 {
@@ -838,69 +831,30 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     List<Fin_GroupExtraCost> groupExtraCostsArr = new List<Fin_GroupExtraCost>();
                     List<List<Fin_GroupExtraCost>> enterOverspendArr = new List<List<Fin_GroupExtraCost>>();
 
-                    var setDataArr = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 17).ToList();
-                    var setDataCurrArr = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
-                    var number = 0; //人数
                     var aMeal = cityPrice.FoodCost.ObjToDecimal() / 2; //一顿三公费用
-                    var findSsetDataCurr = setDataCurrArr.Find(q => q.Id == dto.Currency);
-                    var printRate = 1M;
-
-                    if (cityPrice.Currency != dto.Currency)
-                    {
-                        printRate = dto.Rate;
-                        findSsetDataCurr = setDataCurrArr.Find(q => q.Id == dto.toCurr);
-                    }
+                    var findSetDataCurr = _sqlSugar.Queryable<Sys_SetData>().First(q => q.Id == dto.toCurr && q.IsDel == 0);
 
                     foreach (var item in arr)
                     {
-                        var a = carTouristList.Where(x => x.SId == item.Item1 && x.Price != 0).Select(x => {
-                            
-                            string remake = x.Remark;
-
-                            //餐费超支备注额外处理
-                            if (mealsDic.Values.Contains(item.Item1))
-                            {
-                                var keyId = mealsDic.FirstOrDefault(q => q.Value == item.Item1).Key;
-
-                                //今日一顿餐食费用 (今日一顿餐费 + 今日一顿超支费用)
-                                var dayMealPrice = carTouristList.Where(q => q.SId == keyId && q.Price != 0 && 
-                                DateTime.Compare(x.DatePrice.ObjToDate(),q.DatePrice.ObjToDate()) == 0).Sum( q => q.Price) + x.Price;
-
-                                var findSetData = setDataArr.Find(q => q.Id == keyId);
-
-                                if (di.VisitPNumber > 1 && x.Count == 1)
-                                {
-                                    number = di.VisitPNumber;
-                                }
-                                else
-                                {
-                                    number = x.Count;
-                                }
-
-                                dayMealPrice = dayMealPrice / number * printRate;  //转三公币种
-                                var price = (int)Math.Round((dayMealPrice * number) - (aMeal * number));
-                                remake = $"{x.DatePrice?.ToString("M/d")} {findSetData?.Name}{findSsetDataCurr?.Name} {(int)Math.Round(dayMealPrice * number)} - 财政{aMeal} * {number}  = {findSsetDataCurr?.Name}{price}";
-                            }
-
-                            return new Fin_GroupExtraCost
-                            {
-                                Coefficient = item.Item4,
-                                CreateTime = DateTime.Now,
-                                CreateUserId = dto.CreateUserId,
-                                DiId = dto.DiId,
-                                FilePath = string.Empty,
-                                IsDel = 0,
-                                PriceCount = x.Count,
-                                Price = x.Price,
-                                PriceDt = x.DatePrice.ObjToDate(),
-                                PriceCurrency = x.Currency,
-                                PriceSum = x.Count * x.Price,
-                                PriceName = di.TeamName + "-" + priceCity + "-" + $"{item.Item2}(地接导入)",
-                                PriceType = 1028,
-                                PriceDetailType = item.Item3,
-                                Remark = remake,
-                                Area = opSingleCityId
-                            };
+                        var a = carTouristList.Where(x => x.SId == item.Item1 && x.Price != 0).Select(x => new Fin_GroupExtraCost
+                        {
+                            Coefficient = item.Item4,
+                            CreateTime = DateTime.Now,
+                            CreateUserId = dto.CreateUserId,
+                            DiId = dto.DiId,
+                            FilePath = string.Empty,
+                            IsDel = 0,
+                            PriceCount = x.Count,
+                            Price = x.Price,
+                            PriceDt = x.DatePrice.ObjToDate(),
+                            PriceCurrency = x.Currency,
+                            PriceSum = x.Count * x.Price,
+                            PriceName = di.TeamName + "-" + priceCity + "-" + $"{item.Item2}(地接导入)",
+                            PriceType = 1028,
+                            PriceDetailType = item.Item3,
+                            Remark = x.Remark,
+                            Area = opSingleCityId
+                        
                         }).ToList();
 
                         if (a.Count > 0)
@@ -920,7 +874,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     string remake = string.Empty;
                     var exitMealCount = 0;
                     var price = 0M;
-                    var day = 0;
+                    //var day = 0;
                     while (start <= end)
                     {
                         //查看每日每顿是否存在超支
@@ -935,23 +889,23 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         {
                             remake += $"{start.ToString("M/d")}午餐和晚餐,";
                             exitMealCount += 2;
-                            price += (aMeal * 2  * di.VisitPNumber) - (mealPriceWu * printRate) - (mealPriceWan * printRate);
+                            price += (aMeal * 2  * di.VisitPNumber) - (mealPriceWu * dto.Rate) - (mealPriceWan * dto.Rate);
                         }
                         else if (isExistsWu)
                         {
                             remake += $"{start.ToString("M/d")}午餐,";
                             exitMealCount += 1;
-                            price += (aMeal  * di.VisitPNumber) - (mealPriceWu * printRate);
+                            price += (aMeal  * di.VisitPNumber) - (mealPriceWu * dto.Rate);
                         }
                         else if (isExistsWan)
                         {
                             remake += $"{start.ToString("M/d")}晚餐,";
                             exitMealCount += 1;
-                            price += (aMeal * di.VisitPNumber)  - (mealPriceWan * printRate);
+                            price += (aMeal * di.VisitPNumber)  - (mealPriceWan * dto.Rate);
                         }
 
                         start = start.AddDays(1);
-                        day++;
+                        //day++;
                     }
 
                     var priceTypeArr = new int[] { 1061 , 1069 };
@@ -959,7 +913,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     if (exitMealCount > 0 && priceTypeArr.Contains(opSingle.PriceType))
                     {
                         remake = remake.TrimEnd(',');
-                        remake += $"财政 {findSsetDataCurr?.Name} {aMeal} * {di.VisitPNumber} * {exitMealCount}餐";
+                        remake += $"财政 {findSetDataCurr?.Name} {aMeal} * {di.VisitPNumber} * {exitMealCount}餐";
                         int priceInt = (int)Math.Round(price / di.VisitPNumber / exitMealCount);
                         groupExtraCostsArr.Add(new Fin_GroupExtraCost
                         {
@@ -972,7 +926,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                             PriceCount = di.VisitPNumber * exitMealCount * -1 ,
                             Price = priceInt,
                             PriceDt = opSingle.ServiceStartTime.ObjToDate(),
-                            PriceCurrency = findSsetDataCurr == null ? dto.toCurr: findSsetDataCurr.Id ,
+                            PriceCurrency = findSetDataCurr == null ? dto.toCurr: findSetDataCurr.Id ,
                             PriceSum = (di.VisitPNumber * exitMealCount * -1) * priceInt,
                             PriceName = di.TeamName + "-" + priceCity + "-" + $"退餐费(地接导入)",
                             PriceType = 1028,
@@ -1049,51 +1003,64 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     }
 
                     #endregion
-                }
 
+                    var existingRecords = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
+                                          .Where(a => carTouristList.Select(item => item.Id).Contains(a.Id) &&
+                                                      a.CTGGRId == dto.CTGGRId &&
+                                                      a.IsDel == 0)
+                                          .ToListAsync();
 
-                foreach (var item in carTouristList)
-                {
+                    var existingRecordsDict = existingRecords.ToDictionary(a => (a.Id));
+
+                    var insertList = new List<Grp_CarTouristGuideGroundReservationsContent>();
+                    var updateList = new List<Grp_CarTouristGuideGroundReservationsContent>();
 
-                    Grp_CarTouristGuideGroundReservationsContent QueryData = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().First(a => a.SId == item.SId && a.Id == item.Id && a.DiId == item.DiId
-                    && a.CTGGRId == dto.CTGGRId && a.IsDel == 0);
-                    if (QueryData == null)
+                    foreach (var item in carTouristList)
                     {
-                        int id = await _sqlSugar.Insertable(item).ExecuteReturnIdentityAsync();
-                        if (id == 0)
+                        if (!existingRecordsDict.TryGetValue((item.Id), out var existingRecord))
                         {
-                            RollbackTran();
-                            return result = new Result() { Code = -2, Msg = "添加失败" };
+                            insertList.Add(item);
+                        }
+                        else
+                        {
+                            existingRecord.Price = item.Price;
+                            existingRecord.PriceContent = item.PriceContent;
+                            existingRecord.Currency = dto.Currency;
+                            existingRecord.Remark = item.Remark;
+                            existingRecord.DatePrice = item.DatePrice;
+                            existingRecord.Count = item.Count;
+                            existingRecord.Units = item.Units;
+                            updateList.Add(existingRecord);
                         }
                     }
-                    else
+
+                    // 执行批量插入
+                    if (insertList.Any())
                     {
-                        int CTable = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.Id == item.Id).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent
+                        var insertIds = await _sqlSugar.Insertable(insertList).ExecuteReturnIdentityAsync();
+                        if (insertIds == 0)
                         {
-                            Price = item.Price,
-                            PriceContent = item.PriceContent,
-                            Currency = dto.Currency,
-                            Remark = item.Remark,
-                            DatePrice = item.DatePrice,
-                            Count = item.Count,
-                            Units = item.Units,
-                        }).ExecuteCommandAsync();
-
-                        if (CTable == 0)
+                            throw new Exception("添加失败,请稍后重试!");
+                        }
+                    }
+
+                    // 执行批量更新
+                    if (updateList.Any())
+                    {
+                        var updateCount = await _sqlSugar.Updateable(updateList).ExecuteCommandAsync();
+                        if (updateCount == 0)
                         {
-                            RollbackTran();
-                            return result = new Result() { Code = -1, Msg = "修改失败,请稍后重试!" };
+                            throw new Exception("修改失败,请稍后重试!");
                         }
                     }
                 }
 
                 Regex regex = new Regex("^[\u4e00-\u9fa5]{0,}$");
 
-                //修改C表数据
-                //List<Grp_CarTouristGuideGroundReservationsContent> carTouristListEnd = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a=>a.DiId==dto.DiId && a.CTGGRId==dto.CTGGRId && a.IsDel==0).ToList();
+                #region 修改C表数据
+                
                 Grp_CreditCardPayment c = new Grp_CreditCardPayment();
                 c.PaymentCurrency = dto.Currency;
-
                 for (int i = 0; i < dto.SelectCheck.Count; i++)
                 {
                     if (!regex.IsMatch(dto.SelectCheck[i]))
@@ -1112,7 +1079,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         break;
                     }
                 }
-
                 c.PayPercentage = dto.PayPercentage;
                 c.ConsumptionDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 c.CTable = 79;
@@ -1197,6 +1163,8 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     }
                 }
 
+                #endregion
+
                 _ = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservations>().Where(a => a.Id == dto.CTGGRId && a.DiId == dto.DiId && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservations
                 {
                     CId = dto.Currency,

+ 43 - 45
OASystem/OASystem.Infrastructure/Repositories/Resource/OfficialActivitiesRepository.cs

@@ -186,20 +186,42 @@ FROM
 
             #endregion
 
-            if (dto.Status == 1)//添加
+            _sqlSugar.BeginTran();
+
+            //添加到资料库
+            Res_InvitationOfficialActivityData res_InvitationData = new Res_InvitationOfficialActivityData();
+            res_InvitationData.Country = dto.Country;
+            res_InvitationData.City = dto.Area;
+            res_InvitationData.UnitName = dto.Client;
+            res_InvitationData.Delegation = dto.DiId.ToString();
+            res_InvitationData.Address = dto.Address;
+            res_InvitationData.CreateUserId = dto.CreateUserId;
+            res_InvitationData.Contact = dto.Contact;
+            res_InvitationData.Job = dto.Job;
+            res_InvitationData.Tel = dto.Tel;
+            res_InvitationData.Field = dto.Field;
+
+            Res_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync
+                (a => a.Country == res_InvitationData.Country && a.City == res_InvitationData.City && a.UnitName == res_InvitationData.UnitName && a.IsDel == 0 && a.Address == res_InvitationData.Address);
+
+            if (ifNullUp == null)
+            {
+                int DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
+            }
+            else
             {
-                _sqlSugar.BeginTran();
+                res_InvitationData.Id = ifNullUp.Id;
+                await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>(res_InvitationData).ExecuteCommandAsync();
+            }
 
-                //处理sql注入 2024-05-22 袁
-                //string selectSql = string.Format(@"select * from Res_OfficialActivities where Client='{0}' and Address='{1}' and IsDel='{2}'", dto.Client, dto.Address, 0);
-                //var res_InvitationOfficial = await _sqlSugar.SqlQueryable<Res_OfficialActivities>(selectSql).FirstAsync();//查询是否存在
+            if (dto.Status == 1)//添加
+            {
                 var res_InvitationOfficial = await _sqlSugar.Queryable< Res_OfficialActivities >().FirstAsync(x=>x.Client == dto.Client && x.Address == dto.Address && x.IsDel == 0 && x.DiId == dto.DiId);
 
                 if (res_InvitationOfficial != null)
                 {
                     _sqlSugar.RollbackTran();
-                    return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
-
+                    result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
                 }
                 else//不存在,可添加
                 {
@@ -209,44 +231,12 @@ FROM
                     if (id == 0)
                     {
                         _sqlSugar.RollbackTran();
-                        return result = new Result() { Code = -1, Msg = "添加失败!" };
-                    }
-
-                    //添加到资料库
-                    Res_InvitationOfficialActivityData res_InvitationData = new Res_InvitationOfficialActivityData();
-                    res_InvitationData.Country = dto.Country;
-                    res_InvitationData.City = dto.Area;
-                    res_InvitationData.UnitName = dto.Client;
-                    res_InvitationData.Delegation = dto.DiId.ToString();
-                    res_InvitationData.Address = dto.Address;
-                    res_InvitationData.CreateUserId = dto.CreateUserId;
-                    res_InvitationData.Contact = dto.Contact;
-                    res_InvitationData.Job = dto.Job;
-                    res_InvitationData.Tel = dto.Tel;
-
-                    Res_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync
-                        (a => a.Country == res_InvitationData.Country && a.City == res_InvitationData.City && a.UnitName == res_InvitationData.UnitName && a.IsDel == 0 && a.Address == res_InvitationData.Address);
-
-                    if (ifNullUp == null)
-                    {
-                        int DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
-                        if (DataID != 0)
-                        {
-                            _sqlSugar.CommitTran();
-                            return  new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
-                        }
-                        else
-                        {
-                            _sqlSugar.RollbackTran();
-                            return  new Result() { Code = -1, Msg = "添加失败!" };
-                        }
+                         result = new Result() { Code = -1, Msg = "添加失败!" };
                     }
                     else
                     {
                         _sqlSugar.CommitTran();
-                        result.Code = 0;
-                        result.Msg = "添加成功!";
-                        return result;
+                        result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
                     }
                 }
             }
@@ -279,16 +269,24 @@ FROM
                     IsPay = dto.IsPay,
                     IsSubmitApproval = dto.IsSubmitApproval,
                 });
-                if (!res)
+                if (res)
                 {
-                    return result = new Result() { Code = -1, Msg = "修改失败!" };
+                    _sqlSugar.CommitTran();
+                    result = new Result() { Code = 0, Msg = "修改成功!", Data = new { Id = dto.Id } };
+                }
+                else
+                {
+                    _sqlSugar.RollbackTran();
+                    result = new Result() { Code = -1, Msg = "修改失败!" };
                 }
-                return result = new Result() { Code = 0, Msg = "修改成功!", Data = new { Id = dto.Id } };
             }
             else
             {
-                return new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
+                _sqlSugar.RollbackTran();
+                result  =  new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
             }
+
+            return result;
         }
 
         public async Task<Result> PostReqReqSampleTips(string country, string Area,string client)