InvitationOfficialActivitiesRepository.cs 29 KB

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