| | |
| | | using Furion; |
| | | using Furion.DatabaseAccessor; |
| | | using Furion.DataValidation; |
| | | using Furion.DistributedIDGenerator; |
| | | using Furion.FriendlyException; |
| | | using Furion.HttpRemote; |
| | | using Mapster; |
| | |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using static System.Runtime.InteropServices.JavaScript.JSType; |
| | | |
| | | namespace FlexJobApi.UserServer.Application |
| | | { |
| | |
| | | /// </summary> |
| | | public class EnterpriseEmployeesCommandHandler( |
| | | IRepository<EnterpriseEmployee> rep, |
| | | IRepository<User> repUser |
| | | IRepository<User> repUser, |
| | | IRepository<EnterpriseEmployeeContract> repEnterpriseEmployeeContract |
| | | ) : |
| | | IRequestHandler<ImportEnterpriseEmployeesCommand, ImportEnterpriseEmployeesCommandResult>, |
| | | IRequestHandler<EditEnterpriseEmployeeCommand, Guid> |
| | | IRequestHandler<EditEnterpriseEmployeeCommand, Guid>, |
| | | IRequestHandler<InviteEnterpriseEmployeeElectronSignCommand, Guid> |
| | | { |
| | | private readonly IRepository<EnterpriseEmployee> rep = rep; |
| | | private readonly IRepository<User> repUser = repUser; |
| | | private readonly IRepository<EnterpriseEmployeeContract> repEnterpriseEmployeeContract = repEnterpriseEmployeeContract; |
| | | |
| | | /// <summary> |
| | | /// 导入灵工信息 |
| | |
| | | { |
| | | user.Name = model.Name; |
| | | user.ContactPhoneNumber = model.ContactPhoneNumber; |
| | | user.Identity = model.Identity; |
| | | user.Gender = model.Gender; |
| | | user.Birthday = model.Birthday; |
| | | user.Age = model.Age; |
| | |
| | | /// <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) => |
| | | (entity) => |
| | | { |
| | | if (request.Id.HasValue && entity.UserId.HasValue) |
| | | { |
| | | throw Oops.Oh(EnumErrorCodeType.s510, "已报名无法修改信息"); |
| | | var user = repUser.AsQueryable().FirstOrDefault(it => it.Id == entity.UserId.Value); |
| | | if (user!.IsReal == true) |
| | | { |
| | | throw Oops.Oh(EnumErrorCodeType.s510, "已实名无法修改信息"); |
| | | } |
| | | else |
| | | { |
| | | user.Name = request.Name; |
| | | user.ContactPhoneNumber = request.ContactPhoneNumber; |
| | | user.Identity = request.Identity; |
| | | user.Birthday = request.Identity.GetBirthday(); |
| | | user.Gender = request.Gender; |
| | | user.Age = request.Age; |
| | | repUser.Update(user); |
| | | } |
| | | } |
| | | request.Adapt(entity); |
| | | }, |
| | | cancellationToken); |
| | | return entity.Id; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 邀请灵工签约 |
| | | /// </summary> |
| | | /// <param name="request"></param> |
| | | /// <param name="cancellationToken"></param> |
| | | /// <returns></returns> |
| | | public async Task<Guid> Handle(InviteEnterpriseEmployeeElectronSignCommand 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, "已邀请"); |
| | | 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; |
| | | } |
| | | } |
| | | } |