|
|
@@ -9,7 +9,6 @@ import com.sqx.common.utils.DateUtils;
|
|
|
import com.sqx.common.utils.Result;
|
|
|
import com.sqx.modules.app.entity.UserBrowse;
|
|
|
import com.sqx.modules.app.entity.UserEntity;
|
|
|
-import com.sqx.modules.app.entity.UserMoney;
|
|
|
import com.sqx.modules.app.entity.UserMoneyDetails;
|
|
|
import com.sqx.modules.app.service.UserBrowseService;
|
|
|
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
|
|
@@ -20,23 +19,25 @@ import com.sqx.modules.common.service.CommonInfoService;
|
|
|
import com.sqx.modules.firstLogin.service.HrService;
|
|
|
import com.sqx.modules.myCollection.entity.MyCollection;
|
|
|
import com.sqx.modules.myCollection.service.MyCollectionService;
|
|
|
+import com.sqx.modules.pay.entity.PayDetails;
|
|
|
+import com.sqx.modules.pay.service.PayDetailsService;
|
|
|
import com.sqx.modules.resumes.dao.PostPushDao;
|
|
|
import com.sqx.modules.resumes.dao.RuleClassifyDao;
|
|
|
import com.sqx.modules.resumes.entity.Company;
|
|
|
+import com.sqx.modules.resumes.entity.CompanyUser;
|
|
|
import com.sqx.modules.resumes.entity.PostPush;
|
|
|
import com.sqx.modules.resumes.entity.RuleClassify;
|
|
|
import com.sqx.modules.resumes.service.CompanyService;
|
|
|
+import com.sqx.modules.resumes.service.CompanyUserService;
|
|
|
import com.sqx.modules.resumes.service.PostPushService;
|
|
|
import com.sqx.modules.resumes.vo.CityVo;
|
|
|
import com.sqx.modules.resumes.vo.LetterCity;
|
|
|
-import com.sqx.modules.utils.PinYinUti;
|
|
|
import com.sqx.modules.utils.SenInfoCheckUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
@@ -72,88 +73,199 @@ public class PostPushServiceImpl extends ServiceImpl<PostPushDao, PostPush> impl
|
|
|
@Autowired
|
|
|
private HrService hrService;
|
|
|
|
|
|
+// @Override
|
|
|
+// public Result savePostPush(PostPush postPush, Long userId) {
|
|
|
+// if (userId == null) {
|
|
|
+// userId = companyService.getById(postPush.getCompanyId()).getUserId();
|
|
|
+// }
|
|
|
+// QueryWrapper<PostPush> wrapper = new QueryWrapper<PostPush>().eq("rule_classify_id", postPush.getRuleClassifyId()).eq("company_id", postPush.getCompanyId()).notIn("status", 3, 4);
|
|
|
+// reentrantReadWriteLock.writeLock().lock();
|
|
|
+// try {
|
|
|
+// if (postPush.getPostPushId() != null) {
|
|
|
+// PostPush push = baseMapper.selectById(postPush.getPostPushId());
|
|
|
+// if (push.getStatus() != 2 && push.getStatus() != 3 && push.getStatus() != 5) {
|
|
|
+// return Result.error("当前状态不能修改,请先取消");
|
|
|
+// }
|
|
|
+// if (push.getStatus() == 5) {
|
|
|
+// if (LocalDateTime.now().isAfter(push.getOverdueTime())) {
|
|
|
+// return Result.error("当前招聘信息已过期");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //过滤当前数据,否则会因相同岗位限制而无法修改
|
|
|
+// wrapper.ne("post_push_id", postPush.getPostPushId());
|
|
|
+// }
|
|
|
+// Integer count = baseMapper.selectCount(wrapper);
|
|
|
+// if (count > 0) {
|
|
|
+// return Result.error("相同岗位只能发布一条招聘信息");
|
|
|
+// }
|
|
|
+// RuleClassify ruleClassify = ruleClassifyDao.selectById(postPush.getRuleClassifyId());
|
|
|
+// postPush.setStatus(1);
|
|
|
+// postPush.setRuleClassifyName(ruleClassify.getRuleClassifyName());
|
|
|
+// postPush.setUpdateTime(DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN));
|
|
|
+// UserEntity userEntity1 = userService.selectUserById(userId);
|
|
|
+// if(userEntity1.getIsCompanyVip()!=null && userEntity1.getIsCompanyVip()==1){
|
|
|
+// postPush.setPayMoney(ruleClassify.getMemberPrice());
|
|
|
+// }else{
|
|
|
+// postPush.setPayMoney(ruleClassify.getPrice());
|
|
|
+// }
|
|
|
+// postPush.setCityInitial(PinYinUti.getFirstPinYin(postPush.getCity()));
|
|
|
+// RuleClassify twoClassify = ruleClassifyDao.selectOne(new QueryWrapper<RuleClassify>().eq("rule_classify_id", ruleClassify.getParentId()));
|
|
|
+// RuleClassify oneClassify = ruleClassifyDao.selectOne(new QueryWrapper<RuleClassify>().eq("rule_classify_id", twoClassify.getParentId()));
|
|
|
+// postPush.setClassifyTwoId(twoClassify.getRuleClassifyId());
|
|
|
+// postPush.setClassifyOneId(oneClassify.getRuleClassifyId());
|
|
|
+// UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId);
|
|
|
+// //当支付金额大于0时才支付。
|
|
|
+// if (postPush.getPayMoney().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+// if(userEntity1.getIsCompanyVip()!=null && userEntity1.getIsCompanyVip()==1){
|
|
|
+// if (ruleClassify.getMemberPrice().compareTo(userMoney.getMoney()) > 0) {
|
|
|
+// return Result.error("账户余额不足,请充值!");
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// if (ruleClassify.getPrice().compareTo(userMoney.getMoney()) > 0) {
|
|
|
+// return Result.error("账户余额不足,请充值!");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// userMoneyService.updateMoney(2, userId, postPush.getPayMoney());
|
|
|
+// UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
|
|
+// userMoneyDetails.setMoney(postPush.getPayMoney());
|
|
|
+// userMoneyDetails.setUserId(userId);
|
|
|
+// userMoneyDetails.setTitle("发布招募岗位成功");
|
|
|
+// userMoneyDetails.setContent("扣除账户钻石:" + postPush.getPayMoney());
|
|
|
+// userMoneyDetails.setType(2);
|
|
|
+// userMoneyDetails.setClassify(1);
|
|
|
+// userMoneyDetails.setCreateTime(DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN));
|
|
|
+// userMoneyDetailsService.save(userMoneyDetails);
|
|
|
+// Company company = companyService.getById(postPush.getCompanyId());
|
|
|
+// UserEntity userEntity = userService.getById(company.getUserId());
|
|
|
+// if (StringUtils.isNotBlank(userEntity.getOpenId())) {
|
|
|
+// sendPostMeg(userEntity, postPush);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //是否是修改操作
|
|
|
+// if (postPush.getPostPushId() != null) {
|
|
|
+// return Result.upStatus(baseMapper.updateById(postPush));
|
|
|
+// } else {
|
|
|
+// postPush.setCreateTime(LocalDateTime.now());
|
|
|
+// return Result.upStatus(baseMapper.insert(postPush));
|
|
|
+// }
|
|
|
+//
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("岗位发布异常:" + e.getMessage(), e);
|
|
|
+// } finally {
|
|
|
+// reentrantReadWriteLock.writeLock().unlock();
|
|
|
+// }
|
|
|
+// return Result.error("系统繁忙,请稍后再试!");
|
|
|
+// }
|
|
|
+ @Autowired
|
|
|
+ private CompanyUserService companyUserService;
|
|
|
+ @Autowired
|
|
|
+ private PayDetailsService payDetailsService;
|
|
|
+ @Autowired
|
|
|
+ private PostPushService postPushService;
|
|
|
+
|
|
|
@Override
|
|
|
public Result savePostPush(PostPush postPush, Long userId) {
|
|
|
- if (userId == null) {
|
|
|
- userId = companyService.getById(postPush.getCompanyId()).getUserId();
|
|
|
- }
|
|
|
- QueryWrapper<PostPush> wrapper = new QueryWrapper<PostPush>().eq("rule_classify_id", postPush.getRuleClassifyId()).eq("company_id", postPush.getCompanyId()).notIn("status", 3, 4);
|
|
|
- reentrantReadWriteLock.writeLock().lock();
|
|
|
- try {
|
|
|
- if (postPush.getPostPushId() != null) {
|
|
|
- PostPush push = baseMapper.selectById(postPush.getPostPushId());
|
|
|
- if (push.getStatus() != 2 && push.getStatus() != 3 && push.getStatus() != 5) {
|
|
|
- return Result.error("当前状态不能修改,请先取消");
|
|
|
- }
|
|
|
- if (push.getStatus() == 5) {
|
|
|
- if (LocalDateTime.now().isAfter(push.getOverdueTime())) {
|
|
|
+ QueryWrapper<CompanyUser> queryWrapper =new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("user_id",userId).eq("is_use",1);
|
|
|
+ CompanyUser companyUser = companyUserService.getOne(queryWrapper);
|
|
|
+ if (companyUser == null) {//初次注册
|
|
|
+ postPush.setStatus(6);
|
|
|
+ postPushService.saveOrUpdate(postPush);
|
|
|
+ return Result.success("招聘信息已暂存,等待公司认证后再次发布");
|
|
|
+ } else {
|
|
|
+ Company company = companyService.getById(companyUser.getCompanyId());
|
|
|
+ if (company.getStatus() != 2) {
|
|
|
+ return Result.error("公司信息不完整或未通过审核");
|
|
|
+ } else {//公司存在判断是更改还是发布新的
|
|
|
+ if (postPush.getPostPushId() != null) {//更改
|
|
|
+ PostPush push = baseMapper.selectById(postPush.getPostPushId());
|
|
|
+ if (push.getStatus() != 2 && push.getStatus() != 3 && push.getStatus() != 5) {
|
|
|
+ return Result.error("当前状态不能修改,请先取消");
|
|
|
+ }
|
|
|
+ if (push.getStatus() == 5) {
|
|
|
return Result.error("当前招聘信息已过期");
|
|
|
+ } else {
|
|
|
+ postPush.setCompanyId(companyUser.getCompanyId());
|
|
|
+ postPush.setStatus(1);
|
|
|
+ baseMapper.updateById(postPush);
|
|
|
+ return Result.success("更新岗位信息中,请等待审核");
|
|
|
+ }
|
|
|
+ } else {//新发布,发布岗位相同,不能发布
|
|
|
+ UserEntity userEntity = userService.getById(userId);
|
|
|
+ postPush.setUserId(String.valueOf(userId));
|
|
|
+ postPush.setCompanyId(company.getCompanyId());
|
|
|
+ postPush.setStatus(1);
|
|
|
+ QueryWrapper<PostPush> queryWrapperClassify = new QueryWrapper<>();
|
|
|
+ queryWrapperClassify.eq("rule_classify_id", postPush.getRuleClassifyId()).eq("user_id", userId).notIn("status", 3, 4);
|
|
|
+ PayDetails payDetails = payDetailsService.getOne(new QueryWrapper<PayDetails>().eq("order_id", postPush.getOrderId()));
|
|
|
+ Integer count = baseMapper.selectCount(queryWrapperClassify);
|
|
|
+ if (count > 0) {
|
|
|
+ return Result.error("相同岗位只能发布一条招聘信息");
|
|
|
+ } else {//发布岗位不同
|
|
|
+ if (userEntity.getIsUserVip() == 0) {//发布者是不是vip
|
|
|
+ if (payDetails == null || payDetails.getState() != 1) {
|
|
|
+ return Result.error("请完成订单支付");
|
|
|
+ } else {
|
|
|
+ baseMapper.insert(postPush);
|
|
|
+ return Result.success("新发布的岗位正在审核中请等待");
|
|
|
+ }
|
|
|
+ } else {//发布者是vip
|
|
|
+ if (userEntity.getVipPostTimes() == 0) {//没有免费次数
|
|
|
+ if (payDetails == null || payDetails.getState() != 1) {
|
|
|
+ return Result.error("请完成订单支付");
|
|
|
+ } else {
|
|
|
+ baseMapper.insert(postPush);
|
|
|
+ return Result.success("新发布的岗位正在审核中请等待");
|
|
|
+ }
|
|
|
+ } else {//有免费次数
|
|
|
+ userEntity.setVipPostTimes(userEntity.getVipPostTimes() - 1);
|
|
|
+ userService.updateById(userEntity);
|
|
|
+ baseMapper.insert(postPush);
|
|
|
+ return Result.success("新发布的岗位正在审核中请等待");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- //过滤当前数据,否则会因相同岗位限制而无法修改
|
|
|
- wrapper.ne("post_push_id", postPush.getPostPushId());
|
|
|
- }
|
|
|
- Integer count = baseMapper.selectCount(wrapper);
|
|
|
- if (count > 0) {
|
|
|
- return Result.error("相同岗位只能发布一条招聘信息");
|
|
|
- }
|
|
|
- RuleClassify ruleClassify = ruleClassifyDao.selectById(postPush.getRuleClassifyId());
|
|
|
- postPush.setStatus(1);
|
|
|
- postPush.setRuleClassifyName(ruleClassify.getRuleClassifyName());
|
|
|
- postPush.setUpdateTime(DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN));
|
|
|
- UserEntity userEntity1 = userService.selectUserById(userId);
|
|
|
- if(userEntity1.getIsCompanyVip()!=null && userEntity1.getIsCompanyVip()==1){
|
|
|
- postPush.setPayMoney(ruleClassify.getMemberPrice());
|
|
|
- }else{
|
|
|
- postPush.setPayMoney(ruleClassify.getPrice());
|
|
|
}
|
|
|
- postPush.setCityInitial(PinYinUti.getFirstPinYin(postPush.getCity()));
|
|
|
- RuleClassify twoClassify = ruleClassifyDao.selectOne(new QueryWrapper<RuleClassify>().eq("rule_classify_id", ruleClassify.getParentId()));
|
|
|
- RuleClassify oneClassify = ruleClassifyDao.selectOne(new QueryWrapper<RuleClassify>().eq("rule_classify_id", twoClassify.getParentId()));
|
|
|
- postPush.setClassifyTwoId(twoClassify.getRuleClassifyId());
|
|
|
- postPush.setClassifyOneId(oneClassify.getRuleClassifyId());
|
|
|
- UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId);
|
|
|
- //当支付金额大于0时才支付。
|
|
|
- if (postPush.getPayMoney().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- if(userEntity1.getIsCompanyVip()!=null && userEntity1.getIsCompanyVip()==1){
|
|
|
- if (ruleClassify.getMemberPrice().compareTo(userMoney.getMoney()) > 0) {
|
|
|
- return Result.error("账户余额不足,请充值!");
|
|
|
- }
|
|
|
- }else{
|
|
|
- if (ruleClassify.getPrice().compareTo(userMoney.getMoney()) > 0) {
|
|
|
- return Result.error("账户余额不足,请充值!");
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public Result addDue(Long postPushId,Long orderId,Long userId) {
|
|
|
+ PostPush postPush = baseMapper.selectById(postPushId);
|
|
|
+ UserEntity userEntity = userService.getById(userId);
|
|
|
+ PayDetails payDetails = payDetailsService.getOne(new QueryWrapper<PayDetails>().eq("order_id", orderId));
|
|
|
+ if (postPush.getStatus()==2||postPush.getStatus()==4) {
|
|
|
+
|
|
|
+ if (userEntity.getIsUserVip() == 0) {//非vip
|
|
|
+ if (payDetails.getState() != 1) {
|
|
|
+ return Result.error("请完成支付");
|
|
|
+ } else {
|
|
|
+ postPush.setIsDue(1);
|
|
|
+ postPush.setOrderId(Math.toIntExact(orderId));
|
|
|
+ baseMapper.updateById(postPush);
|
|
|
+ return Result.success("发布为急聘成功");
|
|
|
}
|
|
|
- userMoneyService.updateMoney(2, userId, postPush.getPayMoney());
|
|
|
- UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
|
|
- userMoneyDetails.setMoney(postPush.getPayMoney());
|
|
|
- userMoneyDetails.setUserId(userId);
|
|
|
- userMoneyDetails.setTitle("发布招募岗位成功");
|
|
|
- userMoneyDetails.setContent("扣除账户钻石:" + postPush.getPayMoney());
|
|
|
- userMoneyDetails.setType(2);
|
|
|
- userMoneyDetails.setClassify(1);
|
|
|
- userMoneyDetails.setCreateTime(DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN));
|
|
|
- userMoneyDetailsService.save(userMoneyDetails);
|
|
|
- Company company = companyService.getById(postPush.getCompanyId());
|
|
|
- UserEntity userEntity = userService.getById(company.getUserId());
|
|
|
- if (StringUtils.isNotBlank(userEntity.getOpenId())) {
|
|
|
- sendPostMeg(userEntity, postPush);
|
|
|
+ } else {//vip
|
|
|
+ if (userEntity.getVipDueTimes() == 0) {//没有免费次数
|
|
|
+ if (payDetails.getState() != 1) {
|
|
|
+ return Result.error("请完成支付");
|
|
|
+ } else {
|
|
|
+ postPush.setUpdateTime(String.valueOf(LocalDateTime.now()));
|
|
|
+ postPush.setIsDue(1);
|
|
|
+ postPush.setOrderId(Math.toIntExact(orderId));
|
|
|
+ baseMapper.updateById(postPush);
|
|
|
+ return Result.success("发布为急聘成功");
|
|
|
+ }
|
|
|
+ } else {//有免费次数
|
|
|
+ userEntity.setVipDueTimes(userEntity.getVipPostTimes() - 1);
|
|
|
+ postPush.setIsDue(1);
|
|
|
+ postPush.setUpdateTime(String.valueOf(LocalDateTime.now()));
|
|
|
+ baseMapper.updateById(postPush);
|
|
|
+ return Result.success("发布为急聘成功");
|
|
|
}
|
|
|
}
|
|
|
- //是否是修改操作
|
|
|
- if (postPush.getPostPushId() != null) {
|
|
|
- return Result.upStatus(baseMapper.updateById(postPush));
|
|
|
- } else {
|
|
|
- postPush.setCreateTime(LocalDateTime.now());
|
|
|
- return Result.upStatus(baseMapper.insert(postPush));
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("岗位发布异常:" + e.getMessage(), e);
|
|
|
- } finally {
|
|
|
- reentrantReadWriteLock.writeLock().unlock();
|
|
|
+ }else {
|
|
|
+ return Result.error("当前岗位状态不能发布急聘");
|
|
|
}
|
|
|
- return Result.error("系统繁忙,请稍后再试!");
|
|
|
}
|
|
|
|
|
|
private void sendPostMeg(UserEntity userEntity, PostPush postPush) {
|
|
|
@@ -366,6 +478,11 @@ public class PostPushServiceImpl extends ServiceImpl<PostPushDao, PostPush> impl
|
|
|
return postPushList;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Object> getHotPost() {
|
|
|
+ return baseMapper.getHotPost();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/*@Override
|
|
|
public PostPush selectPostPushDetails(Long userId, Long postPushId, Double lng, Double lat) {
|