Commit 57ac035d authored by cy's avatar cy

解决方案查询次数扣减事务问题

parent e7b25f9b
......@@ -10,6 +10,7 @@ import cn.wisenergy.model.enums.StudentClassEnum;
import cn.wisenergy.model.enums.StudentType;
import cn.wisenergy.model.vo.*;
import cn.wisenergy.service.app.SchemeService;
import cn.wisenergy.service.app.UserLimitService;
import cn.wisenergy.service.app.UserVolunteerService;
import cn.wisenergy.service.common.VolunteerManager;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -62,6 +63,14 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
@Autowired
private VolunteerManager volunteerManager;
@Autowired
private UserLimitService userLimitService;
@Autowired
private UserLimitMapper userLimitMapper;
/**
* 错误码
*/
private static final int ERROR_CODE = 1;
@Override
public R<VolunteerVo> getList(SchemeVo queryVo) {
......@@ -257,12 +266,30 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
return R.ok(volunteerVo);
}
//获取用户查询次数信息
UserLimit userLimit = userLimitMapper.getByUserId(user.getId());
if (null == userLimit) {
return R.error("用户查询信息不存在!");
}
if (userLimit.getUsableLimit() == 0) {
return R.error(1, "您的查询次数已使用完了,请充值!");
}
//6保存用户方案记录、志愿之间的关联关系,扣减查询次数
R<Integer> bool = volunteerManager.saveUserVolunteer(user, list, scoreInfo, queryVo.getBigMajorNames());
R<Integer> bool = volunteerManager.saveUserVolunteer(user, list, scoreInfo, queryVo.getBigMajorNames(),userLimit);
if (null != bool && bool.getCode() == 500) {
return R.error(bool.getMessage());
}
/* //调用扣减查询次数接口
R<Boolean> result = userLimitService.minusLimit(user.getId());
if (null != result && result.getCode() == ERROR_CODE) {
return R.error("扣减查询次数失败!");
}*/
volunteerVo.setUserId(user.getId());
assert bool != null;
volunteerVo.setRecordId(bool.getData());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment