diff --git a/Src/Dlhis.Canteen/Voucher/Controllers/VouchersController.cs b/Src/Dlhis.Canteen/Voucher/Controllers/VouchersController.cs
index fddb8478..da0b65b0 100644
--- a/Src/Dlhis.Canteen/Voucher/Controllers/VouchersController.cs
+++ b/Src/Dlhis.Canteen/Voucher/Controllers/VouchersController.cs
@@ -84,11 +84,9 @@ public class VouchersController : ControllerBase
///
///
[HttpGet("balance/page")]
- [IgnoreTenant]
public async Task> GetVoucherBalancePageAsync([FromQuery] VoucherBalancePageRequest request)
{
var srv = _namedResolver.GetService(request.Type.ToString() + "VoucherService");
-
return await srv.GetVoucherBalancePageAsync(request);
}
@@ -101,7 +99,9 @@ public class VouchersController : ControllerBase
[IgnoreTenant]
public async Task> GetMyVoucherBalancePageAsync([FromQuery] VoucherBalancePageRequest request)
{
+ var userCode = _currentUser.GetUserClaim(UserClaimConstants.JinkoCode);
var srv = _namedResolver.GetService(request.Type.ToString() + "VoucherService");
+ request.UserCode = userCode;
return await srv.GetVoucherBalancePageAsync(request);
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.Canteen/Voucher/Services/Implements/BaseVoucherService.cs b/Src/Dlhis.Canteen/Voucher/Services/Implements/BaseVoucherService.cs
index 05d31b3f..7168b89a 100644
--- a/Src/Dlhis.Canteen/Voucher/Services/Implements/BaseVoucherService.cs
+++ b/Src/Dlhis.Canteen/Voucher/Services/Implements/BaseVoucherService.cs
@@ -3,6 +3,7 @@ using Dlhis.Canteen.Voucher.Requests;
using Dlhis.Canteen.Voucher.Response;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Canteen.Entities.Voucher;
+using Kurisu.AspNetCore.Authentication.Abstractions;
using Kurisu.AspNetCore.CustomClass;
using Kurisu.AspNetCore.DataAccess.Dto;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
@@ -13,19 +14,24 @@ namespace Dlhis.Canteen.Tickets.Services.Implements;
public abstract class BaseVoucherService : IVoucherService
{
+ private readonly ICurrentUser _currentUser;
+
protected IDbContext DbContext { get; set; }
- protected BaseVoucherService(IDbContext dbContext)
+ protected BaseVoucherService(IServiceProvider serviceProvider)
{
- DbContext = dbContext;
+ DbContext = serviceProvider.GetService();
+ _currentUser = serviceProvider.GetService();
}
public async Task> GetPageAsync(VoucherPageRequest request)
{
+ var tenantId = _currentUser.GetStringTenantId();
+
var pagination = await DbContext.Queryable()
.LeftJoin((x, u) => x.No == u.VoucherNo)
.LeftJoin((x, u, ga) => u.UserCode == ga.Code)
- .Where(x => x.Type == request.Type)
+ .Where((x, u) => x.Type == request.Type && u.Factory == tenantId)
.WhereIF(request.UserCode.IsPresent(), (x, u, ga) => u.UserCode == request.UserCode)
.WhereIF(request.SearchDateTimePeriod.HasValue(),
(x, u, ga) => x.CreateTime >= request.SearchDateTimePeriod.Start &&
diff --git a/Src/Dlhis.Canteen/Voucher/Services/Implements/BirthdayVoucherService.cs b/Src/Dlhis.Canteen/Voucher/Services/Implements/BirthdayVoucherService.cs
index e878e34e..7a5c121f 100644
--- a/Src/Dlhis.Canteen/Voucher/Services/Implements/BirthdayVoucherService.cs
+++ b/Src/Dlhis.Canteen/Voucher/Services/Implements/BirthdayVoucherService.cs
@@ -1,4 +1,3 @@
-using System.Collections.Generic;
using System.Text;
using Dlhis.Basic.Api;
using Dlhis.Canteen.Tickets.Services;
@@ -15,7 +14,6 @@ using Kurisu.AspNetCore.CustomClass;
using Kurisu.AspNetCore.DataAccess.Dto;
using Kurisu.AspNetCore.DataAccess.Entity;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
-using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
using Kurisu.AspNetCore.Utils.Extensions;
using SqlSugar;
@@ -27,9 +25,9 @@ public class BirthdayVoucherService : BaseVoucherService, IVoucherService
private readonly IFactorySettingApi _factorySettingApi;
///
- public BirthdayVoucherService(IDbContext dbContext, IFactorySettingApi factorySettingApi) : base(dbContext)
+ public BirthdayVoucherService(IServiceProvider serviceProvider) : base(serviceProvider)
{
- _factorySettingApi = factorySettingApi;
+ _factorySettingApi = serviceProvider.GetService();
}
///
@@ -164,6 +162,7 @@ public class BirthdayVoucherService : BaseVoucherService, IVoucherService
//var limit = end.Date.AddHours(9);//9点入职
return await DbContext.Queryable()
.WhereIF(userCodes.IsPresent(), x => userCodes.Contains(x.Code))
+ .Where(x => !SqlFunc.IsNullOrEmpty(x.DepartmentNo))
.Where(x => x.Type == GainfoUserTypeEnumType.Normal || x.Type == GainfoUserTypeEnumType.SecurityWhite)
.Where(x => x.Birthday.HasValue && !string.IsNullOrEmpty(x.CostId))
.WhereIF(isToday, x => SqlFunc.DateValue(x.Birthday.Value, DateType.Month) == begin.Month && SqlFunc.DateValue(x.Birthday.Value, DateType.Day) == begin.Day)
@@ -222,7 +221,7 @@ public class BirthdayVoucherService : BaseVoucherService, IVoucherService
return await DbContext.Queryable()
.LeftJoin((x, bPlace) => x.BusinessPlaceCode == bPlace.Code)
.LeftJoin((x, bPlace, department) => x.DepartmentNo == department.No)
- .Where(x => x.UserCode == request.UserCode)
+ .WhereIF(request.UserCode.IsPresent(), x => x.UserCode == request.UserCode)
.WhereIF(request.SearchDateTimePeriod.HasValue(), x => x.CostDate >= request.SearchDateTimePeriod.Start && x.CostDate <= request.SearchDateTimePeriod.End) //成本日期
.Where(x => x.Status == BalanceRecordStatusEnumType.Valid && x.Type == BalanceRecordTypeEnumType.Out) //有效,消费数据
.Where(x => x.Source == BalanceRecordSourceEnumType.Birthday)