using AutoMapper; using OASystem.Domain.Entities.Groups; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OASystem.Infrastructure.Repositories.Groups { public class GroupCostParameterRepository : BaseRepository { public GroupCostParameterRepository(SqlSugarClient sqlSugar) : base(sqlSugar) { } public List GetGroupCostParameterListByDiid(int diid) { return Query(x=>x.DiId == diid).ToList(); } public Grp_GroupCostParameter GetGroupCostParameterMainByDiid(int diid) { return Query(x => x.DiId == diid).First(x => x.CostType == "A"); } public async Task UpdateIsShareById(int id,int IsShare) { return await UpdateAsync(x => x.Id == id, x=>new Grp_GroupCostParameter { IsShare = IsShare }); } public async Task DeleteGroupCostParameterListByDiid(int diid) { return await SoftDeleteAsync(x=>x.DiId == diid); } public async Task SaveAsync(List List,int Userid, int diid) { bool isTrue = false; try { BeginTran(); isTrue = await DeleteGroupCostParameterListByDiid(diid); if (List.Count > 0) { List.ForEach(x => { x.CreateUserId = Userid; x.CreateTime = DateTime.Now; }); isTrue = Adds(List) > 0; } CommitTran(); } catch (Exception ex) { RollbackTran(); isTrue = false; } return isTrue; } public object GetBaoPi(int diid) { List dynamics = new List(); try { Grp_EnterExitCost eec = _sqlSugar.Queryable().First(x => x.DiId == diid); if (eec != null) { var AirJJ = new { Type = "JJC", Price = eec.AirJJ }; dynamics.Add(AirJJ); var AirGW = new { Type = "GWC", Price = eec.AirGW }; dynamics.Add(AirGW); List dac1 = _sqlSugar.Queryable().Where(x => x.DiId == diid && x.Type == 1 && x.NationalTravelFeeId > 0).ToList(); //酒店费用 List dac2 = _sqlSugar.Queryable().Where(x => x.DiId == diid && x.Type == 2 && x.NationalTravelFeeId > 0).ToList(); //餐费用 List dac3 = (from item in _sqlSugar.Queryable() //公杂费用 where item.DiId == diid && item.Type == 3 && item.NationalTravelFeeId > 0 select item).ToList(); decimal SumHotel = 0; decimal SumMeals = 0; decimal SumGongZa = 0; List hotelList = new List(); List checkString = new List(); if (dac1.Count != 0)//酒店费用 { for (int i = 0; i < dac1.Count; i++) { if (!string.IsNullOrWhiteSpace(dac1[i].Place)) { if (!checkString.Contains(dac1[i].Place)) { var hotelData = new { CountryOrCity = dac1[i].Place, Price = dac1[i].SubTotal }; hotelList.Add(hotelData); checkString.Add(dac1[i].Place); } } SumHotel += dac1[i].SubTotal; } } hotelList = hotelList.Distinct().ToList(); List MealsList = new List(); if (dac2.Count != 0) //餐费用 { for (int i = 0; i < dac2.Count; i++) { if (checkString.Contains(dac2[i].Place)) { var mealsData = new { CountryOrCity = dac2[i].Place, Price = dac2[i].SubTotal }; MealsList.Add(mealsData); } SumMeals += dac2[i].SubTotal; } } MealsList = MealsList.Distinct().ToList(); List GongZaList = new List(); if (dac3.Count != 0) //公杂费用 { for (int i = 0; i < dac3.Count; i++) { if (checkString.Contains(dac3[i].Place)) { var gongZaData = new { CountryOrCity = dac3[i].Place, Price = dac3[i].SubTotal }; GongZaList.Add(gongZaData); } SumGongZa += dac3[i].SubTotal; } } GongZaList = GongZaList.Distinct().ToList(); //签证 var Visa = new { Type = "Visa", Price = eec.Visa, Desc = eec.VisaRemark }; dynamics.Add(Visa); //核酸检测费 var HeSuan = new { Type = "HeSuan", Price = eec.HeSuan //元/人 }; dynamics.Add(HeSuan); //保险费 var Insurance = new { Type = "Insurance", Price = eec.Safe //元/人 }; dynamics.Add(Insurance); // 伙食费 var Meals = new { Type = "Meals", Content = MealsList }; dynamics.Add(Meals); // 酒店费用 var Hotel = new { Type = "Hotel", Content = hotelList }; dynamics.Add(Hotel); // 公杂费用 var GongZa = new { Type = "GongZa", Content = GongZaList }; dynamics.Add(GongZa); decimal AirJJCTotal = 0; decimal AirGWCTotal = 0; //境内费用(其他费用)选择框 if (eec.ChoiceOne == 1) { AirJJCTotal += Math.Round((eec.InsidePay), 2); AirGWCTotal += Math.Round((eec.InsidePay), 2); } //国际旅费合计选择框 if (eec.ChoiceTwo == 1) { if (eec.AirJJC_Checked == 1) AirJJCTotal += Math.Round((eec.OutsideJJPay), 2); if (eec.AirGWC_Checked == 1) AirGWCTotal += Math.Round((eec.OutsaideGWPay), 2); } //住宿费合计选择框 if (eec.ChoiceThree == 1) { AirJJCTotal += Math.Round(SumHotel, 2); AirGWCTotal += Math.Round(SumHotel, 2); } //伙食费合计选择框 if (eec.ChoiceFour == 1) { AirJJCTotal += Math.Round(SumMeals, 2); AirGWCTotal += Math.Round(SumMeals, 2); } //公杂费合计选择框 if (eec.ChoiceFour == 1) { AirJJCTotal += Math.Round(SumGongZa, 2); AirGWCTotal += Math.Round(SumGongZa, 2); } // 报批总报价 - 经济舱 var SumAirJJC = new { Type = "SumAirJJC", Price = AirJJCTotal }; dynamics.Add(SumAirJJC); //报批总报价 - 公务舱 var SumAirGWC = new { Type = "SumAirGWC", Price = AirGWCTotal }; dynamics.Add(SumAirGWC); } } catch (Exception) { dynamics = new List(); } return dynamics; } } }