From 3a57c342ff5b39467b9dd0d5ba3c624311a581f1 Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期五, 22 八月 2025 16:44:06 +0800 Subject: [PATCH] feat:开发 --- FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 50 insertions(+), 4 deletions(-) diff --git a/FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs b/FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs index d5e01c0..ba2e8dd 100644 --- a/FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs +++ b/FlexJobApi.UserServer.Application/EnterpriseEmployees/Commands/EnterpriseEmployeesCommandHandler.cs @@ -2,10 +2,12 @@ using Furion; using Furion.DatabaseAccessor; using Furion.DataValidation; +using Furion.DistributedIDGenerator; using Furion.FriendlyException; using Furion.HttpRemote; using Mapster; using MediatR; +using Microsoft.AspNetCore.Components.Forms; using Microsoft.EntityFrameworkCore; using MiniExcelLibs; using NetTopologySuite.Index.HPRtree; @@ -24,14 +26,19 @@ /// 鐏靛伐鍛戒护澶勭悊鍣� /// </summary> public class EnterpriseEmployeesCommandHandler( + IMediator mediator, IRepository<EnterpriseEmployee> rep, - IRepository<User> repUser + IRepository<User> repUser, + IRepository<EnterpriseEmployeeContract> repEnterpriseEmployeeContract ) : IRequestHandler<ImportEnterpriseEmployeesCommand, ImportEnterpriseEmployeesCommandResult>, - IRequestHandler<EditEnterpriseEmployeeCommand, Guid> + IRequestHandler<EditEnterpriseEmployeeCommand, Guid>, + IRequestHandler<InviteElectronSignCommand, Guid> { + private readonly IMediator mediator = mediator; private readonly IRepository<EnterpriseEmployee> rep = rep; private readonly IRepository<User> repUser = repUser; + private readonly IRepository<EnterpriseEmployeeContract> repEnterpriseEmployeeContract = repEnterpriseEmployeeContract; /// <summary> /// 瀵煎叆鐏靛伐淇℃伅 @@ -158,10 +165,10 @@ /// <param name="request"></param> /// <param name="cancellationToken"></param> /// <returns></returns> - public Task<Guid> Handle(EditEnterpriseEmployeeCommand request, CancellationToken cancellationToken) + public async Task<Guid> Handle(EditEnterpriseEmployeeCommand request, CancellationToken cancellationToken) { var logier = JwtUtils.GetCurrentLogier(); - return request.SaveData<EnterpriseEmployee, EditEnterpriseEmployeeCommand>( + var entity = await request.SaveData<EnterpriseEmployee, EditEnterpriseEmployeeCommand>( q => q.Where(it => it.EnterpriseId == logier.EnterpriseId), it => it.EnterpriseId == logier.EnterpriseId && it.Id != request.Id && it.Identity == request.Identity, (entity) => @@ -187,6 +194,45 @@ request.Adapt(entity); }, cancellationToken); + return entity.Id; + } + + /// <summary> + /// 閭�璇风伒宸ョ绾� + /// </summary> + /// <param name="request"></param> + /// <param name="cancellationToken"></param> + /// <returns></returns> + public async Task<Guid> Handle(InviteElectronSignCommand 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, "宸茬绾�"); + if (entity.UserSignContractStatus == EnumTaskUserSignContractStatus.Effect) throw Oops.Oh(EnumErrorCodeType.s400, "宸茬敓鏁�"); + if (entity.UserSignContractStatus == EnumTaskUserSignContractStatus.Wait) throw Oops.Oh(EnumErrorCodeType.s400, "宸查個璇�"); + await mediator.Send(new CheckContractTemplateCommand + { + Id = request.Id + }, cancellationToken); + entity.ContractTemplateId = request.Id; + entity.UserSignContractStatus = EnumTaskUserSignContractStatus.Wait; + entity.UserSignContractTime = null; + entity.EnterpriseSignContractStatus = null; + entity.EnterpriseSignContractTime = null; + entity.ContractCode = $"{DateTime.Now:yyyyMMddHHmmss}{new Random(IDGen.NextID().GetHashCode()).Next(1000, 9999)}"; + var contract = new EnterpriseEmployeeContract + { + EnterpriseEmployeeId = entity.Id, + ContractTemplateId = entity.ContractTemplateId, + ContractCode = entity.ContractCode, + UserSignContractStatus = entity.UserSignContractStatus, + }; + await repEnterpriseEmployeeContract.InsertAsync(contract); + await rep.UpdateAsync(entity); + return entity.Id; } } } -- Gitblit v1.9.1