You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
322 lines
15 KiB
322 lines
15 KiB
using System;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Yitter.IdGenerator;
|
|
using Znyc.Cloudcar.Admin.Commons;
|
|
using Znyc.Cloudcar.Admin.Commons.Entitys;
|
|
using Znyc.Cloudcar.Admin.Commons.Enums;
|
|
using Znyc.Cloudcar.Admin.Commons.Extensions;
|
|
using Znyc.Cloudcar.Admin.Commons.Helpers;
|
|
using Znyc.Cloudcar.Admin.Commons.Mapping;
|
|
using Znyc.Cloudcar.Admin.Commons.Pages;
|
|
using Znyc.Cloudcar.Admin.Commons.Services;
|
|
using Znyc.Cloudcar.Admin.Security.Dtos;
|
|
using Znyc.Cloudcar.Admin.Security.Entitys;
|
|
using Znyc.Cloudcar.Admin.Security.IRepositories;
|
|
using Znyc.Cloudcar.Admin.Security.IServices;
|
|
|
|
namespace Znyc.Cloudcar.Admin.Security.Services
|
|
{
|
|
/// <summary>
|
|
/// ��ְ����
|
|
/// </summary>
|
|
public class ApplyJobService : BaseService<ApplyJobEntity, ApplyJobOutputDto, long>, IApplyJobService
|
|
{
|
|
private readonly IApplyJobRepository _applyJobRepository;
|
|
private readonly IAuditRepository _auditRepository;
|
|
public readonly IDictionaryService _dictionaryService;
|
|
private readonly IIndustryJobsService _industryJobsService;
|
|
private readonly IRegionRepository _regionRepository;
|
|
private readonly IUserRepository _userRepository;
|
|
private readonly IWxUnifyUserRepository _wxUnifyUserRepository;
|
|
private readonly ICallFeedbackRepository _callFeedbackRepository;
|
|
|
|
public ApplyJobService(IApplyJobRepository repository,
|
|
IDictionaryService dictionaryService,
|
|
IRegionRepository regionRepository,
|
|
IIndustryJobsService industryJobsService,
|
|
IAuditRepository auditRepository,
|
|
IUserRepository userRepository,
|
|
ICallFeedbackRepository callFeedbackRepository,
|
|
IWxUnifyUserRepository wxUnifyUserRepository
|
|
) : base(repository)
|
|
{
|
|
_applyJobRepository = repository;
|
|
_dictionaryService = dictionaryService;
|
|
_regionRepository = regionRepository;
|
|
_industryJobsService = industryJobsService;
|
|
_auditRepository = auditRepository;
|
|
_userRepository = userRepository;
|
|
_wxUnifyUserRepository = wxUnifyUserRepository;
|
|
_callFeedbackRepository = callFeedbackRepository;
|
|
}
|
|
|
|
/// <summary>
|
|
/// ͬ������ʵ�塣
|
|
/// </summary>
|
|
/// <param name="entity">ʵ��</param>
|
|
/// <param name="trans">�������</param>
|
|
/// <returns></returns>
|
|
public override long Insert(ApplyJobEntity entity, IDbTransaction trans = null)
|
|
{
|
|
long result = repository.Insert(entity, trans);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// �첽����ʵ�塣
|
|
/// </summary>
|
|
/// <param name="entity">ʵ��</param>
|
|
/// <param name="id">����ID</param>
|
|
/// <param name="trans">�������</param>
|
|
/// <returns></returns>
|
|
public override async Task<bool> UpdateAsync(ApplyJobEntity entity, long id, IDbTransaction trans = null)
|
|
{
|
|
bool result = await repository.UpdateAsync(entity, id, trans);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 异步新增数据
|
|
/// </summary>
|
|
/// <param name="intput">ʵ��</param>
|
|
/// <returns></returns>
|
|
public async Task<CommonResult> InsertAsync(ApplyJobEntity input)
|
|
{
|
|
CommonResult result = new CommonResult();
|
|
input.Id = YitIdHelper.NextId();
|
|
input.State = (int)ProductStatusEnum.Review;
|
|
input.UserId = 1001;
|
|
input.IsPublic = true;
|
|
input.SerialNumber = StringHelper.GetSerialNumber(ProductTypeEnum.ApplyJob, input.IndustryId, input.JobId);
|
|
input.ModifiedTime = DateTime.Now;
|
|
input.RefreshDate = DateTime.Now;
|
|
input.AreaId = "";
|
|
input.Address = input.Address.TrimEnd(',');
|
|
input.IsRealAuthentication = true;
|
|
input.IsTop = false;
|
|
if (input.BirthDate != null)
|
|
{
|
|
input.Age = StringHelper.GetAgeByBirthDate(input.BirthDate);
|
|
}
|
|
result.Success = await repository.InsertAsync(input) > 0 ? true : false;
|
|
return result;
|
|
}
|
|
|
|
public async Task<CommonResult> UpdateAsync(ApplyJobEntity tinfo)
|
|
{
|
|
CommonResult result = new CommonResult();
|
|
ApplyJobEntity info = await repository.GetAsync(tinfo.Id);
|
|
if (!(info?.Id > 0))
|
|
{
|
|
result.Success = false;
|
|
result.ErrMsg = "求职信息不存在";
|
|
return result;
|
|
}
|
|
|
|
// info.Title = tinfo.Title;
|
|
info.Content = tinfo.Content;
|
|
// info.Name = tinfo.Name;
|
|
info.Phone = tinfo.Phone;
|
|
info.IndustryId = tinfo.IndustryId;
|
|
info.JobId = tinfo.JobId;
|
|
info.ProvinceId = tinfo.ProvinceId;
|
|
info.CityId = tinfo.CityId;
|
|
info.State = tinfo.State;
|
|
info.IsTop = tinfo.IsTop;
|
|
info.IsHaveDriverLicense = tinfo.IsHaveDriverLicense;
|
|
info.IsPublic = tinfo.IsPublic;
|
|
// info.TopExpireTime = tinfo.TopExpireTime;
|
|
info.ExperienceId = tinfo.ExperienceId;
|
|
info.ModifiedUserId = tinfo.ModifiedUserId;
|
|
info.ModifiedTime = tinfo.ModifiedTime;
|
|
info.BirthDate = tinfo.BirthDate;
|
|
if (info.BirthDate != null)
|
|
{
|
|
info.Age = StringHelper.GetAgeByBirthDate(info.BirthDate);
|
|
}
|
|
info.Gender = tinfo.Gender;
|
|
info.Address = tinfo.Address;
|
|
await repository.UpdateAsync(info, tinfo.Id).ConfigureAwait(false);
|
|
result.Success = true;
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 求职分页查询
|
|
/// </summary>
|
|
/// <param name="search">查询条件</param>
|
|
/// <returns></returns>
|
|
public async Task<PageResult<ApplyJobOutputDto>> FindWithPagerSearchAsync(SearchCloudcarModel search)
|
|
{
|
|
bool order = search.Order == "asc" ? false : true;
|
|
string where = GetDataPrivilege(false);
|
|
if (!string.IsNullOrEmpty(search.Keywords))
|
|
{
|
|
@where += $" and (Content like '%{search.Keywords}%' or Phone like '%{search.Keywords}%' or SerialNumber like '%{search.Keywords}%' or Address like '%{search.Keywords}%')";
|
|
}
|
|
|
|
//if (search.State == (int)ProductStatusEnum.Pass)
|
|
//{
|
|
// @where += " and (State=1 or State=2 )";
|
|
//}
|
|
|
|
//if (search.State >= 0 && search.State != (int)ProductStatusEnum.Pass)
|
|
//{
|
|
// @where += $" and State={search.State}";
|
|
//}
|
|
|
|
if (!string.IsNullOrEmpty(search.StartTime))
|
|
{
|
|
@where += $" and ModifiedTime >='{search.StartTime} 00:00:00'";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(search.EndTime))
|
|
{
|
|
@where += $" and ModifiedTime <='{search.EndTime} 23:59:59'";
|
|
}
|
|
|
|
if (search.industryId > 0)
|
|
{
|
|
@where += $" and IndustryId={search.industryId}";
|
|
}
|
|
|
|
if (search.jobId > 0)
|
|
{
|
|
@where += $" and JobId={search.jobId}";
|
|
}
|
|
|
|
System.Collections.Generic.List<UserOutputDto> users = (await _userRepository.GetListWhereAsync(" `State`=10")).MapTo<UserOutputDto>();
|
|
if (!string.IsNullOrEmpty(search.UserName))
|
|
{
|
|
System.Collections.Generic.List<long> uIds = users.Where(x => x.UserName.Contains(search.UserName)).Select(x => x.Id).ToList();
|
|
@where += $" and UserId in ({string.Join(",", uIds.ToArray())})";
|
|
}
|
|
//行业岗位
|
|
System.Collections.Generic.List<IndustryJobsOutputDto> industryJobs = await _industryJobsService.GetAllListAsync();
|
|
//工作经验
|
|
System.Collections.Generic.List<DictionaryListOutput> experiences = await _dictionaryService.GetListByPidAsync(CommonConst.Dictionary_Experience);
|
|
//云平台统一用户信息
|
|
System.Collections.Generic.List<string> uninIds = users.Select(x => x.UnionId).ToList();
|
|
System.Collections.Generic.List<WxUnifyUserOutputDto> wxUnifyUsers = (await _wxUnifyUserRepository.GetListWhereAsync($" IsDeleted=0 AND UnionId IN ('{string.Join("','", uninIds.ToArray())}')"))
|
|
.MapTo<WxUnifyUserOutputDto>();
|
|
|
|
PagerInfo pagerInfo = new PagerInfo
|
|
{
|
|
CurrenetPageIndex = search.CurrenetPageIndex,
|
|
PageSize = search.PageSize
|
|
};
|
|
System.Collections.Generic.List<ApplyJobEntity> list = await repository.FindWithPagerAsync(where, pagerInfo, search.Sort, order);
|
|
System.Collections.Generic.List<ApplyJobOutputDto> listDto = list.MapTo<ApplyJobOutputDto>();
|
|
foreach (ApplyJobOutputDto item in listDto)
|
|
{
|
|
item.ExperienceName = experiences.Find(x => x.Id == item.ExperienceId)?.Value;
|
|
item.IndustryName = industryJobs.Find(x => x.Id == item.IndustryId)?.Name;
|
|
item.JobName = industryJobs.Find(x => x.Id == item.JobId)?.Name;
|
|
item.DriverLicense = "";
|
|
if (item.IsHaveDriverLicense != null)
|
|
{
|
|
item.DriverLicense = item.IsHaveDriverLicense == true ? "有驾驶证" : "无驾驶证";
|
|
}
|
|
item.Top = item.IsTop ? "已置顶" : "未置顶";
|
|
item.TopExpireDate = item.IsTop ? item.TopExpireDate : null;
|
|
item.Public = item.IsPublic ? "已公开" : "未公开";
|
|
item.StatusName = EnumExtensions
|
|
.ParseEnum(typeof(ProductStatusEnum), item.State.ToString()).ToDescription();
|
|
UserOutputDto user = users.Find(x => x.Id == item.UserId);
|
|
item.UserName = user?.UserName ?? CommonConst.Default_UserName;
|
|
item.AvatarUrl = CommonConst.Default_Image_Prefix + (user?.AvatarUrl ?? CommonConst.Default_AvataUrl);
|
|
if (item.State == (int)ProductStatusEnum.Fail)
|
|
{
|
|
string key = $" ProductId={ item.Id} AND ProductType=1 AND HandleStatus={item.State} ORDER BY CreatedTime DESC LIMIT 1";
|
|
item.Note = (await _auditRepository.GetWhereAsync(key))?.Note ?? "";
|
|
}
|
|
item.NickName = wxUnifyUsers.Find(x => x.UnionId == user.UnionId)?.NickName ?? CommonConst.Default_UserName;
|
|
item.WxAvatarUrl = wxUnifyUsers.Find(x => x.UnionId == user.UnionId)?.AvatarUrl ?? (CommonConst.Default_Image_Prefix + CommonConst.Default_AvataUrl);
|
|
//通话评价
|
|
item.CallFeedbacks = (await _callFeedbackRepository.GetListWhereAsync($" ProductId={item.Id} AND ProductType=1")).MapTo<CallFeedbackOutputDto>();
|
|
foreach (var callFeedback in item.CallFeedbacks)
|
|
{
|
|
var callUser = users.Find(x => x.Id == callFeedback.UserId);
|
|
callFeedback.Phone = callUser.Phone;
|
|
callFeedback.NickName = wxUnifyUsers.Find(x => x.UnionId == callUser.UnionId)?.NickName ?? CommonConst.Default_UserName;
|
|
callFeedback.WxAvatarUrl = wxUnifyUsers.Find(x => x.UnionId == callUser.UnionId)?.AvatarUrl ?? (CommonConst.Default_Image_Prefix + CommonConst.Default_AvataUrl);
|
|
callFeedback.Content = EnumExtensions
|
|
.ParseEnum(typeof(CallFeedbackStatusEnum), callFeedback.State.ToString()).ToDescription();
|
|
if (callFeedback.IsRead == false && item.IsReadForCallFeedback == false)
|
|
{
|
|
item.IsReadForCallFeedback = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
PageResult<ApplyJobOutputDto> pageResult = new PageResult<ApplyJobOutputDto>
|
|
{
|
|
CurrentPage = pagerInfo.CurrenetPageIndex,
|
|
Items = listDto,
|
|
ItemsPerPage = pagerInfo.PageSize,
|
|
TotalItems = pagerInfo.RecordCount
|
|
};
|
|
return pageResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 单条查询
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public async Task<ApplyJobOutputDto> GetById(long id)
|
|
{
|
|
ApplyJobOutputDto applyDto = await GetOutDtoAsync(id);
|
|
//行业岗位
|
|
System.Collections.Generic.List<IndustryJobsOutputDto> industryJobs = await _industryJobsService.GetAllListAsync();
|
|
//工作经验
|
|
System.Collections.Generic.List<DictionaryListOutput> experiences = await _dictionaryService.GetListByPidAsync(CommonConst.Dictionary_Experience);
|
|
//
|
|
System.Collections.Generic.List<UserOutputDto> users = (await _userRepository.GetListWhereAsync(" `State`=10")).MapTo<UserOutputDto>();
|
|
|
|
applyDto.ExperienceName = experiences.Find(x => x.Id == applyDto.ExperienceId)?.Value;
|
|
applyDto.IndustryName = industryJobs.Find(x => x.Id == applyDto.IndustryId)?.Name;
|
|
applyDto.JobName = industryJobs.Find(x => x.Id == applyDto.JobId)?.Name;
|
|
applyDto.DriverLicense = "";
|
|
if (applyDto.IsHaveDriverLicense != null)
|
|
{
|
|
applyDto.DriverLicense = applyDto.IsHaveDriverLicense == true ? "有驾驶证" : "无驾驶证";
|
|
}
|
|
applyDto.Top = applyDto.IsTop ? "已置顶" : "未置顶";
|
|
applyDto.TopExpireDate = applyDto.IsTop ? applyDto.TopExpireDate : null;
|
|
applyDto.Public = applyDto.IsPublic ? "已公开" : "未公开";
|
|
applyDto.StatusName = EnumExtensions
|
|
.ParseEnum(typeof(ProductStatusEnum), applyDto.State.ToString()).ToDescription();
|
|
UserOutputDto user = users.Find(x => x.Id == applyDto.UserId);
|
|
applyDto.UserName = user?.UserName ?? CommonConst.Default_UserName;
|
|
applyDto.AvatarUrl = CommonConst.Default_Image_Prefix + (user?.AvatarUrl ?? CommonConst.Default_AvataUrl);
|
|
return applyDto;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 下架求职信息
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="userId"></param>
|
|
/// <returns></returns>
|
|
public async Task<CommonResult> RevocationAsync(long id, long userId)
|
|
{
|
|
CommonResult result = new CommonResult();
|
|
ApplyJobEntity info = await repository.GetAsync(id);
|
|
if (!(info?.Id > 0))
|
|
{
|
|
result.Success = false;
|
|
result.ErrMsg = "求职信息不存在";
|
|
return result;
|
|
}
|
|
info.State = (int)ProductStatusEnum.Cancel;
|
|
info.ModifiedUserId = userId;
|
|
info.ModifiedTime = DateTime.Now;
|
|
await repository.UpdateAsync(info, info.Id).ConfigureAwait(false);
|
|
result.Success = true;
|
|
return result;
|
|
}
|
|
}
|
|
}
|