zoujiajian 2 years ago
parent
commit
3512f09e61

+ 15 - 16
netflix-service/src/main/java/com/cyksj/service/exchange/impl/ExchangeCodeServiceImpl.java

@@ -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("车位异常");
 		}
 	}
 

+ 5 - 2
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -1539,7 +1539,11 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 	public void setRelation(Long relationId, Long groupsId, Long userId, Long goodsId, Boolean isLoginPopularize, GroupsRelation.Status status) {
 		if (!redisService.setNx(RedisKey.GROUPS_RELATION_NUM_KEY + relationId, userId, 60 * 5L)) {
 			log.info("=====>用户:{}未抢到座位:{}", userId, relationId);
-			throw new BusinessRuntimeException("客官手慢啦,该座位已经有人啦!");
+			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;
@@ -1548,7 +1552,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		if (count == 0) {
 			log.error("车位异常 groupId:{}", groupsId);
 			groupsMapper.updateAvailableNum(groupsId);
-			redisService.del(RedisKey.GROUPS_RELATION_NUM_KEY + relationId);
 			throw new BusinessRuntimeException("车位异常");
 		}
 	}