InvitationOfficialActivitiesRepository.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. using AutoMapper;
  2. using MathNet.Numerics.Statistics.Mcmc;
  3. using NPOI.SS.Formula.Functions;
  4. using OASystem.Domain;
  5. using OASystem.Domain.Dtos.Groups;
  6. using OASystem.Domain.Entities.Financial;
  7. using OASystem.Domain.Entities.Groups;
  8. using OASystem.Domain.Entities.Resource;
  9. using OASystem.Domain.ViewModels.Groups;
  10. using OASystem.Domain.ViewModels.QiYeWeChat;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Security.Cryptography;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. namespace OASystem.Infrastructure.Repositories.Groups
  18. {
  19. public class InvitationOfficialActivitiesRepository : BaseRepository<Grp_InvitationOfficialActivities, InvitationOfficialActivitiesListDto>
  20. {
  21. private readonly IMapper _mapper;
  22. public InvitationOfficialActivitiesRepository(SqlSugarClient sqlSugar, IMapper mapper) :
  23. base(sqlSugar)
  24. {
  25. this._mapper = mapper;
  26. }
  27. /// <summary>
  28. /// 根据商邀费用Id查询C表和商邀资料及费用表
  29. /// </summary>
  30. /// <param name="dto"></param>
  31. /// <returns></returns>
  32. public async Task<Result> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  33. {
  34. Result result = new Result() { Code = -2, Msg = "程序错误" };
  35. try
  36. {
  37. Grp_InvitationOfficialActivities grp_Invitation = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().First(a => a.Id == dto.Id && a.IsDel == 0);
  38. Grp_CreditCardPayment grp_CreditCard = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable==81);
  39. Res_InvitationOfficialActivityData res_InvitationOfficialActivityData = new Res_InvitationOfficialActivityData();
  40. if (grp_Invitation!=null)
  41. {
  42. res_InvitationOfficialActivityData = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().First(a =>a.Country==grp_Invitation.InviterArea && a.UnitName==grp_Invitation.Inviter && a.IsDel == 0);
  43. if (dto.PortType == 1)
  44. {
  45. var data = new
  46. {
  47. _Invitation = grp_Invitation,
  48. _InvitationData = res_InvitationOfficialActivityData,
  49. _CreditCard = grp_CreditCard,
  50. };
  51. result = new Result() { Code = 0, Msg = "查询成功!", Data = data };
  52. }
  53. else
  54. {
  55. InvitationOfficialActivitiesByIdView invitation = _mapper.Map<InvitationOfficialActivitiesByIdView>(grp_Invitation);
  56. res_InvitationOfficialActivityData ??= new Res_InvitationOfficialActivityData();
  57. invitation.ConsumptionPatterns = grp_CreditCard.ConsumptionPatterns;
  58. invitation.ConsumptionDate = grp_CreditCard.ConsumptionDate;
  59. invitation.PayDId = grp_CreditCard.PayDId;
  60. invitation.ConsumptionPatterns = grp_CreditCard.ConsumptionPatterns;
  61. invitation.ConsumptionDate = grp_CreditCard.ConsumptionDate;
  62. invitation.BankNo = grp_CreditCard.BankNo;
  63. invitation.CardholderName = grp_CreditCard.CardholderName;
  64. invitation.CompanyBankNo = grp_CreditCard.CompanyBankNo;
  65. invitation.OtherBankName = grp_CreditCard.OtherBankName;
  66. invitation.OtherSideNo = grp_CreditCard.OtherSideNo;
  67. invitation.OtherSideName = grp_CreditCard.OtherSideName;
  68. invitation.PayMoney = grp_CreditCard.PayMoney;
  69. invitation.PaymentCurrency = grp_CreditCard.PaymentCurrency;
  70. invitation.OrbitalPrivateTransfer = grp_CreditCard.OrbitalPrivateTransfer;
  71. invitation.Payee = grp_CreditCard.Payee;
  72. invitation.Address = res_InvitationOfficialActivityData.Address;
  73. invitation.Contact = res_InvitationOfficialActivityData.Contact;
  74. invitation.Job = res_InvitationOfficialActivityData.Job;
  75. invitation.Tel = res_InvitationOfficialActivityData.Tel;
  76. invitation.Email = res_InvitationOfficialActivityData.Email;
  77. invitation.Fax = res_InvitationOfficialActivityData.Fax;
  78. invitation.OtherInformation = res_InvitationOfficialActivityData.Remark;
  79. invitation.CTDId = grp_CreditCard.CTDId;
  80. result = new Result() { Code = 0, Msg = "查询成功!", Data = invitation };
  81. }
  82. }
  83. else
  84. {
  85. if (dto.PortType == 1)
  86. {
  87. var data = new
  88. {
  89. _Invitation = grp_Invitation,
  90. _InvitationData = res_InvitationOfficialActivityData,
  91. _CreditCard = grp_CreditCard,
  92. };
  93. result = new Result() { Code = 0, Msg = "暂无数据!", Data = data };
  94. }
  95. else
  96. {
  97. InvitationOfficialActivitiesByIdView invitation = _mapper.Map<InvitationOfficialActivitiesByIdView>(grp_Invitation);
  98. result = new Result() { Code = 0, Msg = "暂无数据!", Data = invitation };
  99. }
  100. }
  101. }
  102. catch (Exception)
  103. {
  104. result = new Result() { Code = -2, Msg = "程序错误" };
  105. throw;
  106. }
  107. return result;
  108. }
  109. /// <summary>
  110. /// 根据团组id查询商邀费用数据
  111. /// </summary>
  112. /// <param name="dto"></param>
  113. /// <returns></returns>
  114. public async Task<Result> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  115. {
  116. Result result = new Result() { Code = -2, Msg = "未知错误" };
  117. try
  118. {
  119. ListViewBase<InvitationOfficialActivitiesView> rst = new ListViewBase<InvitationOfficialActivitiesView>() { ReceiveDt=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") };
  120. string sqlWhere = string.Empty;
  121. if (!string.IsNullOrWhiteSpace(dto.Inviter))
  122. {
  123. sqlWhere += string.Format(@" And Inviter like '%{0}%'", dto.Inviter);
  124. }
  125. if (!string.IsNullOrWhiteSpace(dto.StartInviteTime) && !string.IsNullOrWhiteSpace(dto.EndInviteTime))
  126. {
  127. sqlWhere += string.Format(@" And i.InviteTime between '{0}' and '{1}'", dto.StartInviteTime, dto.EndInviteTime);
  128. }
  129. sqlWhere += string.Format(@" And i.DiId={0} And i.IsDel={1}", dto.DiId, 0);
  130. string UserId = "";
  131. List<Grp_GroupsTaskAssignment> gtaUIdList = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(a => a.DIId == dto.DiId && a.IsDel == 0 && a.CTId == 81).ToList();
  132. foreach (Grp_GroupsTaskAssignment gta in gtaUIdList)
  133. UserId += gta.UId + ",";
  134. if (!string.IsNullOrWhiteSpace(UserId))
  135. {
  136. UserId = UserId.Substring(0, UserId.Length - 1);
  137. }
  138. else
  139. {
  140. UserId = "0";
  141. }
  142. sqlWhere += string.Format(@" And i.CreateUserId in ({0})", UserId);
  143. if (dto.IsPaySign != -1) {
  144. sqlWhere += string.Format(@" And ccp.IsPay = {0} ", dto.IsPaySign);
  145. }
  146. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  147. {
  148. Regex r = new Regex("And");
  149. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  150. }
  151. //10011
  152. //string sql = string.Format(@"Select Id,DiId,InviterArea,Inviter,InviteTime,
  153. // InviteCost,(Select Name From Sys_SetData Where id=i.InviteCurrency And IsDel=0) As InviteCurrency,
  154. // SendCost,(Select Name From Sys_SetData Where id=i.SendCurrency And IsDel=0) As SendCurrency,
  155. // EventsCost,(Select Name From Sys_SetData Where id=i.EventsCurrency And IsDel=0) As EventsCurrency,
  156. // TranslateCost,(Select Name From Sys_SetData Where id=i.TranslateCurrency And IsDel=0) As TranslateCurrency,
  157. // IsGoOfficaiaBussiness,
  158. // (Select PayMoney From Grp_CreditCardPayment Where CTable=81 And CId=i.Id And IsDel=0) As PayMoney,
  159. // (Select (Select Name From Sys_SetData Where Id =ccp.PaymentCurrency And IsDel=0 ) As PaymentCurrency
  160. // From Grp_CreditCardPayment ccp Where CTable=81 And CId=i.Id And IsDel=0) As PaymentCurrency,
  161. // (Select IsAuditGM From Grp_CreditCardPayment Where CTable=81 And CId=i.Id And IsDel=0) As IsAudit,
  162. // Attachment From Grp_InvitationOfficialActivities i {0} Order By i.id Desc", sqlWhere);
  163. string sql = string.Format(@" Select i.Id,i.DiId,i.InviterArea,i.Inviter,i.InviteTime,i.InviteCost,sd1.[Name] as InviteCurrency
  164. ,i.SendCost,sd2.[Name] as SendCurrency,i.EventsCost,sd3.[Name] as EventsCurrency,i.TranslateCost,sd4.[Name] as TranslateCurrency
  165. ,i.IsGoOfficaiaBussiness,ccp.PayMoney,sd5.[Name] as PaymentCurrency,IsAuditGM as IsAudit,i.Attachment,ccp.IsPay
  166. From Grp_InvitationOfficialActivities as i With(Nolock) Inner Join Grp_CreditCardPayment as ccp With(Nolock) On i.Id = ccp.CId
  167. Left Join Sys_SetData as sd1 On i.InviteCurrency = sd1.Id
  168. Left Join Sys_SetData as sd2 On i.SendCurrency = sd2.Id
  169. Left Join Sys_SetData as sd3 On i.EventsCurrency = sd3.Id
  170. Left Join Sys_SetData as sd4 On i.TranslateCurrency = sd4.Id
  171. Left Join Sys_SetData as sd5 On ccp.PaymentCurrency = sd5.Id
  172. {0} And ccp.CTable = 81
  173. Order By i.id Desc ", sqlWhere);
  174. List<InvitationOfficialActivitiesView> _DecreasePayments = await _sqlSugar.SqlQueryable<InvitationOfficialActivitiesView>(sql).ToListAsync();
  175. if (_DecreasePayments.Count != 0)
  176. {
  177. if (dto.PageIndex != 0 && dto.PageSize != 0)
  178. {
  179. int count = _DecreasePayments.Count;
  180. float totalPage = (float)count / dto.PageSize;//总页数
  181. if (totalPage == 0) totalPage = 1;
  182. else totalPage = (int)Math.Ceiling((double)totalPage);
  183. List<InvitationOfficialActivitiesView> invitationOfficialActivities = new List<InvitationOfficialActivitiesView>();
  184. for (int i = 0; i < dto.PageSize; i++)
  185. {
  186. var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
  187. if (RowIndex < _DecreasePayments.Count)
  188. {
  189. invitationOfficialActivities.Add(_DecreasePayments[RowIndex]);
  190. }
  191. else
  192. {
  193. break;
  194. }
  195. }
  196. rst.DataList = invitationOfficialActivities;
  197. rst.DataCount = count;
  198. rst.CurrPageIndex = dto.PageIndex;
  199. rst.CurrPageSize = dto.PageSize;
  200. rst.ReturnDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  201. return result = new Result() { Code = 0, Msg = "查询成功!", Data = rst };
  202. }
  203. else
  204. {
  205. return result = new Result() { Code = 0, Msg = "查询成功!", Data = _DecreasePayments };
  206. }
  207. }
  208. else
  209. {
  210. if (dto.PageIndex != 0 && dto.PageSize != 0)
  211. {
  212. rst.DataList = _DecreasePayments;
  213. rst.DataCount = _DecreasePayments.Count;
  214. rst.CurrPageIndex = dto.PageIndex;
  215. rst.CurrPageSize = dto.PageSize;
  216. rst.ReturnDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  217. return result = new Result() { Code = 0, Msg = "暂无数据!", Data = rst };
  218. }
  219. else
  220. {
  221. return result = new Result() { Code = 0, Msg = "暂无数据!", Data = _DecreasePayments };
  222. }
  223. }
  224. }
  225. catch (Exception ex)
  226. {
  227. return result = new Result() { Code = -2, Msg = ex.Message };
  228. }
  229. }
  230. /// <summary>
  231. /// Info Page Basic Data
  232. /// </summary>
  233. /// <returns></returns>
  234. public async Task<Result> _InitBasicData()
  235. {
  236. Result result = new Result() { Code = -2, Msg = "程序错误!" };
  237. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToList();
  238. //支付方式
  239. var _payTypeDatas = setDatas.Where(it => it.STid == 14).Select(it => new { Id = it.Id, Name = it.Name, Remark = it.Remark }).ToList();
  240. ///转账标识
  241. var _costIdentificationDatas = new List<dynamic>()
  242. {
  243. new { Id = 0,Name = "公转" },
  244. new { Id = 1,Name = "私转" }
  245. };
  246. //卡类型
  247. var _cardTypeDatas = setDatas.Where(it => it.STid == 15).Select(it => new SetDataCurrencyInfoView { Id = it.Id, Name = it.Name, Remark = it.Remark }).ToList();
  248. var data = new {
  249. PayTypeData = _payTypeDatas,
  250. CostIdentificationData = _costIdentificationDatas,
  251. CardTypeData = _cardTypeDatas
  252. };
  253. result.Code = 0;
  254. result.Data = data;
  255. return result;
  256. }
  257. /// <summary>
  258. /// 商邀费用操作(Status:1.新增,2.修改)
  259. /// </summary>
  260. /// <param name="dto"></param>
  261. /// <returns></returns>
  262. public async Task<Result> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto, Func<int, int, int, Task<Result>> fn)
  263. {
  264. Result result = new Result() { Code = -2, Msg = "程序错误!" };
  265. BeginTran();
  266. try
  267. {
  268. int id = 0;
  269. Grp_InvitationOfficialActivities grp_Invitation = _mapper.Map<Grp_InvitationOfficialActivities>(dto);
  270. if (dto.Status == 1)//添加
  271. {
  272. string selectSql = string.Format(@"select * from Grp_InvitationOfficialActivities where InviterArea='{0}' and Inviter='{1}' and DiId={2} and IsDel={3}"
  273. , dto.InviterArea, dto.Inviter, dto.DiId, 0);
  274. var _InvitationOfficialActivities = await _sqlSugar.SqlQueryable<Grp_InvitationOfficialActivities>(selectSql).FirstAsync();//查询是否存在
  275. if (_InvitationOfficialActivities != null)
  276. {
  277. return result = new Result() { Code = -1, Msg = "该数据已存在,请勿重复添加!" };
  278. }
  279. else
  280. {
  281. id = await AddAsyncReturnId(grp_Invitation);
  282. if (id != 0)//修改或添加商邀资料
  283. {
  284. Res_InvitationOfficialActivityData res_InvitationData = _mapper.Map<Res_InvitationOfficialActivityData>(dto);
  285. res_InvitationData.Country = dto.InviterArea;
  286. res_InvitationData.UnitName = dto.Inviter;
  287. res_InvitationData.Delegation = dto.DiId.ToString();
  288. Res_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync
  289. (a => a.Country == res_InvitationData.Country && a.City == res_InvitationData.City && a.UnitName == res_InvitationData.UnitName && a.IsDel == 0);
  290. if (ifNullUp == null)///添加或修改商邀资料
  291. {
  292. res_InvitationData.Remark = dto.OtherInformation;
  293. int DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
  294. if (DataID != 0)
  295. {
  296. result = new Result() { Code = 0, Msg = "添加成功!" };
  297. }
  298. else
  299. {
  300. RollbackTran();
  301. result = new Result() { Code = -1, Msg = "添加失败!" };
  302. }
  303. }
  304. else
  305. {
  306. int CTable = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>().Where(a => a.Id == ifNullUp.Id).SetColumns(a => new Res_InvitationOfficialActivityData
  307. {
  308. Contact = dto.Contact,
  309. Tel = dto.Tel,
  310. Email = dto.Email,
  311. Fax = dto.Fax,
  312. Address = dto.Address,
  313. Remark = dto.OtherInformation,
  314. }).ExecuteCommandAsync();
  315. }
  316. Grp_CreditCardPayment C = new Grp_CreditCardPayment();
  317. C.PayDId = dto.PayDId;
  318. if (C.PayDId == 72)
  319. {
  320. C.IsPay = 1;
  321. }
  322. C.ConsumptionPatterns = dto.ConsumptionPatterns;
  323. C.ConsumptionDate = dto.ConsumptionDate;
  324. C.CTDId = dto.CTDId;
  325. C.BankNo = dto.BankNo;
  326. C.CardholderName = dto.CardholderName;
  327. C.PayMoney = dto.PayMoney;
  328. C.PaymentCurrency = dto.PaymentCurrency;
  329. C.CompanyBankNo = dto.CompanyBankNo;
  330. C.OtherBankName = dto.OtherBankName;
  331. C.OtherSideNo = dto.OtherSideNo;
  332. C.OtherSideName = dto.OtherSideName;
  333. C.Remark = "";
  334. C.CreateUserId = dto.CreateUserId;
  335. C.MFOperator = 0;
  336. C.MFOperatorDate = "";
  337. C.IsAuditDM = 0;
  338. C.AuditDMOperate = 0;
  339. C.AuditDMDate = "";
  340. C.IsAuditMF = 0;
  341. C.AuditMFOperate = 0;
  342. C.AuditMFDate = "";
  343. C.IsAuditGM = 0;
  344. C.AuditGMOperate = 0;
  345. C.AuditGMDate = "";
  346. C.IsPay = 0;
  347. C.DIId = dto.DiId;
  348. C.CId = id;
  349. C.CTable = 81;
  350. C.PayPercentage = 100;
  351. C.PayThenMoney = 0;
  352. C.PayPercentageOld = 0;
  353. C.PayThenMoneyOld = 0;
  354. C.UpdateDate = "";
  355. C.Payee = dto.Payee;
  356. C.OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer;
  357. C.ExceedBudget = 0;
  358. //获取新汇率 int diId,int CId, int currencyId
  359. var rate = await fn(dto.DiId, 81, dto.InviteCurrency);
  360. if (rate.Code == 0)
  361. {
  362. var rateInfo = (rate.Data as CurrencyInfo);
  363. if (rateInfo is not null)
  364. {
  365. C.DayRate = rateInfo.Rate;
  366. C.RMBPrice = rateInfo.Rate * C.PayMoney;
  367. }
  368. else
  369. {
  370. C.DayRate = 1;
  371. C.RMBPrice = C.PayMoney;
  372. }
  373. }
  374. int cId = await _sqlSugar.Insertable(C).ExecuteReturnIdentityAsync();
  375. if (cId != 0)
  376. {
  377. result = new Result() { Code = 0, Msg = "添加成功!" };
  378. }
  379. else
  380. {
  381. RollbackTran();
  382. result = new Result() { Code = -1, Msg = "添加失败!" };
  383. }
  384. }
  385. }
  386. }
  387. else//修改
  388. {
  389. var thisTime = new DateTime();
  390. DateTime.TryParse(dto.InviteTime, out thisTime);
  391. bool res = await UpdateAsync(a => a.Id == grp_Invitation.Id, a => new Grp_InvitationOfficialActivities
  392. {
  393. DiId = dto.DiId,
  394. InviterArea = dto.InviterArea,
  395. Inviter = dto.Inviter,
  396. InviteTime = thisTime,
  397. Attachment = dto.Attachment,
  398. InviteCost = dto.InviteCost,
  399. InviteCurrency = dto.InviteCurrency,
  400. SendCost = dto.SendCost,
  401. SendCurrency = dto.SendCurrency,
  402. EventsCost = dto.EventsCost,
  403. EventsCurrency = dto.EventsCurrency,
  404. TranslateCost = dto.TranslateCost,
  405. TranslateCurrency = dto.TranslateCurrency,
  406. IsGoOfficaiaBussiness = dto.IsGoOfficaiaBussiness,
  407. Remark = dto.Remark,
  408. });
  409. if (res)
  410. {
  411. Res_InvitationOfficialActivityData res_InvitationData = _mapper.Map<Res_InvitationOfficialActivityData>(dto);
  412. res_InvitationData.Country = dto.InviterArea;
  413. res_InvitationData.UnitName = dto.Inviter;
  414. Res_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync
  415. (a => a.Country == res_InvitationData.Country && a.City == res_InvitationData.City && a.UnitName == res_InvitationData.UnitName && a.IsDel == 0);
  416. if (ifNullUp == null)///添加或修改商邀资料
  417. {
  418. res_InvitationData.Remark = dto.OtherInformation;
  419. res_InvitationData.Delegation = dto.DiId.ToString();
  420. int DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
  421. if (DataID != 0)
  422. {
  423. result = new Result() { Code = 0, Msg = "添加成功!" };
  424. }
  425. else
  426. {
  427. RollbackTran();
  428. result = new Result() { Code = -1, Msg = "添加失败!" };
  429. }
  430. }
  431. else
  432. {
  433. int CTable = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>()
  434. .Where(a => a.Id == ifNullUp.Id)
  435. .SetColumns(a => new Res_InvitationOfficialActivityData
  436. {
  437. Contact = dto.Contact,
  438. Tel = dto.Tel,
  439. Email = dto.Email,
  440. Fax = dto.Fax,
  441. Address = dto.Address,
  442. Remark = dto.OtherInformation,
  443. }).ExecuteCommandAsync();
  444. }
  445. Grp_CreditCardPayment grp_CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == grp_Invitation.Id && a.CTable == 81 && a.IsDel == 0);
  446. if (grp_CreditCardPayment != null)
  447. {
  448. if (dto.PayDId == 72)
  449. {
  450. grp_CreditCardPayment.IsPay = 1;
  451. }
  452. grp_CreditCardPayment.PayMoney = dto.PayMoney;
  453. grp_CreditCardPayment.PaymentCurrency = dto.PaymentCurrency;
  454. grp_CreditCardPayment.Payee = dto.Payee;
  455. grp_CreditCardPayment.OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer;
  456. //获取新汇率 int diId,int CId, int currencyId
  457. var rate = await fn(dto.DiId, 81, dto.InviteCurrency);
  458. grp_CreditCardPayment.DayRate = 1;
  459. grp_CreditCardPayment.RMBPrice = grp_CreditCardPayment.PayMoney;
  460. if (rate.Code == 0)
  461. {
  462. var rateInfo = (rate.Data as CurrencyInfo);
  463. if (rateInfo is not null)
  464. {
  465. grp_CreditCardPayment.DayRate = rateInfo.Rate;
  466. grp_CreditCardPayment.RMBPrice = rateInfo.Rate * grp_CreditCardPayment.PayMoney;
  467. }
  468. }
  469. int CTable = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  470. .Where(a => a.Id == grp_CreditCardPayment.Id)
  471. .SetColumns(a => new Grp_CreditCardPayment
  472. {
  473. ConsumptionPatterns = dto.ConsumptionPatterns,
  474. ConsumptionDate = dto.ConsumptionDate,
  475. PayDId = dto.PayDId,
  476. IsPay = grp_CreditCardPayment.IsPay,
  477. CTDId = dto.CTDId,
  478. BankNo = dto.BankNo,
  479. CardholderName = dto.CardholderName,
  480. CompanyBankNo = dto.CompanyBankNo,
  481. OtherBankName = dto.OtherBankName,
  482. OtherSideNo = dto.OtherSideNo,
  483. OtherSideName = dto.OtherSideName,
  484. PayMoney = grp_CreditCardPayment.PayMoney,
  485. PaymentCurrency = grp_CreditCardPayment.PaymentCurrency,
  486. Payee = grp_CreditCardPayment.Payee,
  487. OrbitalPrivateTransfer = grp_CreditCardPayment.OrbitalPrivateTransfer,
  488. DayRate = grp_CreditCardPayment.DayRate,
  489. RMBPrice = grp_CreditCardPayment.RMBPrice,
  490. }).ExecuteCommandAsync();
  491. if (CTable != 0)
  492. {
  493. result = new Result() { Code = 0, Msg = "修改成功!" };
  494. }
  495. else
  496. {
  497. result = new Result() { Code = -1, Msg = "修改失败!" };
  498. RollbackTran();
  499. }
  500. }
  501. else
  502. {
  503. RollbackTran();
  504. result = new Result() { Code = -1, Msg = "修改失败!" };
  505. }
  506. }
  507. else
  508. {
  509. RollbackTran();
  510. result = new Result() { Code = -1, Msg = "修改失败!" };
  511. }
  512. }
  513. CommitTran();
  514. }
  515. catch (Exception ex)
  516. {
  517. result = new Result() { Code = -2, Msg = "程序错误!" };
  518. throw;
  519. }
  520. return result;
  521. }
  522. }
  523. }