using System; using System.Threading.Tasks; using Znyc.Recruitment.Admin.Commons; using Znyc.Recruitment.Admin.Commons.Mapping; using Znyc.Recruitment.Admin.Commons.Pages; using Znyc.Recruitment.Admin.Commons.Services; using Znyc.Recruitment.Admin.Security.Dtos; using Znyc.Recruitment.Admin.Security.Entitys; using Znyc.Recruitment.Admin.Security.IRepositories; using Znyc.Recruitment.Admin.Security.IServices; namespace Znyc.Recruitment.Admin.Security.Services { /// /// 充值服务 /// public class PaymentRecordService : BaseService, IPaymentRecordService { private readonly IPaymentRecordRepository _PaymentRecordRepository; private readonly ICurrencyRepository _currencyRepository; private readonly IUserRepository _userRepository; public PaymentRecordService( IUserRepository userRepository, ICurrencyRepository currencyRepository, IPaymentRecordRepository PaymentRecordRepository ) : base(PaymentRecordRepository) { _userRepository = userRepository; _currencyRepository = currencyRepository; _PaymentRecordRepository = PaymentRecordRepository; } /// /// 云币列表 /// /// /// /// public async Task> FindWithPagerSearchAsync(SearchPaymentRecordModel search) { bool order = search.Order == "asc" ? false : true; string where = GetDataPrivilege(false); @where += " and PayStatus=20"; //金额类型 if (search.PaymentMoney > 0) { @where += $" and PaymentMoney={search.PaymentMoney}"; } //起始时间 if (!string.IsNullOrEmpty(search.StartTime)) { @where += $" and CreatedTime >='{search.StartTime} 00:00:00'"; } if (!string.IsNullOrEmpty(search.EndTime)) { @where += $" and CreatedTime <='{search.EndTime} 23:59:59'"; } PagerInfo pagerInfo = new PagerInfo { CurrenetPageIndex = search.CurrenetPageIndex, PageSize = search.PageSize }; //查询充值记录表 System.Collections.Generic.List list = (await repository.FindWithPagerAsync(where, pagerInfo, search.Sort, order)).MapTo(); //获取所有用户信息(查缓存) System.Collections.Generic.List users = (await _userRepository.GetListWhereAsync(" `Status`=1")).MapTo(); foreach (PaymentRecordOutputDto item in list) { UserOutputDto user = users.Find(x => x.Id == item.UserId); item.UserName = user?.UserName; item.AvatarUrl = CommonConst.Default_Image_Prefix + user?.AvatarUrl; item.Phone = user?.Phone; // item = EnumExtensions.ParseEnum(typeof(OperatingTypeEnum), item.OperatingType.ToString()).ToDescription(); // item.CurrencyTypeName = EnumExtensions.ParseEnum(typeof(OperatingCreditsTypeEnum), item.CurrencyType.ToString()).ToDescription(); } PageResult pageResult = new PageResult { CurrentPage = pagerInfo.CurrenetPageIndex, Items = list, ItemsPerPage = pagerInfo.PageSize, TotalItems = pagerInfo.RecordCount }; return pageResult; } } }