feat: 账户充值记录查询支持分页与条件筛选
为已登录账户的充值记录查询新增分页能力,支持按时间区间、是否免费、充值金额范围等条件筛选,并统一返回 PagedResultDto 结构,同时同步更新服务接口定义。
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
using Yi.Framework.Ddd.Application.Contracts;
|
||||||
|
|
||||||
|
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Recharge;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 充值记录查询输入
|
||||||
|
/// </summary>
|
||||||
|
public class RechargeGetListInput : PagedAllResultRequestDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 是否免费(充值金额等于0)
|
||||||
|
/// </summary>
|
||||||
|
public bool? IsFree { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 充值金额最小值
|
||||||
|
/// </summary>
|
||||||
|
public decimal? MinRechargeAmount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 充值金额最大值
|
||||||
|
/// </summary>
|
||||||
|
public decimal? MaxRechargeAmount { get; set; }
|
||||||
|
}
|
||||||
@@ -1,9 +1,15 @@
|
|||||||
using Yi.Framework.AiHub.Application.Contracts.Dtos.Recharge;
|
using Volo.Abp.Application.Dtos;
|
||||||
|
using Yi.Framework.AiHub.Application.Contracts.Dtos.Recharge;
|
||||||
|
|
||||||
namespace Yi.Framework.AiHub.Application.Contracts.IServices;
|
namespace Yi.Framework.AiHub.Application.Contracts.IServices;
|
||||||
|
|
||||||
public interface IRechargeService
|
public interface IRechargeService
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 查询已登录的账户充值记录(分页)
|
||||||
|
/// </summary>
|
||||||
|
Task<PagedResultDto<RechargeGetListOutput>> GetListByAccountAsync(RechargeGetListInput input);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 移除用户vip及角色
|
/// 移除用户vip及角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SqlSugar;
|
||||||
|
using Volo.Abp.Application.Dtos;
|
||||||
using Volo.Abp.Application.Services;
|
using Volo.Abp.Application.Services;
|
||||||
using Volo.Abp.Users;
|
using Volo.Abp.Users;
|
||||||
using Yi.Framework.AiHub.Application.Contracts.Dtos.Recharge;
|
using Yi.Framework.AiHub.Application.Contracts.Dtos.Recharge;
|
||||||
@@ -35,19 +37,29 @@ namespace Yi.Framework.AiHub.Application.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询已登录的账户充值记录
|
/// 查询已登录的账户充值记录(分页)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Route("recharge/account")]
|
[Route("recharge/account")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<List<RechargeGetListOutput>> GetListByAccountAsync()
|
public async Task<PagedResultDto<RechargeGetListOutput>> GetListByAccountAsync([FromQuery]RechargeGetListInput input)
|
||||||
{
|
{
|
||||||
var userId = CurrentUser.Id;
|
var userId = CurrentUser.Id;
|
||||||
var entities = await _repository._DbQueryable.Where(x => x.UserId == userId)
|
RefAsync<int> total = 0;
|
||||||
|
|
||||||
|
var entities = await _repository._DbQueryable
|
||||||
|
.Where(x => x.UserId == userId)
|
||||||
|
.WhereIF(input.StartTime.HasValue, x => x.CreationTime >= input.StartTime!.Value)
|
||||||
|
.WhereIF(input.EndTime.HasValue, x => x.CreationTime <= input.EndTime!.Value)
|
||||||
|
.WhereIF(input.IsFree == true, x => x.RechargeAmount == 0)
|
||||||
|
.WhereIF(input.IsFree == false, x => x.RechargeAmount > 0)
|
||||||
|
.WhereIF(input.MinRechargeAmount.HasValue, x => x.RechargeAmount >= input.MinRechargeAmount!.Value)
|
||||||
|
.WhereIF(input.MaxRechargeAmount.HasValue, x => x.RechargeAmount <= input.MaxRechargeAmount!.Value)
|
||||||
.OrderByDescending(x => x.CreationTime)
|
.OrderByDescending(x => x.CreationTime)
|
||||||
.ToListAsync();
|
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||||
|
|
||||||
var output = entities.Adapt<List<RechargeGetListOutput>>();
|
var output = entities.Adapt<List<RechargeGetListOutput>>();
|
||||||
return output;
|
return new PagedResultDto<RechargeGetListOutput>(total, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user