You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
4.0 KiB
99 lines
4.0 KiB
using System;
|
|
using System.Threading.Tasks;
|
|
using Znyc.Cloudcar.Admin.Commons;
|
|
using Znyc.Cloudcar.Admin.Commons.Enums;
|
|
using Znyc.Cloudcar.Admin.Commons.Extensions;
|
|
using Znyc.Cloudcar.Admin.Commons.Mapping;
|
|
using Znyc.Cloudcar.Admin.Commons.Pages;
|
|
using Znyc.Cloudcar.Admin.Commons.Services;
|
|
using Znyc.Cloudcar.Admin.Security.Dtos;
|
|
using Znyc.Cloudcar.Admin.Security.Entitys;
|
|
using Znyc.Cloudcar.Admin.Security.IRepositories;
|
|
using Znyc.Cloudcar.Admin.Security.IServices;
|
|
|
|
namespace Znyc.Cloudcar.Admin.Security.Services
|
|
{
|
|
/// <summary>
|
|
/// 用户云币服务
|
|
/// </summary>
|
|
public class CurrencyRecordService : BaseService<CurrencyRecordEntity, CurrencyRecordOutputDto, long>, ICurrencyRecordService
|
|
{
|
|
private readonly ICurrencyRecordRepository _currencyRecordRepository;
|
|
private readonly ICurrencyRepository _currencyRepository;
|
|
private readonly IUserRepository _userRepository;
|
|
|
|
public CurrencyRecordService(
|
|
IUserRepository userRepository,
|
|
ICurrencyRepository currencyRepository,
|
|
ICurrencyRecordRepository currencyRecordRepository
|
|
) : base(currencyRecordRepository)
|
|
{
|
|
_userRepository = userRepository;
|
|
_currencyRepository = currencyRepository;
|
|
_currencyRecordRepository = currencyRecordRepository;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 云币列表
|
|
/// </summary>
|
|
/// <param name="search"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public async Task<PageResult<CurrencyRecordOutputDto>> FindWithPagerSearchAsync(SearchCurrencyRecordModel search)
|
|
{
|
|
bool order = search.Order == "asc" ? false : true;
|
|
string where = GetDataPrivilege(false);
|
|
//用户id
|
|
@where += $" and UserId ={search.Filter.UserId}";
|
|
//收支途径
|
|
if (search.CurrencyType > 0)
|
|
{
|
|
@where += $" and CurrencyType={search.CurrencyType}";
|
|
}
|
|
//收支类型
|
|
if (search.OperatingType > 0)
|
|
{
|
|
@where += $" and OperatingType={search.OperatingType}";
|
|
}
|
|
//起始时间
|
|
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<CurrencyRecordOutputDto> list = (await repository.FindWithPagerAsync(where, pagerInfo, search.Sort, order)).MapTo<CurrencyRecordOutputDto>();
|
|
//获取所有用户信息(查缓存)
|
|
System.Collections.Generic.List<UserOutputDto> users = (await _userRepository.GetListWhereAsync(" `State`=10")).MapTo<UserOutputDto>();
|
|
|
|
foreach (CurrencyRecordOutputDto 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.OperatingTypeName = EnumExtensions.ParseEnum(typeof(OperatingTypeEnum), item.OperatingType.ToString()).ToDescription();
|
|
item.CurrencyTypeName = EnumExtensions.ParseEnum(typeof(CurrencyTypeEnum), item.CurrencyType.ToString()).ToDescription();
|
|
}
|
|
PageResult<CurrencyRecordOutputDto> pageResult = new PageResult<CurrencyRecordOutputDto>
|
|
{
|
|
CurrentPage = pagerInfo.CurrenetPageIndex,
|
|
Items = list,
|
|
ItemsPerPage = pagerInfo.PageSize,
|
|
TotalItems = pagerInfo.RecordCount
|
|
};
|
|
return pageResult;
|
|
}
|
|
}
|
|
}
|