|
|
@@ -391,11 +391,14 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
orderDonMapper.insert(orderDon);
|
|
|
log.info("用户{}兑换规格:{}车位成功", user.getId(), orderDon.getSkuId());
|
|
|
|
|
|
- if (relation.getIsClaudeCodeUpgrade() != null && relation.getIsClaudeCodeUpgrade()) {
|
|
|
- //claude code 是否升级
|
|
|
+ if (relation.getIsClaudeCodeRenew() != null && relation.getIsClaudeCodeRenew()) {
|
|
|
+ //claude code续费
|
|
|
orderDon.setOrderType(2);
|
|
|
orderDonMapper.updateById(orderDon);
|
|
|
- claudeCodeService.handleClaudeCodeUserPackageSku(relation, sku, orderDon.getId());
|
|
|
+ //续费且升级
|
|
|
+ if (relation.getIsClaudeCodeUpgrade() != null && relation.getIsClaudeCodeUpgrade()) {
|
|
|
+ claudeCodeService.handleClaudeCodeUserPackageSku(relation, sku, orderDon.getId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (orderDonTye == OrderDon.Type.EX_CODE) {
|
|
|
@@ -424,23 +427,31 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
|
|
|
@Override
|
|
|
public GroupsRelation getRelationNoOrder(GoodsDonSku sku, Long userId, Long yhsId) {
|
|
|
- //claude code商品兑换 只能兑换一次 后续兑换增加车票时长
|
|
|
+ //claude code商品兑换
|
|
|
if (sku.getGoodsId() == Constant.CLAUDE_CODE_GOODS_ID) {
|
|
|
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("您当前已有车票,暂时无法兑换");
|
|
|
+ GoodsDonSku relationSku = goodsDonSkuMapper.selectById(groupsRelationView.getSkuId());
|
|
|
+ //兑换的规格 低于当前规格 不让兑换
|
|
|
+ if (relationSku.getCodePoints() > sku.getCodePoints()) {
|
|
|
+ throw BusinessRuntimeException.getInstance("请在claude code当前版本过期后再兑换");
|
|
|
+ }
|
|
|
+ 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.setIsClaudeCodeRenew(Boolean.TRUE);
|
|
|
+ if (relationSku.getCodePoints() != sku.getCodePoints()) {
|
|
|
+ relation.setIsClaudeCodeUpgrade(true);
|
|
|
+ }
|
|
|
+ return relation;
|
|
|
}
|
|
|
}
|
|
|
Integer retryNum = 1;
|