ForeignReceivablesRepository.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. using AutoMapper;
  2. using MathNet.Numerics.Statistics.Mcmc;
  3. using NPOI.SS.Formula.Functions;
  4. using OASystem.Domain;
  5. using OASystem.Domain.Dtos.Financial;
  6. using OASystem.Domain.Dtos.Groups;
  7. using OASystem.Domain.Entities.Financial;
  8. using OASystem.Domain.Entities.Groups;
  9. using OASystem.Domain.ViewModels.Financial;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using OASystem.Infrastructure.Repositories.System;
  13. using SqlSugar;
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Linq;
  17. using System.Text;
  18. using System.Threading.Tasks;
  19. namespace OASystem.Infrastructure.Repositories.Financial
  20. {
  21. /// <summary>
  22. /// 财务 - 团组应收款项 仓库
  23. /// 雷怡 2023.08.16 15:03
  24. /// </summary>
  25. public class ForeignReceivablesRepository : BaseRepository<Fin_ForeignReceivables, Fin_ForeignReceivablesView>
  26. {
  27. private readonly IMapper _mapper;
  28. private readonly DelegationInfoRepository _delegationRep;
  29. private readonly SetDataRepository _setDataRep;
  30. public ForeignReceivablesRepository(SqlSugarClient sqlSugar, IMapper mapper, DelegationInfoRepository delegationRep, SetDataRepository setDataRep)
  31. : base(sqlSugar)
  32. {
  33. _mapper = mapper;
  34. _delegationRep = delegationRep;
  35. _setDataRep = setDataRep;
  36. }
  37. #region 关联已收款项
  38. /// <summary>
  39. /// 收款账单 数据源
  40. /// </summary>
  41. /// <returns></returns>
  42. public async Task<JsonView> GetDataSource(ForeignReceivablesDataSourcesDto dto)
  43. {
  44. JsonView result = new() { Code = StatusCodes.Status204NoContent };
  45. //已收款项 判断如果是市场部的人员进来的话 只显示自己的 其他的都显示全部的
  46. var userInfos = await _sqlSugar.Queryable<Sys_Users>()
  47. .InnerJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  48. .Where((u, d) => u.IsDel == 0 && d.DepName.Contains("市场部") && u.Id == dto.CurrUserId)
  49. .ToListAsync();
  50. string sqlWhere = "";
  51. if (userInfos.Count > 0) sqlWhere = string.Format(@$" And JietuanOperator={dto.CurrUserId} ");
  52. string sql = string.Format(@$"Select Id,TeamName GroupName From Grp_DelegationInfo
  53. Where TeamName != '' And IsDel = 0 {sqlWhere}
  54. Order By Id Desc");
  55. var _groupNameList = await _sqlSugar.SqlQueryable<GroupNameView>(sql).ToListAsync();
  56. //var groupNameData = await _delegationRep.GetGroupNameList(new GroupNameDto());
  57. var currencyData = await _setDataRep.GetSetDataBySTId(_setDataRep, 66); //币种
  58. var remittanceMethodData = await _setDataRep.GetSetDataBySTId(_setDataRep, 14); //汇款方式
  59. result.Code = StatusCodes.Status200OK;
  60. result.Msg = "成功!";
  61. result.Data = new
  62. {
  63. GroupNameData = _groupNameList,
  64. CurrencyData = currencyData.Data,
  65. RemittanceMethodData = remittanceMethodData.Data
  66. };
  67. return result;
  68. }
  69. /// <summary>
  70. /// 根据diid查询团组应收款项
  71. /// </summary>
  72. /// <param name="diid"></param>
  73. /// <returns></returns>
  74. public async Task<Result> GetGroupReceivablesInfoByDiId(ForForeignReceivablesInfoDto dto)
  75. {
  76. Result result = new() { Code = -2 };
  77. var groupInfoData = await _delegationRep.GetGroupInfo(new GroupInfoDto() { Id = dto.DiId });
  78. //应收款项
  79. string groupReceivedSql = string.Format(@"Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0}", dto.DiId);
  80. var groupReceivedList = await _sqlSugar.SqlQueryable<ForeignReceivablesView>(groupReceivedSql).ToListAsync();
  81. //已收款项
  82. string groupProceedsReceivedSql = string.Format(@"Select * From Fin_ProceedsReceived Where IsDel=0 And Diid={0}", dto.DiId);
  83. var groupProceedsReceivedList = await _sqlSugar.SqlQueryable<ProceedsReceivedView>(groupProceedsReceivedSql).ToListAsync();
  84. List<ProceedsReceivedView> NotFIDData = new List<ProceedsReceivedView>();
  85. if (dto.PortType == 1)
  86. {
  87. foreach (var item in groupReceivedList)
  88. {
  89. item._ProceedsReceivedDatas = groupProceedsReceivedList.Where(s => s.FID == item.Id).ToList();
  90. }
  91. NotFIDData = groupProceedsReceivedList.Where(s => !groupReceivedList.Any(e => s.FID == e.Id)).ToList();
  92. }
  93. result.Code = 0;
  94. result.Msg = "查询成功!";
  95. result.Data = new
  96. {
  97. GroupInfo = groupInfoData.Data,
  98. GroupCollectionStatementData = new
  99. {
  100. ReceivedData = groupReceivedList,
  101. UnallocatedData = NotFIDData
  102. }
  103. };
  104. return result;
  105. }
  106. /// <summary>
  107. /// 应收款项 删除
  108. /// </summary>
  109. /// <param name="dto"></param>
  110. /// <returns></returns>
  111. public async Task<Result> _Del(DelForForeignReceivablesInfoDto dto)
  112. {
  113. Result result = new Result() { Code = -1, Msg = "程序错误!" };
  114. _sqlSugar.BeginTran();
  115. try
  116. {
  117. var res = await _sqlSugar.Updateable<Fin_ForeignReceivables>()
  118. .Where(it => it.Id == dto.Id)
  119. .SetColumns(it => new Fin_ForeignReceivables()
  120. {
  121. IsDel = 1,
  122. DeleteUserId = dto.UserId,
  123. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  124. }
  125. ).ExecuteCommandAsync();
  126. if (res > 0)
  127. {
  128. await _sqlSugar.Updateable<Fin_ProceedsReceived>()
  129. .Where(a => a.FID == dto.Id)
  130. .SetColumns(a => new Fin_ProceedsReceived
  131. {
  132. IsDel = 1,
  133. DeleteUserId = dto.UserId,
  134. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  135. }).ExecuteCommandAsync();
  136. _sqlSugar.CommitTran();
  137. result.Msg = "删除成功!";
  138. result.Code = 0;
  139. }
  140. else
  141. {
  142. _sqlSugar.RollbackTran();
  143. result.Msg = "删除失败!";
  144. return result;
  145. }
  146. }
  147. catch (Exception ex)
  148. {
  149. _sqlSugar.RollbackTran();
  150. result.Msg = ex.Message;
  151. return result;
  152. }
  153. return result;
  154. }
  155. /// <summary>
  156. /// 财务模块
  157. /// 收款账单 Add And Update
  158. /// </summary>
  159. /// <param name="diid"></param>
  160. /// <returns></returns>
  161. public async Task<Result> PostReceivablesOperate(ForeignReceivablesAddAndUpdateDto dto)
  162. {
  163. Result result = new() { Code = -2 };
  164. if (dto.foreignReceivablesInfos.Count <= 0)
  165. {
  166. result.Msg = "收款账单没有信息,不能进行,添加或修改操作!!!";
  167. return result;
  168. }
  169. int addCount = 0, updateCount = 0;
  170. if (dto.PortType == 1)
  171. {
  172. List<Fin_ForeignReceivables> _ForeignReceivables = new List<Fin_ForeignReceivables>();
  173. foreach (var item in dto.foreignReceivablesInfos)
  174. {
  175. _ForeignReceivables.Add(new Fin_ForeignReceivables()
  176. {
  177. Diid = dto.DiId,
  178. Id = item.Id,
  179. PriceName = item.PriceName,
  180. Price = item.Price,
  181. Count = item.Count,
  182. Unit = item.Unit,
  183. ItemSumPrice = item.ItemSumPrice,
  184. Rate = item.Rate,
  185. Currency = item.Currency,
  186. AddingWay = item.AddingWay,
  187. CreateUserId = dto.UserId,
  188. CreateTime = DateTime.Now,
  189. Remark = item.Remark
  190. });
  191. }
  192. if (_ForeignReceivables.Count > 0)
  193. {
  194. var x = _sqlSugar.Storageable(_ForeignReceivables).ToStorage();
  195. addCount = x.AsInsertable.ExecuteCommand(); //不存在插入
  196. updateCount = x.AsUpdateable.ExecuteCommand(); //存在更新
  197. }
  198. result.Code = 0;
  199. result.Msg = string.Format(@"操作成功!添加:{0}条;更新:{1};", addCount, updateCount);
  200. }
  201. return result;
  202. }
  203. /// <summary>
  204. /// 根据diid查询团组应收款项
  205. /// </summary>
  206. /// <param name="diid"></param>
  207. /// <returns></returns>
  208. public async Task<Result> GetGroupReceivablesByDiid(int diid)
  209. {
  210. Result result = new() { Code = -2 };
  211. string sql = string.Format(@"Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0}", diid);
  212. var groupReceivedList = await _sqlSugar.SqlQueryable<Fin_ForeignReceivables>(sql).ToListAsync();
  213. result.Code = 0;
  214. result.Msg = "查询成功!";
  215. result.Data = groupReceivedList;
  216. return result;
  217. }
  218. /// <summary>
  219. /// 根据diid 数组 查询团组应收款项
  220. /// </summary>
  221. /// <param name="diid"></param>
  222. /// <returns></returns>
  223. public async Task<Result> GetGroupReceivablesByDiids(int[] diids)
  224. {
  225. Result result = new() { Code = -2 };
  226. //string sql = string.Format(@"Select * From Fin_ProceedsReceived Where IsDel=0 And Diid={0}", diids);
  227. var groupReceivedList = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  228. .Where(pr => pr.IsDel == 0 && diids.Contains(pr.Diid)).ToListAsync();
  229. result.Code = 0;
  230. result.Msg = "查询成功!";
  231. result.Data = groupReceivedList;
  232. return result;
  233. }
  234. #endregion
  235. #region 未关联已收款项
  236. /// <summary>
  237. /// 收款账单 数据源
  238. /// </summary>
  239. /// <returns></returns>
  240. public async Task<JsonView> PostDataSource(ForeignReceivablesDataSourcesDto dto)
  241. {
  242. JsonView result = new() { Code = StatusCodes.Status204NoContent };
  243. //已收款项 判断如果是市场部的人员进来的话 只显示自己的 其他的都显示全部的
  244. var userInfos = await _sqlSugar.Queryable<Sys_Users>()
  245. .InnerJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  246. .Where((u, d) => u.IsDel == 0 && d.DepName.Contains("市场部") && u.Id == dto.CurrUserId)
  247. .ToListAsync();
  248. string sqlWhere = "";
  249. if (userInfos.Count > 0) sqlWhere = string.Format(@$" And JietuanOperator={dto.CurrUserId} ");
  250. string sql = string.Format(@$"Select Id,TeamName GroupName From Grp_DelegationInfo
  251. Where TeamName != '' And IsDel = 0 {sqlWhere}
  252. Order By Id Desc");
  253. var _groupNameList = await _sqlSugar.SqlQueryable<GroupNameView>(sql).ToListAsync();
  254. //var groupNameData = await _delegationRep.GetGroupNameList(new GroupNameDto());
  255. var currencyData = await _setDataRep.GetSetDataBySTId(_setDataRep, 66); //币种
  256. var remittanceMethodData = await _setDataRep.GetSetDataBySTId(_setDataRep, 14); //汇款方式
  257. result.Code = StatusCodes.Status200OK;
  258. result.Msg = "成功!";
  259. result.Data = new
  260. {
  261. GroupNameData = _groupNameList,
  262. CurrencyData = currencyData.Data,
  263. RemittanceMethodData = remittanceMethodData.Data
  264. };
  265. return result;
  266. }
  267. /// <summary>
  268. /// 根据diid查询团组应收款项
  269. /// </summary>
  270. /// <param name="diid"></param>
  271. /// <returns></returns>
  272. public async Task<JsonView> PostGroupReceivablesInfoByDiId(ForForeignReceivablesNewDto dto)
  273. {
  274. JsonView result = new() { Code = 400,Msg="" };
  275. //var groupInfoData = await _delegationRep.GetGroupInfo(new GroupInfoDto() { Id = dto.DiId });
  276. var groupInfoData = await _delegationRep.Query(x => x.Id == dto.DiId)
  277. .Select(x => new
  278. {
  279. x.Id,
  280. x.TeamName,
  281. x.TourCode,
  282. x.ClientName,
  283. VisitCountry = x.VisitCountry.Replace("|","、"),
  284. x.VisitDays,
  285. x.VisitPNumber,
  286. x.VisitStartDate,
  287. x.VisitEndDate
  288. })
  289. .FirstAsync();
  290. //应收款项
  291. string groupReceivedSql = string.Format(@"Select *,su.CnName As AuditorName From Fin_ForeignReceivables ffr
  292. Left Join Sys_Users su On ffr.Auditor = su.Id
  293. Where ffr.IsDel=0 And ffr.Diid={0}", dto.DiId);
  294. var groupReceivedList = await _sqlSugar.SqlQueryable<ProceedsReceivedNewView>(groupReceivedSql).ToListAsync();
  295. result.Code = 200;
  296. result.Msg = "查询成功!";
  297. result.Data = new
  298. {
  299. GroupInfo = groupInfoData,
  300. GroupCollectionStatementData = groupReceivedList
  301. };
  302. return result;
  303. }
  304. /// <summary>
  305. /// 财务模块
  306. /// 收款账单 Add And Update
  307. /// </summary>
  308. /// <param name="diid"></param>
  309. /// <returns></returns>
  310. public async Task<JsonView> PostReceivablesSave(ForeignReceivablesSaveDto dto)
  311. {
  312. JsonView result = new() { Code = 4002 };
  313. if (dto.foreignReceivablesInfos.Count <= 0)
  314. {
  315. result.Msg = "收款账单没有信息,不能进行,添加或修改操作!!!";
  316. return result;
  317. }
  318. int addCount = 0, updateCount = 0;
  319. if (dto.PortType == 1)
  320. {
  321. //查询值是否更改
  322. var selectInfos = await _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(it => it.Diid == dto.DiId && it.Status == 1).ToListAsync();
  323. List <Fin_ForeignReceivables> _ForeignReceivables = new List<Fin_ForeignReceivables>();
  324. foreach (var item in dto.foreignReceivablesInfos)
  325. {
  326. int status = 0, auditor = 0;
  327. string auditTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  328. var info = selectInfos.Find(x => x.Id == item.Id);
  329. if (info != null)
  330. {
  331. if (info.ItemSumPrice == item.ItemSumPrice)
  332. {
  333. status = info.Status;
  334. auditor = info.Auditor;
  335. auditTime = info.AuditTime;
  336. }
  337. }
  338. _ForeignReceivables.Add(new Fin_ForeignReceivables()
  339. {
  340. Diid = dto.DiId,
  341. Id = item.Id,
  342. PriceName = item.PriceName,
  343. Price = item.Price,
  344. Count = item.Count,
  345. Unit = item.Unit,
  346. ItemSumPrice = item.ItemSumPrice,
  347. Rate = item.Rate,
  348. Currency = item.Currency,
  349. AddingWay = item.AddingWay,
  350. CreateUserId = dto.UserId,
  351. CreateTime = DateTime.Now,
  352. Remark = item.Remark,
  353. Status = status,
  354. Auditor = auditor,
  355. AuditTime = auditTime
  356. });
  357. }
  358. if (_ForeignReceivables.Count > 0)
  359. {
  360. var x = _sqlSugar.Storageable(_ForeignReceivables).ToStorage();
  361. addCount = x.AsInsertable.ExecuteCommand(); //不存在插入
  362. updateCount = x.AsUpdateable.IgnoreColumns(it => new
  363. {
  364. //it.Status,
  365. //it.Auditor,
  366. //it.AuditTime,
  367. it.CreateUserId,
  368. it.CreateTime
  369. }).ExecuteCommand(); //存在更新
  370. }
  371. result.Code = 200;
  372. result.Msg = string.Format(@"操作成功!添加:{0}条;更新:{1};", addCount, updateCount);
  373. }
  374. return result;
  375. }
  376. /// <summary>
  377. /// 财务模块
  378. /// 收款账单
  379. /// Audit
  380. /// </summary>
  381. /// <param name="diid"></param>
  382. /// <returns></returns>
  383. public async Task<JsonView> FeeAudit(FeeAuditDto dto)
  384. {
  385. JsonView result = new() { Code = 400 };
  386. //验证
  387. var info = await _sqlSugar.Queryable<Fin_ForeignReceivables>().FirstAsync(x => x.Id == dto.Id);
  388. if (info == null)
  389. {
  390. result.Msg = "数据不存在";
  391. return result;
  392. }
  393. if (info.AddingWay != 2)
  394. {
  395. result.Msg = "该条数据类型不是“实际报价”类型不可审核!";
  396. return result;
  397. }
  398. var AuditStatus = await _sqlSugar.Updateable<Fin_ForeignReceivables>()
  399. .SetColumns(a => new Fin_ForeignReceivables
  400. {
  401. Status = dto.Status,
  402. Auditor = dto.UserId,
  403. AuditTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  404. })
  405. .Where(a => a.Id == dto.Id)
  406. .ExecuteCommandAsync();
  407. if (AuditStatus > 0)
  408. {
  409. result.Msg = "操作成功!";
  410. result.Code = 200;
  411. }
  412. else
  413. {
  414. result.Msg = "操作失败!";
  415. }
  416. return result;
  417. }
  418. /// <summary>
  419. /// 财务模块
  420. /// 收款账单
  421. /// Del
  422. /// </summary>
  423. /// <param name="diid"></param>
  424. /// <returns></returns>
  425. public async Task<Result> PostReceivablesDel(ForeignReceivablesDelDto dto)
  426. {
  427. Result result = new() { Code = -2 };
  428. var delStatus = await _sqlSugar.Updateable<Fin_ForeignReceivables>()
  429. .SetColumns(a => new Fin_ForeignReceivables
  430. {
  431. IsDel = 1,
  432. DeleteUserId = dto.UserId,
  433. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  434. })
  435. .Where(a => a.Id == dto.Id)
  436. .ExecuteCommandAsync();
  437. if (delStatus > 0)
  438. {
  439. result.Msg = "操作成功!";
  440. result.Code = 0;
  441. }
  442. else
  443. {
  444. result.Msg = "操作成功!";
  445. }
  446. return result;
  447. }
  448. public void OverSpSeteceivables(OverSpSeteceivablesDto dto)
  449. {
  450. var querySaveReceivables = _sqlSugar.Queryable<Fin_ForeignReceivables>()
  451. .First(x => x.Diid == dto.DiId && x.AddingWay == 3 && x.IsDel == 0);
  452. //获取所有超支数据
  453. //整理超支数据
  454. //币种不同则计算rmb值
  455. var overspList = _sqlSugar.Queryable<Fin_GroupExtraCost, Grp_CreditCardPayment>
  456. ((e, c) => c.CTable == 1015 && c.CId == e.Id && c.IsDel == 0).
  457. Where((e, c) => e.IsDel == 0 && e.DiId == dto.DiId && (e.SupervisorConfirm == 1 || e.ManagerConfirm == 1)).
  458. Select((e, c) => new
  459. {
  460. e.Price,
  461. e.PriceCount,
  462. e.Coefficient,
  463. e.PriceSum,
  464. c.RMBPrice,
  465. c.DayRate,
  466. e.PriceCurrency,
  467. e.Remark,
  468. })
  469. .ToList();
  470. var overspListGroup = overspList.GroupBy(x => x.PriceCurrency).ToList();
  471. string foreignReceivablesRemake = string.Empty;
  472. int count = 1;
  473. overspList.ForEach(x =>
  474. {
  475. foreignReceivablesRemake += $"{count}.{x.Remark}";
  476. count++;
  477. });
  478. if (querySaveReceivables != null)
  479. {
  480. if (overspList.Count() > 0)
  481. {
  482. if (overspListGroup.Count() > 1)
  483. {
  484. querySaveReceivables.Currency = 836; //人民币
  485. querySaveReceivables.Rate = 1;
  486. querySaveReceivables.Price = overspListGroup.Sum(x => x.Sum(y => y.PriceSum * y.Coefficient * y.DayRate));
  487. querySaveReceivables.ItemSumPrice = overspListGroup.Sum(x => x.Sum(y => y.PriceSum * y.Coefficient * y.DayRate));
  488. querySaveReceivables.Remark = foreignReceivablesRemake;
  489. querySaveReceivables.CreateTime = DateTime.Now;
  490. }
  491. else
  492. {
  493. querySaveReceivables.Currency = overspList[0].PriceCurrency;
  494. querySaveReceivables.Rate = overspList[0].DayRate;
  495. querySaveReceivables.Price = overspListGroup[0].Sum(x => x.PriceSum * x.Coefficient);
  496. querySaveReceivables.ItemSumPrice = overspListGroup[0].Sum(x => x.PriceSum * x.Coefficient);
  497. querySaveReceivables.Remark = foreignReceivablesRemake;
  498. querySaveReceivables.AddingWay = 3;
  499. querySaveReceivables.CreateTime = DateTime.Now;
  500. }
  501. }
  502. else
  503. {
  504. querySaveReceivables.Currency = 836; //人民币
  505. querySaveReceivables.Rate = 1;
  506. querySaveReceivables.Price = 0;
  507. querySaveReceivables.ItemSumPrice = 0;
  508. querySaveReceivables.Remark = "";
  509. querySaveReceivables.CreateTime = DateTime.Now;
  510. querySaveReceivables.Count = 1;
  511. }
  512. _sqlSugar.Updateable(querySaveReceivables).ExecuteCommand();
  513. }
  514. else
  515. {
  516. if (overspList.Count() > 0)
  517. {
  518. if (overspListGroup.Count() > 1)
  519. {
  520. querySaveReceivables = new Fin_ForeignReceivables
  521. {
  522. CreateTime = DateTime.Now,
  523. CreateUserId = dto.CreateUserId,
  524. Diid = dto.DiId,
  525. PriceName = "超支费用",
  526. AddingWay = 3,
  527. Count = 1,
  528. Currency = 836,
  529. ItemSumPrice = overspList.Sum(x => x.PriceSum * x.Coefficient * x.DayRate),
  530. Price = overspList.Sum(x => x.PriceSum * x.Coefficient * x.DayRate),
  531. Rate = 1,
  532. IsDel = 0,
  533. Remark = foreignReceivablesRemake,
  534. Unit = "团",
  535. };
  536. }
  537. else
  538. {
  539. querySaveReceivables = new Fin_ForeignReceivables
  540. {
  541. CreateTime = DateTime.Now,
  542. CreateUserId = dto.CreateUserId,
  543. Diid = dto.DiId,
  544. PriceName = "超支费用",
  545. AddingWay = 3,
  546. Count = 1,
  547. Currency = overspList[0].PriceCurrency,
  548. ItemSumPrice = overspList.Sum(x => x.PriceSum * x.Coefficient),
  549. Price = overspList.Sum(x => x.PriceSum * x.Coefficient),
  550. Rate = overspList[0].DayRate,
  551. IsDel = 0,
  552. Remark = foreignReceivablesRemake,
  553. Unit = "团",
  554. };
  555. }
  556. }
  557. _sqlSugar.Insertable(querySaveReceivables).ExecuteCommand();
  558. }
  559. }
  560. #endregion
  561. }
  562. }