CarTouristGuideGroundRepository.cs 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598
  1. using Aspose.Words.Tables;
  2. using AutoMapper;
  3. using NPOI.SS.Formula.Functions;
  4. using NPOI.SS.UserModel;
  5. using NPOI.Util;
  6. using OASystem.Domain;
  7. using OASystem.Domain.AesEncryption;
  8. using OASystem.Domain.Dtos.Financial;
  9. using OASystem.Domain.Dtos.Groups;
  10. using OASystem.Domain.Dtos.QiYeWeChat;
  11. using OASystem.Domain.Entities.Financial;
  12. using OASystem.Domain.Entities.Groups;
  13. using OASystem.Domain.Entities.Resource;
  14. using OASystem.Domain.ViewModels.Groups;
  15. using OASystem.Infrastructure.Repositories.Financial;
  16. using OASystem.Infrastructure.Repositories.System;
  17. using OASystem.Infrastructure.Tools;
  18. using SqlSugar.Extensions;
  19. using System.Collections.Generic;
  20. using System.Linq;
  21. using System.Reflection;
  22. using static NPOI.HSSF.Util.HSSFColor;
  23. namespace OASystem.Infrastructure.Repositories.Groups
  24. {
  25. public class CarTouristGuideGroundRepository : BaseRepository<Grp_CarTouristGuideGroundReservations, Grp_CarTouristGuideGroundReservationsContent>
  26. {
  27. private readonly IMapper _mapper;
  28. private readonly CheckBoxsRepository _checkRep;
  29. private readonly SetDataRepository _setDataRep;
  30. private readonly DailyFeePaymentRepository _daiRep; //日付申请仓库
  31. private readonly GroupCostParameterRepository _groupCostParameterRepository;
  32. private readonly ForeignReceivablesRepository _foreignReceivablesRepository;
  33. public CarTouristGuideGroundRepository(SqlSugarClient sqlSugar, IMapper mapper, CheckBoxsRepository checkRep, SetDataRepository setDataRep,
  34. DailyFeePaymentRepository daiRep, GroupCostParameterRepository groupCostParameterRepository, ForeignReceivablesRepository foreignReceivablesRepository)
  35. : base(sqlSugar)
  36. {
  37. _mapper = mapper;
  38. _checkRep = checkRep;
  39. _setDataRep = setDataRep;
  40. _daiRep = daiRep;
  41. _groupCostParameterRepository = groupCostParameterRepository;
  42. _foreignReceivablesRepository = foreignReceivablesRepository;
  43. }
  44. public async Task<Result> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  45. {
  46. Result result = new Result() { Code = -2, Msg = "未知错误" };
  47. BeginTran();
  48. try
  49. {
  50. int id = 0;
  51. var grp_CarTouristGuide = _mapper.Map<Grp_CarTouristGuideGroundReservations>(dto);
  52. if (dto.Status == 1)//添加
  53. {
  54. var grp_CarTouristGuideGround = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  55. .First(a => a.IsDel == 0 &&
  56. a.Area == dto.Area &&
  57. a.BusName == dto.BusName &&
  58. a.ServiceGuide == dto.ServiceGuide &&
  59. a.DiId == dto.DiId &&
  60. a.BusTel == dto.BusTel &&
  61. a.ServiceTel == dto.ServiceTel &&
  62. a.PriceName == dto.PriceName
  63. );
  64. grp_CarTouristGuideGround = null;
  65. if (grp_CarTouristGuideGround != null)
  66. {
  67. return result = new Result() { Code = -1, Msg = "该笔费用已存在,请勿重复添加!" };
  68. }
  69. else
  70. {
  71. id = await AddAsyncReturnId(grp_CarTouristGuide);
  72. if (id == 0)
  73. {
  74. RollbackTran();
  75. result = new Result() { Code = -1, Msg = "添加失败,请稍后重试!" };
  76. }
  77. else
  78. {
  79. result = new Result() { Code = 0, Msg = "添加成功!" };
  80. }
  81. }
  82. }
  83. else if (dto.Status == 2)//修改
  84. {
  85. bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_CarTouristGuideGroundReservations
  86. {
  87. Area = grp_CarTouristGuide.Area,
  88. ServiceCompany = grp_CarTouristGuide.ServiceCompany,
  89. ServiceGuide = grp_CarTouristGuide.ServiceGuide,
  90. ServiceTel = grp_CarTouristGuide.ServiceTel,
  91. BusName = grp_CarTouristGuide.BusName,
  92. BusDescription = grp_CarTouristGuide.BusDescription,
  93. BusTel = grp_CarTouristGuide.BusTel,
  94. ServiceStartTime = grp_CarTouristGuide.ServiceStartTime,
  95. ServiceEndTime = grp_CarTouristGuide.ServiceEndTime,
  96. ServiceDescription = grp_CarTouristGuide.ServiceDescription,
  97. QuotedPriceExplanation = grp_CarTouristGuide.QuotedPriceExplanation,
  98. OrbitalPrivateTransfer = grp_CarTouristGuide.OrbitalPrivateTransfer,
  99. Remark = grp_CarTouristGuide.Remark,
  100. PriceType = grp_CarTouristGuide.PriceType,
  101. PriceName = grp_CarTouristGuide.PriceName,
  102. });
  103. if (res)
  104. {
  105. id = dto.Id;
  106. result = new Result() { Code = 0, Msg = "修改成功!" };
  107. }
  108. else
  109. {
  110. RollbackTran();
  111. result = new Result() { Code = -1, Msg = "修改失败,请稍后重试!" };
  112. }
  113. }
  114. #region add导游地接数据屏蔽
  115. //if (id != 0)
  116. //{
  117. // var _LocalGuideDataCar = _sqlSugar.Queryable<Res_LocalGuideData>()
  118. // .First(a =>
  119. // a.UnitName == AesEncryptionHelper.Encrypt(dto.BusName) &&
  120. // a.ContactTel == AesEncryptionHelper.Encrypt(dto.BusTel) &&
  121. // a.IsDel == 0
  122. // );
  123. // if (_LocalGuideDataCar == null)
  124. // {
  125. // var res_LocalGuideCar = new Res_LocalGuideData();
  126. // res_LocalGuideCar.UnitName = dto.BusName;
  127. // res_LocalGuideCar.ContactTel = dto.BusTel;
  128. // res_LocalGuideCar.CreateUserId = dto.CreateUserId;
  129. // EncryptionProcessor.EncryptProperties(res_LocalGuideCar);
  130. // int cId = await _sqlSugar.Insertable(res_LocalGuideCar).ExecuteReturnIdentityAsync();
  131. // }
  132. // var _LocalGuideDataService = _sqlSugar.Queryable<Res_LocalGuideData>()
  133. // .First(a =>
  134. // a.UnitName == AesEncryptionHelper.Encrypt(dto.ServiceCompany) &&
  135. // a.ContactTel == AesEncryptionHelper.Encrypt(dto.ServiceTel) &&
  136. // a.IsDel == 0
  137. // );
  138. // if (_LocalGuideDataService == null)
  139. // {
  140. // Res_LocalGuideData res_LocalGuideService = new Res_LocalGuideData();
  141. // res_LocalGuideService.UnitName = dto.ServiceCompany;
  142. // res_LocalGuideService.ContactTel = dto.ServiceTel;
  143. // res_LocalGuideService.Contact = dto.ServiceTel;
  144. // res_LocalGuideService.CreateUserId = dto.CreateUserId;
  145. // EncryptionProcessor.EncryptProperties(res_LocalGuideService);
  146. // int cId = await _sqlSugar.Insertable(res_LocalGuideService).ExecuteReturnIdentityAsync();
  147. // }
  148. //}
  149. #endregion
  150. CommitTran();
  151. }
  152. catch (Exception ex)
  153. {
  154. result = new Result() { Code = -2, Msg = "未知错误" + ex.Message };
  155. }
  156. return result;
  157. }
  158. public Result CarTouristGuideGroundContent(CarTouristGuideGroundContentDto dto)
  159. {
  160. Result result = new Result() { Code = -2, Msg = "未知错误" };
  161. try
  162. {
  163. Grp_CarTouristGuideGroundReservations grpCarOp = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().First(x => x.Id == dto.Id);
  164. if (!DateTime.TryParse(grpCarOp?.ServiceStartTime, out DateTime start))
  165. {
  166. result.Msg = "服务开始时间不存在!";
  167. result.Code = -1;
  168. return result;
  169. }
  170. if (!DateTime.TryParse(grpCarOp?.ServiceEndTime, out DateTime end))
  171. {
  172. result.Msg = "服务结束时间不存在!";
  173. result.Code = -1;
  174. return result;
  175. }
  176. if (DateTime.Compare(end, start) < 0)
  177. {
  178. result.Msg = "服务时间区间有误!结束时间不应该小于开始时间!";
  179. result.Code = -1;
  180. return result;
  181. }
  182. TimeSpan ts = end - start; //计算时间差
  183. int day = ts.Days;
  184. var diid = Query<Grp_GroupsTaskAssignment>(a => a.IsDel == 0 && a.UId == dto.UserId && a.CTId == 79)
  185. .Select(x => x.DIId)
  186. .Distinct()
  187. .ToList();
  188. //团组下拉框
  189. List<Grp_DelegationInfo> _Delegations = diid.Any()
  190. ? _sqlSugar.Queryable<Grp_DelegationInfo>()
  191. .Where(x => x.IsDel == 0 && diid.Contains(x.Id)).ToList()
  192. : new List<Grp_DelegationInfo>();
  193. List<ShareGroupInfoIIView> grp_Delegations = _mapper.Map<List<ShareGroupInfoIIView>>(_Delegations);
  194. //支付方式
  195. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  196. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  197. //列表初始化
  198. List<Sys_SetData> TableInitialization = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 17 && a.IsDel == 0).ToList();
  199. List<SetDataInfoView> _TableInitialization = _mapper.Map<List<SetDataInfoView>>(TableInitialization);
  200. _TableInitialization = _TableInitialization.OrderBy(x => x.RemarkSort).ToList();
  201. List<Sys_SetData> ssd = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.STid == 78).ToList();
  202. List<SetDataInfoView> ssdv = _mapper.Map<List<Sys_SetData>, List<SetDataInfoView>>(ssd);
  203. var carTouristGuides = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  204. .LeftJoin<Sys_SetData>((a, b) => b.IsDel == 0 && a.SId == b.Id)
  205. .Where(a => a.IsDel == 0 && a.CTGGRId == dto.Id)
  206. .Select((a, b) => new CarTouristGuideGroundReservationsContentView
  207. {
  208. SId = a.SId,
  209. Id = a.Id,
  210. Count = a.Count,
  211. DatePrice = a.DatePrice,
  212. Price = a.Price,
  213. PriceContent = a.PriceContent,
  214. Units = a.Units,
  215. SidName = b.Name
  216. })
  217. .ToList();
  218. var weikuanSign = new int[] { 1070, 1071, 1452 };
  219. TableInitialization.RemoveAll(x => weikuanSign.Contains(x.Id));
  220. var weiKuanArr = _TableInitialization.Where(x => weikuanSign.Contains(x.Id)).ToList();
  221. var weiKuanResultArr = carTouristGuides.Where(x => weikuanSign.Contains(x.SId)).ToList();
  222. carTouristGuides.RemoveAll(x => weikuanSign.Contains(x.SId));
  223. var existingSIdArr = new HashSet<int>(carTouristGuides.Select(x => x.SId));
  224. foreach (var itemSt in TableInitialization)
  225. {
  226. if (!existingSIdArr.Contains(itemSt.Id))
  227. {
  228. carTouristGuides.Add(new CarTouristGuideGroundReservationsContentView
  229. {
  230. SId = itemSt.Id,
  231. Count = 1,
  232. SidName = itemSt.Name,
  233. });
  234. existingSIdArr.Add(itemSt.Id);
  235. }
  236. }
  237. var groupResult = carTouristGuides.GroupBy(x => x.SId).ToDictionary(x => x.Key, x => x.ToList());
  238. foreach (var item in groupResult.Keys)
  239. {
  240. var startForTime = start;
  241. var dayResult = new List<CarTouristGuideGroundReservationsContentView>();
  242. for (var i = 0; i <= day; i++)
  243. {
  244. dayResult.Add(new CarTouristGuideGroundReservationsContentView
  245. {
  246. Count = 1,
  247. DatePrice = startForTime,
  248. SId = item,
  249. SidName = groupResult[item][0].SidName
  250. });
  251. startForTime = startForTime.AddDays(1);
  252. }
  253. if (groupResult[item].Count != day)
  254. {
  255. for (var m = 0; m < groupResult[item].Count; m++)
  256. {
  257. for (var m1 = 0; m1 < dayResult.Count; m1++)
  258. {
  259. if (groupResult[item][m].DatePrice == dayResult[m1].DatePrice)
  260. {
  261. dayResult[m1] = groupResult[item][m];
  262. }
  263. }
  264. }
  265. }
  266. else
  267. {
  268. groupResult[item] = groupResult[item].OrderBy(x => x.DatePrice).ToList();
  269. if (groupResult[item][0].DatePrice == dayResult[0].DatePrice && groupResult[item][day - 1].DatePrice == dayResult[day - 1].DatePrice)
  270. {
  271. dayResult = groupResult[item];
  272. }
  273. else
  274. {
  275. for (var m = 0; m < groupResult[item].Count; m++)
  276. {
  277. for (var m1 = 0; m1 < dayResult.Count; m1++)
  278. {
  279. if (groupResult[item][m].DatePrice == dayResult[m1].DatePrice)
  280. {
  281. dayResult[m1] = groupResult[item][m];
  282. }
  283. }
  284. }
  285. }
  286. }
  287. groupResult[item] = dayResult;
  288. }
  289. carTouristGuides = groupResult.Values.SelectMany(sublist => sublist).OrderBy(x => x.SId).ThenBy(x => x.DatePrice).ToList();
  290. var _CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment, Sys_SetData, Sys_SetData>(
  291. (g, s1, s2) => new JoinQueryInfos(
  292. JoinType.Left, g.PayDId == s1.Id,
  293. JoinType.Left, g.PaymentCurrency == s2.Id
  294. ))
  295. .Where((g, s1, s2) => g.CId == dto.Id && g.IsDel == 0 && g.CTable == 79)
  296. .Select((g, s1, s2) => new CarTouristCreditCardPaymentView
  297. {
  298. IsAuditGM = g.IsAuditGM,
  299. PayDId = g.PayDId,
  300. PaymentCurrency = g.PaymentCurrency,
  301. Payee = g.Payee,
  302. PayMoney = g.PayMoney,
  303. PayPercentage = g.PayPercentage,
  304. PayName = s1.Name,
  305. PaymentCurrencyName = s2.Name,
  306. OrbitalPrivateTransfer = g.OrbitalPrivateTransfer,
  307. OrbitalPrivateTransferStr = g.OrbitalPrivateTransfer == 0 ? "公转" : "私转",
  308. BankNo = g.BankNo,
  309. CardholderName = g.CardholderName,
  310. CompanyBankNo = g.CompanyBankNo,
  311. ConsumptionDate = g.ConsumptionDate,
  312. ConsumptionPatterns = g.ConsumptionPatterns,
  313. Ctdid = g.CTDId,
  314. OtherBankName = g.OtherBankName,
  315. OtherSideName = g.OtherSideName,
  316. OtherSideNo = g.OtherSideNo,
  317. })
  318. .First();
  319. Dictionary<string, string> soureDic = new Dictionary<string, string>()
  320. {
  321. {"车费", "VF"},
  322. {"导游费", "T/G S"},
  323. {"客户午餐费用" , "L"},
  324. {"导游景点费" , "T/G EF"},
  325. {"导游小费" , "T/G T"},
  326. // --
  327. {"司机小费", "DRV T"},
  328. {"司机餐补", "C/F M"},
  329. {"车超时费", "C/F OF"},
  330. {"导游餐补", "T/G M"},
  331. {"导游房补", "T/G A"},
  332. {"导游交通", "T/G TF"},
  333. {"客户早餐费用", "B"},
  334. {"客户晚餐费用", "D"},
  335. {"景点门票费", "EF"},
  336. {"饮料/零食/水果", "B/R/F"},
  337. {"翻译费", "I/F"},
  338. };
  339. var checkedItem = new List<string>();
  340. var checkedItemId = new List<int>();
  341. var isSaveCheck = false;
  342. if (string.IsNullOrWhiteSpace(grpCarOp.SelectCheck))
  343. {
  344. //获取成本选中
  345. var checkTopArr = _checkRep.GetCheckBoxsByDiid(grpCarOp.DiId);
  346. if (true)
  347. {
  348. var FindTop = checkTopArr.Find(x => x.CbType == "Top");
  349. if (FindTop != null)
  350. {
  351. var selectName = FindTop.CbValues.Split(',').ToList<string>();
  352. foreach (var soureKey in soureDic.Keys)
  353. {
  354. var find = selectName.Find(x => x == soureDic[soureKey]);
  355. if (find == null)
  356. {
  357. var Lindex = carTouristGuides.FindIndex(x => x.SidName == soureKey);
  358. //carTouristGuides.RemoveRange(Lindex, day + 1);
  359. }
  360. else
  361. {
  362. checkedItem.Add(soureKey);
  363. checkedItemId.Add(_TableInitialization.Find(x => x.Name == soureKey)!.Id);
  364. }
  365. }
  366. }
  367. else
  368. {
  369. checkedItem = _TableInitialization.Select(x => x.Name).ToList();
  370. checkedItemId.AddRange(_TableInitialization.Select(x => x.Id).ToList());
  371. }
  372. }
  373. }
  374. else
  375. {
  376. isSaveCheck = true;
  377. var checkedItemThis = grpCarOp.SelectCheck.Split(",").ToList<string>();
  378. int number = 0;
  379. foreach (var item in checkedItemThis)
  380. {
  381. if (!int.TryParse(item, out number))
  382. {
  383. checkedItemId.Add(_TableInitialization.Find(x => x.Name == item)!.Id);
  384. checkedItem.Add(item);
  385. }
  386. else
  387. {
  388. checkedItemId.Add(number);
  389. checkedItem.Add(_TableInitialization.Find(x => x.Id == int.Parse(item))!.Name);
  390. }
  391. }
  392. }
  393. if (grpCarOp.PriceType == 1062) //尾款id
  394. {
  395. if (isSaveCheck)
  396. {
  397. checkedItemId.AddRange(weiKuanArr.Select(x => x.Id).ToList());
  398. checkedItem.AddRange(weiKuanArr.Select(x => x.Name).ToList());
  399. checkedItemId = checkedItemId.Distinct().ToList();
  400. checkedItem = checkedItem.Distinct().ToList();
  401. }
  402. else
  403. {
  404. checkedItemId = weiKuanArr.Select(x => x.Id).ToList();
  405. checkedItem = weiKuanArr.Select(x => x.Name).ToList();
  406. }
  407. var weiPrice = weiKuanResultArr.Find(x => x.SId == 1070);
  408. if (weiPrice != null)
  409. {
  410. weiPrice.SidName = "尾款金额";
  411. }
  412. var weiOther = weiKuanResultArr.Find(x => x.SId == 1071);
  413. if (weiOther != null)
  414. {
  415. weiOther.SidName = "其他额外费用";
  416. }
  417. var cityPrice = weiKuanResultArr.Find(x => x.SId == 1452);
  418. if (cityPrice != null)
  419. {
  420. cityPrice.SidName = "城市税";
  421. }
  422. carTouristGuides.Add(weiPrice ??= new CarTouristGuideGroundReservationsContentView
  423. {
  424. Count = 1,
  425. DatePrice = DateTime.Now,
  426. Price = 0,
  427. PriceContent = "",
  428. SId = 1070,
  429. SidName = "尾款金额",
  430. Units = 0,
  431. });
  432. carTouristGuides.Add(weiOther ??= new CarTouristGuideGroundReservationsContentView
  433. {
  434. Count = 1,
  435. DatePrice = DateTime.Now,
  436. Price = 0,
  437. PriceContent = "",
  438. SId = 1071,
  439. SidName = "其他额外费用",
  440. Units = 0,
  441. });
  442. carTouristGuides.Add(cityPrice ??= new CarTouristGuideGroundReservationsContentView
  443. {
  444. Count = 1,
  445. DatePrice = DateTime.Now,
  446. Price = 0,
  447. PriceContent = "",
  448. SId = 1452,
  449. SidName = "城市税",
  450. Units = 0,
  451. });
  452. }
  453. else
  454. {
  455. _TableInitialization.RemoveAll(x => weikuanSign.Contains(x.Id));
  456. checkedItem.RemoveAll(x => x == "尾款金额" || x == "其他额外费用");
  457. checkedItemId.RemoveAll(x => weikuanSign.Contains(x));
  458. }
  459. //三公费用金额以及币种
  460. var boolParse = int.TryParse(grpCarOp.Area, out int natiId);
  461. var NationalTravelFee = _sqlSugar.Queryable<Grp_NationalTravelFee>()
  462. .LeftJoin<Sys_SetData>((a, b) => a.Currency == b.Id)
  463. .Where((a, b) => a.IsDel == 0 && b.IsDel == 0)
  464. .Select((a, b) => new
  465. {
  466. a.Id,
  467. a.Currency,
  468. CurrencyStr = b.Name,
  469. a.FoodCost,
  470. a.RoomCost,
  471. a.PublicCost,
  472. })
  473. .First((a) => boolParse == true && a.Id == natiId);
  474. var rate = new
  475. {
  476. grpCarOp.Rate,
  477. grpCarOp.toCurr
  478. };
  479. var bankCard = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 15)
  480. .Select(x => new
  481. {
  482. x.Id,
  483. x.Name
  484. })
  485. .OrderByDescending(x => x.Id)
  486. .ToList();
  487. if (dto.PortType == 1)
  488. {
  489. var data = new
  490. {
  491. Payment = _Payment,
  492. Delegations = grp_Delegations,
  493. carTouristGuides = carTouristGuides,
  494. CreditCardPayment = _CreditCardPayment,
  495. start,
  496. end,
  497. ssdv,
  498. checkedItem,
  499. existItem = _TableInitialization.Select(x => x.Name).ToList(),
  500. NationalTravelFee,
  501. rate,
  502. bankCard
  503. };
  504. return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
  505. }
  506. else if (dto.PortType == 2)
  507. {
  508. var data = new
  509. {
  510. Payment = _Payment,
  511. TableInitialization = _TableInitialization,
  512. carTouristGuides = carTouristGuides,
  513. CreditCardPayment = _CreditCardPayment ??= new CarTouristCreditCardPaymentView(),
  514. ssdv,
  515. checkedItemId,
  516. NationalTravelFee,
  517. rate,
  518. bankCard
  519. };
  520. return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
  521. }
  522. return result = new Result() { Code = -1, Msg = "请传入有效portType" };
  523. }
  524. catch (Exception ex)
  525. {
  526. return result = new Result() { Code = -2, Msg = "未知错误" };
  527. }
  528. }
  529. /// <summary>
  530. /// web弃用
  531. /// </summary>
  532. /// <param name="dto"></param>
  533. /// <returns></returns>
  534. public Result OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  535. {
  536. Result result = new Result() { Code = -2, Msg = "未知错误" };
  537. try
  538. {
  539. List<Grp_CarTouristGuideGroundReservationsContent> grp_CarTouristsContent = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.IsDel == 0 && a.CTGGRId == dto.Id).ToList();
  540. List<CarTouristGuideGroundReservationsContentView> carTouristGuides = _mapper.Map<List<CarTouristGuideGroundReservationsContentView>>(grp_CarTouristsContent);
  541. foreach (var item in carTouristGuides)
  542. {
  543. item.SidName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == item.SId).Name;
  544. }
  545. Grp_CreditCardPayment CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79);
  546. CarTouristCreditCardPaymentView _CreditCardPayment = _mapper.Map<CarTouristCreditCardPaymentView>(CreditCardPayment);
  547. if (_CreditCardPayment != null)
  548. {
  549. _CreditCardPayment.PayName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == _CreditCardPayment.PayDId).Name;
  550. _CreditCardPayment.PaymentCurrencyName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == _CreditCardPayment.PaymentCurrency).Name;
  551. if (_CreditCardPayment.OrbitalPrivateTransfer == 0) _CreditCardPayment.OrbitalPrivateTransferStr = "公转";
  552. else _CreditCardPayment.OrbitalPrivateTransferStr = "私转";
  553. }
  554. var data = new
  555. {
  556. CarTouristsContent = carTouristGuides,
  557. CreditCardPayment = _CreditCardPayment,
  558. };
  559. return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
  560. }
  561. catch (Exception ex)
  562. {
  563. return result = new Result() { Code = -2, Msg = "未知错误(" + ex.Message + ")" };
  564. }
  565. }
  566. /// <summary>
  567. /// 根据diid查询op费用列表
  568. /// </summary>
  569. /// <param name="dto"></param>
  570. /// <returns></returns>
  571. public async Task<Result> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  572. {
  573. Result result = new Result() { Code = -2, Msg = "未知错误" };
  574. if (dto.PortType == 0 || string.IsNullOrWhiteSpace(dto.PortType.ToString()))
  575. {
  576. return result = new Result() { Code = -1, Msg = "请传入PortType参数,请求端口分类 1 Web 2 Android 3 IOS" };
  577. }
  578. try
  579. {
  580. #region SQL条件拼接
  581. string sqlWhere = string.Empty;
  582. sqlWhere += string.Format(@"And t.DIId={0} and t.isdel={1}", dto.DiId, 0);
  583. string UserId = "";
  584. List<Grp_GroupsTaskAssignment> gtaUIdList = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(a => a.DIId == dto.DiId && a.IsDel == 0 && a.CTId == 79).ToList();
  585. foreach (Grp_GroupsTaskAssignment gta in gtaUIdList)
  586. UserId += gta.UId + ",";
  587. if (!string.IsNullOrWhiteSpace(UserId))
  588. {
  589. UserId = UserId.Substring(0, UserId.Length - 1);
  590. }
  591. else
  592. {
  593. UserId = "0";
  594. }
  595. sqlWhere += string.Format(@" And t.CreateUserId in ({0})", UserId);
  596. if (dto.IsPaySign != -1)
  597. {
  598. sqlWhere += string.Format(@" And c.IsPay = {0} ", dto.IsPaySign);
  599. }
  600. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  601. {
  602. Regex r = new Regex("And");
  603. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  604. }
  605. #endregion
  606. int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
  607. int endIndex = startIndex + dto.PageSize - 1;
  608. Regex regex = new Regex("^[\u4e00-\u9fa5]*$");
  609. //城市列表
  610. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>()
  611. .Where(x => x.IsDel == 0)
  612. .Select(x => new
  613. {
  614. x.Id,
  615. x.Country,
  616. x.City,
  617. })
  618. .ToList();
  619. if (dto.PortType == 1)
  620. {
  621. 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
  622. Grp_CarTouristGuideGroundReservations t
  623. left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id and c.isdel=0
  624. left Join Sys_SetData s on s.Id=c.PaymentCurrency {0}
  625. order by c.IsAuditGM,c.PayPercentage desc", sqlWhere);
  626. List<Grp_CarTouristGuideGroundView> infoViews = _sqlSugar.SqlQueryable<Grp_CarTouristGuideGroundView>(sql).ToList();
  627. foreach (var item in infoViews)
  628. {
  629. if (!regex.IsMatch(item.Area))
  630. {
  631. for (int i = 0; i < data.Count; i++)
  632. {
  633. if (item.Area.Equals(data[i].Id.ToString()))
  634. {
  635. item.Area = string.Format("{0} {1}", data[i].Country, data[i].City);
  636. }
  637. }
  638. }
  639. if (string.IsNullOrWhiteSpace(item.priceTypeStr))
  640. {
  641. item.priceTypeStr = "未选择!";
  642. }
  643. if (item.OrbitalPrivateTransfer == 0) item.OrbitalPrivateTransferStr = "公转";
  644. else if (item.OrbitalPrivateTransfer == 1) item.OrbitalPrivateTransferStr = "私转";
  645. item.ServiceStartTime = Convert.ToDateTime(item.ServiceStartTime).ToString("yyyy-MM-dd");
  646. item.ServiceEndTime = Convert.ToDateTime(item.ServiceEndTime).ToString("yyyy-MM-dd");
  647. item.ServiceQuotedPrice = item.PayMoney;
  648. item.PayThenMoney = Math.Round(item.PayPercentage / 100 * item.ServiceQuotedPrice, 2);
  649. item.RemainingBalance = Math.Round(item.ServiceQuotedPrice - item.PayPercentage / 100 * item.ServiceQuotedPrice, 2);
  650. if (item.IsAuditGM == 0) item.IsAuditGMStr = "未审核";
  651. else if (item.IsAuditGM == 1) item.IsAuditGMStr = "已通过";
  652. else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
  653. else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
  654. Sys_SetData s = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == item.PayDid);
  655. if (s != null)
  656. {
  657. item.PayStrd = s.Name;
  658. }
  659. else item.PayStrd = "未选择";
  660. }
  661. return result = new Result() { Code = 0, Msg = "查询成功!", Data = infoViews };
  662. }
  663. else if (dto.PortType == 2 || dto.PortType == 3)
  664. {
  665. string sql = string.Format(@"Select * From (
  666. 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
  667. from
  668. Grp_CarTouristGuideGroundReservations t
  669. left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id and c.isdel=0
  670. left Join Sys_SetData s on s.Id=c.PaymentCurrency {0}
  671. ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
  672. List<Grp_CarTouristGuideGroundView> grp_CarTourists = _sqlSugar.SqlQueryable<Grp_CarTouristGuideGroundView>(sql).ToList();
  673. foreach (var item in grp_CarTourists)
  674. {
  675. if (!regex.IsMatch(item.Area))
  676. {
  677. for (int i = 0; i < data.Count; i++)
  678. {
  679. if (item.Area.Equals(data[i].Id.ToString()))
  680. {
  681. item.Area = string.Format("{0} {1}", data[i].Country, data[i].City);
  682. }
  683. }
  684. }
  685. if (string.IsNullOrWhiteSpace(item.priceTypeStr))
  686. {
  687. item.priceTypeStr = "未选择!";
  688. }
  689. if (item.OrbitalPrivateTransfer == 0) item.OrbitalPrivateTransferStr = "公转";
  690. else if (item.OrbitalPrivateTransfer == 1) item.OrbitalPrivateTransferStr = "私转";
  691. item.ServiceStartTime = Convert.ToDateTime(item.ServiceStartTime).ToString("yyyy-MM-dd");
  692. item.ServiceEndTime = Convert.ToDateTime(item.ServiceEndTime).ToString("yyyy-MM-dd");
  693. if (item.IsAuditGM == 0) item.IsAuditGMStr = "未审核";
  694. else if (item.IsAuditGM == 1) item.IsAuditGMStr = "已通过";
  695. else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
  696. else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
  697. item.ServiceQuotedPrice = item.PayMoney;
  698. item.PayThenMoney = Math.Round(item.PayPercentage / 100 * item.ServiceQuotedPrice, 2);
  699. item.RemainingBalance = Math.Round(item.ServiceQuotedPrice - item.PayPercentage / 100 * item.ServiceQuotedPrice, 2);
  700. Sys_SetData s = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == item.PayDid);
  701. if (s != null)
  702. {
  703. item.PayStrd = s.Name;
  704. }
  705. else item.PayStrd = "未选择";
  706. }
  707. string CountSql = string.Format(@"Select COUNT(1) as Count From (
  708. select t.*,s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage from
  709. Grp_CarTouristGuideGroundReservations t
  710. left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id and c.isdel=0
  711. left Join Sys_SetData s on s.Id=t.CId {0}
  712. ) temp ", sqlWhere);
  713. DataCount dataCount = _sqlSugar.SqlQueryable<DataCount>(CountSql).First();
  714. if (dataCount != null)
  715. {
  716. int count = dataCount.Count;
  717. float totalPage = (float)count / dto.PageSize;//总页数
  718. if (totalPage == 0) totalPage = 1;
  719. else totalPage = (int)Math.Ceiling((double)totalPage);
  720. ListViewBase<Grp_CarTouristGuideGroundView> rst = new ListViewBase<Grp_CarTouristGuideGroundView>();
  721. rst.DataList = grp_CarTourists;
  722. rst.DataCount = count;
  723. rst.CurrPageIndex = dto.PageIndex;
  724. rst.CurrPageSize = dto.PageSize;
  725. return result = new Result() { Code = 0, Msg = "查询成功!", Data = rst };
  726. }
  727. }
  728. }
  729. catch (Exception)
  730. {
  731. return result = new Result() { Code = -2, Msg = "未知错误" };
  732. }
  733. return result;
  734. }
  735. /// <summary>
  736. /// OP费用录入填写详情
  737. /// </summary>
  738. /// <param name="dto"></param>
  739. /// <returns></returns>
  740. public async Task<Result> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  741. {
  742. Result result = new Result() { Code = -2, Msg = "未知错误" };
  743. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  744. if (di == null)
  745. {
  746. result.Code = -1;
  747. result.Msg = "无该团组信息!";
  748. return result;
  749. }
  750. try
  751. {
  752. BeginTran();
  753. List<Grp_CarTouristGuideGroundReservationsContent> carTouristList = dto.OPContentList.Select(item => new Grp_CarTouristGuideGroundReservationsContent
  754. {
  755. Id = item.Id,
  756. DiId = dto.DiId,
  757. CTGGRId = dto.CTGGRId,
  758. SId = item.SId,
  759. Price = item.Price,
  760. PriceContent = item.priceContent,
  761. Currency = dto.Currency,
  762. CreateUserId = dto.CreateUserId,
  763. Units = item.Units,
  764. DatePrice = item.DatePrice,
  765. Count = item.Count,
  766. }).ToList();
  767. #region 旧数据处理
  768. string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm ss");
  769. var ids = carTouristList.Select(x1 => x1.Id);
  770. _ = _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(x => x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId && !ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Grp_CarTouristGuideGroundReservationsContent
  771. {
  772. IsDel = 1,
  773. DeleteTime = time,
  774. DeleteUserId = dto.CreateUserId,
  775. }).ExecuteCommand();
  776. #endregion
  777. if (carTouristList.Count > 0)
  778. {
  779. #region 超支处理
  780. Dictionary<int, int> mealsDic = new Dictionary<int, int>()
  781. {
  782. {988,1074},
  783. {93,1075},
  784. {989,1076},
  785. };
  786. //限制只能选择地区
  787. var opSingle = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().First(x => x.Id == dto.CTGGRId && x.IsDel == 0);
  788. var opSingleCityId = 0;
  789. Grp_NationalTravelFee cityPrice = null;
  790. string priceCity = string.Empty;
  791. //三公费用
  792. if (int.TryParse(opSingle.Area, out opSingleCityId))
  793. {
  794. cityPrice = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x =>
  795. x.Id == opSingleCityId
  796. ).First();
  797. priceCity = cityPrice == null ? string.Empty : cityPrice.Country + cityPrice?.City;
  798. }
  799. else
  800. {
  801. cityPrice = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x =>
  802. !string.IsNullOrEmpty(x.City) && x.City.Contains(opSingle.Area)
  803. ).First();
  804. priceCity = opSingle.Area;
  805. }
  806. cityPrice ??= new Grp_NationalTravelFee
  807. {
  808. FoodCost = 0.00M,
  809. Id = 0,
  810. };
  811. List<Tuple<int, string, int, decimal>> arr = new List<Tuple<int, string, int, decimal>>();
  812. arr.Add(new Tuple<int, string, int, decimal>(1074, "早餐超支费用", 1077, 1M)); // sid name setdataid 系数
  813. arr.Add(new Tuple<int, string, int, decimal>(1075, "午餐超支费用", 1078, 1M));
  814. arr.Add(new Tuple<int, string, int, decimal>(1076, "晚餐超支费用", 1079, 1M));
  815. arr.Add(new Tuple<int, string, int, decimal>(982, "车超时费用", 1050, 2.4M));
  816. arr.Add(new Tuple<int, string, int, decimal>(1059, "导游超时费用", 1072, 1M));
  817. arr.Add(new Tuple<int, string, int, decimal>(1085, "景点门票超支费用", 1086, 1.2M));
  818. arr.Add(new Tuple<int, string, int, decimal>(1073, "翻译超时费用", 1087, 1.5M));
  819. //超支费用表(数据添加) Fin_GroupExtraCost
  820. List<Fin_GroupExtraCost> groupExtraCostsArr = new List<Fin_GroupExtraCost>();
  821. List<List<Fin_GroupExtraCost>> enterOverspendArr = new List<List<Fin_GroupExtraCost>>();
  822. var aMeal = cityPrice.FoodCost.ObjToDecimal() / 2; //一顿三公费用
  823. var findSetDataCurr = _sqlSugar.Queryable<Sys_SetData>().First(q => q.Id == dto.toCurr && q.IsDel == 0);
  824. var carCurr = _sqlSugar.Queryable<Sys_SetData>().First(q => q.Id == carTouristList.First().Currency && q.IsDel == 0);
  825. foreach (var item in arr)
  826. {
  827. var a = carTouristList.Where(x => x.SId == item.Item1 && x.Price != 0).Select(x => new Fin_GroupExtraCost
  828. {
  829. Coefficient = item.Item4,
  830. CreateTime = DateTime.Now,
  831. CreateUserId = dto.CreateUserId,
  832. DiId = dto.DiId,
  833. FilePath = string.Empty,
  834. IsDel = 0,
  835. PriceCount = x.Count,
  836. Price = x.Price,
  837. PriceDt = x.DatePrice.ObjToDate(),
  838. PriceCurrency = x.Currency,
  839. PriceSum = x.Count * x.Price,
  840. PriceName = di.TeamName + "-" + priceCity + "-" + $"{item.Item2}(地接导入)",
  841. PriceType = 1028,
  842. PriceDetailType = item.Item3,
  843. Remark = x.PriceContent,
  844. Area = opSingleCityId
  845. }).ToList();
  846. if (a.Count > 0)
  847. {
  848. enterOverspendArr.Add(a);
  849. }
  850. }
  851. //数组中的费用
  852. if (enterOverspendArr.Count > 0)
  853. {
  854. groupExtraCostsArr.AddRange(enterOverspendArr.SelectMany(x => x).ToList());
  855. }
  856. var start = opSingle.ServiceStartTime.ObjToDate();
  857. var end = opSingle.ServiceEndTime.ObjToDate();
  858. string remake = string.Empty;
  859. var exitMealCount = 0;
  860. var price = 0M;
  861. //var day = 0;
  862. var consumerMealStr = string.Empty;
  863. var consumerMealNumber = 0;
  864. var consumerMealAllPrice = 0.00M;
  865. while (start <= end)
  866. {
  867. //查看每日每顿是否存在超支
  868. //不存在则加入退费 (三公一顿 - 消费金额)
  869. //93 , 989
  870. bool isExistsWu = carTouristList.Where(x => x.SId == mealsDic[93] && x.IsDel == 0 && DateTime.Compare(start, x.DatePrice.ObjToDate()) == 0 && x.Price > 0).Count() == 0;
  871. bool isExistsWan = carTouristList.Where(x => x.SId == mealsDic[989] && x.IsDel == 0 && DateTime.Compare(start, x.DatePrice.ObjToDate()) == 0 && x.Price > 0).Count() == 0;
  872. var mealPriceWu = carTouristList.Where(x => x.SId == 93 && x.IsDel == 0 && DateTime.Compare(start, x.DatePrice.ObjToDate()) == 0).Sum(x => x.Price * x.Count);
  873. var mealPriceWan = carTouristList.Where(x => x.SId == 989 && x.IsDel == 0 && DateTime.Compare(start, x.DatePrice.ObjToDate()) == 0).Sum(x => x.Price * x.Count);
  874. var mealPriceWuChao = carTouristList.Where(x => x.SId == mealsDic[93] && x.IsDel == 0 && DateTime.Compare(start, x.DatePrice.ObjToDate()) == 0).Sum(x => x.Price * x.Count);
  875. var mealPriceWanChao = carTouristList.Where(x => x.SId == mealsDic[989] && x.IsDel == 0 && DateTime.Compare(start, x.DatePrice.ObjToDate()) == 0).Sum(x => x.Price * x.Count);
  876. if (mealPriceWu > 0)
  877. {
  878. consumerMealStr += $"{start.ToString("M/d")}午餐消费{mealPriceWu + mealPriceWuChao}{carCurr?.Name},";
  879. consumerMealNumber++;
  880. consumerMealAllPrice += mealPriceWu + mealPriceWuChao;
  881. }
  882. if (mealPriceWan > 0)
  883. {
  884. consumerMealStr += $"{start.ToString("M/d")}晚餐消费{mealPriceWan + mealPriceWanChao}{carCurr?.Name},";
  885. consumerMealNumber++;
  886. consumerMealAllPrice += mealPriceWan + mealPriceWanChao;
  887. }
  888. if (isExistsWu && isExistsWan)
  889. {
  890. remake += $"{start.ToString("M/d")}午餐和晚餐,";
  891. exitMealCount += 2;
  892. price += (aMeal * 2 * di.VisitPNumber) - (mealPriceWu * dto.Rate) - (mealPriceWan * dto.Rate);
  893. }
  894. else if (isExistsWu)
  895. {
  896. remake += $"{start.ToString("M/d")}午餐,";
  897. exitMealCount += 1;
  898. price += (aMeal * di.VisitPNumber) - (mealPriceWu * dto.Rate);
  899. }
  900. else if (isExistsWan)
  901. {
  902. remake += $"{start.ToString("M/d")}晚餐,";
  903. exitMealCount += 1;
  904. price += (aMeal * di.VisitPNumber) - (mealPriceWan * dto.Rate);
  905. }
  906. start = start.AddDays(1);
  907. //day++;
  908. }
  909. var priceTypeArr = new int[] { 1061, 1069 };
  910. if (exitMealCount > 0 && priceTypeArr.Contains(opSingle.PriceType))
  911. {
  912. string searchKey = "宴请";
  913. remake = remake.TrimEnd(',');
  914. remake += $"财政 {findSetDataCurr?.Name} {aMeal} * {di.VisitPNumber} * {exitMealCount}餐";
  915. remake += $",[TuT]{consumerMealStr} 共{consumerMealNumber}顿 {consumerMealAllPrice} {carCurr?.Name}";
  916. decimal priceInt = price / di.VisitPNumber / exitMealCount;
  917. groupExtraCostsArr.Add(new Fin_GroupExtraCost
  918. {
  919. Coefficient = 1,
  920. CreateTime = DateTime.Now,
  921. CreateUserId = dto.CreateUserId,
  922. DiId = dto.DiId,
  923. FilePath = string.Empty,
  924. IsDel = 0,
  925. PriceCount = di.VisitPNumber * exitMealCount * -1,
  926. Price = priceInt,
  927. PriceDt = opSingle.ServiceStartTime.ObjToDate(),
  928. PriceCurrency = findSetDataCurr == null ? dto.toCurr : findSetDataCurr.Id,
  929. PriceSum = (di.VisitPNumber * exitMealCount * -1) * priceInt,
  930. PriceName = di.TeamName + "-" + priceCity + "-" + $"退餐费(地接导入)",
  931. PriceType = 1028,
  932. PriceDetailType = 1088,
  933. Remark = remake,
  934. Area = opSingleCityId,
  935. SYsupervisorConfirm = dto.OPContentList.Where(x => x.priceContent.Contains(searchKey)).Count() > 0 ? 1 : 0,
  936. });
  937. }
  938. var needToConfirm = new int[] { 1088, 1050 };
  939. if (groupExtraCostsArr.Count > 0)
  940. {
  941. foreach (var item in groupExtraCostsArr)
  942. {
  943. var ManagerConfirm = needToConfirm.Contains(item.PriceDetailType) ? 0 : 1;
  944. var SupervisorConfirm = needToConfirm.Contains(item.PriceDetailType) ? 0 : 1;
  945. var SYsupervisorConfirm = needToConfirm.Contains(item.PriceDetailType) ? 0 : 1;
  946. if (item.SYsupervisorConfirm > 0)
  947. {
  948. SYsupervisorConfirm = 1;
  949. }
  950. var QuerySgin = _sqlSugar.Queryable<Fin_GroupExtraCost>()
  951. .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"))
  952. .First();
  953. if (QuerySgin == null)
  954. {
  955. var resultId = await PostGroupExtraCost_Operator(new Fin_GroupExtraCostDto_OP
  956. {
  957. coefficient = item.Coefficient,
  958. createUser = dto.CreateUserId,
  959. currency = item.PriceCurrency,
  960. diId = item.DiId,
  961. editType = 1,
  962. filePath = string.Empty,
  963. payee = dto.Payee,
  964. PortType = 1,
  965. PriceCount = item.PriceCount,
  966. priceName = item.PriceName,
  967. remark = item.Remark,
  968. price = item.Price,
  969. priceDetailType = item.PriceDetailType,
  970. priceType = item.PriceType,
  971. PriceDt = item.PriceDt.ToString("yyyy-MM-dd"),
  972. payType = dto.PayDId,
  973. costSign = dto.OrbitalPrivateTransfer,
  974. Area = item.Area,
  975. ManagerConfirm = ManagerConfirm,
  976. SupervisorConfirm = SupervisorConfirm,
  977. SYsupervisorConfirm = SYsupervisorConfirm
  978. });
  979. _sqlSugar.Insertable<Fin_LocalGuideRelevancyOverspend>(new Fin_LocalGuideRelevancyOverspend
  980. {
  981. CreateTime = DateTime.Now,
  982. CreateUserId = dto.CreateUserId,
  983. IsDel = 0,
  984. LocalGuideId = opSingle.Id,
  985. OverspendId = resultId.Data,
  986. }).ExecuteCommand();
  987. }
  988. else
  989. {
  990. item.Id = QuerySgin.Id;
  991. _ = await PostGroupExtraCost_Operator(new Fin_GroupExtraCostDto_OP
  992. {
  993. coefficient = item.Coefficient,
  994. createUser = dto.CreateUserId,
  995. currency = item.PriceCurrency,
  996. diId = item.DiId,
  997. editType = 2,
  998. filePath = string.Empty,
  999. payee = dto.Payee,
  1000. PortType = 1,
  1001. PriceCount = item.PriceCount,
  1002. priceName = item.PriceName,
  1003. remark = item.Remark,
  1004. price = item.Price,
  1005. priceDetailType = item.PriceDetailType,
  1006. priceType = item.PriceType,
  1007. PriceDt = item.PriceDt.ToString("yyyy-MM-dd"),
  1008. payType = dto.PayDId,
  1009. costSign = dto.OrbitalPrivateTransfer,
  1010. Id = item.Id,
  1011. Area = item.Area,
  1012. });
  1013. }
  1014. }
  1015. _foreignReceivablesRepository.OverSpSeteceivables(new OverSpSeteceivablesDto
  1016. {
  1017. CreateUserId = dto.CreateUserId,
  1018. DiId = dto.DiId,
  1019. });
  1020. }
  1021. #endregion
  1022. var existingRecords = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  1023. .Where(a => carTouristList.Select(item => item.Id).Contains(a.Id) &&
  1024. a.CTGGRId == dto.CTGGRId &&
  1025. a.IsDel == 0
  1026. )
  1027. .ToListAsync();
  1028. var existingRecordsDict = existingRecords.ToDictionary(a => (a.Id));
  1029. var insertList = new List<Grp_CarTouristGuideGroundReservationsContent>();
  1030. var updateList = new List<Grp_CarTouristGuideGroundReservationsContent>();
  1031. foreach (var item in carTouristList)
  1032. {
  1033. if (!existingRecordsDict.TryGetValue((item.Id), out var existingRecord))
  1034. {
  1035. insertList.Add(item);
  1036. }
  1037. else
  1038. {
  1039. existingRecord.Price = item.Price;
  1040. existingRecord.PriceContent = item.PriceContent;
  1041. existingRecord.Currency = dto.Currency;
  1042. existingRecord.Remark = item.Remark;
  1043. existingRecord.DatePrice = item.DatePrice;
  1044. existingRecord.Count = item.Count;
  1045. existingRecord.Units = item.Units;
  1046. updateList.Add(existingRecord);
  1047. }
  1048. }
  1049. // 执行批量插入
  1050. if (insertList.Any())
  1051. {
  1052. var insertIds = await _sqlSugar.Insertable(insertList).ExecuteReturnIdentityAsync();
  1053. if (insertIds == 0)
  1054. {
  1055. throw new Exception("添加失败,请稍后重试!");
  1056. }
  1057. }
  1058. // 执行批量更新
  1059. if (updateList.Any())
  1060. {
  1061. var updateCount = await _sqlSugar.Updateable(updateList).ExecuteCommandAsync();
  1062. if (updateCount == 0)
  1063. {
  1064. throw new Exception("修改失败,请稍后重试!");
  1065. }
  1066. }
  1067. }
  1068. //城市税排除计算
  1069. var excludeList = new List<int>(); // { 1452 }
  1070. #region 修改C表数据
  1071. Grp_CreditCardPayment c = new Grp_CreditCardPayment();
  1072. c.PaymentCurrency = dto.Currency;
  1073. for (int i = 0; i < dto.SelectCheck.Count; i++)
  1074. {
  1075. if (int.TryParse(dto.SelectCheck[i], out _))
  1076. {
  1077. for (int j = 0; j < carTouristList.Count; j++)
  1078. {
  1079. if (int.Parse(dto.SelectCheck[i]) == carTouristList[j].SId)
  1080. {
  1081. if (excludeList.Contains(carTouristList[j].SId))
  1082. {
  1083. continue;
  1084. }
  1085. c.PayMoney += carTouristList[j].Price * carTouristList[j].Count;
  1086. }
  1087. }
  1088. }
  1089. else
  1090. {
  1091. c.PayMoney = carTouristList.Sum(x =>
  1092. {
  1093. if (excludeList.Contains(x.SId))
  1094. {
  1095. return 0;
  1096. }
  1097. return x.Price * x.Count;
  1098. });
  1099. break;
  1100. }
  1101. }
  1102. c.PayPercentage = dto.PayPercentage;
  1103. c.ConsumptionDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1104. c.CTable = 79;
  1105. c.CId = dto.CTGGRId;
  1106. c.IsAuditGM = 0;
  1107. c.PayDId = dto.PayDId;
  1108. c.DIId = dto.DiId;
  1109. c.OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer;
  1110. c.Payee = dto.Payee;
  1111. c.CreateUserId = dto.CreateUserId;
  1112. //--------------------添加C表字段---------------
  1113. c.ConsumptionPatterns = dto.ConsumptionPatterns;
  1114. c.CTDId = dto.Ctdid;
  1115. c.BankNo = dto.BankNo;
  1116. c.CardholderName = dto.CardholderName;
  1117. c.ConsumptionDate = dto.ConsumptionDate;
  1118. c.CompanyBankNo = dto.CompanyBankNo;
  1119. c.OtherBankName = dto.OtherBankName;
  1120. c.OtherSideNo = dto.OtherSideNo;
  1121. c.OtherSideName = dto.OtherSideName;
  1122. //2025-04-07 第四次更改 PayDId == 72(刷卡) IsPay == 1
  1123. if (c.PayDId == 72) c.IsPay = 1;
  1124. else c.IsPay = 0;
  1125. c.RMBPrice = c.PayMoney;
  1126. c.DayRate = 1;
  1127. #region 老汇率获取
  1128. //Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == dto.DiId && a.IsDel == 0 && a.CTable == 79);
  1129. //List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>();
  1130. //if (_TeamRate != null)
  1131. //{
  1132. // Sys_SetData _SetData = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == c.PaymentCurrency);
  1133. // if (_SetData != null)
  1134. // {
  1135. // currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
  1136. // CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData.Name);
  1137. // if (CurrencyRate != null)
  1138. // {
  1139. // c.RMBPrice = c.PayMoney * Convert.ToDecimal(CurrencyRate.Rate);
  1140. // c.DayRate = CurrencyRate.Rate;
  1141. // }
  1142. // }
  1143. //}
  1144. #endregion
  1145. var rate = await _setDataRep.PostCurrencyByDiid(dto.DiId, 79, dto.Currency);
  1146. if (rate.Code == 0)
  1147. {
  1148. var rateData = rate.Data as CurrencyInfo;
  1149. if (rateData != null)
  1150. {
  1151. c.RMBPrice = c.PayMoney * rateData.Rate;
  1152. c.DayRate = rateData.Rate;
  1153. }
  1154. }
  1155. int noticeSign = 1; //企业微信通知标识
  1156. int noticeCcpId = 0;
  1157. Grp_CreditCardPayment grp_CreditCard = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.CTGGRId && a.IsDel == 0 && a.CTable == 79 && a.DIId == dto.DiId);
  1158. if (grp_CreditCard != null)//修改
  1159. {
  1160. 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
  1161. {
  1162. PaymentCurrency = c.PaymentCurrency,
  1163. PayMoney = c.PayMoney,
  1164. PayPercentage = c.PayPercentage,
  1165. CTable = c.CTable,
  1166. PayDId = c.PayDId,
  1167. OrbitalPrivateTransfer = c.OrbitalPrivateTransfer,
  1168. Payee = c.Payee,
  1169. IsPay = c.IsPay,
  1170. RMBPrice = c.RMBPrice,
  1171. DayRate = c.DayRate,
  1172. //添加属性
  1173. ConsumptionPatterns = c.ConsumptionPatterns,
  1174. CTDId = c.CTDId,
  1175. BankNo = c.BankNo,
  1176. CardholderName = c.CardholderName,
  1177. ConsumptionDate = c.ConsumptionDate,
  1178. CompanyBankNo = c.CompanyBankNo,
  1179. OtherBankName = c.OtherBankName,
  1180. OtherSideNo = c.OtherSideNo,
  1181. OtherSideName = c.OtherSideName
  1182. }).ExecuteCommandAsync();
  1183. noticeSign = 2;
  1184. noticeCcpId = grp_CreditCard.Id;
  1185. if (CTable == 0)
  1186. {
  1187. RollbackTran();
  1188. return result = new Result() { Code = -2, Msg = "修改失败" };
  1189. }
  1190. }
  1191. else//添加
  1192. {
  1193. int id = await _sqlSugar.Insertable(c).ExecuteReturnIdentityAsync();
  1194. noticeCcpId = id;
  1195. if (id == 0)
  1196. {
  1197. RollbackTran();
  1198. return result = new Result() { Code = -2, Msg = "添加失败" };
  1199. }
  1200. }
  1201. #endregion
  1202. _ = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservations>()
  1203. .Where(a => a.Id == dto.CTGGRId && a.DiId == dto.DiId && a.IsDel == 0)
  1204. .SetColumns(a => new Grp_CarTouristGuideGroundReservations
  1205. {
  1206. CId = dto.Currency,
  1207. ServiceQuotedPrice = c.PayMoney,
  1208. OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer,
  1209. SelectCheck = string.Join(',', dto.SelectCheck),
  1210. Rate = dto.Rate,
  1211. toCurr = dto.toCurr
  1212. })
  1213. .ExecuteCommandAsync();
  1214. var data = new { ccpId = noticeCcpId, sign = noticeSign };
  1215. result = new Result() { Code = 0, Msg = "保存成功", Data = data };
  1216. CommitTran();
  1217. }
  1218. catch (Exception ex)
  1219. {
  1220. RollbackTran();
  1221. result = new Result() { Code = -2, Msg = $"接口异常!({ex.Message})" };
  1222. }
  1223. return result;
  1224. }
  1225. /// <summary>
  1226. /// 超支费用
  1227. /// 1增、2改、3删
  1228. /// </summary>
  1229. /// <param name="dto"></param>
  1230. /// <returns></returns>
  1231. private async Task<Result> PostGroupExtraCost_Operator(Fin_GroupExtraCostDto_OP dto)
  1232. {
  1233. Result rt = new Result();
  1234. #region 验证
  1235. #endregion
  1236. Fin_GroupExtraCost _entity = new Fin_GroupExtraCost();
  1237. _entity.DiId = dto.diId;
  1238. _entity.PriceName = dto.priceName;
  1239. _entity.Price = dto.price;
  1240. _entity.PriceCurrency = dto.currency;
  1241. _entity.PriceType = dto.priceType;
  1242. _entity.Coefficient = dto.coefficient;
  1243. _entity.PriceDetailType = dto.priceDetailType;
  1244. _entity.FilePath = dto.filePath;
  1245. _entity.Remark = dto.remark;
  1246. _entity.PriceCount = dto.PriceCount;
  1247. _entity.PriceDt = DateTime.Parse(dto.PriceDt);
  1248. _entity.PriceSum = dto.price * dto.PriceCount;
  1249. _entity.Area = dto.Area;
  1250. _entity.SupervisorConfirm = dto.SupervisorConfirm;
  1251. _entity.ManagerConfirm = dto.ManagerConfirm;
  1252. _entity.SYsupervisorConfirm = dto.SYsupervisorConfirm;
  1253. _daiRep.BeginTran();
  1254. if (dto.editType == 1)
  1255. {
  1256. _entity.CreateUserId = dto.createUser;
  1257. _entity.CreateTime = DateTime.Now;
  1258. _entity.IsDel = 0;
  1259. int returnId = await _daiRep.AddAsyncReturnId<Fin_GroupExtraCost>(_entity);
  1260. if (returnId > 0)
  1261. {
  1262. dto.Id = returnId;
  1263. }
  1264. }
  1265. else if (dto.editType == 2)
  1266. {
  1267. bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
  1268. {
  1269. PriceName = dto.priceName,
  1270. Price = dto.price,
  1271. PriceCurrency = dto.currency,
  1272. PriceType = dto.priceType,
  1273. PriceDetailType = dto.priceDetailType,
  1274. Coefficient = dto.coefficient,
  1275. FilePath = dto.filePath,
  1276. Remark = dto.remark,
  1277. PriceCount = dto.PriceCount,
  1278. PriceDt = _entity.PriceDt,
  1279. PriceSum = _entity.PriceSum,
  1280. Area = _entity.Area,
  1281. });
  1282. if (!res)
  1283. {
  1284. _daiRep.RollbackTran();
  1285. //Ok(JsonView(false, "2操作失败!"))
  1286. rt.Msg = "2操作失败!";
  1287. return rt;
  1288. }
  1289. }
  1290. else if (dto.editType == 3)
  1291. {
  1292. string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
  1293. bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
  1294. {
  1295. IsDel = 1,
  1296. DeleteTime = delTime,
  1297. DeleteUserId = dto.createUser
  1298. });
  1299. if (!res)
  1300. {
  1301. _daiRep.RollbackTran();
  1302. rt.Msg = "3操作失败!";
  1303. return rt;
  1304. }
  1305. }
  1306. else
  1307. {
  1308. _daiRep.RollbackTran();
  1309. rt.Msg = "未知的editType";
  1310. return rt;
  1311. }
  1312. if (!(await extraCost_editCreditCardPayment(dto)))
  1313. {
  1314. rt.Msg = "ccp操作失败";
  1315. return rt;
  1316. }
  1317. _daiRep.CommitTran();
  1318. rt.Code = 0;
  1319. rt.Msg = "操作成功";
  1320. rt.Data = dto.Id;
  1321. return rt;
  1322. }
  1323. private async Task<bool> extraCost_editCreditCardPayment(Fin_GroupExtraCostDto_OP costDto)
  1324. {
  1325. //设置团组汇率
  1326. decimal dcm_dayrate = 1M;
  1327. decimal dcm_rmbPrice = costDto.price;
  1328. int ispay = costDto.payType == 72 ? 1 : 0;
  1329. if (costDto.costSign != 3)
  1330. {
  1331. //获取新汇率 int diId,int CId, int currencyId
  1332. Result rate = await _setDataRep.PostCurrencyByDiid(costDto.diId, 1015, costDto.currency);
  1333. if (rate.Code == 0)
  1334. {
  1335. var rateInfo = (rate.Data as CurrencyInfo);
  1336. if (rateInfo is not null)
  1337. {
  1338. dcm_dayrate = rateInfo.Rate;
  1339. dcm_rmbPrice = rateInfo.Rate * dcm_rmbPrice;
  1340. }
  1341. else
  1342. {
  1343. dcm_dayrate = 1;
  1344. }
  1345. }
  1346. }
  1347. Grp_CreditCardPayment ccp = _daiRep.Query<Grp_CreditCardPayment>(s => s.CId == costDto.Id && s.CTable == 1015).First();
  1348. if (ccp == null)
  1349. {
  1350. ccp = new Grp_CreditCardPayment();
  1351. ccp.PayDId = costDto.payType;// dto
  1352. ccp.ConsumptionPatterns = "";
  1353. ccp.ConsumptionDate = "";
  1354. ccp.CTDId = costDto.payCardId;// dto
  1355. ccp.BankNo = "";
  1356. ccp.CardholderName = "";
  1357. ccp.PayMoney = costDto.price;// dto
  1358. ccp.PaymentCurrency = costDto.currency;// dto
  1359. ccp.CompanyBankNo = "";
  1360. ccp.OtherBankName = "";
  1361. ccp.OtherSideNo = "";
  1362. ccp.OtherSideName = "";
  1363. ccp.Remark = "";
  1364. ccp.CreateUserId = costDto.createUser;
  1365. ccp.CreateTime = DateTime.Now;
  1366. ccp.MFOperator = 0;
  1367. ccp.MFOperatorDate = "";
  1368. ccp.IsAuditDM = 0;
  1369. ccp.AuditDMOperate = 0;
  1370. ccp.AuditDMDate = "";
  1371. ccp.IsAuditMF = 0;
  1372. ccp.AuditMFOperate = 0;
  1373. ccp.AuditMFDate = "";
  1374. ccp.IsAuditGM = 0;
  1375. ccp.AuditGMOperate = 0;
  1376. ccp.AuditGMDate = "";
  1377. ccp.IsPay = ispay; // upd
  1378. ccp.DIId = costDto.diId;// dto
  1379. ccp.CId = costDto.Id;// dto
  1380. ccp.CTable = 1015; //超支费用指向id
  1381. ccp.IsDel = 0;
  1382. ccp.PayPercentage = 100M;
  1383. ccp.PayThenMoney = 0M;
  1384. ccp.PayPercentageOld = 100M;
  1385. ccp.PayThenMoneyOld = 0M;
  1386. ccp.UpdateDate = "";
  1387. ccp.Payee = costDto.payee;// dto
  1388. ccp.OrbitalPrivateTransfer = costDto.costSign;// dto
  1389. ccp.ExceedBudget = 0;
  1390. ccp.DayRate = dcm_dayrate; //upd
  1391. ccp.RMBPrice = dcm_rmbPrice; //upd
  1392. int ccpInsertId = _daiRep.AddReturnId<Grp_CreditCardPayment>(ccp);
  1393. if (ccpInsertId > 0)
  1394. {
  1395. return true;
  1396. }
  1397. }
  1398. else
  1399. {
  1400. if (costDto.editType == 2)
  1401. {
  1402. bool res = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
  1403. {
  1404. PayDId = costDto.payType,
  1405. CTDId = costDto.payCardId,
  1406. PayMoney = costDto.price,
  1407. PaymentCurrency = costDto.currency,
  1408. IsPay = ispay,
  1409. Payee = costDto.payee,
  1410. OrbitalPrivateTransfer = costDto.costSign,
  1411. DayRate = dcm_dayrate,
  1412. RMBPrice = dcm_rmbPrice
  1413. });
  1414. return res;
  1415. }
  1416. else if (costDto.editType == 3)
  1417. {
  1418. string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
  1419. bool res2 = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
  1420. {
  1421. IsDel = 1,
  1422. DeleteTime = delTime,
  1423. DeleteUserId = costDto.createUser
  1424. });
  1425. return res2;
  1426. }
  1427. }
  1428. return false;
  1429. }
  1430. public async Task<Result> GroupExtraCost_OperatorList(List<Fin_GroupExtraCostDto_OP> dto)
  1431. {
  1432. Result rt = new Result();
  1433. foreach (var item in dto)
  1434. {
  1435. await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.PriceName == item.priceName && s.DiId == item.diId,
  1436. s => new Fin_GroupExtraCost
  1437. {
  1438. IsDel = 1,
  1439. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  1440. DeleteUserId = item.createUser
  1441. });
  1442. rt = await PostGroupExtraCost_Operator(item);
  1443. }
  1444. return rt;
  1445. }
  1446. }
  1447. }