|
|
@@ -8,6 +8,7 @@ import cn.hutool.http.HttpException;
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.http.Method;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
@@ -810,6 +811,15 @@ public class ClaudeCodeServiceImpl implements ClaudeCodeService {
|
|
|
throw new BusinessRuntimeException("积分卡已过期");
|
|
|
}
|
|
|
|
|
|
+ ClaudeCodeResp userBalance = getUserBalance(userId);
|
|
|
+ JSONObject data = Jsons.parseObject(userBalance.getData(), JSONObject.class);
|
|
|
+ Integer availableCredits = data.getInt("available_credits");
|
|
|
+ Integer creditLimit = data.getInt("credit_limit");
|
|
|
+ //超出积分 异常
|
|
|
+ if (availableCredits + creditCard.getCreditAmount() > creditLimit) {
|
|
|
+ throw BusinessRuntimeException.getInstance("目前使用只能补充到{0},建议您消耗更多积分后再兑换使用", creditLimit);
|
|
|
+ }
|
|
|
+
|
|
|
Integer beforeCodePoints = claudeCodeUser.getCodePoints();
|
|
|
Integer addCodePoints = creditCard.getCreditAmount();
|
|
|
Integer afterCodePoints = beforeCodePoints + addCodePoints;
|