using AutoMapper; using OASystem.Domain; using OASystem.Domain.Dtos.Groups; using OASystem.Domain.Entities.Groups; using OASystem.Domain.Entities.Resource; using OASystem.Domain.ViewModels.Groups; using OASystem.Infrastructure.Repositories.System; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OASystem.Infrastructure.Repositories.Groups { public class DecreasePaymentsRepository : BaseRepository { private readonly IMapper _mapper; public DecreasePaymentsRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar) { this._mapper = mapper; } /// /// 根据团组Id查询数据 /// /// /// public async Task DecreasePaymentsList(DecreasePaymentsListDto dto) { Result result = new Result() { Code = -2, Msg = "未知错误" }; try { string sql = string.Format(@"select Id,DiId,PriceName,Price,(select name from Sys_SetData where id=s.Currency) as Currency,FilePath, (select CnName from Sys_Users where Id=s.CreateUserId) as 'CreateUserName',CreateTime,(select IsAuditGM from Grp_CreditCardPayment where CTable=98 and CId=s.Id) as 'isAudit' from Grp_DecreasePayments s where DIID={0} and IsDel=0 ", dto.DiId); List _DecreasePayments = await _sqlSugar.SqlQueryable(sql).ToListAsync(); if (_DecreasePayments.Count != 0) { result = new Result() { Code = 0, Msg = "查询成功!",Data=_DecreasePayments }; } else { result = new Result() { Code = 0, Msg = "暂无数据!", Data = _DecreasePayments }; } } catch (Exception ex) { result = new Result() { Code = -2, Msg = "未知错误" }; } return result; } public async Task DecreasePaymentsSelect(DecreasePaymentsDto dto) { Result result = new Result() { Code = -2, Msg = "未知错误" }; try { #region 团组下拉框 List grp_GroupsTaskAssignment = Query(a => a.IsDel == 0 && a.UId == dto.UserId && a.CTId == 98).ToList(); string DiId = ""; foreach (var item in grp_GroupsTaskAssignment) { DiId += item.DIId + ","; } DiId = DiId.Substring(0, DiId.Length - 1); string sql = string.Format(@"select * from Grp_DelegationInfo where Id in({0}) and IsDel={1}", DiId, 0); List grp_Delegations = _sqlSugar.SqlQueryable(sql).ToList(); if (grp_Delegations.Count == 0) { return result = new Result() { Code = -1, Msg = "查询失败!" }; } #endregion #region 其他下拉框查询 //支付方式 List Payment = _sqlSugar.Queryable().Where(a => a.STid == 14 && a.IsDel == 0).ToList(); List _Payment = _mapper.Map>(Payment); #endregion var data = new { Payment = _Payment, GroupName = grp_Delegations, }; return result = new Result() { Code = 0, Msg = "查询成功!", Data = data }; } catch (Exception ex) { return result = new Result() { Code = -2, Msg = "程序错误" }; throw; } } } }