fix 用户查询消费根据钱包
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Basic.Api;
|
||||
using Dlhis.Canteen.Order.Repository;
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Canteen.Setting.Services;
|
||||
@@ -29,6 +30,7 @@ public class BalanceService : IBalanceService
|
||||
private readonly ITenantApi _tenantApi;
|
||||
private readonly ICanteenSettingService _canteenSettingService;
|
||||
private readonly RedisCache _redisCache;
|
||||
private readonly IBalanceRepository _balanceRepository;
|
||||
private readonly IBusinessPlacePermissionsApi _businessPlacePermissionsApi;
|
||||
|
||||
public BalanceService(IDbContext dbContext,
|
||||
@@ -36,6 +38,7 @@ public class BalanceService : IBalanceService
|
||||
ITenantApi tenantApi,
|
||||
ICanteenSettingService canteenSettingService,
|
||||
RedisCache redisCache,
|
||||
IBalanceRepository balanceRepository,
|
||||
IBusinessPlacePermissionsApi businessPlacePermissionsApi)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
@@ -43,6 +46,7 @@ public class BalanceService : IBalanceService
|
||||
_tenantApi = tenantApi;
|
||||
_canteenSettingService = canteenSettingService;
|
||||
_redisCache = redisCache;
|
||||
_balanceRepository = balanceRepository;
|
||||
_businessPlacePermissionsApi = businessPlacePermissionsApi;
|
||||
}
|
||||
|
||||
@@ -122,7 +126,7 @@ public class BalanceService : IBalanceService
|
||||
balanceRecord.Remark = "退款";
|
||||
await _dbContext.UpdateAsync(balanceRecord);
|
||||
|
||||
if (balanceRecord.Source == BalanceRecordSourceEnumType.EMealVoucher)
|
||||
if (balanceRecord.Source == BalanceRecordSourceEnumType.EMealVoucher)
|
||||
{
|
||||
var originData = balanceRecord.UserNo.Split(":");
|
||||
var eNo = originData[0];
|
||||
@@ -323,13 +327,16 @@ public class BalanceService : IBalanceService
|
||||
|
||||
public async Task<BalanceRecordUserResultResponse> GetPageByUserAsync(BalanceRecordUserPageRequest request)
|
||||
{
|
||||
var jinkoCode = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
|
||||
var userCode = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
|
||||
|
||||
var factory = await _dbContext.Queryable<WalletEntity>().Where(x => x.Code == request.WalletCode).Select(x => x.Factory).FirstAsync();
|
||||
var factories = await _balanceRepository.GetWalletFactoriesAsync(factory);
|
||||
|
||||
var page = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
.LeftJoin<GainfoEntity>((record, ga) => record.UserNo == ga.No)
|
||||
.LeftJoin<DepartmentEntity>((record, ga, department) => ga.DepartmentNo == department.No)
|
||||
.LeftJoin<BusinessPlaceEntity>((record, ga, department, bPlace) => record.BusinessPlaceCode == bPlace.Code)
|
||||
.Where((record, ga) => record.UserCode == jinkoCode)
|
||||
.Where((record, ga) => record.UserCode == userCode && factories.Contains(record.TenantId))
|
||||
.Where(record => record.Status == BalanceRecordStatusEnumType.Valid && record.Type == BalanceRecordTypeEnumType.Out)
|
||||
.Where(record => record.Source != BalanceRecordSourceEnumType.EMealVoucher) //不展示电子餐券信息
|
||||
.WhereIF(request.SearchDateTimePeriod.HasValue(), record => record.CostDate >= request.SearchDateTimePeriod.Start && record.CostDate <= request.SearchDateTimePeriod.End)
|
||||
@@ -353,10 +360,10 @@ public class BalanceService : IBalanceService
|
||||
var monthEnd = monthStart.AddMonths(1).AddSeconds(-1);
|
||||
|
||||
var monthSum = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
.Where(x => x.CostDateTime >= monthStart && x.CostDateTime <= monthEnd)
|
||||
.Where(x => x.UserCode == userCode && factories.Contains(x.TenantId))
|
||||
.Where(x => x.CostDate >= monthStart && x.CostDate <= monthEnd)
|
||||
.Where(x => x.Status == BalanceRecordStatusEnumType.Valid && x.Type == BalanceRecordTypeEnumType.Out)
|
||||
.Where(x => x.Source != BalanceRecordSourceEnumType.EMealVoucher)
|
||||
.Where(x => x.UserCode == jinkoCode)
|
||||
.SumAsync(x => SqlFunc.Abs(x.Amount));
|
||||
|
||||
return new BalanceRecordUserResultResponse
|
||||
|
||||
Reference in New Issue
Block a user