Commit 55e1bca3c0ad1e16cc935935d24cfeddd69abaa7
1 parent
625265b1
【代码修复】PAY:微信扫码支付 v2 版本,缺少 product_id 的报错
Showing
2 changed files
with
14 additions
and
2 deletions
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
| ... | ... | @@ -2,9 +2,11 @@ package cn.iocoder.yudao.framework.web.core.handler; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.exceptions.ExceptionUtil; |
| 4 | 4 | import cn.hutool.core.map.MapUtil; |
| 5 | +import cn.hutool.core.util.ObjUtil; | |
| 5 | 6 | import cn.hutool.core.util.StrUtil; |
| 6 | 7 | import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; |
| 7 | 8 | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| 9 | +import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | |
| 8 | 10 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 9 | 11 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; |
| 10 | 12 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| ... | ... | @@ -222,8 +224,17 @@ public class GlobalExceptionHandler { |
| 222 | 224 | // 不包含的时候,才进行打印,避免 ex 堆栈过多 |
| 223 | 225 | if (!IGNORE_ERROR_MESSAGES.contains(ex.getMessage())) { |
| 224 | 226 | // 即使打印,也只打印第一层 StackTraceElement,并且使用 warn 在控制台输出,更容易看到 |
| 225 | - StackTraceElement[] stackTrace = ex.getStackTrace(); | |
| 226 | - log.warn("[serviceExceptionHandler]\n\t{}", stackTrace[0]); | |
| 227 | + try { | |
| 228 | + StackTraceElement[] stackTraces = ex.getStackTrace(); | |
| 229 | + for (StackTraceElement stackTrace : stackTraces) { | |
| 230 | + if (ObjUtil.notEqual(stackTrace.getClassName(), ServiceExceptionUtil.class.getName())) { | |
| 231 | + log.warn("[serviceExceptionHandler]\n\t{}", stackTrace); | |
| 232 | + break; | |
| 233 | + } | |
| 234 | + } | |
| 235 | + } catch (Exception ignored) { | |
| 236 | + // 忽略日志,避免影响主流程 | |
| 237 | + } | |
| 227 | 238 | } |
| 228 | 239 | return CommonResult.error(ex.getCode(), ex.getMessage()); |
| 229 | 240 | } | ... | ... |
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClient.java
| ... | ... | @@ -35,6 +35,7 @@ public class WxNativePayClient extends AbstractWxPayClient { |
| 35 | 35 | protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { |
| 36 | 36 | // 构建 WxPayUnifiedOrderRequest 对象 |
| 37 | 37 | WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO); |
| 38 | +// .setProductId(reqDTO.getOutTradeNo()); // V2 必须传递 productId,无需在微信配置。该参数在 V3 简化,无需传递! | |
| 38 | 39 | // 执行请求 |
| 39 | 40 | WxPayNativeOrderResult response = client.createOrder(request); |
| 40 | 41 | ... | ... |