From 0a2215fac7b72abba17f816cec53b94e36debdbd Mon Sep 17 00:00:00 2001
From: sunpengfei <i@angelzzz.com>
Date: 星期五, 29 八月 2025 10:33:09 +0800
Subject: [PATCH] feat:开发

---
 FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs |   52 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs b/FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs
index fe173ab..1836a63 100644
--- a/FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs
+++ b/FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs
@@ -37,13 +37,15 @@
             IRepository<EnterpriseEmployeeContract> repEnterpriseEmployeeContract,
             IRepository<ElectronSignSetting> repElectronSignSetting,
             IRepository<ContractTemplate> repContractTemplate,
-            IRepository<EnterpriseCost> repEnterpriseCost
+            IRepository<EnterpriseCost> repEnterpriseCost,
+            IRepository<TaskInfoUser> repTaskInfoUser
         ) :
         IRequestHandler<ImportEnterpriseEmployeesCommand, ImportEnterpriseEmployeesCommandResult>,
         IRequestHandler<EditEnterpriseEmployeeCommand, Guid>,
         IRequestHandler<InviteElectronSignCommand, Guid>,
         IRequestHandler<PersonalUserElectronSignCommand, PersonalUserElectronSignCommandResult>,
-        IRequestHandler<EnterpriseUserElectronSignCommand, EnterpriseUserElectronSignCommandResult>
+        IRequestHandler<EnterpriseUserElectronSignCommand, EnterpriseUserElectronSignCommandResult>,
+        IRequestHandler<StopElectronSignCommand, Guid>
     {
         private readonly IMediator mediator = mediator;
         private readonly IRepository<EnterpriseEmployee> rep = rep;
@@ -53,6 +55,7 @@
         private readonly IRepository<ElectronSignSetting> repElectronSignSetting = repElectronSignSetting;
         private readonly IRepository<ContractTemplate> repContractTemplate = repContractTemplate;
         private readonly IRepository<EnterpriseCost> repEnterpriseCost = repEnterpriseCost;
+        private readonly IRepository<TaskInfoUser> repTaskInfoUser = repTaskInfoUser;
 
         /// <summary>
         /// 瀵煎叆鐏靛伐淇℃伅
@@ -226,7 +229,6 @@
             if (entity == null) throw Oops.Oh(EnumErrorCodeType.s404, "鐏靛伐");
             if (entity.UserSignContractStatus == EnumTaskUserSignContractStatus.Wait) throw Oops.Oh(EnumErrorCodeType.s400, "宸查個璇�");
             if (entity.UserSignContractStatus == EnumTaskUserSignContractStatus.Pass) throw Oops.Oh(EnumErrorCodeType.s400, "宸茬绾�");
-            if (entity.UserSignContractStatus == EnumTaskUserSignContractStatus.Effect) throw Oops.Oh(EnumErrorCodeType.s400, "宸茬敓鏁�");
             await mediator.Send(new CheckContractTemplateCommand
             {
                 Id = request.ContractTemplateId
@@ -272,7 +274,6 @@
             if (entity == null) throw Oops.Oh(EnumErrorCodeType.s510, "鏈姤鍚嶈浼佷笟");
             if (entity.UserSignContractStatus == null) throw Oops.Oh(EnumErrorCodeType.s510, "浼佷笟鏈彂璧风绾�");
             if (entity.UserSignContractStatus == EnumTaskUserSignContractStatus.Pass) throw Oops.Oh(EnumErrorCodeType.s510, "宸茬绾�");
-            if (entity.UserSignContractStatus == EnumTaskUserSignContractStatus.Effect) throw Oops.Oh(EnumErrorCodeType.s510, "宸茬敓鏁�");
             if (entity.UserSignContractStatus == EnumTaskUserSignContractStatus.Refuse) throw Oops.Oh(EnumErrorCodeType.s510, "宸叉嫆绛�");
             if (entity.UserSignContractStatus == EnumTaskUserSignContractStatus.Stop) throw Oops.Oh(EnumErrorCodeType.s510, "宸茬粓姝�");
             var contract = await repEnterpriseEmployeeContract.AsQueryable()
@@ -343,7 +344,6 @@
             if (entity == null) throw Oops.Oh(EnumErrorCodeType.s510, "鐏靛伐涓嶅瓨鍦�");
             if (entity.UserSignContractStatus == null) throw Oops.Oh(EnumErrorCodeType.s510, "鏈個璇风绾�");
             if (entity.UserSignContractStatus == EnumTaskUserSignContractStatus.Wait) throw Oops.Oh(EnumErrorCodeType.s510, "璇峰厛绛夊緟鐏靛伐绛剧害瀹屾垚");
-            if (entity.UserSignContractStatus == EnumTaskUserSignContractStatus.Effect) throw Oops.Oh(EnumErrorCodeType.s510, "宸茬敓鏁�");
             if (entity.UserSignContractStatus == EnumTaskUserSignContractStatus.Refuse) throw Oops.Oh(EnumErrorCodeType.s510, "宸叉嫆绛�");
             if (entity.UserSignContractStatus == EnumTaskUserSignContractStatus.Stop) throw Oops.Oh(EnumErrorCodeType.s510, "宸茬粓姝�");
             var contract = await repEnterpriseEmployeeContract.AsQueryable()
@@ -378,5 +378,47 @@
             }
             return result.Result.Adapt<EnterpriseUserElectronSignCommandResult>();
         }
+
+        /// <summary>
+        /// 鐏靛伐瑙g害
+        /// </summary>
+        /// <param name="request"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task<Guid> Handle(StopElectronSignCommand request, CancellationToken cancellationToken)
+        {
+            var logier = JwtUtils.GetCurrentLogier();
+            var entity = await rep.AsQueryable()
+                .Where(it => it.EnterpriseId == logier.EnterpriseId && it.Id == request.Id)
+                .FirstOrDefaultAsync();
+            if (entity == null) throw Oops.Oh(EnumErrorCodeType.s404, "鐏靛伐");
+            if (entity.UserSignContractStatus != EnumTaskUserSignContractStatus.Pass) throw Oops.Oh(EnumErrorCodeType.s400, "鏈绾�");
+            entity.UserSignContractStatus = EnumTaskUserSignContractStatus.Stop;
+            entity.EnterpriseSignContractStatus = EnumTaskUserSignContractStatus.Stop;
+            await rep.UpdateAsync(entity);
+
+            var contract = await repEnterpriseEmployeeContract.AsQueryable()
+                .OrderByDescending(it => it.CreatedTime)
+                .Where(it => it.EnterpriseEmployeeId == entity.Id)
+                .FirstOrDefaultAsync();
+            if (contract == null) throw Oops.Oh(EnumErrorCodeType.s404, "鍚堝悓");
+            contract.UserSignContractStatus = EnumTaskUserSignContractStatus.Stop;
+            contract.EnterpriseSignContractStatus = EnumTaskUserSignContractStatus.Stop;
+            await repEnterpriseEmployeeContract.UpdateAsync(contract);
+
+            var taskUsers = await repTaskInfoUser.AsQueryable()
+                .Where(it => it.EnterpriseEmployeeId == entity.Id && it.HireStatus == EnumTaskUserHireStatus.Pass)
+                .ToListAsync();
+            if (taskUsers.IsNotNull())
+            {
+                foreach (var taskUser in taskUsers)
+                {
+                    taskUser.HireStatus = EnumTaskUserHireStatus.Wait;
+                }
+                await repTaskInfoUser.UpdateAsync(taskUsers);
+            }
+
+            return entity.Id;
+        }
     }
 }

--
Gitblit v1.9.1