瀏覽代碼

fix cc、codex过期直接清除

zoujiajian 7 月之前
父節點
當前提交
c84df083cf

+ 25 - 4
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -311,9 +311,10 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 			Integer vipUserCount = vipUserMapper.selectCount(Wrappers.lambdaQuery(VipUser.class)
 					.in(VipUser::getUserId, userIds)
 					.gt(VipUser::getExpiryTime, now));
-			list.getDataList().forEach(ticket -> {
+			List<RenewalView> removeElements = null;
+			for (RenewalView ticket : list.getDataList()) {
 				if (ticket.getSkuId() == null || ticket.getGoodsId() == null) {
-					return;
+					continue;
 				}
 				if (ticket.getGoodsId() == 18 && ticket.getSkuNum() > 1) {
 					ticket.setPassword(null);
@@ -433,7 +434,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 						for (OrderDiscountPlusPurchaseSkuRelation data : plusPurchaseSkuRelations) {
 							String relationIds = data.getRelationIds();
 							if (StrUtil.isEmpty(relationIds)) {
-								return;
+								continue;
 							}
 							try {
 								List<Long> relationList = Jsons.parseList(relationIds, Long.class);
@@ -509,7 +510,27 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 						ticket.setIsPay(codexUser.getIsPay());
 					}
 				}
-			});
+
+				//codex、cc 不保留过期
+				if (ticket.getGoodsId() == Constant.CLAUDE_CODE_GOODS_ID || ticket.getGoodsId() == Constant.CODEX_GOODS_ID) {
+					//如果过期 直接清除
+					if (ticket.getExpiryTime() != null && ticket.getExpiryTime().before(now)) {
+						GroupsRelation groupsRelation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getId, ticket.getRelationId()).eq(GroupsRelation::getUserId, ticket.getUserId()).last("limit 1"));
+						if (groupsRelation != null) {
+							clearService.clearTicket(groupsRelation, UserTicketClearedRecord.Source.self);
+						}
+						if (removeElements == null) {
+							removeElements = new ArrayList<>();
+						}
+						removeElements.add(ticket);
+					}
+				}
+			}
+			if (CollUtil.isNotEmpty(removeElements)) {
+				list.getDataList().removeAll(removeElements);
+				list.setTotalCount(size - removeElements.size());
+				removeElements.clear();
+			}
 		}
 		userLoginRecordService.saveUserLoginDayRecord(userId);
 		return list;