From c8b232ee669808e954765711fd3d77afe68071fb Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 5 Jun 2024 17:54:41 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=95=B0=E6=8D=AE=E6=95=8F=E6=84=9F?= =?UTF-8?q?=E5=88=86=E9=85=8D=E8=A7=92=E8=89=B2=E5=8F=AF=E8=A7=81,?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=9F=BA=E5=9C=B0,=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1lock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Organization/Controllers/GainfoMealController.cs | 2 +- .../Organization/Services/Implements/MealUserService.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfoMealController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfoMealController.cs index b93a4490..ba1aa625 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/GainfoMealController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/GainfoMealController.cs @@ -37,7 +37,7 @@ public class GainfoMealController : ControllerBase /// /// 迁移 /// - [Authorize(Roles = "admin")] + /// [Transactional] [Authorize(Roles = "admin,tenant-admin")] [HttpPost("migration")] diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/MealUserService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/MealUserService.cs index e9789d4c..6efd6968 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/MealUserService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/MealUserService.cs @@ -54,6 +54,7 @@ public class MealUserService : IMealUserService /// public async Task MigrationAsync(GainfoBalanceMigrationRequest request) { + //只能针对离职人员 var gainfoLeave = await _dbContext.Queryable().Where(x => x.Code == request.BeforeCode).SingleAsync(); gainfoLeave.ThrowIfNull("需要对已离职人员迁移"); @@ -63,9 +64,6 @@ public class MealUserService : IMealUserService return; } - var gainfo = await _dbContext.Queryable().Where(x => x.Code == request.NowCode).SingleAsync(); - gainfo.ThrowIfNull("目标人员不存在"); - //清空余额 await _dbContext.Updateable() .SetColumns(x => x.Balance == 0) @@ -73,6 +71,10 @@ public class MealUserService : IMealUserService .SetColumns(x => x.Version == x.Version + 1) .Where(x => x.UserCode == request.BeforeCode) //不需要判断version .ExecuteCommandAsync(); + + //转移到现有人员 + var gainfo = await _dbContext.Queryable().Where(x => x.Code == request.NowCode).SingleAsync(); + gainfo.ThrowIfNull("目标人员不存在"); var now = DateTime.Now;