InvitationOfficialActivitiesRepository.cs 30 KB

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