InvitationOfficialActivitiesRepository.cs 30 KB

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