Browse Source

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

leiy 1 year ago
parent
commit
cf292cc535

+ 29 - 0
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -5035,6 +5035,35 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, ex.Message));
             }
         }
+
+        /// <summary>
+        /// 获取三公详细所有城市
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        public IActionResult OpCarCityResult()
+        {
+            var jw = JsonView(false);
+            var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x=>x.IsDel == 0).Select(x => new
+            {
+                x.Id,
+                x.Country,
+                x.City,
+            }).ToList();
+
+            if (data.Count > 0)
+            {
+                jw = JsonView(true, "获取成功!", data);
+            }
+            else
+            {
+                jw.Msg = "城市数据未空!";
+                jw.Data = new string[0];
+            }
+
+            return Ok(jw);
+        }
+
         #endregion
 
         #region 团组成本

+ 115 - 21
OASystem/OASystem.Infrastructure/Repositories/Groups/CarTouristGuideGroundRepository.cs

@@ -1,5 +1,6 @@
 using Aspose.Words.Tables;
 using AutoMapper;
+using NPOI.SS.Formula.Functions;
 using NPOI.SS.UserModel;
 using NPOI.Util;
 using OASystem.Domain;
@@ -8,6 +9,7 @@ using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.Entities.Resource;
 using OASystem.Domain.ViewModels.Groups;
+using OASystem.Infrastructure.Repositories.System;
 using OASystem.Infrastructure.Tools;
 using SqlSugar.Extensions;
 using System.Collections.Generic;
@@ -19,12 +21,14 @@ namespace OASystem.Infrastructure.Repositories.Groups
     {
         private readonly IMapper _mapper;
         private readonly CheckBoxsRepository _checkRep;
+        private readonly SetDataRepository _setDataRep;
 
-        public CarTouristGuideGroundRepository(SqlSugarClient sqlSugar, IMapper mapper , CheckBoxsRepository checkRep)
+        public CarTouristGuideGroundRepository(SqlSugarClient sqlSugar, IMapper mapper , CheckBoxsRepository checkRep, SetDataRepository setDataRep)
             : base(sqlSugar)
         {
             _mapper = mapper;
             _checkRep = checkRep;
+            _setDataRep = setDataRep;
         }
 
         public async Task<Result> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
@@ -600,32 +604,122 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     Count = item.Count,
                 }).ToList();
 
-                //车超时费
-                //餐费和三公经费那个表做完匹配后也放进超支表里
-                DataTable tb = new DataTable();
-                tb.Columns.Add("日期", typeof(DateTime));
-                tb.Columns.Add("费用", typeof(decimal));
-                var addsTourClientList = new List<Grp_TourClientList>();
-                var carExtraList = carTouristList.Where(x => x.SId == 982).ToList();
-                var mealPriceList = carTouristList.Where(x => x.SId == 93 || x.SId == 988 || x.SId == 989).GroupBy(x => x.DatePrice).ToList();
-                mealPriceList.ForEach(x =>
+                if (carTouristList.Count > 0)
                 {
-                    var row = tb.NewRow();
-                    row["日期"] = x.Key;
-                    row["费用"] = x.Sum(x => x.Price);
-                });
-                //限制只能选择地区
+                    //#region load
 
-                //三公费用
-                var cityPrice = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x =>              
-                    !string.IsNullOrEmpty(x.City) && x.City.Contains("")
-                ).ToList(); 
 
-                //超支费用表
+                    ////车超时费
+                    ////餐费和三公经费那个表做完匹配后也放进超支表里
+                    //DataTable tb = new DataTable();
+                    //tb.Columns.Add("日期", typeof(DateTime));
+                    //tb.Columns.Add("费用", typeof(decimal));
+                    //tb.Columns.Add("币种", typeof(string));
+                    //var addsTourClientList = new List<Grp_TourClientList>();
+                    //var carExtraList = carTouristList.Where(x => x.SId == 982).ToList();
+                    //var mealPriceList = carTouristList.Where(x => x.SId == 93 || x.SId == 988 || x.SId == 989).GroupBy(x => x.DatePrice).ToList();
+                    //mealPriceList.ForEach(x =>
+                    //{
+                    //    var row = tb.NewRow();
+                    //    row["日期"] = x.Key;
+                    //    row["费用"] = x.Sum(x => x.Price * x.Count);
+                    //    row["币种"] = x.FirstOrDefault()?.Currency;
+                    //    tb.Rows.Add(row);
+                    //});
+
+                    ////限制只能选择地区
+
+
+                    ////三公费用
+                    //var cityPrice = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x =>
+                    //    !string.IsNullOrEmpty(x.City) && x.City.Contains("")
+                    //).First();
+
+                    ////超支费用表(数据添加)  Fin_GroupExtraCost
+                    //List<Fin_GroupExtraCost> groupExtraCostsArr = new List<Fin_GroupExtraCost>();
+
+                    ////币种
+                    //var currOpResult = await _setDataRep.PostCurrencyByDiid(carTouristList[0].DiId, 79, carTouristList[0].Currency);
+                    //var currOp = currOpResult.Code == 0 ? (currOpResult.Data as CurrencyInfo) == null ? 1 : (currOpResult.Data as CurrencyInfo).Rate : 1;
+                    //var cityCurrResult = await _setDataRep.PostCurrencyByDiid(carTouristList[0].DiId, 79, cityPrice.Currency);
+                    //var cityCurr = cityCurrResult.Code == 0 ? (cityCurrResult.Data as CurrencyInfo) == null ? 1 : (cityCurrResult.Data as CurrencyInfo).Rate : 1;
+                    //var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId);
+
+                    //if (di == null)
+                    //{
+                    //    result.Code = -1;
+                    //    result.Msg = "无该团组信息!";
+                    //    return result;
+                    //}
+
+
+                    //if (carExtraList.Count > 0)
+                    //{
+                    //    foreach (var item in carExtraList)
+                    //    {
+                    //        groupExtraCostsArr.Add(new Fin_GroupExtraCost
+                    //        {
+                    //            Price = item.Price * item.Count,
+                    //            CreateTime = DateTime.Now,
+                    //            CreateUserId = dto.CreateUserId,
+                    //            Coefficient = 1,
+                    //            DiId = dto.DiId,
+                    //            PriceCurrency = item.Currency,
+                    //            PriceName = di.TeamName + "车超时费(地接导入)",
+                    //            PriceType = 1050,
+                    //            PriceDt = item.DatePrice.ObjToDate(),
+                    //        });
+                    //    }
+                    //}
+
+
+                    //if (tb.Rows.Count > 0)
+                    //{
+                    //    foreach (DataRow item in tb.Rows)
+                    //    {
+                    //        decimal foodCost = 1;
+                    //        if (!decimal.TryParse(cityPrice.FoodCost, out foodCost))
+                    //        {
+                    //            //三公费用 ( 城市餐费用有问题! )
+                    //        }
 
+                    //        var price = Convert.ToDecimal(item["费用"]);
+                    //        if (item["币种"].ToString() != cityPrice.Currency.ToString()) //币种不相同
+                    //        {
+                    //            //全部转换为rmb;
+                    //            item["费用"] = price * currOp;
+                    //            cityPrice.FoodCost = (foodCost * cityCurr).ToString("F2");
 
+                    //            item["币种"] = "836";
+                    //            cityPrice.Currency = 836;
+                    //        }
 
-                //超支费用
+                    //        if (price > foodCost)
+                    //        {
+                    //            //每天费用大于三公费用
+                    //            groupExtraCostsArr.Add(new Fin_GroupExtraCost
+                    //            {
+                    //                Price = price - foodCost,
+                    //                CreateTime = DateTime.Now,
+                    //                CreateUserId = dto.CreateUserId,
+                    //                Coefficient = 1,
+                    //                DiId = dto.DiId,
+                    //                PriceCurrency = cityPrice.Currency,
+                    //                PriceName = di.TeamName + "餐费(地接导入)",
+                    //                PriceType = 1049,
+                    //                PriceDt = Convert.ToDateTime(item["日期"]),
+                    //            });
+
+                    //        }
+                    //    }
+                    //}
+
+                    //if (groupExtraCostsArr.Count > 0)
+                    //{
+                    //    _sqlSugar.Insertable<Fin_GroupExtraCost>(groupExtraCostsArr);
+                    //}
+                    //#endregion
+                }
 
 
                 foreach (var item in carTouristList)