fix 就餐人员列表查询根据消费记录显示

This commit is contained in:
2024-11-13 16:11:23 +08:00
parent e2bb6d5d0e
commit 3a47580441
2 changed files with 9 additions and 6 deletions

View File

@@ -28,12 +28,12 @@ public class GainfoMealService : IGainfoMealService
public async Task<Pagination<GainfoMealResponse>> GetPageAsync(GainfoMealPageRequest request)
{
var factory = _currentUser.GetStringTenantId();
var factories = await GetWalletFactoriesAsync(_currentUser.GetStringTenantId());
var factories = await GetWalletFactoriesAsync(factory);
return await _dbContext.Queryable<GainfoEntity>().AS(request.IsLeave ? "GainfoLeave" : "Gainfo")
.LeftJoin<DepartmentEntity>((x, dept) => dept.No == x.DepartmentNo)
.WhereIF(request.Search.IsPresent(), x => x.Code == request.Search || x.Name == request.Search)
.Where(x => x.Factory == factory)
.Where(x => SqlFunc.Subqueryable<BalanceRecordEntity>().Where(p => p.UserCode == x.Code && p.TenantId == factory).Any())
.WhereIF(request.IsLeave && request.SearchDateTimePeriod.HasValue(), x => x.ResignationDate >= request.SearchDateTimePeriod.Start &&
x.ResignationDate <= request.SearchDateTimePeriod.End)
.Select((x, dept) => new GainfoMealResponse

View File

@@ -1,3 +1,4 @@
using Dlhis.Canteen.Order.Repository;
using Dlhis.Canteen.Order.Response;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Canteen.Entities;
@@ -8,12 +9,12 @@ namespace Dlhis.Canteen.Order.Services.Implements;
public class MiddleService : IMiddleService
{
private readonly IDbContext _dbContext;
private readonly IBalanceService _balanceService;
private readonly IBalanceRepository _balanceRepository;
public MiddleService(IDbContext dbContext, IBalanceService balanceService)
public MiddleService(IDbContext dbContext, IBalanceRepository balanceRepository)
{
_dbContext = dbContext;
_balanceService = balanceService;
_balanceRepository = balanceRepository;
}
/// <inheritdoc />
@@ -27,6 +28,8 @@ public class MiddleService : IMiddleService
await _dbContext.InsertAsync(entity);
}
var balance = await _balanceRepository.GetBalanceAsync(entity.UserCode, string.Empty);
//获取人员余额
return await _dbContext.Queryable<GainfoEntity>()
.LeftJoin<DepartmentEntity>((x, department) => x.DepartmentNo == department.No)
@@ -37,7 +40,7 @@ public class MiddleService : IMiddleService
UserName = x.Name,
DepartmentNo = x.DepartmentNo,
DepartmentName = department.Name,
//CurrentBalance = x.Balance todo 余额
CurrentBalance = balance
})
.SingleAsync();
}