init
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
package com.newyetai.recruit.orgapply.service;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.newyetai.recruit.orgapply.dto.*;
|
||||
import com.newyetai.recruit.orgapply.entity.OrgApply;
|
||||
|
||||
/**
|
||||
* 入驻申请表
|
||||
*
|
||||
* @author guixinman
|
||||
* @since 1.0.0 2024-04-08
|
||||
*/
|
||||
@Validated(Default.class)
|
||||
public interface OrgApplyService {
|
||||
|
||||
/**
|
||||
* 入驻申请表 - 创建
|
||||
*
|
||||
* @param operatorDto 操作dto
|
||||
* @return {@link OrgApplyDTO}
|
||||
*/
|
||||
OrgApplyDTO create(@Valid OrgApplyOperatorDTO operatorDto);
|
||||
|
||||
/**
|
||||
* 入驻申请表 - 修改
|
||||
*
|
||||
* @param operatorDto 操作dto
|
||||
* @return {@link OrgApplyDTO}
|
||||
*/
|
||||
OrgApplyDTO modify(@Valid OrgApplyOperatorDTO operatorDto);
|
||||
|
||||
/**
|
||||
* 入驻申请表 - 删除
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link OrgApplyDTO}
|
||||
*/
|
||||
OrgApplyDTO delete(Long id);
|
||||
|
||||
/**
|
||||
* 入驻申请表 - 根据ID查询单个
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link OrgApplyDTO}
|
||||
*/
|
||||
OrgApplyDTO findById(Long id);
|
||||
|
||||
/**
|
||||
* 入驻申请表 - 列表查询
|
||||
*
|
||||
* @param queryDTO 列表查询dto
|
||||
* @return {@link List}<{@link OrgApplyDTO}>
|
||||
*/
|
||||
List<OrgApplyDTO> list(OrgApplyQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 入驻申请表 - 分页查询
|
||||
*
|
||||
* @param queryDTO 分页查询dto
|
||||
* @return {@link OrgApplyDTO}
|
||||
*/
|
||||
List<OrgApplyDTO> page(OrgApplyPageQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* @description: 审批
|
||||
* @return:
|
||||
* @author: guixinman
|
||||
* @param:
|
||||
*/
|
||||
void approve(OrgApplyApproveDTO orgApplyApproveDTO);
|
||||
|
||||
/**
|
||||
* @description: 根据手机号获取 入驻申请单
|
||||
* @return:
|
||||
* @author: guixinman
|
||||
* @param:
|
||||
*/
|
||||
|
||||
List<OrgApply> getInfoByPhone(String phone);
|
||||
|
||||
String share();
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
package com.newyetai.recruit.orgapply.service.impl;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.newyetai.common.constant.CommonConstants;
|
||||
import com.newyetai.common.exception.BusinessException;
|
||||
import com.newyetai.common.exception.util.Assert;
|
||||
import com.newyetai.common.function.TransactionAfterCommit;
|
||||
import com.newyetai.component.dict.util.DictUtils;
|
||||
import com.newyetai.config.service.ConfigService;
|
||||
import com.newyetai.frame.redis.aop.annotation.AutoUnLock;
|
||||
import com.newyetai.frame.redis.dto.LockDTO;
|
||||
import com.newyetai.frame.redis.redisson.RedissonUtils;
|
||||
import com.newyetai.recruit.orgapply.convert.OrgApplyConvert;
|
||||
import com.newyetai.recruit.orgapply.entity.OrgApply;
|
||||
import com.newyetai.recruit.orgapply.dto.*;
|
||||
import com.newyetai.recruit.orgapply.dao.OrgApplyMapper;
|
||||
import com.newyetai.recruit.orgapply.enums.OrgApplyEnum;
|
||||
import com.newyetai.recruit.orgapply.service.OrgApplyService;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.newyetai.common.util.UserContextHolder;
|
||||
import com.newyetai.security.expection.BadLoginException;
|
||||
import com.newyetai.usercenter.common.dto.SlickParamCreateDTO;
|
||||
import com.newyetai.usercenter.common.service.SlickParamService;
|
||||
import com.newyetai.usercenter.enums.OrgTypeEnum;
|
||||
import com.newyetai.usercenter.enums.SmsTemplateCodeEnum;
|
||||
import com.newyetai.usercenter.org.dto.OrgCreateDTO;
|
||||
import com.newyetai.usercenter.org.service.OrgService;
|
||||
import com.newyetai.usercenter.user.dto.UserRegisterCodeInfoDTO;
|
||||
import com.newyetai.usercenter.user.phone.constant.PhoneCodeProviderEnum;
|
||||
import com.newyetai.usercenter.user.phone.dto.PhoneCodeDTO;
|
||||
import com.newyetai.usercenter.user.phone.dto.SmsSimpleSendDTO;
|
||||
import com.newyetai.usercenter.user.phone.dto.SmsSimpleSendDetailDTO;
|
||||
import com.newyetai.usercenter.user.phone.provider.simple.ISimpleSms;
|
||||
import com.newyetai.usercenter.user.phone.util.PhoneCodeUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 入驻申请表
|
||||
*
|
||||
* @author guixinman
|
||||
* @since 1.0.0 2024-04-08
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class OrgApplyServiceImpl implements OrgApplyService {
|
||||
|
||||
@Resource
|
||||
private OrgApplyMapper orgApplyMapper;
|
||||
|
||||
@Autowired
|
||||
private ISimpleSms simpleSms;
|
||||
|
||||
@Autowired
|
||||
private SlickParamService slickParamService;
|
||||
|
||||
@Autowired
|
||||
private OrgService orgService;
|
||||
|
||||
@Autowired
|
||||
private ConfigService configService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @description: 企业名称 + 手机号只能申请一次,不能重复申请,驳回后可以重新提交
|
||||
* @return:
|
||||
* @author: guixinman
|
||||
* @param:
|
||||
*/
|
||||
|
||||
@AutoUnLock
|
||||
@Override
|
||||
public OrgApplyDTO create(OrgApplyOperatorDTO operatorDto) {
|
||||
Assert.isTrue(
|
||||
RedissonUtils.tryLockAutomatically(
|
||||
LockDTO.builder()
|
||||
.tryLockWaitTime(0L)
|
||||
.lockTimeout(60 * 5L)
|
||||
.methodName("org_apply:create")
|
||||
.arg(operatorDto.getCompanyName())
|
||||
.arg(operatorDto.getPhone())
|
||||
.build()
|
||||
),
|
||||
"请稍后再试");
|
||||
String inviterOrgId = configService.getConfigValue("org_apply_inviter_org_id", CommonConstants.PLATFORM_ORG_ID, true);
|
||||
operatorDto.setInviterOrgId(Long.parseLong(inviterOrgId));
|
||||
|
||||
//取消验证码
|
||||
/*boolean match = PhoneCodeUtils.match(PhoneCodeDTO.builder().phone(operatorDto.getPhone())
|
||||
.code(operatorDto.getSmsCode())
|
||||
.providerType(PhoneCodeProviderEnum.ORG_APPLY.getType()).build());
|
||||
Assert.isTrue(match, new BadLoginException("验证码错误"));*/
|
||||
|
||||
Map<String, String> companyTypeMap = DictUtils.getCodeNameMap("company_type");
|
||||
Assert.notNull(companyTypeMap.get(operatorDto.getCompanyType()),"企业类型错误");
|
||||
|
||||
Map<String, String> recruitPositionTypeMap = DictUtils.getCodeNameMap("recruit_position_type");
|
||||
Assert.notNull(recruitPositionTypeMap.get(operatorDto.getRecruitPositionType()),"招聘岗位类型错误");
|
||||
|
||||
List<OrgApply> orgApplys = orgApplyMapper.selectList(new LambdaQueryWrapper<OrgApply>().eq(OrgApply::getDeleted, false).in(OrgApply::getStatus, OrgApplyEnum.INIT.getStatus(), OrgApplyEnum.SUCCESS.getStatus()).eq(OrgApply::getCompanyName, operatorDto.getCompanyName()).eq(OrgApply::getPhone, operatorDto.getPhone()));
|
||||
if (CollectionUtils.isNotEmpty(orgApplys)) {
|
||||
throw new BusinessException("(企业名称 + 手机号)已存在入驻申请,请勿重复提交!");
|
||||
}
|
||||
|
||||
OrgApply orgApply = OrgApplyConvert.INSTANCE.convert(operatorDto);
|
||||
orgApply.setStatus(OrgApplyEnum.INIT.getStatus());
|
||||
|
||||
if (StringUtils.isNotBlank(operatorDto.getUniqueCode())) {
|
||||
OrgApplyInviterDTO orgApplyInviterDTO = slickParamService.parseCode(operatorDto.getUniqueCode(), OrgApplyInviterDTO.class);
|
||||
orgApply.setInviterOrgId(orgApplyInviterDTO.getInviterOrgId());
|
||||
orgApply.setInviterUserId(orgApplyInviterDTO.getInviterUserId());
|
||||
}else {
|
||||
Assert.notNull(operatorDto.getInviterOrgId(),"请选择邀请机构");
|
||||
orgApply.setInviterOrgId(operatorDto.getInviterOrgId());
|
||||
}
|
||||
|
||||
orgApplyMapper.saveEntity(orgApply);
|
||||
return OrgApplyConvert.INSTANCE.convert(orgApply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrgApplyDTO modify(OrgApplyOperatorDTO operatorDto) {
|
||||
OrgApplyDTO orgApplyDto = this.findById(operatorDto.getId());
|
||||
if (Objects.isNull(orgApplyDto)) {
|
||||
return null;
|
||||
}
|
||||
OrgApply orgApply = OrgApplyConvert.INSTANCE.convert(operatorDto);
|
||||
orgApplyMapper.updateEntitySelective(orgApply);
|
||||
return this.findById(operatorDto.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrgApplyDTO delete(Long id) {
|
||||
OrgApplyDTO orgApplyDto = this.findById(id);
|
||||
if (Objects.isNull(orgApplyDto)) {
|
||||
return null;
|
||||
}
|
||||
OrgApply orgApply = OrgApply.builder().build();
|
||||
orgApply.setId(id);
|
||||
orgApplyMapper.deleteEntity(orgApply, UserContextHolder.getLoginUserId());
|
||||
return orgApplyDto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrgApplyDTO findById(Long id) {
|
||||
OrgApply orgApply = orgApplyMapper.getById(id);
|
||||
if (Objects.isNull(orgApply)) {
|
||||
return null;
|
||||
}
|
||||
if (!CommonConstants.PLATFORM_ORG_ID.equals(UserContextHolder.getExistLoginOrgId())) {
|
||||
Assert.isTrue(orgApply.getInviterOrgId().equals(UserContextHolder.getExistLoginOrgId()),"未查询到数据");
|
||||
}
|
||||
return OrgApplyConvert.INSTANCE.convert(orgApply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgApplyDTO> list(OrgApplyQueryDTO queryDTO) {
|
||||
return orgApplyMapper.list(queryDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgApplyDTO> page(OrgApplyPageQueryDTO queryDTO) {
|
||||
if (!CommonConstants.PLATFORM_ORG_ID.equals(UserContextHolder.getExistLoginOrgId())) {
|
||||
queryDTO.setInviterOrgId(UserContextHolder.getExistLoginOrgId());
|
||||
}
|
||||
|
||||
List<OrgApplyDTO> list = orgApplyMapper.page(queryDTO);
|
||||
for (OrgApplyDTO orgApplyDTO : list) {
|
||||
orgApplyDTO.setRecruitPositionTypeName(DictUtils.getCodeNameMap("recruit_position_type").get(orgApplyDTO.getRecruitPositionType()));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@AutoUnLock
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void approve(OrgApplyApproveDTO orgApplyApproveDTO) {
|
||||
LambdaQueryWrapper<OrgApply> queryWrapper = new LambdaQueryWrapper<OrgApply>()
|
||||
.eq(OrgApply::getDeleted, false)
|
||||
.eq(OrgApply::getId, orgApplyApproveDTO.getId());
|
||||
|
||||
if (!CommonConstants.PLATFORM_ORG_ID.equals(UserContextHolder.getExistLoginOrgId())) {
|
||||
queryWrapper.eq(OrgApply::getInviterOrgId, UserContextHolder.getExistLoginOrgId());
|
||||
}
|
||||
|
||||
OrgApply orgApply = orgApplyMapper.selectOne(queryWrapper);
|
||||
Assert.notNull(orgApply, "未查询到数据");
|
||||
if (!orgApply.getStatus().equals(OrgApplyEnum.INIT.getStatus())) {
|
||||
throw new BusinessException("正在处理中...请稍后再试!");
|
||||
}
|
||||
Assert.isTrue(
|
||||
RedissonUtils.tryLockAutomatically(
|
||||
LockDTO.builder()
|
||||
.tryLockWaitTime(0L)
|
||||
.lockTimeout(60 * 5L)
|
||||
.methodName("org_apply:approve")
|
||||
.arg(String.valueOf(orgApplyApproveDTO.getId()))
|
||||
.build()
|
||||
),
|
||||
"正在处理中,请稍后再试");
|
||||
|
||||
if (orgApplyApproveDTO.getStatus().equals(OrgApplyEnum.REJECT.getStatus())) {
|
||||
Assert.isTrue(StringUtils.isNotBlank(orgApplyApproveDTO.getCause()), "请输入驳回原因");
|
||||
}
|
||||
|
||||
int rows = orgApplyMapper.approve(orgApplyApproveDTO.getId(), OrgApplyEnum.INIT.getStatus(), orgApplyApproveDTO.getStatus(), orgApplyApproveDTO.getCause(), UserContextHolder.getExistLoginUserId());
|
||||
if (rows != 1) {
|
||||
throw new BusinessException("审批失败,请稍后再试!");
|
||||
}
|
||||
|
||||
SmsSimpleSendDTO sendDTO = new SmsSimpleSendDTO();
|
||||
|
||||
if (orgApplyApproveDTO.getStatus().equals(OrgApplyEnum.REJECT.getStatus())) {
|
||||
/*//是驳回 短信通知联系人审核结果
|
||||
sendDTO.setTemplateCode(SmsTemplateCodeEnum.ORG_APPLY_REJECT.getTemplateCodeKey());
|
||||
List<SmsSimpleSendDetailDTO> detailDTOS = Lists.newArrayList();
|
||||
sendDTO.setDetailDTOS(detailDTOS);
|
||||
Map<String, Object> params = Maps.newHashMap();
|
||||
params.put("companyName", orgApply.getCompanyName());
|
||||
detailDTOS.add(SmsSimpleSendDetailDTO.builder()
|
||||
.phone(orgApply.getPhone())
|
||||
.parameters(params)
|
||||
.build());
|
||||
TransactionAfterCommit.doSomeThingAfterCommit(()->{
|
||||
simpleSms.send(sendDTO);
|
||||
});*/
|
||||
} else if (orgApplyApproveDTO.getStatus().equals(OrgApplyEnum.SUCCESS.getStatus())) {
|
||||
//审核通过了根据提交的企业信息去创建对应的机构
|
||||
OrgCreateDTO orgCreateDTO = OrgCreateDTO.builder()
|
||||
.type(orgApply.getCompanyType())
|
||||
.orgName(orgApply.getCompanyName())
|
||||
.phone(orgApply.getPhone())
|
||||
.creditCode(orgApply.getCreditCode())
|
||||
.addressCode(orgApply.getAreaCode())
|
||||
.addressName(orgApply.getAddressName())
|
||||
.parentId(orgApply.getInviterOrgId())
|
||||
.recruitPositionType(orgApply.getRecruitPositionType())
|
||||
.businessLicense(orgApply.getBusinessLicenseCode())
|
||||
.registeredAddress(orgApply.getRegisteredAddress())
|
||||
.realName(orgApply.getRealName())
|
||||
.build();
|
||||
orgService.create(orgCreateDTO);
|
||||
|
||||
/*sendDTO.setTemplateCode(SmsTemplateCodeEnum.ORG_APPLY_SUCCESS.getTemplateCodeKey());
|
||||
List<SmsSimpleSendDetailDTO> detailDTOS = Lists.newArrayList();
|
||||
sendDTO.setDetailDTOS(detailDTOS);
|
||||
Map<String, Object> params = Maps.newHashMap();
|
||||
params.put("companyName", orgApply.getCompanyName());
|
||||
detailDTOS.add(SmsSimpleSendDetailDTO.builder()
|
||||
.phone(orgApply.getPhone())
|
||||
.parameters(params)
|
||||
.build());
|
||||
TransactionAfterCommit.doSomeThingAfterCommit(()->{
|
||||
simpleSms.send(sendDTO);
|
||||
});*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgApply> getInfoByPhone(String phone) {
|
||||
/*boolean match = PhoneCodeUtils.match(PhoneCodeDTO.builder().phone(phone)
|
||||
.code(code)
|
||||
.providerType(PhoneCodeProviderEnum.GET_ORG_APPLY.getType()).build());
|
||||
Assert.isTrue(match, new BadLoginException("验证码错误"));*/
|
||||
List<OrgApply> orgApplyList = orgApplyMapper.selectList(new LambdaQueryWrapper<OrgApply>().eq(OrgApply::getPhone, phone).eq(OrgApply::getDeleted, false));
|
||||
return orgApplyList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String share() {
|
||||
|
||||
Assert.isTrue(StringUtils.equals(OrgTypeEnum.ORG_TYPE_GOV.getType(),UserContextHolder.getOrgType()),"没有操作权限");
|
||||
|
||||
UserRegisterCodeInfoDTO codeDTO = UserRegisterCodeInfoDTO.builder()
|
||||
.inviterId(UserContextHolder.getLoginUserId())
|
||||
.inviterOrgId(UserContextHolder.getExistLoginOrgId())
|
||||
.build();
|
||||
|
||||
return slickParamService.create(SlickParamCreateDTO.builder().paramData(codeDTO).build())
|
||||
.getUniqueCode();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user