Bläddra i källkod

fix 更换车票接口幂以及兜底处理多余车票

zoujiajian 1 år sedan
förälder
incheckning
52913c4875

+ 1 - 0
netflix-service/src/main/java/com/cyksj/redis/RedisService.java

@@ -852,6 +852,7 @@ public class RedisService {
         USER_MIRROR_SHOP_BACK_LOGIN_KEY("user_mirror_shop_back_login:", "镜像店铺主后台key", 3 * 60),
         USER_MIRROR_SHOP_AUTH_SUCCESS_KEY("user_mirror_shop_auth_success_key:%s", "镜像店铺主后台微信授权", 60 * 10),
         USER_MIRROR_SHOP_ADVERTISE_CACHE_KEY("user_mirror_shop_advertise_cache_key:", "用户镜像店铺广告缓存key", 60 * 60 * 12),
+        NETFLIX_CHANGE_TICKET_KEY("netflix_change_ticket_key:", "奈飞更换车票key", 60l),
         ;
 
         private String name;

+ 13 - 3
netflix-service/src/main/java/com/cyksj/service/mange/impl/CmsOrderDonServiceImpl.java

@@ -680,6 +680,10 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
         if (relation.getRechargeStatus() != null) {
             throw BusinessRuntimeException.getInstance("代充账号车票无法更换车票");
         }
+        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 userId = relation.getUserId();
         log.info("用户userId:{}更换车票relationId:{}", userId, relationId);
         OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
@@ -763,7 +767,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
         relationClearService.clearTicket(relation, source);
         
         //兜底处理 多余车票
-//        clearOtherChangeTicket(userId, relationId, newRelation);
+        clearOtherChangeTicket(userId, relationId, newRelation);
 
         //奈飞车票
         if (orderDon.getGoodsId() == 1) {
@@ -1574,8 +1578,14 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
                         .eq(OrderDon::getRelationId, rid)
                         .notIn(OrderDon::getStatus, Constant.noOrderAllStatus));
                 if (selectCount == 0) {
-                    log.info("清除用户:{}多余车票", userId);
-                    relationClearService.clearTicket(r, UserTicketClearedRecord.Source.manual);
+                    //不是优惠加购
+                    Integer count = orderDiscountPlusPurchaseSkuRelationMapper.selectCount(Wrappers.lambdaQuery(OrderDiscountPlusPurchaseSkuRelation.class)
+                            .eq(OrderDiscountPlusPurchaseSkuRelation::getUserId, userId)
+                            .apply("JSON_CONTAINS(relation_ids,'" + rid + "')"));
+                    if (count == 0) {
+                        log.info("清除用户:{}多余车票", userId);
+                        relationClearService.clearTicket(r, UserTicketClearedRecord.Source.manual);
+                    }
                 }
             });
         }

+ 5 - 0
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -1053,6 +1053,10 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		if (accountNetflixState == null || accountNetflixState.getState() != 3) {
 			throw BusinessRuntimeException.getInstance("只支持异常账号更换车票");
 		}
+		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 groupId = renewalView.getGroupId();
 		Long skuId = renewalView.getSkuId();
 		Date expiryTime = renewalView.getExpiryTime();
@@ -1078,6 +1082,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 			netflixUserAccountStatusRecord.setDeleted(false);
 			netflixUserAccountStatusRecordMapper.updateById(netflixUserAccountStatusRecord);
 		}
+		redisService.del(key);
 	}
 
 	@Override