DecreasePaymentsRepository.cs 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using AutoMapper;
  2. using OASystem.Domain;
  3. using OASystem.Domain.Dtos.Groups;
  4. using OASystem.Domain.Entities.Groups;
  5. using OASystem.Domain.Entities.Resource;
  6. using OASystem.Domain.ViewModels.Groups;
  7. using OASystem.Infrastructure.Repositories.System;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace OASystem.Infrastructure.Repositories.Groups
  14. {
  15. public class DecreasePaymentsRepository : BaseRepository<Grp_DecreasePayments, Grp_DecreasePayments>
  16. {
  17. private readonly IMapper _mapper;
  18. public DecreasePaymentsRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
  19. {
  20. this._mapper = mapper;
  21. }
  22. /// <summary>
  23. /// 根据团组Id查询数据
  24. /// </summary>
  25. /// <param name="dto"></param>
  26. /// <returns></returns>
  27. public async Task<Result> DecreasePaymentsList(DecreasePaymentsListDto dto)
  28. {
  29. Result result = new Result() { Code = -2, Msg = "未知错误" };
  30. try
  31. {
  32. string sql = string.Format(@"select Id,DiId,PriceName,Price,(select name from Sys_SetData where id=s.Currency) as Currency,FilePath,
  33. (select CnName from Sys_Users where Id=s.CreateUserId) as 'CreateUserName',CreateTime,(select IsAuditGM from
  34. Grp_CreditCardPayment where CTable=98 and CId=s.Id) as 'isAudit' from Grp_DecreasePayments s where DIID={0} and IsDel=0 ", dto.DiId);
  35. List<DecreasePaymentsView> _DecreasePayments = await _sqlSugar.SqlQueryable<DecreasePaymentsView>(sql).ToListAsync();
  36. if (_DecreasePayments.Count != 0)
  37. {
  38. result = new Result() { Code = 0, Msg = "查询成功!",Data=_DecreasePayments };
  39. }
  40. else
  41. {
  42. result = new Result() { Code = 0, Msg = "暂无数据!", Data = _DecreasePayments };
  43. }
  44. }
  45. catch (Exception ex)
  46. {
  47. result = new Result() { Code = -2, Msg = "未知错误" };
  48. }
  49. return result;
  50. }
  51. public async Task<Result> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  52. {
  53. Result result = new Result() { Code = -2, Msg = "未知错误" };
  54. try
  55. {
  56. #region 团组下拉框
  57. List<Grp_GroupsTaskAssignment> grp_GroupsTaskAssignment = Query<Grp_GroupsTaskAssignment>(a => a.IsDel == 0 && a.UId == dto.UserId && a.CTId == 98).ToList();
  58. string DiId = "";
  59. foreach (var item in grp_GroupsTaskAssignment)
  60. {
  61. DiId += item.DIId + ",";
  62. }
  63. DiId = DiId.Substring(0, DiId.Length - 1);
  64. string sql = string.Format(@"select * from Grp_DelegationInfo where Id in({0}) and IsDel={1}", DiId, 0);
  65. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.SqlQueryable<Grp_DelegationInfo>(sql).ToList();
  66. if (grp_Delegations.Count == 0)
  67. {
  68. return result = new Result() { Code = -1, Msg = "查询失败!" };
  69. }
  70. #endregion
  71. #region 其他下拉框查询
  72. //支付方式
  73. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  74. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  75. #endregion
  76. var data = new
  77. {
  78. Payment = _Payment,
  79. GroupName = grp_Delegations,
  80. };
  81. return result = new Result() { Code = 0, Msg = "查询成功!", Data = data };
  82. }
  83. catch (Exception ex)
  84. {
  85. return result = new Result() { Code = -2, Msg = "程序错误" };
  86. throw;
  87. }
  88. }
  89. }
  90. }