diff --git a/Src/Dlhis.Canteen/Order/Request/BalanceRecordUserPageRequest.cs b/Src/Dlhis.Canteen/Order/Request/BalanceRecordUserPageRequest.cs
index 32f30543..44f78456 100644
--- a/Src/Dlhis.Canteen/Order/Request/BalanceRecordUserPageRequest.cs
+++ b/Src/Dlhis.Canteen/Order/Request/BalanceRecordUserPageRequest.cs
@@ -17,6 +17,11 @@ public class BalanceRecordUserPageRequest : PageDto, IValidatableObject
///
public DateTimePeriod SearchDateTimePeriod { get; set; }
+ ///
+ /// 钱包code
+ ///
+ [Required(ErrorMessage = "请选择钱包")]
+ public string WalletCode { get; set; }
public IEnumerable Validate(ValidationContext validationContext)
{
@@ -27,4 +32,4 @@ public class BalanceRecordUserPageRequest : PageDto, IValidatableObject
yield break;
}
-}
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
index 3bedcca8..3f0957d4 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
@@ -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 GetPageByUserAsync(BalanceRecordUserPageRequest request)
{
- var jinkoCode = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
+ var userCode = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
+
+ var factory = await _dbContext.Queryable().Where(x => x.Code == request.WalletCode).Select(x => x.Factory).FirstAsync();
+ var factories = await _balanceRepository.GetWalletFactoriesAsync(factory);
var page = await _dbContext.Queryable()
.LeftJoin((record, ga) => record.UserNo == ga.No)
.LeftJoin((record, ga, department) => ga.DepartmentNo == department.No)
.LeftJoin((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()
- .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