|
|
@@ -424,23 +424,27 @@ 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.setIsClaudeCodeUpgrade(true);
|
|
|
+ return relation;
|
|
|
}
|
|
|
}
|
|
|
Integer retryNum = 1;
|