| | |
| | | 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; |
| | |
| | | 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> |
| | | /// 导入灵工信息 |
| | |
| | | } |
| | | return result.Result.Adapt<EnterpriseUserElectronSignCommandResult>(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 灵工解约 |
| | | /// </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.Effect) 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; |
| | | } |
| | | } |
| | | } |