CreditCardPaymentRepository.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using AutoMapper;
  2. using OASystem.Domain;
  3. using OASystem.Domain.Entities.Groups;
  4. using OASystem.Domain.ViewModels.Financial;
  5. using OASystem.Domain.ViewModels.Groups;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace OASystem.Infrastructure.Repositories.Financial
  12. {
  13. /// <summary>
  14. /// 财务 - 付款信息类
  15. /// 雷怡 2023.08.16 16:19
  16. /// </summary>
  17. public class CreditCardPaymentRepository : BaseRepository<Grp_CreditCardPayment, Grp_Fin_CreditCardPaymentView>
  18. {
  19. private readonly IMapper _mapper;
  20. public CreditCardPaymentRepository(SqlSugarClient sqlSugar, IMapper mapper)
  21. : base(sqlSugar)
  22. {
  23. _mapper = mapper;
  24. }
  25. /// <summary>
  26. /// 根据diid查询团组付款信息
  27. /// </summary>
  28. /// <param name="diid"></param>
  29. /// <param name="isPay">false 未支付 true 已支付</param>
  30. /// <returns></returns>
  31. public async Task<Result> GetGroupPaymentInfoByDiid(int diid,bool isPay)
  32. {
  33. Result result = new() { Code = -2 };
  34. int _isPay = 0;
  35. if (isPay) { _isPay = 1; }
  36. string sql = string.Format(@"Select * From Grp_CreditCardPayment Where IsDel=0 And Diid={0} And IsPay={1}", diid, _isPay);
  37. var groupReceivablesList = await _sqlSugar.SqlQueryable<Fin_ProceedsReceivedView>(sql).ToListAsync();
  38. result.Code = 0;
  39. result.Msg = "查询成功!";
  40. result.Data = groupReceivablesList;
  41. return result;
  42. }
  43. /// <summary>
  44. /// 根据diid 数组 查询团组付款信息
  45. /// </summary>
  46. /// <param name="diid"></param>
  47. /// <param name="isPay">false 未支付 true 已支付</param>
  48. /// <returns></returns>
  49. public async Task<Result> GetGroupPaymentInfoByDiids(int[] diids, bool isPay)
  50. {
  51. Result result = new() { Code = -2 };
  52. int _isPay = 0;
  53. if (isPay) { _isPay = 1; }
  54. var groupReceivablesList = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  55. .Where(ccp => ccp.IsDel == 0 && diids.Contains(ccp.DIId) && ccp.IsPay == _isPay) .ToListAsync();
  56. result.Code = 0;
  57. result.Msg = "查询成功!";
  58. result.Data = groupReceivablesList;
  59. return result;
  60. }
  61. /// <summary>
  62. /// 团组 其他款项/退款
  63. /// </summary>
  64. /// <param name="diid">团组Id</param>
  65. /// <param name="isPay"></param>
  66. /// <returns></returns>
  67. public async Task<Result> GetGroupRefundByDiid(int diid, bool isPay)
  68. {
  69. Result result = new() { Code = -2 };
  70. int _isPay = 0;
  71. if (isPay) { _isPay = 1; }
  72. string sql = string.Format(@"Select ccp.DIId,ccp.CreateUserId,ccp.AuditGMDate,sd1.name As PayType,ccp.OrbitalPrivateTransfer,ccp.PayDid,
  73. ccp.payee,ccp.IsPay,gdp.CreateTime,gdp.PriceName,gdp.Price,sd.[Name] Currency,
  74. ccp.PayMoney As Spread,ccp.DayRate,gdp.Remark From Fin_OtherPrice gdp
  75. join Grp_CreditCardPayment ccp On ccp.Diid = gdp.Diid and ccp.Cid = gdp.Id
  76. join Sys_SetData sd On sd.Id =gdp.CurrencyId
  77. join Sys_SetData sd1 On sd1.id=ccp.PayDid
  78. Where ccp.DIId={0} And gdp.IsDel = 0 and ccp.isDel=0 and ccp.CTable=285 and ccp.IsPay = {1} ", diid, _isPay);
  79. var groupRefundList = await _sqlSugar.SqlQueryable<GroupRefundView>(sql).ToListAsync();
  80. result.Code = 0;
  81. result.Msg = "查询成功!";
  82. result.Data = groupRefundList;
  83. return result;
  84. }
  85. /// <summary>
  86. /// 团组 根据diid 数组 查询 其他款项/退款
  87. /// </summary>
  88. /// <param name="diid">团组Id</param>
  89. /// <param name="isPay"></param>
  90. /// <returns></returns>
  91. public async Task<Result> GetGroupRefundByDiids(int[] diids, bool isPay)
  92. {
  93. Result result = new() { Code = -2 };
  94. int _isPay = 0;
  95. if (isPay) { _isPay = 1; }
  96. string _diidsStr = string.Empty;
  97. #region 处理Diid
  98. StringBuilder diidSb = new StringBuilder();
  99. for (int i = 0; i < diids.Length; i++)
  100. {
  101. if (i == diids.Length - 1)
  102. {
  103. diidSb.Append(diids[i]);
  104. }
  105. else
  106. {
  107. diidSb.Append(diids[i]).Append(",");
  108. }
  109. }
  110. _diidsStr = diidSb.ToString().Trim();
  111. #endregion
  112. string sql = string.Format(@"Select ccp.DIId,ccp.CreateUserId,ccp.AuditGMDate,sd1.name As PayType,ccp.OrbitalPrivateTransfer,ccp.PayDid,
  113. ccp.payee,ccp.IsPay,gdp.CreateTime,gdp.PriceName,gdp.Price,sd.[Name] Currency,
  114. ccp.PayMoney As Spread,ccp.DayRate,gdp.Remark From Fin_OtherPrice gdp
  115. join Grp_CreditCardPayment ccp On ccp.Diid = gdp.Diid and ccp.Cid = gdp.Id
  116. join Sys_SetData sd On sd.Id =gdp.CurrencyId
  117. join Sys_SetData sd1 On sd1.id=ccp.PayDid
  118. Where ccp.isDel=0 And gdp.IsDel = 0 And ccp.DIId In ({0}) And ccp.CTable=285 and ccp.IsPay = {1} ", _diidsStr, _isPay);
  119. var groupRefundList = await _sqlSugar.SqlQueryable<GroupRefundView>(sql).ToListAsync();
  120. result.Code = 0;
  121. result.Msg = "查询成功!";
  122. result.Data = groupRefundList;
  123. return result;
  124. }
  125. }
  126. }