BUGFIX:微信名解析、toproductimage 打光积分不足code码修改;
This commit is contained in:
@@ -49,6 +49,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -2405,6 +2406,15 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
String response = restTemplate.getForObject(url, String.class);
|
String response = restTemplate.getForObject(url, String.class);
|
||||||
|
|
||||||
|
// 强制校正编码为 UTF-8(如果返回的是 ISO-8859-1 编码)
|
||||||
|
if (!isUTF8(response)) { // 检查编码方法,下面会提供
|
||||||
|
byte[] bytes = response.getBytes(StandardCharsets.ISO_8859_1);
|
||||||
|
response = new String(bytes, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打印调试信息
|
||||||
|
log.info("WeChat user info response: {}", response);
|
||||||
|
|
||||||
// 转换为 JSON 对象
|
// 转换为 JSON 对象
|
||||||
JSONObject jsonResponse = JSONObject.parseObject(response);
|
JSONObject jsonResponse = JSONObject.parseObject(response);
|
||||||
if (jsonResponse.containsKey("errcode")) {
|
if (jsonResponse.containsKey("errcode")) {
|
||||||
@@ -2414,6 +2424,17 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
return jsonResponse;
|
return jsonResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isUTF8(String text) {
|
||||||
|
try {
|
||||||
|
byte[] bytes = text.getBytes(StandardCharsets.ISO_8859_1);
|
||||||
|
String decoded = new String(bytes, StandardCharsets.UTF_8);
|
||||||
|
return decoded.equals(text);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private JSONObject getAccessTokenFromWeChat(String code) {
|
private JSONObject getAccessTokenFromWeChat(String code) {
|
||||||
// 构造微信接口请求 URL
|
// 构造微信接口请求 URL
|
||||||
String url = String.format(
|
String url = String.format(
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.ai.da.common.config.exception.BusinessException;
|
|||||||
import com.ai.da.common.constant.CommonConstant;
|
import com.ai.da.common.constant.CommonConstant;
|
||||||
import com.ai.da.common.context.UserContext;
|
import com.ai.da.common.context.UserContext;
|
||||||
import com.ai.da.common.enums.CreditsEventsEnum;
|
import com.ai.da.common.enums.CreditsEventsEnum;
|
||||||
|
import com.ai.da.common.response.ResultEnum;
|
||||||
import com.ai.da.common.utils.*;
|
import com.ai.da.common.utils.*;
|
||||||
import com.ai.da.mapper.primary.*;
|
import com.ai.da.mapper.primary.*;
|
||||||
import com.ai.da.mapper.primary.entity.*;
|
import com.ai.da.mapper.primary.entity.*;
|
||||||
@@ -274,7 +275,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
// 判断用户当前积分是否够本次生成消耗
|
// 判断用户当前积分是否够本次生成消耗
|
||||||
Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.TO_PRODUCT_IMAGE, toProductImageDTO.getToProductImageVOList().size());
|
Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.TO_PRODUCT_IMAGE, toProductImageDTO.getToProductImageVOList().size());
|
||||||
if (!preDeduction) {
|
if (!preDeduction) {
|
||||||
throw new BusinessException("Not enough Credits");
|
throw new BusinessException("Not enough Credits", ResultEnum.WARNING.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||||
@@ -540,7 +541,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
// 判断用户当前积分是否够本次生成消耗
|
// 判断用户当前积分是否够本次生成消耗
|
||||||
Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.RELIGHT, toProductImageDTO.getToProductImageVOList().size());
|
Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.RELIGHT, toProductImageDTO.getToProductImageVOList().size());
|
||||||
if (!preDeduction) {
|
if (!preDeduction) {
|
||||||
throw new BusinessException("Not enough Credits");
|
throw new BusinessException("Not enough Credits", ResultEnum.WARNING.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||||
|
|||||||
Reference in New Issue
Block a user