1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402 |
- using Aspose.Words.Tables;
- using AutoMapper;
- using NPOI.SS.Formula.Functions;
- using NPOI.SS.UserModel;
- using NPOI.Util;
- using OASystem.Domain;
- using OASystem.Domain.Dtos.Financial;
- using OASystem.Domain.Dtos.Groups;
- using OASystem.Domain.Entities.Financial;
- using OASystem.Domain.Entities.Groups;
- using OASystem.Domain.Entities.Resource;
- using OASystem.Domain.ViewModels.Groups;
- using OASystem.Infrastructure.Repositories.Financial;
- using OASystem.Infrastructure.Repositories.System;
- using OASystem.Infrastructure.Tools;
- using SqlSugar.Extensions;
- using System.Collections.Generic;
- using System.Reflection;
- namespace OASystem.Infrastructure.Repositories.Groups
- {
- public class CarTouristGuideGroundRepository : BaseRepository<Grp_CarTouristGuideGroundReservations, Grp_CarTouristGuideGroundReservationsContent>
- {
- private readonly IMapper _mapper;
- private readonly CheckBoxsRepository _checkRep;
- private readonly SetDataRepository _setDataRep;
- private readonly DailyFeePaymentRepository _daiRep;
- private readonly GroupCostParameterRepository _groupCostParameterRepository;
- public CarTouristGuideGroundRepository(SqlSugarClient sqlSugar, IMapper mapper, CheckBoxsRepository checkRep, SetDataRepository setDataRep, DailyFeePaymentRepository daiRep, GroupCostParameterRepository groupCostParameterRepository)
- : base(sqlSugar)
- {
- _mapper = mapper;
- _checkRep = checkRep;
- _setDataRep = setDataRep;
- _daiRep = daiRep;
- _groupCostParameterRepository = groupCostParameterRepository;
- }
- public async Task<Result> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
- {
- Result result = new Result() { Code = -2, Msg = "未知错误" };
- BeginTran();
- try
- {
- int id = 0;
- Grp_CarTouristGuideGroundReservations grp_CarTouristGuide = _mapper.Map<Grp_CarTouristGuideGroundReservations>(dto);
- if (dto.Status == 1)
- {
- Grp_CarTouristGuideGroundReservations grp_CarTouristGuideGround = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().First(a => a.IsDel == 0 && a.Area == dto.Area && a.BusName == dto.BusName && a.ServiceGuide == dto.ServiceGuide && a.DiId == dto.DiId && a.BusTel == dto.BusTel && a.ServiceTel == dto.ServiceTel && a.PriceName == dto.PriceName);
- if (grp_CarTouristGuideGround != null)
- {
- return result = new Result() { Code = -1, Msg = "该笔费用已存在,请勿重复添加!" };
- }
- else
- {
- id = await AddAsyncReturnId(grp_CarTouristGuide);
- if (id == 0)
- {
- RollbackTran();
- result = new Result() { Code = -1, Msg = "添加失败,请稍后重试!" };
- }
- else
- {
- result = new Result() { Code = 0, Msg = "添加成功!" };
- }
- }
- }
- else if (dto.Status == 2)
- {
- bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_CarTouristGuideGroundReservations
- {
- Area = grp_CarTouristGuide.Area,
- ServiceCompany = grp_CarTouristGuide.ServiceCompany,
- ServiceGuide = grp_CarTouristGuide.ServiceGuide,
- ServiceTel = grp_CarTouristGuide.ServiceTel,
- BusName = grp_CarTouristGuide.BusName,
- BusDescription = grp_CarTouristGuide.BusDescription,
- BusTel = grp_CarTouristGuide.BusTel,
- ServiceStartTime = grp_CarTouristGuide.ServiceStartTime,
- ServiceEndTime = grp_CarTouristGuide.ServiceEndTime,
- ServiceDescription = grp_CarTouristGuide.ServiceDescription,
- QuotedPriceExplanation = grp_CarTouristGuide.QuotedPriceExplanation,
- OrbitalPrivateTransfer = grp_CarTouristGuide.OrbitalPrivateTransfer,
- Remark = grp_CarTouristGuide.Remark,
- PriceType = grp_CarTouristGuide.PriceType,
- PriceName = grp_CarTouristGuide.PriceName,
- });
- if (res)
- {
- id = dto.Id;
- result = new Result() { Code = 0, Msg = "修改成功!" };
- }
- else
- {
- RollbackTran();
- result = new Result() { Code = -1, Msg = "修改失败,请稍后重试!" };
- }
- }
- if (id != 0)
- {
- Res_LocalGuideData _LocalGuideDataCar = _sqlSugar.Queryable<Res_LocalGuideData>().First(a => a.UnitName == dto.BusName && a.ContactTel == dto.BusTel && a.IsDel == 0);
- if (_LocalGuideDataCar == null)
- {
- Res_LocalGuideData res_LocalGuideCar = new Res_LocalGuideData();
- res_LocalGuideCar.UnitName = dto.BusName;
- res_LocalGuideCar.ContactTel = dto.BusTel;
- res_LocalGuideCar.CreateUserId = dto.CreateUserId;
- int cId = await _sqlSugar.Insertable(res_LocalGuideCar).ExecuteReturnIdentityAsync();
- }
- Res_LocalGuideData _LocalGuideDataService = _sqlSugar.Queryable<Res_LocalGuideData>().First(a => a.UnitName == dto.ServiceCompany && a.ContactTel == dto.ServiceTel && a.IsDel == 0);
- if (_LocalGuideDataService == null)
- {
- Res_LocalGuideData res_LocalGuideService = new Res_LocalGuideData();
- res_LocalGuideService.UnitName = dto.ServiceCompany;
- res_LocalGuideService.ContactTel = dto.ServiceTel;
- res_LocalGuideService.Contact = dto.ServiceTel;
- res_LocalGuideService.CreateUserId = dto.CreateUserId;
- int cId = await _sqlSugar.Insertable(res_LocalGuideService).ExecuteReturnIdentityAsync();
- }
- }
- CommitTran();
- }
- catch (Exception ex)
- {
- result = new Result() { Code = -2, Msg = "未知错误" + ex.Message };
- }
- return result;
- }
- public Result CarTouristGuideGroundContent(CarTouristGuideGroundContentDto dto)
- {
- Result result = new Result() { Code = -2, Msg = "未知错误" };
- try
- {
- DateTime start = new DateTime();
- DateTime end = new DateTime();
- Grp_CarTouristGuideGroundReservations grpCarOp = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().First(x => x.Id == dto.Id);
- if (!DateTime.TryParse(grpCarOp?.ServiceStartTime, out start))
- {
- result.Msg = "服务开始时间不存在!";
- result.Code = -1;
- return result;
- }
- if (!DateTime.TryParse(grpCarOp?.ServiceEndTime, out end))
- {
- result.Msg = "服务结束时间不存在!";
- result.Code = -1;
- return result;
- }
- TimeSpan ts = end - start;
- int day = ts.Days;
- List<Grp_GroupsTaskAssignment> grp_GroupsTaskAssignment = Query<Grp_GroupsTaskAssignment>(a => a.IsDel == 0 && a.UId == dto.UserId && a.CTId == 79).ToList();
- string DiId = "0";
- foreach (var item in grp_GroupsTaskAssignment)
- {
- DiId += item.DIId + ",";
- }
- if (DiId != "0")
- {
- DiId = DiId.Substring(0, DiId.Length - 1);
- }
- string sql = string.Format(@"select * from Grp_DelegationInfo where Id in({0}) and IsDel={1}", DiId, 0);
-
- List<Grp_DelegationInfo> _Delegations = _sqlSugar.SqlQueryable<Grp_DelegationInfo>(sql).ToList();
- List<ShareGroupInfoIIView> grp_Delegations = _mapper.Map<List<ShareGroupInfoIIView>>(_Delegations);
-
- List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
-
- List<Sys_SetData> TableInitialization = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 17 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _TableInitialization = _mapper.Map<List<SetDataInfoView>>(TableInitialization);
- List<Sys_SetData> ssd = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.STid == 78).ToList();
- List<SetDataInfoView> ssdv = _mapper.Map<List<Sys_SetData>, List<SetDataInfoView>>(ssd);
- List<Grp_CarTouristGuideGroundReservationsContent> grp_CarTouristsContent = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.IsDel == 0 && a.CTGGRId == dto.Id).ToList();
- List<CarTouristGuideGroundReservationsContentView> carTouristGuides = _mapper.Map<List<CarTouristGuideGroundReservationsContentView>>(grp_CarTouristsContent);
- TableInitialization.RemoveAll(x => x.Id == 1070 || x.Id == 1071);
- var weiKuanArr = _TableInitialization.Where(x => x.Id == 1070 || x.Id == 1071).ToList();
- var weiKuanResultArr = carTouristGuides.Where(x => x.SId == 1070 || x.SId == 1071).ToList();
- carTouristGuides.RemoveAll(x => x.SId == 1070 || x.SId == 1071);
- foreach (var itemSt in TableInitialization)
- {
- var findResult = carTouristGuides.Find(x => x.SId == itemSt.Id);
- if (findResult == null)
- {
- carTouristGuides.Add(new CarTouristGuideGroundReservationsContentView
- {
- SId = itemSt.Id,
- Count = 1,
- SidName = itemSt.Name,
- });
- }
- }
- var groupResult = carTouristGuides.GroupBy(x => x.SId).ToDictionary(x => x.Key, x => x.ToList());
- foreach (var item in groupResult.Keys)
- {
- #region 倒推初始化逻辑
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #endregion
- var startForTime = start;
- var dayResult = new List<CarTouristGuideGroundReservationsContentView>();
- for (var i = 0; i <= day; i++)
- {
- dayResult.Add(new CarTouristGuideGroundReservationsContentView
- {
- Count = 1,
- DatePrice = startForTime,
- SId = item,
- });
- startForTime = startForTime.AddDays(1);
- }
- if (groupResult[item].Count != day)
- {
- for (var m = 0; m < groupResult[item].Count; m++)
- {
- for (var m1 = 0; m1 < dayResult.Count; m1++)
- {
- if (groupResult[item][m].DatePrice == dayResult[m1].DatePrice)
- {
- dayResult[m1] = groupResult[item][m];
- }
- }
- }
- }
- else
- {
- groupResult[item] = groupResult[item].OrderBy(x => x.DatePrice).ToList();
- if (groupResult[item][0].DatePrice == dayResult[0].DatePrice && groupResult[item][day - 1].DatePrice == dayResult[day - 1].DatePrice)
- {
- dayResult = groupResult[item];
- }
- else
- {
- for (var m = 0; m < groupResult[item].Count; m++)
- {
- for (var m1 = 0; m1 < dayResult.Count; m1++)
- {
- if (groupResult[item][m].DatePrice == dayResult[m1].DatePrice)
- {
- dayResult[m1] = groupResult[item][m];
- }
- }
- }
- }
- }
- groupResult[item] = dayResult;
- }
- carTouristGuides = groupResult.Values.SelectMany(sublist => sublist).OrderBy(x => x.SId).ThenBy(x => x.DatePrice).ToList();
- foreach (var item in carTouristGuides.Where(x => string.IsNullOrWhiteSpace(x.SidName)).ToList())
- {
- item.SidName = TableInitialization.Find(x => x.Id == item.SId)?.Name;
- }
- Grp_CreditCardPayment CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79);
- CarTouristCreditCardPaymentView _CreditCardPayment = _mapper.Map<CarTouristCreditCardPaymentView>(CreditCardPayment);
- if (_CreditCardPayment != null)
- {
- _CreditCardPayment.PayName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == _CreditCardPayment.PayDId).Name;
- _CreditCardPayment.PaymentCurrencyName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == _CreditCardPayment.PaymentCurrency).Name;
- if (_CreditCardPayment.OrbitalPrivateTransfer == 0) _CreditCardPayment.OrbitalPrivateTransferStr = "公转";
- else _CreditCardPayment.OrbitalPrivateTransferStr = "私转";
- }
- Dictionary<string, string> soureDic = new Dictionary<string, string>()
- {
- {"车费", "VF"},
- {"导游费", "T/G S"},
- {"客户午餐费用" , "L"},
- {"导游景点费" , "T/G EF"},
- {"导游小费" , "T/G T"},
-
- {"司机小费", "DRV T"},
- {"司机餐补", "C/F M"},
- {"车超时费", "C/F OF"},
- {"导游餐补", "T/G M"},
- {"导游房补", "T/G A"},
- {"导游交通", "T/G TF"},
- {"客户早餐费用", "B"},
- {"客户晚餐费用", "D"},
- {"景点门票费", "EF"},
- {"饮料/零食/水果", "B/R/F"},
- {"翻译费", "I/F"},
- };
- var checkedItem = new List<string>();
- var checkedItemId = new List<int>();
- var isSaveCheck = false;
- if (string.IsNullOrWhiteSpace(grpCarOp.SelectCheck))
- {
-
- var checkTopArr = _checkRep.GetCheckBoxsByDiid(grpCarOp.DiId);
- if (true)
- {
- var FindTop = checkTopArr.Find(x => x.CbType == "Top");
- if (FindTop != null)
- {
- var selectName = FindTop.CbValues.Split(',').ToList<string>();
- foreach (var soureKey in soureDic.Keys)
- {
- var find = selectName.Find(x => x == soureDic[soureKey]);
- if (find == null)
- {
- var Lindex = carTouristGuides.FindIndex(x => x.SidName == soureKey);
-
- }
- else
- {
- checkedItem.Add(soureKey);
- checkedItemId.Add(_TableInitialization.Find(x => x.Name == soureKey)!.Id);
- }
- }
- }
- else
- {
- checkedItem = _TableInitialization.Select(x => x.Name).ToList();
- checkedItemId.AddRange(_TableInitialization.Select(x => x.Id).ToList());
- }
- }
- }
- else
- {
- isSaveCheck = true;
- var checkedItemThis = grpCarOp.SelectCheck.Split(",").ToList<string>();
- int number = 0;
- foreach (var item in checkedItemThis)
- {
- if (!int.TryParse(item, out number))
- {
- checkedItemId.Add(_TableInitialization.Find(x => x.Name == item)!.Id);
- checkedItem.Add(item);
- }
- else
- {
- checkedItemId.Add(number);
- checkedItem.Add(_TableInitialization.Find(x => x.Id == int.Parse(item))!.Name);
- }
- }
- }
- if (grpCarOp.PriceType == 1062)
- {
- if (isSaveCheck)
- {
- checkedItemId.AddRange(weiKuanArr.Select(x => x.Id).ToList());
- checkedItem.AddRange(weiKuanArr.Select(x => x.Name).ToList());
- checkedItemId = checkedItemId.Distinct().ToList();
- checkedItem = checkedItem.Distinct().ToList();
- }
- else
- {
- checkedItemId = weiKuanArr.Select(x => x.Id).ToList();
- checkedItem = weiKuanArr.Select(x => x.Name).ToList();
- }
-
- var weiPrice = weiKuanResultArr.Find(x => x.SId == 1070);
- if (weiPrice != null)
- {
- weiPrice.SidName = "尾款金额";
- }
- var weiOther = weiKuanResultArr.Find(x => x.SId == 1071);
- if (weiOther != null)
- {
- weiOther.SidName = "其他额外费用";
- }
- carTouristGuides.Add(weiPrice ??= new CarTouristGuideGroundReservationsContentView
- {
- Count = 1,
- DatePrice = DateTime.Now,
- Price = 0,
- PriceContent = "",
- SId = 1070,
- SidName = "尾款金额",
- Units = 0,
- });
- carTouristGuides.Add(weiOther ??= new CarTouristGuideGroundReservationsContentView
- {
- Count = 1,
- DatePrice = DateTime.Now,
- Price = 0,
- PriceContent = "",
- SId = 1071,
- SidName = "其他额外费用",
- Units = 0,
- });
- }
- else
- {
- _TableInitialization.RemoveAll(x => x.Id == 1070 || x.Id == 1071);
- }
- if (dto.PortType == 1)
- {
- var data = new
- {
- Payment = _Payment,
- Delegations = grp_Delegations,
- carTouristGuides = carTouristGuides,
- CreditCardPayment = _CreditCardPayment,
- start,
- end,
- ssdv,
- checkedItem,
- existItem = _TableInitialization.Select(x => x.Name).ToList(),
- };
- return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
- }
- else if (dto.PortType == 2)
- {
- var data = new
- {
- Payment = _Payment,
- TableInitialization = _TableInitialization,
- carTouristGuides = carTouristGuides,
- CreditCardPayment = _CreditCardPayment ??= new CarTouristCreditCardPaymentView(),
- ssdv,
- checkedItemId
- };
- return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
- }
- return result = new Result() { Code = -1, Msg = "请传入有效portType" };
- }
- catch (Exception ex)
- {
- return result = new Result() { Code = -2, Msg = "未知错误" };
- }
- }
-
-
-
-
-
- public Result OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
- {
- Result result = new Result() { Code = -2, Msg = "未知错误" };
- try
- {
- List<Grp_CarTouristGuideGroundReservationsContent> grp_CarTouristsContent = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.IsDel == 0 && a.CTGGRId == dto.Id).ToList();
- List<CarTouristGuideGroundReservationsContentView> carTouristGuides = _mapper.Map<List<CarTouristGuideGroundReservationsContentView>>(grp_CarTouristsContent);
- foreach (var item in carTouristGuides)
- {
- item.SidName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == item.SId).Name;
- }
- Grp_CreditCardPayment CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79);
- CarTouristCreditCardPaymentView _CreditCardPayment = _mapper.Map<CarTouristCreditCardPaymentView>(CreditCardPayment);
- if (_CreditCardPayment != null)
- {
- _CreditCardPayment.PayName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == _CreditCardPayment.PayDId).Name;
- _CreditCardPayment.PaymentCurrencyName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == _CreditCardPayment.PaymentCurrency).Name;
- if (_CreditCardPayment.OrbitalPrivateTransfer == 0) _CreditCardPayment.OrbitalPrivateTransferStr = "公转";
- else _CreditCardPayment.OrbitalPrivateTransferStr = "私转";
- }
- var data = new
- {
- CarTouristsContent = carTouristGuides,
- CreditCardPayment = _CreditCardPayment,
- };
- return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
- }
- catch (Exception ex)
- {
- return result = new Result() { Code = -2, Msg = "未知错误(" + ex.Message + ")" };
- }
- }
-
-
-
-
-
- public async Task<Result> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
- {
- Result result = new Result() { Code = -2, Msg = "未知错误" };
- if (dto.PortType == 0 || string.IsNullOrWhiteSpace(dto.PortType.ToString()))
- {
- return result = new Result() { Code = -1, Msg = "请传入PortType参数,请求端口分类 1 Web 2 Android 3 IOS" };
- }
- try
- {
- #region SQL条件拼接
- string sqlWhere = string.Empty;
- sqlWhere += string.Format(@"And t.DIId={0} and t.isdel={1}", dto.DiId, 0);
- string UserId = "";
- List<Grp_GroupsTaskAssignment> gtaUIdList = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(a => a.DIId == dto.DiId && a.IsDel == 0 && a.CTId == 79).ToList();
- foreach (Grp_GroupsTaskAssignment gta in gtaUIdList)
- UserId += gta.UId + ",";
- if (!string.IsNullOrWhiteSpace(UserId))
- {
- UserId = UserId.Substring(0, UserId.Length - 1);
- }
- else
- {
- UserId = "0";
- }
- sqlWhere += string.Format(@" And t.CreateUserId in ({0})", UserId);
- if (dto.IsPaySign != -1)
- {
- sqlWhere += string.Format(@" And c.IsPay = {0} ", dto.IsPaySign);
- }
- if (!string.IsNullOrEmpty(sqlWhere.Trim()))
- {
- Regex r = new Regex("And");
- sqlWhere = r.Replace(sqlWhere, "Where", 1);
- }
- #endregion
- int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
- int endIndex = startIndex + dto.PageSize - 1;
- Regex regex = new Regex("^[\u4e00-\u9fa5]*$");
-
- var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
- {
- x.Id,
- x.Country,
- x.City,
- }).ToList();
- if (dto.PortType == 1)
- {
- string sql = string.Format(@"select t.*,(select Name from Sys_SetData where isdel = 0 and id = t.priceType) as 'priceTypeStr',s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage,c.PayMoney,c.PayDid,c.IsPay from
- Grp_CarTouristGuideGroundReservations t
- left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id and c.isdel=0
- left Join Sys_SetData s on s.Id=c.PaymentCurrency {0}
- order by c.IsAuditGM,c.PayPercentage desc", sqlWhere);
- List<Grp_CarTouristGuideGroundView> infoViews = _sqlSugar.SqlQueryable<Grp_CarTouristGuideGroundView>(sql).ToList();
- foreach (var item in infoViews)
- {
- if (!regex.IsMatch(item.Area))
- {
- for (int i = 0; i < data.Count; i++)
- {
- if (item.Area.Equals(data[i].Id.ToString()))
- {
- item.Area = string.Format("{0} {1}", data[i].Country, data[i].City);
- }
- }
- }
- if (string.IsNullOrWhiteSpace(item.priceTypeStr))
- {
- item.priceTypeStr = "未选择!";
- }
- if (item.OrbitalPrivateTransfer == 0) item.OrbitalPrivateTransferStr = "公转";
- else if (item.OrbitalPrivateTransfer == 1) item.OrbitalPrivateTransferStr = "私转";
- item.ServiceStartTime = Convert.ToDateTime(item.ServiceStartTime).ToString("yyyy-MM-dd");
- item.ServiceEndTime = Convert.ToDateTime(item.ServiceEndTime).ToString("yyyy-MM-dd");
- item.ServiceQuotedPrice = item.PayMoney;
- item.PayThenMoney = Math.Round(item.PayPercentage / 100 * item.ServiceQuotedPrice, 2);
- item.RemainingBalance = Math.Round(item.ServiceQuotedPrice - item.PayPercentage / 100 * item.ServiceQuotedPrice, 2);
- if (item.IsAuditGM == 0) item.IsAuditGMStr = "未审核";
- else if (item.IsAuditGM == 1) item.IsAuditGMStr = "已通过";
- else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
- else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
- Sys_SetData s = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == item.PayDid);
- if (s != null)
- {
- item.PayStrd = s.Name;
- }
- else item.PayStrd = "未选择";
- }
- return result = new Result() { Code = 0, Msg = "查询成功!", Data = infoViews };
- }
- else if (dto.PortType == 2 || dto.PortType == 3)
- {
- string sql = string.Format(@"Select * From (
- Select row_number() over (order by c.IsAuditGM,c.PayPercentage desc) as RowNumber,t.*,(select Name from Sys_SetData where isdel = 0 and id = t.priceType) as 'priceTypeStr',s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage,c.PayDid,c.PayMoney
- from
- Grp_CarTouristGuideGroundReservations t
- left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id and c.isdel=0
- left Join Sys_SetData s on s.Id=c.PaymentCurrency {0}
- ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
- List<Grp_CarTouristGuideGroundView> grp_CarTourists = _sqlSugar.SqlQueryable<Grp_CarTouristGuideGroundView>(sql).ToList();
- foreach (var item in grp_CarTourists)
- {
- if (!regex.IsMatch(item.Area))
- {
- for (int i = 0; i < data.Count; i++)
- {
- if (item.Area.Equals(data[i].Id.ToString()))
- {
- item.Area = string.Format("{0} {1}", data[i].Country, data[i].City);
- }
- }
- }
- if (string.IsNullOrWhiteSpace(item.priceTypeStr))
- {
- item.priceTypeStr = "未选择!";
- }
- if (item.OrbitalPrivateTransfer == 0) item.OrbitalPrivateTransferStr = "公转";
- else if (item.OrbitalPrivateTransfer == 1) item.OrbitalPrivateTransferStr = "私转";
- item.ServiceStartTime = Convert.ToDateTime(item.ServiceStartTime).ToString("yyyy-MM-dd");
- item.ServiceEndTime = Convert.ToDateTime(item.ServiceEndTime).ToString("yyyy-MM-dd");
- if (item.IsAuditGM == 0) item.IsAuditGMStr = "未审核";
- else if (item.IsAuditGM == 1) item.IsAuditGMStr = "已通过";
- else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
- else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
- item.ServiceQuotedPrice = item.PayMoney;
- item.PayThenMoney = Math.Round(item.PayPercentage / 100 * item.ServiceQuotedPrice, 2);
- item.RemainingBalance = Math.Round(item.ServiceQuotedPrice - item.PayPercentage / 100 * item.ServiceQuotedPrice, 2);
- Sys_SetData s = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == item.PayDid);
- if (s != null)
- {
- item.PayStrd = s.Name;
- }
- else item.PayStrd = "未选择";
- }
- string CountSql = string.Format(@"Select COUNT(1) as Count From (
- select t.*,s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage from
- Grp_CarTouristGuideGroundReservations t
- left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id and c.isdel=0
- left Join Sys_SetData s on s.Id=t.CId {0}
- ) temp ", sqlWhere);
- DataCount dataCount = _sqlSugar.SqlQueryable<DataCount>(CountSql).First();
- if (dataCount != null)
- {
- int count = dataCount.Count;
- float totalPage = (float)count / dto.PageSize;
- if (totalPage == 0) totalPage = 1;
- else totalPage = (int)Math.Ceiling((double)totalPage);
- ListViewBase<Grp_CarTouristGuideGroundView> rst = new ListViewBase<Grp_CarTouristGuideGroundView>();
- rst.DataList = grp_CarTourists;
- rst.DataCount = count;
- rst.CurrPageIndex = dto.PageIndex;
- rst.CurrPageSize = dto.PageSize;
- return result = new Result() { Code = 0, Msg = "查询成功!", Data = rst };
- }
- }
- }
- catch (Exception)
- {
- return result = new Result() { Code = -2, Msg = "未知错误" };
- }
- return result;
- }
-
-
-
-
-
- public async Task<Result> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
- {
- Result result = new Result() { Code = -2, Msg = "未知错误" };
- try
- {
- BeginTran();
- List<Grp_CarTouristGuideGroundReservationsContent> carTouristList = dto.OPContentList.Select(item => new Grp_CarTouristGuideGroundReservationsContent
- {
- 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();
- if (carTouristList.Count > 0)
- {
- #region load
-
-
-
- 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 && x.Price != 0).ToList();
- var mealPriceList = carTouristList.Where(x => (x.SId == 93 || x.SId == 988 || x.SId == 989) && x.Price != 0).GroupBy(x => x.DatePrice).ToList();
- var tgOvertime = carTouristList.Where(x => x.SId == 1059 && x.Price != 0 ).ToList();
-
- List<Grp_GroupCost> _GroupCosts = new List<Grp_GroupCost>();
- var _GroupCostParameters = _groupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.DiId);
- if (_GroupCostParameters != null && _GroupCostParameters.IsShare == 1)
- {
- _GroupCosts = _sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
- }
-
- if (_GroupCosts.Count > 0)
- {
- for (int i = 0; i < _GroupCosts.Count; i++)
- {
- if (string.IsNullOrEmpty(_GroupCosts[i].Date))
- {
- if (i > 0)
- {
- _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
- }
- }
- }
- var CostSoure = _GroupCosts.GroupBy(x => x.Date).ToList();
- _GroupCosts.Clear();
- foreach (var costSoure in CostSoure)
- {
- var cost = costSoure.ToList();
- cost[0].D = cost.Sum(x => x.D);
- cost[0].B = cost.Sum(x => x.B);
- cost[0].L = cost.Sum(x => x.L);
- _GroupCosts.Add(cost[0]);
- }
- }
- 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 opSingle = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().First(x => x.Id == dto.CTGGRId && x.IsDel == 0);
- var opSingleCityId = 0;
- Grp_NationalTravelFee cityPrice = null;
- string priceCity = string.Empty;
-
- if (int.TryParse(opSingle.Area, out opSingleCityId))
- {
- cityPrice = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x =>
- x.Id == opSingleCityId
- ).First();
- priceCity = cityPrice == null ? string.Empty :cityPrice.Country + cityPrice?.City;
- }
- else
- {
- cityPrice = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x =>
- !string.IsNullOrEmpty(x.City) && x.City.Contains(opSingle.Area)
- ).First();
- priceCity = opSingle.Area;
- }
-
- List<Fin_GroupExtraCost> groupExtraCostsArr = new List<Fin_GroupExtraCost>();
- var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
- 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,
- CreateTime = DateTime.Now,
- CreateUserId = dto.CreateUserId,
- Coefficient = 1,
- DiId = dto.DiId,
- PriceCurrency = item.Currency,
- PriceName = di.TeamName +"-"+ priceCity + "-" + "车超时费(地接导入)",
- PriceType = 1028,
- PriceDt = item.DatePrice.ObjToDate(),
- PriceSum = item.Price * item.Count,
- PriceCount = item.Count,
- FilePath = string.Empty,
- PriceDetailType = 1050,
- });
- }
- }
-
- if (tgOvertime.Count > 0)
- {
- foreach (var item in tgOvertime)
- {
- groupExtraCostsArr.Add(new Fin_GroupExtraCost
- {
- Price = item.Price,
- CreateTime = DateTime.Now,
- CreateUserId = dto.CreateUserId,
- Coefficient = 1,
- DiId = dto.DiId,
- PriceCurrency = item.Currency,
- PriceName = di.TeamName + "-" + priceCity + "-" + "导游超时费(地接导入)",
- PriceType = 1028,
- PriceDt = item.DatePrice.ObjToDate(),
- PriceSum = item.Price * item.Count,
- PriceCount = item.Count,
- FilePath = string.Empty,
- PriceDetailType = 1072,
- });
- }
- }
- if (_GroupCostParameters != null)
- {
-
- var currOpResult = await _setDataRep.PostCurrencyByDiid(dto.DiId, 79, carTouristList[0].Currency);
- var currOp = currOpResult.Code == 0 ? (currOpResult.Data as CurrencyInfo) == null ? 1 : (currOpResult.Data as CurrencyInfo)!.Rate : 1;
-
-
-
-
- var costCurr = _GroupCostParameters.Rate;
- if (tb.Rows.Count > 0)
- {
- foreach (DataRow item in tb.Rows)
- {
- var listTime = Convert.ToDateTime(item["日期"]);
- var costFliterArr = _GroupCosts.Where(x => DateTime.TryParse(x.Date, out DateTime costData)
- && costData.ToString("yyyy-MM-dd") == listTime.ToString("yyyy-MM-dd")).ToList();
-
- decimal foodCost = (costFliterArr.Sum(x=>x.D) + costFliterArr.Sum(x => x.L) + costFliterArr.Sum(x => x.B)) * di.VisitPNumber;
- var price = Convert.ToDecimal(item["费用"]);
- if (item["币种"].ToString() != _GroupCostParameters.Currency.ToString().Trim())
- {
- var a = item["币种"].ToString();
- var b = _GroupCostParameters.Currency.ToString().Trim();
-
- if (int.TryParse(a,out int a1))
- {
- a = _sqlSugar.Queryable<Sys_SetData>().First(x=>x.IsDel ==0 && x.Id == a1).Name;
- }
- if (int.TryParse(b, out int b1))
- {
- b = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == b1).Name;
- }
- if (a != b)
- {
-
- item["费用"] = price * currOp;
- foodCost = (foodCost * costCurr);
- item["币种"] = "836";
-
- }
- }
- if (price > foodCost)
- {
-
- groupExtraCostsArr.Add(new Fin_GroupExtraCost
- {
- Price = price - foodCost,
- CreateTime = DateTime.Now,
- CreateUserId = dto.CreateUserId,
- Coefficient = 1,
- DiId = dto.DiId,
- PriceCurrency = Convert.ToInt32(item["币种"]),
- PriceName = di.TeamName + "-" + priceCity + "-" + "餐费(地接导入)",
- PriceType = 1028,
- PriceDt = Convert.ToDateTime(item["日期"]),
- PriceSum = price - foodCost,
- PriceCount = 1,
- FilePath = string.Empty,
- PriceDetailType = 1049,
- });
- }
- }
- }
- }
- var isTrue = false;
- if (groupExtraCostsArr.Count > 0)
- {
- foreach (var item in groupExtraCostsArr)
- {
- var QuerySgin = _sqlSugar.Queryable<Fin_GroupExtraCost>().Where(x => x.PriceName == item.PriceName && x.DiId == item.DiId && x.IsDel == 0 && x.PriceDt.ToString("yyyy-MM-dd") == item.PriceDt.ToString("yyyy-MM-dd")).First();
- if (QuerySgin == null)
- {
- var resultThis = await PostGroupExtraCost_Operator(new Fin_GroupExtraCostDto_OP
- {
- coefficient = 1,
- createUser = dto.CreateUserId,
- currency = item.PriceCurrency,
- diId = item.DiId,
- editType = 1,
- filePath = string.Empty,
- payee = dto.Payee,
- PortType = 1,
- PriceCount = item.PriceCount,
- priceName = item.PriceName,
- remark = item.Remark,
- price = item.Price,
- priceDetailType = item.PriceDetailType,
- priceType = item.PriceType,
- PriceDt = item.PriceDt.ToString("yyyy-MM-dd"),
- payType = dto.PayDId,
- costSign = dto.OrbitalPrivateTransfer
- });
- isTrue = resultThis.Code == 0 ? true : false;
- }
- else
- {
- item.Id = QuerySgin.Id;
- var resultThis = await PostGroupExtraCost_Operator(new Fin_GroupExtraCostDto_OP
- {
- coefficient = 1,
- createUser = dto.CreateUserId,
- currency = item.PriceCurrency,
- diId = item.DiId,
- editType = 2,
- filePath = string.Empty,
- payee = dto.Payee,
- PortType = 1,
- PriceCount = item.PriceCount,
- priceName = item.PriceName,
- remark = item.Remark,
- price = item.Price,
- priceDetailType = item.PriceDetailType,
- priceType = item.PriceType,
- PriceDt = item.PriceDt.ToString("yyyy-MM-dd"),
- payType = dto.PayDId,
- costSign = dto.OrbitalPrivateTransfer,
- Id = item.Id,
- });
- isTrue = resultThis.Code == 0 ? true : false;
- }
- }
- }
- #endregion
- }
- foreach (var item in carTouristList)
- {
- Grp_CarTouristGuideGroundReservationsContent QueryData = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().First(a => a.SId == item.SId && a.Id == item.Id && a.DiId == item.DiId && a.IsDel == 0);
- if (QueryData == null)
- {
- int id = await _sqlSugar.Insertable(item).ExecuteReturnIdentityAsync();
- if (id == 0)
- {
- RollbackTran();
- return result = new Result() { Code = -2, Msg = "添加失败" };
- }
- }
- else
- {
- int CTable = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.Id == item.Id).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent
- {
- 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)
- {
- RollbackTran();
- return result = new Result() { Code = -1, Msg = "修改失败,请稍后重试!" };
- }
- }
- }
- Regex regex = new Regex("^[\u4e00-\u9fa5]{0,}$");
-
-
- 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]))
- {
- for (int j = 0; j < carTouristList.Count; j++)
- {
- if (int.Parse(dto.SelectCheck[i]) == carTouristList[j].SId)
- {
- c.PayMoney += carTouristList[j].Price * carTouristList[j].Count;
- }
- }
- }
- else
- {
- c.PayMoney = carTouristList.Sum(x => x.Price * x.Count);
- break;
- }
- }
- c.PayPercentage = dto.PayPercentage;
- c.ConsumptionDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- c.CTable = 79;
- c.CId = dto.CTGGRId;
- c.IsAuditGM = 0;
- c.PayDId = dto.PayDId;
- c.DIId = dto.DiId;
- c.OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer;
- c.Payee = dto.Payee;
- c.CreateUserId = dto.CreateUserId;
- if (c.PayDId == 72) c.IsPay = 1;
- else c.IsPay = 0;
- c.RMBPrice = c.PayMoney;
- c.DayRate = 1;
- #region 老汇率获取
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #endregion
- var rate = await _setDataRep.PostCurrencyByDiid(dto.DiId, 79 ,dto.Currency);
- if (rate.Code == 0)
- {
- var rateData = rate.Data as CurrencyInfo;
- if (rateData != null)
- {
- c.RMBPrice = c.PayMoney * rateData.Rate;
- c.DayRate = rateData.Rate;
- }
- }
- Grp_CreditCardPayment grp_CreditCard = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.CTGGRId && a.IsDel == 0 && a.CTable == 79 && a.DIId == dto.DiId);
- if (grp_CreditCard != null)
- {
- int CTable = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId).SetColumns(a => new Grp_CreditCardPayment
- {
- PaymentCurrency = c.PaymentCurrency,
- PayMoney = c.PayMoney,
- PayPercentage = c.PayPercentage,
- CTable = c.CTable,
- PayDId = c.PayDId,
- OrbitalPrivateTransfer = c.OrbitalPrivateTransfer,
- Payee = c.Payee,
- IsPay = c.IsPay,
- RMBPrice = c.RMBPrice,
- DayRate = c.DayRate,
- }).ExecuteCommandAsync();
- if (CTable == 0)
- {
- RollbackTran();
- return result = new Result() { Code = -2, Msg = "修改失败" };
- }
- }
- else
- {
- int id = await _sqlSugar.Insertable(c).ExecuteReturnIdentityAsync();
- if (id == 0)
- {
- RollbackTran();
- return result = new Result() { Code = -2, Msg = "添加失败" };
- }
- }
- int CarTouristGuideCTable = 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,
- ServiceQuotedPrice = c.PayMoney,
- OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer,
- SelectCheck = string.Join(',', dto.SelectCheck)
- }).ExecuteCommandAsync();
- if (CarTouristGuideCTable == 0)
- {
- RollbackTran();
- return result = new Result() { Code = -2, Msg = "修改失败" };
- }
- result = new Result() { Code = 0, Msg = "保存成功" };
- CommitTran();
- }
- catch (Exception ex)
- {
- RollbackTran();
- return result = new Result() { Code = -2, Msg = "未知错误" };
- }
- return result;
- }
-
-
-
-
-
-
- private async Task<Result> PostGroupExtraCost_Operator(Fin_GroupExtraCostDto_OP dto)
- {
- Result rt = new Result();
- #region 验证
- #endregion
- Fin_GroupExtraCost _entity = new Fin_GroupExtraCost();
- _entity.DiId = dto.diId;
- _entity.PriceName = dto.priceName;
- _entity.Price = dto.price;
- _entity.PriceCurrency = dto.currency;
- _entity.PriceType = dto.priceType;
- _entity.Coefficient = dto.coefficient;
- _entity.PriceDetailType = dto.priceDetailType;
- _entity.FilePath = dto.filePath;
- _entity.Remark = dto.remark;
- _entity.PriceCount = dto.PriceCount;
- _entity.PriceDt = DateTime.Parse(dto.PriceDt);
- _entity.PriceSum = dto.price * dto.PriceCount;
- _daiRep.BeginTran();
- if (dto.editType == 1)
- {
- _entity.CreateUserId = dto.createUser;
- _entity.CreateTime = DateTime.Now;
- _entity.IsDel = 0;
- int returnId = await _daiRep.AddAsyncReturnId<Fin_GroupExtraCost>(_entity);
- if (returnId > 0)
- {
- dto.Id = returnId;
- }
- }
- else if (dto.editType == 2)
- {
- bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
- {
- PriceName = dto.priceName,
- Price = dto.price,
- PriceCurrency = dto.currency,
- PriceType = dto.priceType,
- PriceDetailType = dto.priceDetailType,
- Coefficient = dto.coefficient,
- FilePath = dto.filePath,
- Remark = dto.remark,
- PriceCount = dto.PriceCount,
- PriceDt = _entity.PriceDt,
- PriceSum = _entity.PriceSum
- });
- if (!res)
- {
- _daiRep.RollbackTran();
-
- rt.Msg = "2操作失败!";
- return rt;
- }
- }
- else if (dto.editType == 3)
- {
- string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
- bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
- {
- IsDel = 1,
- DeleteTime = delTime,
- DeleteUserId = dto.createUser
- });
- if (!res)
- {
- _daiRep.RollbackTran();
- rt.Msg = "3操作失败!";
- return rt;
- }
- }
- else
- {
- _daiRep.RollbackTran();
- rt.Msg = "未知的editType";
- return rt;
- }
- if (!extraCost_editCreditCardPayment(dto))
- {
- rt.Msg = "ccp操作失败";
- return rt;
- }
- _daiRep.CommitTran();
- rt.Code = 0;
- rt.Msg = "操作成功";
- return rt;
- }
- private bool extraCost_editCreditCardPayment(Fin_GroupExtraCostDto_OP costDto)
- {
-
- decimal dcm_dayrate = 1M;
- decimal dcm_rmbPrice = costDto.price;
- int ispay = costDto.payType == 72 ? 1 : 0;
- if (costDto.costSign != 3)
- {
- Grp_TeamRate tr = _daiRep.Query<Grp_TeamRate>(s => s.DiId == costDto.diId && s.CTable == 1015).First();
- if (tr != null)
- {
- if (costDto.currency == 49)
- {
- dcm_dayrate = tr.RateU;
- dcm_rmbPrice = dcm_rmbPrice * tr.RateU;
- }
- else if (costDto.currency == 51)
- {
- dcm_dayrate = tr.RateE;
- dcm_rmbPrice = dcm_rmbPrice * tr.RateE;
- }
- }
- }
- Grp_CreditCardPayment ccp = _daiRep.Query<Grp_CreditCardPayment>(s => s.CId == costDto.Id && s.CTable == 1015).First();
- if (ccp == null)
- {
- ccp = new Grp_CreditCardPayment();
- ccp.PayDId = costDto.payType;
- ccp.ConsumptionPatterns = "";
- ccp.ConsumptionDate = "";
- ccp.CTDId = costDto.payCardId;
- ccp.BankNo = "";
- ccp.CardholderName = "";
- ccp.PayMoney = costDto.price;
- ccp.PaymentCurrency = costDto.currency;
- ccp.CompanyBankNo = "";
- ccp.OtherBankName = "";
- ccp.OtherSideNo = "";
- ccp.OtherSideName = "";
- ccp.Remark = "";
- ccp.CreateUserId = costDto.createUser;
- ccp.CreateTime = DateTime.Now;
- ccp.MFOperator = 0;
- ccp.MFOperatorDate = "";
- ccp.IsAuditDM = 0;
- ccp.AuditDMOperate = 0;
- ccp.AuditDMDate = "";
- ccp.IsAuditMF = 0;
- ccp.AuditMFOperate = 0;
- ccp.AuditMFDate = "";
- ccp.IsAuditGM = 0;
- ccp.AuditGMOperate = 0;
- ccp.AuditGMDate = "";
- ccp.IsPay = ispay;
- ccp.DIId = costDto.diId;
- ccp.CId = costDto.Id;
- ccp.CTable = 1015;
- ccp.IsDel = 0;
- ccp.PayPercentage = 100M;
- ccp.PayThenMoney = 0M;
- ccp.PayPercentageOld = 100M;
- ccp.PayThenMoneyOld = 0M;
- ccp.UpdateDate = "";
- ccp.Payee = costDto.payee;
- ccp.OrbitalPrivateTransfer = costDto.costSign;
- ccp.ExceedBudget = 0;
- ccp.DayRate = dcm_dayrate;
- ccp.RMBPrice = dcm_rmbPrice;
- int ccpInsertId = _daiRep.AddReturnId<Grp_CreditCardPayment>(ccp);
- if (ccpInsertId > 0)
- {
- return true;
- }
- }
- else
- {
- if (costDto.editType == 2)
- {
- bool res = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
- {
- PayDId = costDto.payType,
- CTDId = costDto.payCardId,
- PayMoney = costDto.price,
- PaymentCurrency = costDto.currency,
- IsPay = ispay,
- Payee = costDto.payee,
- OrbitalPrivateTransfer = costDto.costSign,
- DayRate = dcm_dayrate,
- RMBPrice = dcm_rmbPrice
- });
- return res;
- }
- else if (costDto.editType == 3)
- {
- string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
- bool res2 = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
- {
- IsDel = 1,
- DeleteTime = delTime,
- DeleteUserId = costDto.createUser
- });
- return res2;
- }
- }
- return false;
- }
- }
- }
|