|
|
@@ -473,23 +473,22 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
}
|
|
|
|
|
|
private void setRelation(Long relationId, Long userId, Long groupsId, GroupsRelation.Status status) {
|
|
|
- if (redisService.get(RedisKey.GROUPS_RELATION_NUM_KEY + relationId) != null) {
|
|
|
- log.info("=====>用户:{}获取了已有人座位:{}", userId, relationId);
|
|
|
- throw new BusinessRuntimeException("客官手慢啦,该座位已经有人啦!");
|
|
|
- } else {
|
|
|
- if (!redisService.setNx(RedisKey.GROUPS_RELATION_NUM_KEY + relationId, userId, 60 * 5L)) {
|
|
|
- log.info("=====>用户:{}未抢到座位:{}", userId, relationId);
|
|
|
- throw new BusinessRuntimeException("客官手慢啦,该座位已经有人啦!");
|
|
|
- }
|
|
|
- if (status == GroupsRelation.Status.outside) {
|
|
|
- return;
|
|
|
- }
|
|
|
- int count = groupsMapper.decrAvailableNum(groupsId);
|
|
|
- if (count == 0) {
|
|
|
- log.error("车位异常 groupId:{}", groupsId);
|
|
|
- groupsMapper.updateAvailableNum(groupsId);
|
|
|
- throw new BusinessRuntimeException("车位异常");
|
|
|
+ if (!redisService.setNx(RedisKey.GROUPS_RELATION_NUM_KEY + relationId, userId, 60 * 5L)) {
|
|
|
+ log.info("=====>用户:{}未抢到座位:{}", userId, relationId);
|
|
|
+ GroupsRelation relation = groupsRelationMapper.selectById(relationId);
|
|
|
+ if (relation.getUserId() == 0) {
|
|
|
+ redisService.del(RedisKey.GROUPS_RELATION_NUM_KEY + relationId);
|
|
|
}
|
|
|
+ throw new BusinessRuntimeException("系统繁忙,请刷新页面重试");
|
|
|
+ }
|
|
|
+ if (status == GroupsRelation.Status.outside) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int count = groupsMapper.decrAvailableNum(groupsId);
|
|
|
+ if (count == 0) {
|
|
|
+ log.error("车位异常 groupId:{}", groupsId);
|
|
|
+ groupsMapper.updateAvailableNum(groupsId);
|
|
|
+ throw new BusinessRuntimeException("车位异常");
|
|
|
}
|
|
|
}
|
|
|
|