InvitationOfficialActivitiesRepository.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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>()
  43. .First(a =>a.Country==grp_Invitation.InviterArea && a.UnitName==grp_Invitation.Inviter && a.IsDel == 0);
  44. if (dto.PortType == 1)
  45. {
  46. var data = new
  47. {
  48. _Invitation = grp_Invitation,
  49. _InvitationData = res_InvitationOfficialActivityData,
  50. _CreditCard = grp_CreditCard,
  51. };
  52. result = new Result() { Code = 0, Msg = "查询成功!", Data = data };
  53. }
  54. else
  55. {
  56. InvitationOfficialActivitiesByIdView invitation = _mapper.Map<InvitationOfficialActivitiesByIdView>(grp_Invitation);
  57. res_InvitationOfficialActivityData ??= new Res_InvitationOfficialActivityData();
  58. invitation.ConsumptionPatterns = grp_CreditCard.ConsumptionPatterns;
  59. invitation.ConsumptionDate = grp_CreditCard.ConsumptionDate;
  60. invitation.PayDId = grp_CreditCard.PayDId;
  61. invitation.ConsumptionPatterns = grp_CreditCard.ConsumptionPatterns;
  62. invitation.ConsumptionDate = grp_CreditCard.ConsumptionDate;
  63. invitation.BankNo = grp_CreditCard.BankNo;
  64. invitation.CardholderName = grp_CreditCard.CardholderName;
  65. invitation.CompanyBankNo = grp_CreditCard.CompanyBankNo;
  66. invitation.OtherBankName = grp_CreditCard.OtherBankName;
  67. invitation.OtherSideNo = grp_CreditCard.OtherSideNo;
  68. invitation.OtherSideName = grp_CreditCard.OtherSideName;
  69. invitation.PayMoney = grp_CreditCard.PayMoney;
  70. invitation.PaymentCurrency = grp_CreditCard.PaymentCurrency;
  71. invitation.OrbitalPrivateTransfer = grp_CreditCard.OrbitalPrivateTransfer;
  72. invitation.Payee = grp_CreditCard.Payee;
  73. invitation.Address = res_InvitationOfficialActivityData.Address;
  74. invitation.Contact = res_InvitationOfficialActivityData.Contact;
  75. invitation.Job = res_InvitationOfficialActivityData.Job;
  76. invitation.Tel = res_InvitationOfficialActivityData.Tel;
  77. invitation.Email = res_InvitationOfficialActivityData.Email;
  78. invitation.Fax = res_InvitationOfficialActivityData.Fax;
  79. invitation.OtherInformation = res_InvitationOfficialActivityData.Remark;
  80. invitation.CTDId = grp_CreditCard.CTDId;
  81. result = new Result() { Code = 0, Msg = "查询成功!", Data = invitation };
  82. }
  83. }
  84. else
  85. {
  86. if (dto.PortType == 1)
  87. {
  88. var data = new
  89. {
  90. _Invitation = grp_Invitation,
  91. _InvitationData = res_InvitationOfficialActivityData,
  92. _CreditCard = grp_CreditCard,
  93. };
  94. result = new Result() { Code = 0, Msg = "暂无数据!", Data = data };
  95. }
  96. else
  97. {
  98. InvitationOfficialActivitiesByIdView invitation = _mapper.Map<InvitationOfficialActivitiesByIdView>(grp_Invitation);
  99. result = new Result() { Code = 0, Msg = "暂无数据!", Data = invitation };
  100. }
  101. }
  102. }
  103. catch (Exception)
  104. {
  105. result = new Result() { Code = -2, Msg = "程序错误" };
  106. throw;
  107. }
  108. return result;
  109. }
  110. /// <summary>
  111. /// 根据团组id查询商邀费用数据
  112. /// </summary>
  113. /// <param name="dto"></param>
  114. /// <returns></returns>
  115. public async Task<Result> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  116. {
  117. Result result = new Result() { Code = -2, Msg = "未知错误" };
  118. try
  119. {
  120. ListViewBase<InvitationOfficialActivitiesView> rst = new ListViewBase<InvitationOfficialActivitiesView>() { ReceiveDt=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") };
  121. string sqlWhere = string.Empty;
  122. if (!string.IsNullOrWhiteSpace(dto.Inviter))
  123. {
  124. sqlWhere += string.Format(@" And Inviter like '%{0}%'", dto.Inviter);
  125. }
  126. if (!string.IsNullOrWhiteSpace(dto.StartInviteTime) && !string.IsNullOrWhiteSpace(dto.EndInviteTime))
  127. {
  128. sqlWhere += string.Format(@" And i.InviteTime between '{0}' and '{1}'", dto.StartInviteTime, dto.EndInviteTime);
  129. }
  130. sqlWhere += string.Format(@" And i.DiId={0} And i.IsDel={1}", dto.DiId, 0);
  131. string UserId = "";
  132. List<Grp_GroupsTaskAssignment> gtaUIdList = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(a => a.DIId == dto.DiId && a.IsDel == 0 && a.CTId == 81).ToList();
  133. foreach (Grp_GroupsTaskAssignment gta in gtaUIdList)
  134. UserId += gta.UId + ",";
  135. if (!string.IsNullOrWhiteSpace(UserId))
  136. {
  137. UserId = UserId.Substring(0, UserId.Length - 1);
  138. }
  139. else
  140. {
  141. UserId = "0";
  142. }
  143. sqlWhere += string.Format(@" And i.CreateUserId in ({0})", UserId);
  144. //雷怡 2024-05-08 16:19 更改默认值 IsPaySign = -1
  145. if (dto.IsPaySign != -1) {
  146. sqlWhere += string.Format(@" And ccp.IsPay = {0} ", dto.IsPaySign);
  147. }
  148. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  149. {
  150. Regex r = new Regex("And");
  151. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  152. }
  153. //10011
  154. //string sql = string.Format(@"Select Id,DiId,InviterArea,Inviter,InviteTime,
  155. // InviteCost,(Select Name From Sys_SetData Where id=i.InviteCurrency And IsDel=0) As InviteCurrency,
  156. // SendCost,(Select Name From Sys_SetData Where id=i.SendCurrency And IsDel=0) As SendCurrency,
  157. // EventsCost,(Select Name From Sys_SetData Where id=i.EventsCurrency And IsDel=0) As EventsCurrency,
  158. // TranslateCost,(Select Name From Sys_SetData Where id=i.TranslateCurrency And IsDel=0) As TranslateCurrency,
  159. // IsGoOfficaiaBussiness,
  160. // (Select PayMoney From Grp_CreditCardPayment Where CTable=81 And CId=i.Id And IsDel=0) As PayMoney,
  161. // (Select (Select Name From Sys_SetData Where Id =ccp.PaymentCurrency And IsDel=0 ) As PaymentCurrency
  162. // From Grp_CreditCardPayment ccp Where CTable=81 And CId=i.Id And IsDel=0) As PaymentCurrency,
  163. // (Select IsAuditGM From Grp_CreditCardPayment Where CTable=81 And CId=i.Id And IsDel=0) As IsAudit,
  164. // Attachment From Grp_InvitationOfficialActivities i {0} Order By i.id Desc", sqlWhere);
  165. string sql = string.Format(@" Select i.Id,i.DiId,i.InviterArea,i.Inviter,i.InviteTime,i.InviteCost,sd1.[Name] as InviteCurrency
  166. ,i.SendCost,sd2.[Name] as SendCurrency,i.EventsCost,sd3.[Name] as EventsCurrency,i.TranslateCost,sd4.[Name] as TranslateCurrency
  167. ,i.IsGoOfficaiaBussiness,ccp.PayMoney,sd5.[Name] as PaymentCurrency,IsAuditGM as IsAudit,i.Attachment,ccp.IsPay
  168. From Grp_InvitationOfficialActivities as i With(Nolock) Inner Join Grp_CreditCardPayment as ccp With(Nolock) On i.Id = ccp.CId
  169. Left Join Sys_SetData as sd1 On i.InviteCurrency = sd1.Id
  170. Left Join Sys_SetData as sd2 On i.SendCurrency = sd2.Id
  171. Left Join Sys_SetData as sd3 On i.EventsCurrency = sd3.Id
  172. Left Join Sys_SetData as sd4 On i.TranslateCurrency = sd4.Id
  173. Left Join Sys_SetData as sd5 On ccp.PaymentCurrency = sd5.Id
  174. {0} And ccp.CTable = 81
  175. Order By i.id Desc ", sqlWhere);
  176. List<InvitationOfficialActivitiesView> _DecreasePayments = await _sqlSugar.SqlQueryable<InvitationOfficialActivitiesView>(sql).ToListAsync();
  177. if (_DecreasePayments.Count != 0)
  178. {
  179. if (dto.PageIndex != 0 && dto.PageSize != 0)
  180. {
  181. int count = _DecreasePayments.Count;
  182. float totalPage = (float)count / dto.PageSize;//总页数
  183. if (totalPage == 0) totalPage = 1;
  184. else totalPage = (int)Math.Ceiling((double)totalPage);
  185. List<InvitationOfficialActivitiesView> invitationOfficialActivities = new List<InvitationOfficialActivitiesView>();
  186. for (int i = 0; i < dto.PageSize; i++)
  187. {
  188. var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
  189. if (RowIndex < _DecreasePayments.Count)
  190. {
  191. invitationOfficialActivities.Add(_DecreasePayments[RowIndex]);
  192. }
  193. else
  194. {
  195. break;
  196. }
  197. }
  198. rst.DataList = invitationOfficialActivities;
  199. rst.DataCount = count;
  200. rst.CurrPageIndex = dto.PageIndex;
  201. rst.CurrPageSize = dto.PageSize;
  202. rst.ReturnDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  203. return result = new Result() { Code = 0, Msg = "查询成功!", Data = rst };
  204. }
  205. else
  206. {
  207. return result = new Result() { Code = 0, Msg = "查询成功!", Data = _DecreasePayments };
  208. }
  209. }
  210. else
  211. {
  212. if (dto.PageIndex != 0 && dto.PageSize != 0)
  213. {
  214. rst.DataList = _DecreasePayments;
  215. rst.DataCount = _DecreasePayments.Count;
  216. rst.CurrPageIndex = dto.PageIndex;
  217. rst.CurrPageSize = dto.PageSize;
  218. rst.ReturnDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  219. return result = new Result() { Code = 0, Msg = "暂无数据!", Data = rst };
  220. }
  221. else
  222. {
  223. return result = new Result() { Code = 0, Msg = "暂无数据!", Data = _DecreasePayments };
  224. }
  225. }
  226. }
  227. catch (Exception ex)
  228. {
  229. return result = new Result() { Code = -2, Msg = ex.Message };
  230. }
  231. }
  232. /// <summary>
  233. /// Info Page Basic Data
  234. /// </summary>
  235. /// <returns></returns>
  236. public async Task<Result> _InitBasicData()
  237. {
  238. Result result = new Result() { Code = -2, Msg = "程序错误!" };
  239. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToList();
  240. //支付方式
  241. var _payTypeDatas = setDatas.Where(it => it.STid == 14).Select(it => new { Id = it.Id, Name = it.Name, Remark = it.Remark }).ToList();
  242. ///转账标识
  243. var _costIdentificationDatas = new List<dynamic>()
  244. {
  245. new { Id = 0,Name = "公转" },
  246. new { Id = 1,Name = "私转" }
  247. };
  248. //卡类型
  249. var _cardTypeDatas = setDatas.Where(it => it.STid == 15).Select(it => new SetDataCurrencyInfoView { Id = it.Id, Name = it.Name, Remark = it.Remark }).ToList();
  250. var data = new {
  251. PayTypeData = _payTypeDatas,
  252. CostIdentificationData = _costIdentificationDatas,
  253. CardTypeData = _cardTypeDatas
  254. };
  255. result.Code = 0;
  256. result.Data = data;
  257. return result;
  258. }
  259. /// <summary>
  260. /// 商邀费用操作(Status:1.新增,2.修改)
  261. /// </summary>
  262. /// <param name="dto"></param>
  263. /// <returns></returns>
  264. public async Task<Result> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto, Func<int, int, int, Task<Result>> fn)
  265. {
  266. Result result = new Result() { Code = -2, Msg = "程序错误!" };
  267. BeginTran();
  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. id = await AddAsyncReturnId(grp_Invitation);
  280. if (id != 0)//修改或添加商邀资料
  281. {
  282. Res_InvitationOfficialActivityData res_InvitationData = _mapper.Map<Res_InvitationOfficialActivityData>(dto);
  283. res_InvitationData.Country = dto.InviterArea;
  284. res_InvitationData.UnitName = dto.Inviter;
  285. res_InvitationData.Delegation = dto.DiId.ToString();
  286. Res_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync
  287. (a => a.Country == res_InvitationData.Country && a.City == res_InvitationData.City && a.UnitName == res_InvitationData.UnitName && a.IsDel == 0);
  288. if (ifNullUp == null)///添加或修改商邀资料
  289. {
  290. res_InvitationData.Remark = dto.OtherInformation;
  291. int DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
  292. if (DataID != 0)
  293. {
  294. result = new Result() { Code = 0, Msg = "添加成功!" };
  295. }
  296. else
  297. {
  298. RollbackTran();
  299. result = new Result() { Code = -1, Msg = "添加失败!" };
  300. }
  301. }
  302. else
  303. {
  304. int CTable = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>()
  305. .Where(a => a.Id == ifNullUp.Id)
  306. .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. })
  315. .ExecuteCommandAsync();
  316. }
  317. Grp_CreditCardPayment C = new Grp_CreditCardPayment();
  318. C.PayDId = dto.PayDId;
  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. var data = new { ccpId = cId, sign = 1 };
  374. if (cId != 0)
  375. {
  376. result = new Result() { Code = 0, Msg = "添加成功!", Data = data };
  377. }
  378. else
  379. {
  380. RollbackTran();
  381. result = new Result() { Code = -1, Msg = "添加失败!" };
  382. }
  383. }
  384. }
  385. else//修改
  386. {
  387. var thisTime = new DateTime();
  388. 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 = dto.Attachment,
  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_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync
  413. (a => a.Country == res_InvitationData.Country && a.City == res_InvitationData.City && a.UnitName == res_InvitationData.UnitName && a.IsDel == 0);
  414. if (ifNullUp == null)///添加或修改商邀资料
  415. {
  416. res_InvitationData.Remark = dto.OtherInformation;
  417. res_InvitationData.Delegation = dto.DiId.ToString();
  418. int DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
  419. if (DataID != 0)
  420. {
  421. result = new Result() { Code = 0, Msg = "添加成功!" };
  422. }
  423. else
  424. {
  425. RollbackTran();
  426. result = new Result() { Code = -1, Msg = "添加失败!" };
  427. }
  428. }
  429. else
  430. {
  431. int CTable = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>()
  432. .Where(a => a.Id == ifNullUp.Id)
  433. .SetColumns(a => new Res_InvitationOfficialActivityData
  434. {
  435. Contact = dto.Contact,
  436. Tel = dto.Tel,
  437. Email = dto.Email,
  438. Fax = dto.Fax,
  439. Address = dto.Address,
  440. Remark = dto.OtherInformation,
  441. })
  442. .ExecuteCommandAsync();
  443. }
  444. Grp_CreditCardPayment grp_CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == grp_Invitation.Id && a.CTable == 81 && a.IsDel == 0);
  445. if (grp_CreditCardPayment != null)
  446. {
  447. if (dto.PayDId == 72) grp_CreditCardPayment.IsPay = 1;
  448. else grp_CreditCardPayment.IsPay = 0;
  449. grp_CreditCardPayment.PayMoney = dto.PayMoney;
  450. grp_CreditCardPayment.PaymentCurrency = dto.PaymentCurrency;
  451. grp_CreditCardPayment.Payee = dto.Payee;
  452. grp_CreditCardPayment.OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer;
  453. //获取新汇率 int diId,int CId, int currencyId
  454. var rate = await fn(dto.DiId, 81, dto.InviteCurrency);
  455. grp_CreditCardPayment.DayRate = 1;
  456. grp_CreditCardPayment.RMBPrice = grp_CreditCardPayment.PayMoney;
  457. if (rate.Code == 0)
  458. {
  459. var rateInfo = (rate.Data as CurrencyInfo);
  460. if (rateInfo is not null)
  461. {
  462. grp_CreditCardPayment.DayRate = rateInfo.Rate;
  463. grp_CreditCardPayment.RMBPrice = rateInfo.Rate * grp_CreditCardPayment.PayMoney;
  464. }
  465. }
  466. int CTable = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  467. .Where(a => a.Id == grp_CreditCardPayment.Id)
  468. .SetColumns(a => new Grp_CreditCardPayment
  469. {
  470. ConsumptionPatterns = dto.ConsumptionPatterns,
  471. ConsumptionDate = dto.ConsumptionDate,
  472. PayDId = dto.PayDId,
  473. IsPay = grp_CreditCardPayment.IsPay,
  474. CTDId = dto.CTDId,
  475. BankNo = dto.BankNo,
  476. CardholderName = dto.CardholderName,
  477. CompanyBankNo = dto.CompanyBankNo,
  478. OtherBankName = dto.OtherBankName,
  479. OtherSideNo = dto.OtherSideNo,
  480. OtherSideName = dto.OtherSideName,
  481. PayMoney = grp_CreditCardPayment.PayMoney,
  482. PaymentCurrency = grp_CreditCardPayment.PaymentCurrency,
  483. Payee = grp_CreditCardPayment.Payee,
  484. OrbitalPrivateTransfer = grp_CreditCardPayment.OrbitalPrivateTransfer,
  485. DayRate = grp_CreditCardPayment.DayRate,
  486. RMBPrice = grp_CreditCardPayment.RMBPrice,
  487. }).ExecuteCommandAsync();
  488. if (CTable != 0)
  489. {
  490. var data = new { ccpId = grp_CreditCardPayment.Id, sign = 2 };
  491. result = new Result() { Code = 0, Msg = "修改成功!", Data = data };
  492. }
  493. else
  494. {
  495. result = new Result() { Code = -1, Msg = "修改失败!" };
  496. RollbackTran();
  497. }
  498. }
  499. else
  500. {
  501. RollbackTran();
  502. result = new Result() { Code = -1, Msg = "修改失败!" };
  503. }
  504. }
  505. else
  506. {
  507. RollbackTran();
  508. result = new Result() { Code = -1, Msg = "修改失败!" };
  509. }
  510. }
  511. CommitTran();
  512. return result;
  513. }
  514. }
  515. }