zoujiajian 1 anno fa
parent
commit
84ac850c6a

+ 6 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/views/GroupsRelationView.java

@@ -139,4 +139,10 @@ public class GroupsRelationView {
     @DbIgnore
     private String errorMsg;
 
+    /**
+     * 奈飞原先订单id
+     */
+    @DbIgnore
+    private Long nfOriOrderId;
+
 }

+ 36 - 28
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -1220,7 +1220,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		}
 		OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
 				.eq(OrderDon::getRelationId, renewalView.getRelationId())
-				.eq(OrderDon::getUserId, renewalView.getUserId())
+				.in(OrderDon::getUserId, userIdList)
 				.notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
 				.orderByDesc(OrderDon::getId)
 				.last("limit 1"));
@@ -1496,34 +1496,41 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		String key = RedisService.key.NETFLIX_CHANGE_TICKET_KEY.getName() + relationId;
 		if (!redisService.setNx(key, relationId, RedisService.key.NETFLIX_CHANGE_TICKET_KEY.getTimeout())) {
 			throw BusinessRuntimeException.getInstance("正在更换其他车票中..");
-		}		Long skuId = req.getSkuId();
-		SysConfig sysConfig = sysConfigMapper.selectOne(Wrappers.lambdaQuery(SysConfig.class)
-				.eq(SysConfig::getSysKey, Constant.ERROR_NETFLIX_CHANGE_OTHER_SKU_KEY)
-				.last("limit 1"));
-		List<ErrorNetflixChangeOtherSkuTicketDto> errorNetflixChangeOtherSkuTicketDtos = Jsons.parseList(sysConfig.getSysValue(), ErrorNetflixChangeOtherSkuTicketDto.class);
-		ErrorNetflixChangeOtherSkuTicketDto errorNetflixChangeOtherSkuTicketDto;
-		//自定义顺序 直接获取
-		if (betweenDay <= 60) {
-			//检验规格
-			errorNetflixChangeOtherSkuTicketDto = errorNetflixChangeOtherSkuTicketDtos.get(0);
-		} else if (betweenDay <= 120) {
-			errorNetflixChangeOtherSkuTicketDto = errorNetflixChangeOtherSkuTicketDtos.get(1);
-		} else {
-			errorNetflixChangeOtherSkuTicketDto = errorNetflixChangeOtherSkuTicketDtos.get(2);
 		}
-		List<Long> availableSkuIds = errorNetflixChangeOtherSkuTicketDto.getSkuIds();
-		if (!availableSkuIds.contains(skuId)) {
-			throw BusinessRuntimeException.getInstance("不支持更换该类型车票");
-		}
-		//替换车票
-		TicketChangeDto changeDto = getTicketAndGenerateOrder(userId, skuId, netflixRelationView.getStartTime(), expiryTime);
-		//替换记录
-		NetflixUserChangeOtherTicketRecord changeOtherTicketRecord = new NetflixUserChangeOtherTicketRecord();
-		changeOtherTicketRecord.setUserId(userId);
-		changeOtherTicketRecord.setRelationId(relationId);
-		changeOtherTicketRecord.setOtherRelationId(changeDto.getOtherRelationId());
-		changeOtherTicketRecord.setRelateOrderId(changeDto.getOtherOrderId());
-		netflixUserChangeOtherTicketRecordMapper.insert(changeOtherTicketRecord);
+		try {
+			Long skuId = req.getSkuId();
+			SysConfig sysConfig = sysConfigMapper.selectOne(Wrappers.lambdaQuery(SysConfig.class)
+					.eq(SysConfig::getSysKey, Constant.ERROR_NETFLIX_CHANGE_OTHER_SKU_KEY)
+					.last("limit 1"));
+			List<ErrorNetflixChangeOtherSkuTicketDto> errorNetflixChangeOtherSkuTicketDtos = Jsons.parseList(sysConfig.getSysValue(), ErrorNetflixChangeOtherSkuTicketDto.class);
+			ErrorNetflixChangeOtherSkuTicketDto errorNetflixChangeOtherSkuTicketDto;
+			//自定义顺序 直接获取
+			if (betweenDay <= 60) {
+				//检验规格
+				errorNetflixChangeOtherSkuTicketDto = errorNetflixChangeOtherSkuTicketDtos.get(0);
+			} else if (betweenDay <= 120) {
+				errorNetflixChangeOtherSkuTicketDto = errorNetflixChangeOtherSkuTicketDtos.get(1);
+			} else {
+				errorNetflixChangeOtherSkuTicketDto = errorNetflixChangeOtherSkuTicketDtos.get(2);
+			}
+			List<Long> availableSkuIds = errorNetflixChangeOtherSkuTicketDto.getSkuIds();
+			if (!availableSkuIds.contains(skuId)) {
+				throw BusinessRuntimeException.getInstance("不支持更换该类型车票");
+			}
+			//替换车票
+			TicketChangeDto changeDto = getTicketAndGenerateOrder(userId, skuId, netflixRelationView.getStartTime(), expiryTime);
+			//替换记录
+			NetflixUserChangeOtherTicketRecord changeOtherTicketRecord = new NetflixUserChangeOtherTicketRecord();
+			changeOtherTicketRecord.setUserId(userId);
+			changeOtherTicketRecord.setRelationId(relationId);
+			changeOtherTicketRecord.setOtherRelationId(changeDto.getOtherRelationId());
+			changeOtherTicketRecord.setRelateOrderId(changeDto.getOtherOrderId());
+			//该车票订单id
+			changeOtherTicketRecord.setOrderId(netflixRelationView.getNfOriOrderId());
+			netflixUserChangeOtherTicketRecordMapper.insert(changeOtherTicketRecord);
+		} finally {
+			redisService.del(key);
+		}
 	}
 
 	@Override
@@ -1856,6 +1863,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		if (netflixRelationView == null) {
 			throw BusinessRuntimeException.getInstance("奈飞车票已过期");
 		}
+		netflixRelationView.setNfOriOrderId(netflixUseAccountStatusRecord.getOrderId());
 		return netflixRelationView;
 	}