feat 当前人员的消费记录
This commit is contained in:
@@ -3,6 +3,7 @@ using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Attributes;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
@@ -13,10 +14,12 @@ namespace Dlhis.Canteen.Order.Services.Implements;
|
||||
public class BalanceService : IBalanceService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
|
||||
public BalanceService(IDbContext dbContext)
|
||||
public BalanceService(IDbContext dbContext, ICurrentUser currentUser)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
|
||||
public async Task<Pagination<BalanceRecordResponse>> GetPageAsync(BalanceRecordPageRequest request)
|
||||
@@ -123,4 +126,34 @@ public class BalanceService : IBalanceService
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
public async Task<Pagination<BalanceRecordUserResponse>> GetPageByUserAsync(BalanceRecordUserPageRequest request)
|
||||
{
|
||||
//当前用户
|
||||
var userId = _currentUser.GetIntSubjectId();
|
||||
|
||||
var page = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
.LeftJoin<GainfoEntity>((record, ga) => record.UserNo == ga.No)
|
||||
.LeftJoin<DepartmentEntity>((record, ga, department) => ga.DepartmentNo == department.No)
|
||||
.LeftJoin<CanteenBusinessPlaceEntity>((record, ga, department, bplace) => record.BusinessPlaceCode == bplace.Code)
|
||||
.LeftJoin<CanteenBusinessShiftEntity>((record, ga, department, bplace, bshift) => record.BusinessShiftCode == bshift.Code)
|
||||
.WhereIF(request.SearchDateTimePeriod?.Start.HasValue == true, record => record.CreateTime >= request.SearchDateTimePeriod.Start)
|
||||
.WhereIF(request.SearchDateTimePeriod?.End.HasValue == true, record => record.CreateTime <= request.SearchDateTimePeriod.End)
|
||||
.Where((record, ga) => ga.IdentityUserId == userId)
|
||||
.OrderBy(record => record.CreateTime, OrderByType.Desc)
|
||||
.Select((record, ga, department, bplace, bshift) => new BalanceRecordUserResponse
|
||||
{
|
||||
Id = record.Id,
|
||||
Amount = record.Amount,
|
||||
Type = record.Type,
|
||||
Status = record.Status,
|
||||
Source = record.Source,
|
||||
No = record.No,
|
||||
BusinessPlaceName = bplace.Name,
|
||||
BusinessShiftName = bshift.Name,
|
||||
})
|
||||
.ToPageListAsync(request);
|
||||
|
||||
return page;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user