|
@@ -1,12 +1,12 @@
|
|
package com.citu.module.menduner.system.service.job;
|
|
package com.citu.module.menduner.system.service.job;
|
|
|
|
|
|
|
|
|
|
-import cn.hutool.core.collection.ListUtil;
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
import com.citu.framework.common.pojo.PageParam;
|
|
import com.citu.framework.common.pojo.PageParam;
|
|
import com.citu.framework.common.pojo.PageResult;
|
|
import com.citu.framework.common.pojo.PageResult;
|
|
import com.citu.framework.common.util.object.BeanUtils;
|
|
import com.citu.framework.common.util.object.BeanUtils;
|
|
import com.citu.framework.security.core.LoginUser;
|
|
import com.citu.framework.security.core.LoginUser;
|
|
|
|
+import com.citu.module.menduner.common.util.LoginUserContext;
|
|
import com.citu.module.menduner.system.controller.app.enterprise.vo.AppEnterpriseSimpleRespVO;
|
|
import com.citu.module.menduner.system.controller.app.enterprise.vo.AppEnterpriseSimpleRespVO;
|
|
import com.citu.module.menduner.system.controller.app.job.vo.AppEnterpriseJobHomeRespVO;
|
|
import com.citu.module.menduner.system.controller.app.job.vo.AppEnterpriseJobHomeRespVO;
|
|
import com.citu.module.menduner.system.controller.app.job.vo.AppJobAdvertisedDetailRespVO;
|
|
import com.citu.module.menduner.system.controller.app.job.vo.AppJobAdvertisedDetailRespVO;
|
|
@@ -24,9 +24,9 @@ import com.citu.module.menduner.system.dal.mysql.job.JobAdvertisedMapper;
|
|
import com.citu.module.menduner.system.enums.MendunerStatusEnum;
|
|
import com.citu.module.menduner.system.enums.MendunerStatusEnum;
|
|
import com.citu.module.menduner.system.mq.producer.ESProducer;
|
|
import com.citu.module.menduner.system.mq.producer.ESProducer;
|
|
import com.citu.module.menduner.system.service.enterprise.EnterpriseService;
|
|
import com.citu.module.menduner.system.service.enterprise.EnterpriseService;
|
|
|
|
+import com.citu.module.menduner.system.service.enterprise.account.EnterpriseAccountService;
|
|
import com.citu.module.menduner.system.service.enterprise.bind.EnterpriseUserBindService;
|
|
import com.citu.module.menduner.system.service.enterprise.bind.EnterpriseUserBindService;
|
|
import com.citu.module.menduner.system.util.ESOperateEnum;
|
|
import com.citu.module.menduner.system.util.ESOperateEnum;
|
|
-import com.citu.module.menduner.common.util.LoginUserContext;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -40,8 +40,8 @@ import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static com.citu.framework.common.exception.enums.GlobalErrorCodeConstants.FORBIDDEN;
|
|
|
|
import static com.citu.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static com.citu.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
+import static com.citu.module.menduner.system.enums.ErrorCodeConstants.MDE_ENTERPRISE_ACCOUNT_BALANCE_NOT_ENOUGH;
|
|
import static com.citu.module.menduner.system.enums.ErrorCodeConstants.MDE_JOB_ADVERTISED_NOT_EXISTS;
|
|
import static com.citu.module.menduner.system.enums.ErrorCodeConstants.MDE_JOB_ADVERTISED_NOT_EXISTS;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -64,6 +64,9 @@ public class JobAdvertisedServiceImpl implements JobAdvertisedService {
|
|
@Resource
|
|
@Resource
|
|
private EnterpriseUserBindService userBindService;
|
|
private EnterpriseUserBindService userBindService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private EnterpriseAccountService enterpriseAccountService;
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private ESProducer esProducer;
|
|
private ESProducer esProducer;
|
|
|
|
|
|
@@ -113,7 +116,7 @@ public class JobAdvertisedServiceImpl implements JobAdvertisedService {
|
|
@Override
|
|
@Override
|
|
public PageResult<AppJobAdvertisedHomeRespVO> getRecommendedPage(PageParam pageParam) {
|
|
public PageResult<AppJobAdvertisedHomeRespVO> getRecommendedPage(PageParam pageParam) {
|
|
AppJobAdvertisedPageReqVO pageReqVO =
|
|
AppJobAdvertisedPageReqVO pageReqVO =
|
|
- new AppJobAdvertisedPageReqVO(pageParam,AppJobAdvertisedPageReqVO.RECOMMEND);
|
|
|
|
|
|
+ new AppJobAdvertisedPageReqVO(pageParam, AppJobAdvertisedPageReqVO.RECOMMEND);
|
|
pageReqVO.setTop(true);
|
|
pageReqVO.setTop(true);
|
|
return jobAdvertisedMapper.selectPage(pageReqVO);
|
|
return jobAdvertisedMapper.selectPage(pageReqVO);
|
|
}
|
|
}
|
|
@@ -121,7 +124,7 @@ public class JobAdvertisedServiceImpl implements JobAdvertisedService {
|
|
@Override
|
|
@Override
|
|
public PageResult<AppJobAdvertisedHomeRespVO> getLatestPage(PageParam pageParam) {
|
|
public PageResult<AppJobAdvertisedHomeRespVO> getLatestPage(PageParam pageParam) {
|
|
AppJobAdvertisedPageReqVO pageReqVO =
|
|
AppJobAdvertisedPageReqVO pageReqVO =
|
|
- new AppJobAdvertisedPageReqVO(pageParam,AppJobAdvertisedPageReqVO.NEW);
|
|
|
|
|
|
+ new AppJobAdvertisedPageReqVO(pageParam, AppJobAdvertisedPageReqVO.NEW);
|
|
return jobAdvertisedMapper.selectPage(pageReqVO);
|
|
return jobAdvertisedMapper.selectPage(pageReqVO);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -135,7 +138,7 @@ public class JobAdvertisedServiceImpl implements JobAdvertisedService {
|
|
@Override
|
|
@Override
|
|
public PageResult<AppJobAdvertisedHomeRespVO> getHirePage(PageParam pageParam) {
|
|
public PageResult<AppJobAdvertisedHomeRespVO> getHirePage(PageParam pageParam) {
|
|
AppJobAdvertisedPageReqVO pageReqVO =
|
|
AppJobAdvertisedPageReqVO pageReqVO =
|
|
- new AppJobAdvertisedPageReqVO(pageParam,AppJobAdvertisedPageReqVO.HIRE);
|
|
|
|
|
|
+ new AppJobAdvertisedPageReqVO(pageParam, AppJobAdvertisedPageReqVO.HIRE);
|
|
pageReqVO.setHire(true);
|
|
pageReqVO.setHire(true);
|
|
return jobAdvertisedMapper.selectPage(pageReqVO);
|
|
return jobAdvertisedMapper.selectPage(pageReqVO);
|
|
}
|
|
}
|
|
@@ -227,16 +230,14 @@ public class JobAdvertisedServiceImpl implements JobAdvertisedService {
|
|
public boolean save(AppAdminJobSaveReqVO reqVO) {
|
|
public boolean save(AppAdminJobSaveReqVO reqVO) {
|
|
LoginUser loginUser = LoginUserContext.get();
|
|
LoginUser loginUser = LoginUserContext.get();
|
|
JobAdvertisedDO job = JobAdvertisedConvert.INSTANCE.convert3(reqVO);
|
|
JobAdvertisedDO job = JobAdvertisedConvert.INSTANCE.convert3(reqVO);
|
|
- Long enterpriseId =LoginUserContext.getEnterpriseId(loginUser);
|
|
|
|
|
|
+ Long enterpriseId = LoginUserContext.getEnterpriseId(loginUser);
|
|
if (null == reqVO.getId()) {
|
|
if (null == reqVO.getId()) {
|
|
// 新增
|
|
// 新增
|
|
-
|
|
|
|
job.setUserId(loginUser.getId());
|
|
job.setUserId(loginUser.getId());
|
|
-
|
|
|
|
job.setEnterpriseId(enterpriseId);
|
|
job.setEnterpriseId(enterpriseId);
|
|
job.setStatus(MendunerStatusEnum.ENABLE.getStatus());
|
|
job.setStatus(MendunerStatusEnum.ENABLE.getStatus());
|
|
job.setTop(false);
|
|
job.setTop(false);
|
|
- if(!job.getHire()) {
|
|
|
|
|
|
+ if (!job.getHire()) {
|
|
job.setHirePoint(BigDecimal.ZERO);
|
|
job.setHirePoint(BigDecimal.ZERO);
|
|
job.setHirePrice(BigDecimal.ZERO);
|
|
job.setHirePrice(BigDecimal.ZERO);
|
|
}
|
|
}
|
|
@@ -247,17 +248,65 @@ public class JobAdvertisedServiceImpl implements JobAdvertisedService {
|
|
// 修改
|
|
// 修改
|
|
JobAdvertisedDO entity = get(reqVO.getId());
|
|
JobAdvertisedDO entity = get(reqVO.getId());
|
|
|
|
|
|
- if (!Objects.equals(loginUser.getId(), entity.getUserId())
|
|
|
|
- || !Objects.equals(enterpriseId, entity.getEnterpriseId())) {
|
|
|
|
- // TODO 不是自己的数据 (企业管理员更改企业其他用户发布的职位信息)
|
|
|
|
- // throw exception(FORBIDDEN);
|
|
|
|
- }
|
|
|
|
job.setId(entity.getId());
|
|
job.setId(entity.getId());
|
|
jobOperate(job);
|
|
jobOperate(job);
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void validAdd(Long enterpriseId,
|
|
|
|
+ Long userId,
|
|
|
|
+ AppAdminJobSaveReqVO reqVO) {
|
|
|
|
+ if (reqVO.getHire()) {
|
|
|
|
+ if (null != reqVO.getHirePrice()) {
|
|
|
|
+ // 计算需要支付的额外费用(如果是新职位,就是全额;如果是修改,就是差额)
|
|
|
|
+ boolean result = enterpriseAccountService
|
|
|
|
+ .checkBalance(enterpriseId, userId, reqVO.getHirePrice());
|
|
|
|
+ if (!result) {
|
|
|
|
+ // 余额不足
|
|
|
|
+ throw exception(MDE_ENTERPRISE_ACCOUNT_BALANCE_NOT_ENOUGH);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (null != reqVO.getHirePoint()) {
|
|
|
|
+ // 积分
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void validUpdate(Long enterpriseId,
|
|
|
|
+ Long userId,
|
|
|
|
+ JobAdvertisedDO entity,
|
|
|
|
+ AppAdminJobSaveReqVO reqVO) {
|
|
|
|
+
|
|
|
|
+ if (!Objects.equals(userId, entity.getUserId())
|
|
|
|
+ || !Objects.equals(enterpriseId, entity.getEnterpriseId())) {
|
|
|
|
+ // TODO 不是自己的数据 (企业管理员更改企业其他用户发布的职位信息)
|
|
|
|
+ // throw exception(FORBIDDEN);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (reqVO.getHire()) {
|
|
|
|
+ if (null != reqVO.getHirePrice()) {
|
|
|
|
+ // 计算需要支付的额外费用(如果是新职位,就是全额;如果是修改,就是差额)
|
|
|
|
+ BigDecimal extraCost = reqVO.getId() == null ? reqVO.getHirePrice()
|
|
|
|
+ : reqVO.getHirePrice().subtract(entity.getHirePrice());
|
|
|
|
+
|
|
|
|
+ boolean result = enterpriseAccountService
|
|
|
|
+ .checkBalance(enterpriseId, userId, extraCost);
|
|
|
|
+ if (!result) {
|
|
|
|
+ // 余额不足
|
|
|
|
+ throw exception(MDE_ENTERPRISE_ACCOUNT_BALANCE_NOT_ENOUGH);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (null != reqVO.getHirePoint()) {
|
|
|
|
+ // 积分
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
public JobAdvertisedDO get(Long id) {
|
|
public JobAdvertisedDO get(Long id) {
|
|
JobAdvertisedDO job = jobAdvertisedMapper.selectById(id);
|
|
JobAdvertisedDO job = jobAdvertisedMapper.selectById(id);
|
|
if (null == job) {
|
|
if (null == job) {
|