InvitationOfficialActivitiesRepository.cs 29 KB

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