Quellcode durchsuchen

fix 兑换码兑换claude code

zoujiajian vor 1 Jahr
Ursprung
Commit
6cd31f8908

+ 0 - 7
netflix-dao/src/main/java/com/cyksj/model/entity/ClaudeCodeUserRenewExpiryRecord.java

@@ -3,8 +3,6 @@ package com.cyksj.model.entity;
 import lombok.Getter;
 import lombok.Setter;
 
-import java.util.Date;
-
 /**
  * 项目名: yhlxj11111111
  * 文件名: ClaudeCodeUserRenewExpiryRecord
@@ -22,11 +20,6 @@ public class ClaudeCodeUserRenewExpiryRecord extends BaseEntity{
 
 	private Long orderId;
 
-	/**
-	 * 过期时间
-	 */
-	private Date expiryTime;
-
 	/**
 	 * 是否失效 默认false
 	 */

+ 3 - 22
netflix-service/src/main/java/com/cyksj/service/claude/impl/ClaudeCodeServiceImpl.java

@@ -101,7 +101,7 @@ public class ClaudeCodeServiceImpl implements ClaudeCodeService {
 				renewExpiryTime = DateUtil.offsetMonth(DateTime.now(), sku.getMonths());
 			}
 			isUpgrade = true;
-			saveClaudeCodeRenewExpiryRecord(orderId, relationUserId, relationId, renewExpiryTime, skuId);
+			saveClaudeCodeRenewExpiryRecord(orderId, relationUserId, relationId, skuId);
 		}
 		generateOrUpdateClaudeCodeUser(relationUserId, relationId, codePoints, codeCreditRecovery, expiryTime, isUpgrade, orderId, skuId, renewExpiryTime, sku.getSpecVal());
 		try {
@@ -390,25 +390,7 @@ public class ClaudeCodeServiceImpl implements ClaudeCodeService {
 
 	@Override
 	public void handleClaudeCodeUserPackageSku(GroupsRelation relation, GoodsDonSku sku, Long orderId) {
-		Long groupsId = relation.getGroupsId();
-		GroupsTrips groupsTrips = groupsMapper.selectById(groupsId);
-		GoodsDonSku oriRelationSku = skuMapper.selectById(groupsTrips.getSkuId());
-		Integer oriRelationSkuCodePoints = oriRelationSku.getCodePoints();
-		Integer presentCodePoints = sku.getCodePoints();
-		Long oriRelationSkuId = oriRelationSku.getId();
-		Long toUseSkuId = sku.getId();
-		//若是续费升级 记录此时续费升级的过期时间
-		Boolean isUpgrade = false;
-		Date renewExpiryTime = null;
-		if (oriRelationSkuCodePoints <= presentCodePoints && !ObjectUtil.equal(oriRelationSkuId, toUseSkuId)) {
-			if (sku.getDays() != null) {
-				renewExpiryTime = DateUtil.offsetDay(DateTime.now(), sku.getDays());
-			} else {
-				renewExpiryTime = DateUtil.offsetMonth(DateTime.now(), sku.getMonths());
-			}
-			isUpgrade = true;
-			saveClaudeCodeRenewExpiryRecord(orderId, relation.getUserId(), relation.getId(), renewExpiryTime, sku.getId());
-		}
+		generateOrUpdateClaudeCodeUserInfo(orderId, relation.getId(), relation.getUserId(), sku, 2);
 	}
 
 	/**
@@ -510,13 +492,12 @@ public class ClaudeCodeServiceImpl implements ClaudeCodeService {
 	/**
 	 * 记录claude code 续费升级的过期时间
 	 */
-	private void saveClaudeCodeRenewExpiryRecord(Long orderId, Long relationUserId, Long relationId, Date expiryTime, Long skuId) {
+	private void saveClaudeCodeRenewExpiryRecord(Long orderId, Long relationUserId, Long relationId, Long skuId) {
 		ClaudeCodeUserRenewExpiryRecord renewExpiryRecord = new ClaudeCodeUserRenewExpiryRecord();
 		renewExpiryRecord.setOrderId(orderId);
 		renewExpiryRecord.setUserId(relationUserId);
 		renewExpiryRecord.setRelationId(relationId);
 		renewExpiryRecord.setRenewSkuId(skuId);
-		renewExpiryRecord.setExpiryTime(expiryTime);
 		claudeCodeUserRenewExpiryRecordMapper.insert(renewExpiryRecord);
 	}
 

+ 13 - 12
netflix-service/src/main/java/com/cyksj/service/exchange/impl/ExchangeCodeServiceImpl.java

@@ -393,6 +393,8 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
 
 			if (relation.getIsClaudeCodeUpgrade() != null && relation.getIsClaudeCodeUpgrade()) {
 				//claude code 是否升级
+				orderDon.setOrderType(2);
+				orderDonMapper.updateById(orderDon);
 				claudeCodeService.handleClaudeCodeUserPackageSku(relation, sku, orderDon.getId());
 			}
 		}
@@ -427,18 +429,17 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
 			List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
 			GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder().field(GroupsRelationView::getUserId, userIdList).op(Operator.InList).field(GroupsRelationView::getGoodsId, Constant.CLAUDE_CODE_GOODS_ID).field(GroupsRelationView::getExpiryTime, DateTime.now()).op(Operator.GreaterThan).build());
 			if (groupsRelationView != null) {
-//				Date expiryTime = groupsRelationView.getExpiryTime();
-//				if (sku.getDays() != null) {
-//					expiryTime = DateUtil.offsetDay(expiryTime, sku.getDays());
-//				} else {
-//					expiryTime = DateUtil.offsetMonth(expiryTime, sku.getMonths());
-//				}
-//				GroupsRelation relation = groupsRelationMapper.selectById(groupsRelationView.getId());
-//				relation.setExpiryTime(expiryTime);
-//				groupsRelationMapper.updateById(relation);
-//				relation.setIsClaudeCodeUpgrade(true);
-//				return relation;
-				throw BusinessRuntimeException.getInstance("您当前已有车票,暂时无法兑换");
+				Date expiryTime = groupsRelationView.getExpiryTime();
+				if (sku.getDays() != null) {
+					expiryTime = DateUtil.offsetDay(expiryTime, sku.getDays());
+				} else {
+					expiryTime = DateUtil.offsetMonth(expiryTime, sku.getMonths());
+				}
+				GroupsRelation relation = groupsRelationMapper.selectById(groupsRelationView.getId());
+				relation.setExpiryTime(expiryTime);
+				groupsRelationMapper.updateById(relation);
+				relation.setIsClaudeCodeUpgrade(true);
+				return relation;
 			}
 		}
 		Integer retryNum = 1;