using AutoMapper; using OASystem.Domain; using OASystem.Domain.Dtos.Groups; using OASystem.Domain.Entities.Groups; using OASystem.Domain.ViewModels.Groups; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OASystem.Infrastructure.Repositories.Groups { public class InvitationOfficialActivitiesRepository : BaseRepository { private readonly IMapper _mapper; public InvitationOfficialActivitiesRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar) { this._mapper = mapper; } public async Task InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto) { Result result = new Result() { Code = -2, Msg = "程序错误" }; try { Grp_InvitationOfficialActivities grp_Invitation = _sqlSugar.Queryable().First(a => a.Id == dto.Id && a.IsDel == 0); Grp_CreditCardPayment grp_CreditCard = _sqlSugar.Queryable().First(a => a.CId == dto.Id && a.IsDel == 0); var data = new { _Invitation = grp_Invitation, _CreditCard = grp_CreditCard, }; result = new Result() { Code = 0, Msg = "查询成功!", Data = data }; } catch (Exception) { result = new Result() { Code = -2, Msg = "程序错误" }; throw; } return result; } public async Task InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto) { Result result = new Result() { Code = -2, Msg = "未知错误" }; try { string sqlWhere = string.Empty; if (!string.IsNullOrWhiteSpace(dto.Inviter)) { sqlWhere += string.Format(@" And Inviter={0}", dto.Inviter); } if (!string.IsNullOrWhiteSpace(dto.StartInviteTime) && !string.IsNullOrWhiteSpace(dto.EndInviteTime)) { sqlWhere += string.Format(@" And i.InviteTime between '{0}' and '{1}'", dto.StartInviteTime,dto.EndInviteTime); } sqlWhere += string.Format(@" And i.DiId={0} And i.IsDel={1}",dto.DiId,0); if (!string.IsNullOrEmpty(sqlWhere.Trim())) { Regex r = new Regex("And"); sqlWhere = r.Replace(sqlWhere, "Where", 1); } string sql = string.Format(@"select Id,DiId,InviterArea,Inviter,InviteTime,InviteCosts,(select name from Sys_SetData where id=i.Currency and IsDel={0}) as Currency,IsGoOfficaiaBussiness,(select IsAuditGM from Grp_CreditCardPayment where CTable=81 and CId=i.Id and IsDel={0}) as 'isAudit',Attachment from Grp_InvitationOfficialActivities i {1}", 0, sqlWhere); 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; } } }