fix(i18n): 微信能力异常消息消除夹中文伪key, 规范异常类无参构造

- WechatUserService/WechatMaMessageService 5处夹中文伪key改用合法i18n key
- ConfigErrorException/OperationFailException/NonceMissingException 无参构造super(中文)改super(key)
- wechat.json 补充 userInfoNotFound/userNotSubscribed/phoneNotFound 中英文条目
This commit is contained in:
DaxPay Dev
2026-07-01 10:26:31 +08:00
parent 676012c5fb
commit 628ba2b17c
7 changed files with 14 additions and 8 deletions

View File

@@ -34,7 +34,7 @@ public class WechatUserService {
public WechatUserInfoResult getUserInfo(String openId, String appId, String appSecret) {
// 验证参数
if (StrUtil.isBlank(openId) || StrUtil.isBlank(appId) || StrUtil.isBlank(appSecret)) {
throw new OperationFailException(CommonCode.FAIL_CODE, "error.payment.channel.参数不能为空");
throw new OperationFailException(CommonCode.FAIL_CODE, "error.channel.wechat.paramsRequired");
}
try {
@@ -45,7 +45,7 @@ public class WechatUserService {
WxMpUser wxMpUser = wxMpService.getUserService().userInfo(openId);
if (wxMpUser == null) {
throw new OperationFailException(CommonCode.FAIL_CODE, "error.payment.channel.获取用户信息失败");
throw new OperationFailException(CommonCode.FAIL_CODE, "error.channel.wechat.userInfoNotFound");
}
// 转换结果
@@ -68,7 +68,7 @@ public class WechatUserService {
// 判断是否是用户未关注
if (e.getError().getErrorCode() == 49003) {
throw new OperationFailException(CommonCode.FAIL_CODE, "error.payment.channel.用户未关注公众号");
throw new OperationFailException(CommonCode.FAIL_CODE, "error.channel.wechat.userNotSubscribed");
}
// 微信: 获取用户信息失败: {0}
@@ -100,7 +100,7 @@ public class WechatUserService {
WxMaPhoneNumberInfo phoneInfo = wxMaService.getUserService().getPhoneNoInfo(code);
if (phoneInfo == null) {
throw new OperationFailException(CommonCode.FAIL_CODE, "error.payment.channel.获取手机号失败");
throw new OperationFailException(CommonCode.FAIL_CODE, "error.channel.wechat.phoneNotFound");
}
// 转换结果

View File

@@ -151,7 +151,7 @@ public class WechatMaMessageService {
private void validateConfig(String wxAppId, String appSecret) {
if (StrUtil.isBlank(wxAppId) || StrUtil.isBlank(appSecret)) {
log.error("微信配置参数为空wxAppId: {}", wxAppId);
throw new OperationFailException(CommonCode.FAIL_CODE, "error.payment.channel.微信配置参数不能为空");
throw new OperationFailException(CommonCode.FAIL_CODE, "error.channel.wechat.configParamsRequired");
}
}

View File

@@ -26,6 +26,9 @@
"paramsRequired": "Parameters are required",
"phoneFetchFailed": "Failed to fetch phone number: {0}",
"phoneFetchError": "Phone number fetch error: {0}",
"userInfoNotFound": "WeChat user info not found",
"userNotSubscribed": "User has not subscribed to the official account",
"phoneNotFound": "WeChat phone number not found",
"mpAuthFailed": "WeChat official account authentication failed: {0}",
"mpAuthConfigError": "WeChat official account auth configuration error: {0}",
"maAuthFailed": "WeChat mini program authentication failed: {0}",

View File

@@ -26,6 +26,9 @@
"paramsRequired": "参数不能为空",
"phoneFetchFailed": "获取手机号失败: {0}",
"phoneFetchError": "获取手机号异常: {0}",
"userInfoNotFound": "未获取到微信用户信息",
"userNotSubscribed": "用户未关注公众号",
"phoneNotFound": "未获取到微信手机号",
"mpAuthFailed": "微信公众号认证失败: {0}",
"mpAuthConfigError": "微信公众号认证配置错误: {0}",
"maAuthFailed": "微信小程序认证失败: {0}",

View File

@@ -7,7 +7,7 @@ import static cn.daxpay.open.platform.core.code.CommonErrorCode.NONCE_MISSING;
public class NonceMissingException extends BizInfoException {
public NonceMissingException() {
super(NONCE_MISSING, "Nonce缺失");
super(NONCE_MISSING, "error.common.nonceMissing");
initMessageKey("error.common.nonceMissing");
}

View File

@@ -23,7 +23,7 @@ public class ConfigErrorException extends PayFailureException {
public ConfigErrorException() {
// 配置错误
super(DaxPayErrorCode.CONFIG_ERROR,"配置错误");
super(DaxPayErrorCode.CONFIG_ERROR,"pay.error.configError");
initMessageKey("pay.error.configError");
}
}

View File

@@ -22,7 +22,7 @@ public class OperationFailException extends PayFailureException {
}
public OperationFailException() {
super(DaxPayErrorCode.OPERATION_FAIL,"操作失败");
super(DaxPayErrorCode.OPERATION_FAIL,"pay.error.operateFailed");
initMessageKey("pay.error.operateFailed");
}
}