ForeignReceivablesRepository.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using AutoMapper;
  2. using OASystem.Domain;
  3. using OASystem.Domain.Dtos.Financial;
  4. using OASystem.Domain.Dtos.Groups;
  5. using OASystem.Domain.Entities.Financial;
  6. using OASystem.Domain.ViewModels.Financial;
  7. using OASystem.Infrastructure.Repositories.Groups;
  8. using OASystem.Infrastructure.Repositories.System;
  9. using SqlSugar;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. namespace OASystem.Infrastructure.Repositories.Financial
  16. {
  17. /// <summary>
  18. /// 财务 - 团组应收款项 仓库
  19. /// 雷怡 2023.08.16 15:03
  20. /// </summary>
  21. public class ForeignReceivablesRepository : BaseRepository<Fin_ForeignReceivables, Fin_ForeignReceivablesView>
  22. {
  23. private readonly IMapper _mapper;
  24. private readonly DelegationInfoRepository _delegationRep;
  25. private readonly SetDataRepository _setDataRep;
  26. public ForeignReceivablesRepository(SqlSugarClient sqlSugar, IMapper mapper, DelegationInfoRepository delegationRep, SetDataRepository setDataRep)
  27. : base(sqlSugar)
  28. {
  29. _mapper = mapper;
  30. _delegationRep = delegationRep;
  31. _setDataRep = setDataRep;
  32. }
  33. /// <summary>
  34. /// 收款账单 数据源
  35. /// </summary>
  36. /// <returns></returns>
  37. public async Task<Result> GetDataSource()
  38. {
  39. Result result = new() { Code = -2 };
  40. var groupNameData = await _delegationRep.GetGroupNameList(new GroupNameDto());
  41. var currencyData = await _setDataRep.GetSetDataBySTId(_setDataRep,13); //币种
  42. var remittanceMethodData = await _setDataRep.GetSetDataBySTId(_setDataRep, 14); //汇款方式
  43. result.Code = 0;
  44. result.Msg = "成功!";
  45. result.Data = new {
  46. GroupNameData= groupNameData.Data,
  47. CurrencyData = currencyData.Data,
  48. RemittanceMethodData = remittanceMethodData.Data
  49. };
  50. return result;
  51. }
  52. /// <summary>
  53. /// 根据diid查询团组应收款项
  54. /// </summary>
  55. /// <param name="diid"></param>
  56. /// <returns></returns>
  57. public async Task<Result> GetGroupReceivablesInfoByDiId(ForForeignReceivablesInfoDto dto)
  58. {
  59. Result result = new() { Code = -2 };
  60. var groupInfoData = await _delegationRep.GetGroupInfo(new GroupInfoDto() { Id = dto.DiId });
  61. //应收款项
  62. string groupReceivedSql = string.Format(@"Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0}", dto.DiId);
  63. var groupReceivedList = await _sqlSugar.SqlQueryable<ForeignReceivablesInfoView>(groupReceivedSql).ToListAsync();
  64. //已收款项
  65. string groupProceedsReceivedSql = string.Format(@"Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0}", dto.DiId);
  66. var groupProceedsReceivedList = await _sqlSugar.SqlQueryable<ForeignReceivablesInfoView>(groupReceivedSql).ToListAsync();
  67. if (dto.PortType == 1 )
  68. {
  69. }
  70. result.Code = 0;
  71. result.Msg = "查询成功!";
  72. result.Data = new
  73. {
  74. GroupInfo = groupInfoData.Data,
  75. GroupReceivedData = groupReceivedList
  76. };
  77. return result;
  78. }
  79. /// <summary>
  80. /// 根据diid查询团组应收款项
  81. /// </summary>
  82. /// <param name="diid"></param>
  83. /// <returns></returns>
  84. public async Task<Result> GetGroupReceivablesByDiid(int diid)
  85. {
  86. Result result = new() { Code = -2 };
  87. string sql = string.Format(@"Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0}", diid);
  88. var groupReceivedList = await _sqlSugar.SqlQueryable<Fin_ForeignReceivables>(sql).ToListAsync();
  89. result.Code = 0;
  90. result.Msg = "查询成功!";
  91. result.Data = groupReceivedList;
  92. return result;
  93. }
  94. /// <summary>
  95. /// 根据diid 数组 查询团组应收款项
  96. /// </summary>
  97. /// <param name="diid"></param>
  98. /// <returns></returns>
  99. public async Task<Result> GetGroupReceivablesByDiids(int[] diids)
  100. {
  101. Result result = new() { Code = -2 };
  102. //string sql = string.Format(@"Select * From Fin_ProceedsReceived Where IsDel=0 And Diid={0}", diids);
  103. var groupReceivedList = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  104. .Where(pr => pr.IsDel == 0 && diids.Contains(pr.Diid)).ToListAsync();
  105. result.Code = 0;
  106. result.Msg = "查询成功!";
  107. result.Data = groupReceivedList;
  108. return result;
  109. }
  110. }
  111. }