|
@@ -4,7 +4,9 @@ import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.ruoyi.common.constant.CacheConstants;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.redis.RedisCache;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
@@ -27,6 +29,7 @@ import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* @author lsw
|
|
@@ -53,6 +56,9 @@ public class ResumeDeliverServiceImpl extends ServiceImpl<ResumeDeliverMapper, R
|
|
|
private IPayService payService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private Environment env;
|
|
|
|
|
|
@Override
|
|
@@ -91,6 +97,7 @@ public class ResumeDeliverServiceImpl extends ServiceImpl<ResumeDeliverMapper, R
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
@Override
|
|
|
public AjaxResult agree(ResumeDeliverDto dto) throws ParseException {
|
|
|
ResumeDeliver resumeDeliver = getById(dto.getId());
|
|
@@ -98,6 +105,21 @@ public class ResumeDeliverServiceImpl extends ServiceImpl<ResumeDeliverMapper, R
|
|
|
return AjaxResult.error("面试不存在或非法操作");
|
|
|
}
|
|
|
resumeDeliver.setIsAccept(dto.getIsAccept());
|
|
|
+ //兼职接单成功,把兼职设置成进行中...
|
|
|
+ if (dto.getIsAccept() == 1 && resumeDeliver.getType() == 1) {
|
|
|
+ String key = CacheConstants.APP_DELIVER + resumeDeliver.getId() + "-" + AppUtil.getUser().getId();
|
|
|
+ if (redisCache.getCacheObject(key) == null) {
|
|
|
+ resumeDeliver.setIsExpire(1);
|
|
|
+ updateById(resumeDeliver);
|
|
|
+ return AjaxResult.error("抱歉你的兼职邀请已经超时无效了");
|
|
|
+ }
|
|
|
+ Position position = new Position();
|
|
|
+ position.setId(resumeDeliver.getPositionId());
|
|
|
+ position.setComplete(1);
|
|
|
+ if (!positionService.updateById(position)) {
|
|
|
+ throw new ServiceException("更新兼职信息失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!updateById(resumeDeliver)) {
|
|
|
throw new ServiceException("接受或拒绝面试邀请失败");
|
|
|
}
|
|
@@ -137,7 +159,10 @@ public class ResumeDeliverServiceImpl extends ServiceImpl<ResumeDeliverMapper, R
|
|
|
if (resumeDeliver == null || !resumeDeliver.getEnterpriseId().equals(AppUtil.getUser().getId()) || resumeDeliver.getType() == 0) {
|
|
|
return AjaxResult.error("简历不存在或非法操作");
|
|
|
}
|
|
|
- List<ResumeDeliver> list = selectList(new ResumeDeliver().setPositionId(resumeDeliver.getPositionId()).setState(1));
|
|
|
+ if(resumeDeliver.getIsExpire()==1){
|
|
|
+ return AjaxResult.error("对方超时未操作(已过期)");
|
|
|
+ }
|
|
|
+ List<ResumeDeliver> list = selectList(new ResumeDeliver().setPositionId(resumeDeliver.getPositionId()).setState(1).setIsExpire(0));
|
|
|
if (!list.isEmpty() && list.size() > 0) {
|
|
|
return AjaxResult.error("你已发出兼职邀请,请等待对方答复后或者1小时无回应自动排除");
|
|
|
}
|
|
@@ -155,6 +180,9 @@ public class ResumeDeliverServiceImpl extends ServiceImpl<ResumeDeliverMapper, R
|
|
|
if (!updateById(resumeDeliver)) {
|
|
|
throw new ServiceException("发送兼职邀请失败");
|
|
|
}
|
|
|
+ //用户的接单信息缓存起来60分钟,超时无效。
|
|
|
+ String key = CacheConstants.APP_DELIVER + resumeDeliver.getId() + "-" + resumeDeliver.getUserId();
|
|
|
+ redisCache.setCacheObject(key, resumeDeliver, 1, TimeUnit.MINUTES);
|
|
|
sendMessage(resumeDeliver);
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
@@ -313,6 +341,11 @@ public class ResumeDeliverServiceImpl extends ServiceImpl<ResumeDeliverMapper, R
|
|
|
if (position == null) {
|
|
|
throw new ServiceException("兼职不存在");
|
|
|
}
|
|
|
+ position.setComplete(2);
|
|
|
+ if (!positionService.updateById(position)) {
|
|
|
+ throw new ServiceException("更新兼职信息失败");
|
|
|
+ }
|
|
|
+
|
|
|
User user = userService.getById(resumeDeliver.getUserId());
|
|
|
user.setMoney(user.getMoney().add(new BigDecimal(position.getSalary())));
|
|
|
if (!userService.updateById(user)) {
|